diff --git a/stix/lib/stix-cmn.h b/stix/lib/stix-cmn.h index cf6ec5e..6307bc0 100644 --- a/stix/lib/stix-cmn.h +++ b/stix/lib/stix-cmn.h @@ -610,7 +610,7 @@ struct stix_cmgr_t /* ========================================================================= * COMPILER FEATURE TEST MACROS * =========================================================================*/ -#if !defined(__has_builtin) +#if !defined(__has_builtin) && defined(_INTELC32_) /* intel c code builder 1.0 ended up with an error without this override */ #define __has_builtin(x) 0 #endif @@ -668,10 +668,15 @@ struct stix_cmgr_t #if __has_builtin(__builtin_smulll_overflow) #define STIX_HAVE_BUILTIN_SMULLL_OVERFLOW #endif + + #if __has_builtin(__builtin_expect) + #define STIX_HAVE_BUILTIN_EXPECT + #endif #elif defined(__GNUC__) && defined(__GNUC_MINOR__) #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) #define STIX_HAVE_BUILTIN_CTZ + #define STIX_HAVE_BUILTIN_EXPECT #endif #if (__GNUC__ >= 5) @@ -692,9 +697,12 @@ struct stix_cmgr_t #endif - - - - +#if defined(STIX_HAVE_BUILTIN_EXPECT) +# define STIX_LIKELY(x) (__builtin_expect(!!x,1)) +# define STIX_UNLIKELY(x) (__builtin_expect(!!x,0)) +#else +# define STIX_LIKELY(x) (x) +# define STIX_UNLIKELY(x) (x) +#endif #endif diff --git a/stix/lib/stix.h b/stix/lib/stix.h index e563fa8..e7d0a94 100644 --- a/stix/lib/stix.h +++ b/stix/lib/stix.h @@ -304,7 +304,7 @@ typedef enum stix_obj_type_t stix_obj_type_t; #define STIX_OBJ_GET_FLAGS_EXTRA(oop) STIX_GETBITS(stix_oow_t, (oop)->_flags, STIX_OBJ_FLAGS_EXTRA_SHIFT, STIX_OBJ_FLAGS_EXTRA_BITS) #define STIX_OBJ_GET_FLAGS_KERNEL(oop) STIX_GETBITS(stix_oow_t, (oop)->_flags, STIX_OBJ_FLAGS_KERNEL_SHIFT, STIX_OBJ_FLAGS_KERNEL_BITS) #define STIX_OBJ_GET_FLAGS_MOVED(oop) STIX_GETBITS(stix_oow_t, (oop)->_flags, STIX_OBJ_FLAGS_MOVED_SHIFT, STIX_OBJ_FLAGS_MOVED_BITS) -#define STIX_OBJ_GET_FLAGS_NGC(oop) STIX_GETBITS(stix_oow_t, (oop)->_flags, STIX_OBJ_FLAGS_TRAILER_SHIFT, STIX_OBJ_FLAGS_MOVED_BITS) +#define STIX_OBJ_GET_FLAGS_NGC(oop) STIX_GETBITS(stix_oow_t, (oop)->_flags, STIX_OBJ_FLAGS_NGC_SHIFT, STIX_OBJ_FLAGS_NGC_BITS) #define STIX_OBJ_GET_FLAGS_TRAILER(oop) STIX_GETBITS(stix_oow_t, (oop)->_flags, STIX_OBJ_FLAGS_TRAILER_SHIFT, STIX_OBJ_FLAGS_TRAILER_BITS) #define STIX_OBJ_SET_FLAGS_TYPE(oop,v) STIX_SETBITS(stix_oow_t, (oop)->_flags, STIX_OBJ_FLAGS_TYPE_SHIFT, STIX_OBJ_FLAGS_TYPE_BITS, v) @@ -312,7 +312,7 @@ typedef enum stix_obj_type_t stix_obj_type_t; #define STIX_OBJ_SET_FLAGS_EXTRA(oop,v) STIX_SETBITS(stix_oow_t, (oop)->_flags, STIX_OBJ_FLAGS_EXTRA_SHIFT, STIX_OBJ_FLAGS_EXTRA_BITS, v) #define STIX_OBJ_SET_FLAGS_KERNEL(oop,v) STIX_SETBITS(stix_oow_t, (oop)->_flags, STIX_OBJ_FLAGS_KERNEL_SHIFT, STIX_OBJ_FLAGS_KERNEL_BITS, v) #define STIX_OBJ_SET_FLAGS_MOVED(oop,v) STIX_SETBITS(stix_oow_t, (oop)->_flags, STIX_OBJ_FLAGS_MOVED_SHIFT, STIX_OBJ_FLAGS_MOVED_BITS, v) -#define STIX_OBJ_SET_FLAGS_NGC(oop,v) STIX_SETBITS(stix_oow_t, (oop)->_flags, STIX_OBJ_FLAGS_NGC_SHIFT, STIX_OBJ_FLAGS_MOVED_BITS, v) +#define STIX_OBJ_SET_FLAGS_NGC(oop,v) STIX_SETBITS(stix_oow_t, (oop)->_flags, STIX_OBJ_FLAGS_NGC_SHIFT, STIX_OBJ_FLAGS_NGC_BITS, v) #define STIX_OBJ_SET_FLAGS_TRAILER(oop,v) STIX_SETBITS(stix_oow_t, (oop)->_flags, STIX_OBJ_FLAGS_TRAILER_SHIFT, STIX_OBJ_FLAGS_TRAILER_BITS, v) #define STIX_OBJ_GET_SIZE(oop) ((oop)->_size)