@@ -20,14 +20,16 @@ #ifdef __GNUC__ # define OF_INLINE inline __attribute__((always_inline)) # define OF_LIKELY(cond) __builtin_expect(!!(cond), 1) # define OF_UNLIKELY(cond) __builtin_expect(!!(cond), 0) +# define OF_CONST_FUNC __attribute__((const)) #else # define OF_INLINE inline # define OF_LIKELY(cond) cond # define OF_UNLIKELY(cond) cond +# define OF_CONST_FUNC #endif /* Required to build universal binaries on OS X */ #if __BIG_ENDIAN__ || __LITTLE_ENDIAN__ # if __BIG_ENDIAN__ && __LITTLE_ENDIAN__ @@ -55,27 +57,27 @@ # define OF_PATH_DELIM '/' #else # define OF_PATH_DELIM '\\' #endif -static OF_INLINE uint16_t +static OF_INLINE uint16_t OF_CONST_FUNC OF_BSWAP16_CONST(uint16_t i) { return (i & UINT16_C(0xFF00)) >> 8 | (i & UINT16_C(0x00FF)) << 8; } -static OF_INLINE uint32_t +static OF_INLINE uint32_t OF_CONST_FUNC OF_BSWAP32_CONST(uint32_t i) { return (i & UINT32_C(0xFF000000)) >> 24 | (i & UINT32_C(0x00FF0000)) >> 8 | (i & UINT32_C(0x0000FF00)) << 8 | (i & UINT32_C(0x000000FF)) << 24; } -static OF_INLINE uint64_t +static OF_INLINE uint64_t OF_CONST_FUNC OF_BSWAP64_CONST(uint64_t i) { return (i & UINT64_C(0xFF00000000000000)) >> 56 | (i & UINT64_C(0x00FF000000000000)) >> 40 | (i & UINT64_C(0x0000FF0000000000)) >> 24 | @@ -84,11 +86,11 @@ (i & UINT64_C(0x0000000000FF0000)) << 24 | (i & UINT64_C(0x000000000000FF00)) << 40 | (i & UINT64_C(0x00000000000000FF)) << 56; } -static OF_INLINE uint16_t +static OF_INLINE uint16_t OF_CONST_FUNC OF_BSWAP16_NONCONST(uint16_t i) { #if defined(OF_X86_ASM) || defined(OF_AMD64_ASM) __asm__ ( "xchgb %h0, %b0" @@ -112,11 +114,11 @@ (i & UINT16_C(0x00FF)) << 8; #endif return i; } -static OF_INLINE uint32_t +static OF_INLINE uint32_t OF_CONST_FUNC OF_BSWAP32_NONCONST(uint32_t i) { #if defined(OF_X86_ASM) || defined(OF_AMD64_ASM) __asm__ ( "bswap %0" @@ -142,11 +144,11 @@ (i & UINT32_C(0x000000FF)) << 24; #endif return i; } -static OF_INLINE uint64_t +static OF_INLINE uint64_t OF_CONST_FUNC OF_BSWAP64_NONCONST(uint64_t i) { #if defined(OF_AMD64_ASM) __asm__ ( "bswap %0"