diff --git a/include/assert.h b/include/assert.h index 7ce0e1512d7..c506102b804 100644 --- a/include/assert.h +++ b/include/assert.h @@ -50,11 +50,11 @@ #define PANIC() __assert(__FILE__, __LINE__, "panic") #ifdef CONFIG_DEBUG_ASSERTIONS_EXPRESSION -#define ASSERT(f) do { if (unlikely(!(f))) __assert(__FILE__, __LINE__, #f); } while (0) -#define VERIFY(f) do { if (unlikely((f) < 0)) __assert(__FILE__, __LINE__, #f); } while (0) +#define ASSERT(f) do { if (predict_false(!(f))) __assert(__FILE__, __LINE__, #f); } while (0) +#define VERIFY(f) do { if (predict_false((f) < 0)) __assert(__FILE__, __LINE__, #f); } while (0) #else -#define ASSERT(f) do { if (unlikely(!(f))) __assert(__FILE__, __LINE__, NULL); } while (0) -#define VERIFY(f) do { if (unlikely((f) < 0)) __assert(__FILE__, __LINE__, NULL); } while (0) +#define ASSERT(f) do { if (predict_false(!(f))) __assert(__FILE__, __LINE__, NULL); } while (0) +#define VERIFY(f) do { if (predict_false((f) < 0)) __assert(__FILE__, __LINE__, NULL); } while (0) #endif #ifdef CONFIG_DEBUG_ASSERTIONS diff --git a/include/nuttx/compiler.h b/include/nuttx/compiler.h index 6b39014b455..d223433de45 100644 --- a/include/nuttx/compiler.h +++ b/include/nuttx/compiler.h @@ -156,8 +156,8 @@ /* Branch prediction */ -# define likely(x) __builtin_expect((x), 1) -# define unlikely(x) __builtin_expect((x), 0) +# define predict_true(x) __builtin_expect(!!(x), 1) +# define predict_false(x) __builtin_expect((x), 0) /* Code locate */ @@ -476,8 +476,8 @@ */ # define noreturn_function -# define likely(x) (x) -# define unlikely(x) (x) +# define predict_true(x) (x) +# define predict_false(x) (x) # define locate_code(n) # define aligned_data(n) # define locate_data(n) @@ -628,8 +628,8 @@ */ # define noreturn_function -# define likely(x) (x) -# define unlikely(x) (x) +# define predict_true(x) (x) +# define predict_false(x) (x) # define aligned_data(n) # define locate_code(n) # define locate_data(n) @@ -737,8 +737,8 @@ # define weak_const_function # define noreturn_function # define farcall_function -# define likely(x) (x) -# define unlikely(x) (x) +# define predict_true(x) (x) +# define predict_false(x) (x) # define locate_code(n) # define aligned_data(n) # define locate_data(n) @@ -826,8 +826,8 @@ # define restrict # define noreturn_function # define farcall_function -# define likely(x) (x) -# define unlikely(x) (x) +# define predict_true(x) (x) +# define predict_false(x) (x) # define aligned_data(n) # define locate_code(n) # define locate_data(n) @@ -890,8 +890,8 @@ # define restrict # define noreturn_function # define farcall_function -# define likely(x) (x) -# define unlikely(x) (x) +# define predict_true(x) (x) +# define predict_false(x) (x) # define aligned_data(n) # define locate_code(n) # define locate_data(n)