fixed NGC bit handlign macros.

added STIX_LIKELY() and STIX_UNLIKELY() for gcc using __builtin_expect.
This commit is contained in:
hyunghwan.chung 2016-09-11 16:42:27 +00:00
parent 2b97473c5e
commit 0504fbde72
2 changed files with 15 additions and 7 deletions

View File

@ -610,7 +610,7 @@ struct stix_cmgr_t
/* ========================================================================= /* =========================================================================
* COMPILER FEATURE TEST MACROS * 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 */ /* intel c code builder 1.0 ended up with an error without this override */
#define __has_builtin(x) 0 #define __has_builtin(x) 0
#endif #endif
@ -668,10 +668,15 @@ struct stix_cmgr_t
#if __has_builtin(__builtin_smulll_overflow) #if __has_builtin(__builtin_smulll_overflow)
#define STIX_HAVE_BUILTIN_SMULLL_OVERFLOW #define STIX_HAVE_BUILTIN_SMULLL_OVERFLOW
#endif #endif
#if __has_builtin(__builtin_expect)
#define STIX_HAVE_BUILTIN_EXPECT
#endif
#elif defined(__GNUC__) && defined(__GNUC_MINOR__) #elif defined(__GNUC__) && defined(__GNUC_MINOR__)
#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
#define STIX_HAVE_BUILTIN_CTZ #define STIX_HAVE_BUILTIN_CTZ
#define STIX_HAVE_BUILTIN_EXPECT
#endif #endif
#if (__GNUC__ >= 5) #if (__GNUC__ >= 5)
@ -692,9 +697,12 @@ struct stix_cmgr_t
#endif #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 #endif

View File

@ -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_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_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_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_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) #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_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_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_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_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) #define STIX_OBJ_GET_SIZE(oop) ((oop)->_size)