libstdc++: Use __builtin_expect in __glibcxx_assert
libstdc++-v3/ChangeLog: * include/bits/c++config (__replacement_assert): Add noreturn attribute. (__glibcxx_assert_impl): Use __builtin_expect to hint that the assertion is expected to pass.
This commit is contained in:
parent
aecea4158f
commit
7db5967f10
|
@ -468,7 +468,8 @@ namespace std
|
||||||
{
|
{
|
||||||
// Avoid the use of assert, because we're trying to keep the <cassert>
|
// Avoid the use of assert, because we're trying to keep the <cassert>
|
||||||
// include out of the mix.
|
// include out of the mix.
|
||||||
extern "C++" inline void
|
extern "C++" _GLIBCXX_NORETURN
|
||||||
|
inline void
|
||||||
__replacement_assert(const char* __file, int __line,
|
__replacement_assert(const char* __file, int __line,
|
||||||
const char* __function, const char* __condition)
|
const char* __function, const char* __condition)
|
||||||
{
|
{
|
||||||
|
@ -478,7 +479,7 @@ namespace std
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#define __glibcxx_assert_impl(_Condition) \
|
#define __glibcxx_assert_impl(_Condition) \
|
||||||
if (!bool(_Condition)) \
|
if (__builtin_expect(!bool(_Condition), false)) \
|
||||||
std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \
|
std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \
|
||||||
#_Condition)
|
#_Condition)
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue