From 26a91d2a26d5b9ede41df0c877cb18ee13d8556c Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 15 Mar 2013 01:09:19 -0400 Subject: [PATCH] Replace all the "static __inline__" functions with SDL_FORCE_INLINE. --- include/SDL_atomic.h | 10 +++++----- include/SDL_bits.h | 7 +------ include/SDL_endian.h | 33 ++++++++++++++------------------- 3 files changed, 20 insertions(+), 30 deletions(-) diff --git a/include/SDL_atomic.h b/include/SDL_atomic.h index c89d0b71d..be60f9916 100644 --- a/include/SDL_atomic.h +++ b/include/SDL_atomic.h @@ -205,7 +205,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int * \return The previous value of the atomic variable. */ #ifndef SDL_AtomicSet -static __inline__ int SDL_AtomicSet(SDL_atomic_t *a, int v) +SDL_FORCE_INLINE int SDL_AtomicSet(SDL_atomic_t *a, int v) { int value; do { @@ -219,7 +219,7 @@ static __inline__ int SDL_AtomicSet(SDL_atomic_t *a, int v) * \brief Get the value of an atomic variable */ #ifndef SDL_AtomicGet -static __inline__ int SDL_AtomicGet(SDL_atomic_t *a) +SDL_FORCE_INLINE int SDL_AtomicGet(SDL_atomic_t *a) { int value = a->value; SDL_CompilerBarrier(); @@ -235,7 +235,7 @@ static __inline__ int SDL_AtomicGet(SDL_atomic_t *a) * \note This same style can be used for any number operation */ #ifndef SDL_AtomicAdd -static __inline__ int SDL_AtomicAdd(SDL_atomic_t *a, int v) +SDL_FORCE_INLINE int SDL_AtomicAdd(SDL_atomic_t *a, int v) { int value; do { @@ -279,7 +279,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr(void* *a, void *oldval, void * * \return The previous value of the pointer. */ #ifndef SDL_AtomicSetPtr -static __inline__ void* SDL_AtomicSetPtr(void* *a, void* v) +SDL_FORCE_INLINE void* SDL_AtomicSetPtr(void* *a, void* v) { void* value; do { @@ -293,7 +293,7 @@ static __inline__ void* SDL_AtomicSetPtr(void* *a, void* v) * \brief Get the value of a pointer atomically. */ #ifndef SDL_AtomicGetPtr -static __inline__ void* SDL_AtomicGetPtr(void* *a) +SDL_FORCE_INLINE void* SDL_AtomicGetPtr(void* *a) { void* value = *a; SDL_CompilerBarrier(); diff --git a/include/SDL_bits.h b/include/SDL_bits.h index 3192c8e41..4b35a77cf 100644 --- a/include/SDL_bits.h +++ b/include/SDL_bits.h @@ -40,11 +40,6 @@ extern "C" { /** * \file SDL_bits.h - * - * Uses inline functions for compilers that support them, and static - * functions for those that do not. Because these functions become - * static for compilers that do not support inline functions, this - * header should only be included in files that actually use them. */ /** @@ -54,7 +49,7 @@ extern "C" { * * \return Index of the most significant bit. */ -static __inline__ Sint8 +SDL_FORCE_INLINE Sint8 SDL_MostSignificantBitIndex32(Uint32 x) { #if defined(__GNUC__) diff --git a/include/SDL_endian.h b/include/SDL_endian.h index 5cfa32e30..a1a11df09 100644 --- a/include/SDL_endian.h +++ b/include/SDL_endian.h @@ -66,29 +66,24 @@ extern "C" { /** * \file SDL_endian.h - * - * Uses inline functions for compilers that support them, and static - * functions for those that do not. Because these functions become - * static for compilers that do not support inline functions, this - * header should only be included in files that actually use them. */ #if defined(__GNUC__) && defined(__i386__) && \ !(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */) -static __inline__ Uint16 +SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) { __asm__("xchgb %b0,%h0": "=q"(x):"0"(x)); return x; } #elif defined(__GNUC__) && defined(__x86_64__) -static __inline__ Uint16 +SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) { __asm__("xchgb %b0,%h0": "=Q"(x):"0"(x)); return x; } #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) -static __inline__ Uint16 +SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) { int result; @@ -97,14 +92,14 @@ SDL_Swap16(Uint16 x) return (Uint16)result; } #elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) -static __inline__ Uint16 +SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) { __asm__("rorw #8,%0": "=d"(x): "0"(x):"cc"); return x; } #else -static __inline__ Uint16 +SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) { return SDL_static_cast(Uint16, ((x << 8) | (x >> 8))); @@ -112,21 +107,21 @@ SDL_Swap16(Uint16 x) #endif #if defined(__GNUC__) && defined(__i386__) -static __inline__ Uint32 +SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x) { __asm__("bswap %0": "=r"(x):"0"(x)); return x; } #elif defined(__GNUC__) && defined(__x86_64__) -static __inline__ Uint32 +SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x) { __asm__("bswapl %0": "=r"(x):"0"(x)); return x; } #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) -static __inline__ Uint32 +SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x) { Uint32 result; @@ -137,14 +132,14 @@ SDL_Swap32(Uint32 x) return result; } #elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) -static __inline__ Uint32 +SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x) { __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0": "=d"(x): "0"(x):"cc"); return x; } #else -static __inline__ Uint32 +SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x) { return SDL_static_cast(Uint32, ((x << 24) | ((x << 8) & 0x00FF0000) | @@ -153,7 +148,7 @@ SDL_Swap32(Uint32 x) #endif #if defined(__GNUC__) && defined(__i386__) -static __inline__ Uint64 +SDL_FORCE_INLINE Uint64 SDL_Swap64(Uint64 x) { union @@ -171,14 +166,14 @@ SDL_Swap64(Uint64 x) return v.u; } #elif defined(__GNUC__) && defined(__x86_64__) -static __inline__ Uint64 +SDL_FORCE_INLINE Uint64 SDL_Swap64(Uint64 x) { __asm__("bswapq %0": "=r"(x):"0"(x)); return x; } #else -static __inline__ Uint64 +SDL_FORCE_INLINE Uint64 SDL_Swap64(Uint64 x) { Uint32 hi, lo; @@ -195,7 +190,7 @@ SDL_Swap64(Uint64 x) #endif -static __inline__ float +SDL_FORCE_INLINE float SDL_SwapFloat(float x) { union