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:
Jonathan Wakely 2020-09-21 23:43:25 +01:00
parent aecea4158f
commit 7db5967f10
1 changed files with 3 additions and 2 deletions

View File

@ -468,7 +468,8 @@ namespace std
{
// Avoid the use of assert, because we're trying to keep the <cassert>
// include out of the mix.
extern "C++" inline void
extern "C++" _GLIBCXX_NORETURN
inline void
__replacement_assert(const char* __file, int __line,
const char* __function, const char* __condition)
{
@ -478,7 +479,7 @@ namespace std
}
}
#define __glibcxx_assert_impl(_Condition) \
if (!bool(_Condition)) \
if (__builtin_expect(!bool(_Condition), false)) \
std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \
#_Condition)
#endif