Skip to content

Commit 709a7f1

Browse files
committed
[libc] Add __builtin_expect tag on assert conditions; NFC
1 parent fc65a96 commit 709a7f1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

libc/src/__support/libc_assert.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ LIBC_INLINE void report_assertion_failure(const char *assertion,
7171

7272
#define LIBC_ASSERT(COND) \
7373
do { \
74-
if (!(COND)) { \
74+
if (LIBC_UNLIKELY(!(COND))) { \
7575
LIBC_NAMESPACE::write_to_stderr(__FILE__ ":" __LIBC_LINE_STR__ \
7676
": Assertion failed: '" #COND \
7777
"' in function: '"); \

libc/src/assert/assert.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define assert(e) (void)0
2020
#else
2121
#define assert(e) \
22-
((e) ? (void)0 \
23-
: LIBC_NAMESPACE::__assert_fail(#e, __FILE__, __LINE__, \
24-
__PRETTY_FUNCTION__))
22+
(LIBC_LIKELY(e) ? (void)0 \
23+
: LIBC_NAMESPACE::__assert_fail(#e, __FILE__, __LINE__, \
24+
__PRETTY_FUNCTION__))
2525
#endif // NDEBUG

0 commit comments

Comments
 (0)