Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Replace all the "static __inline__" functions with SDL_FORCE_INLINE.
  • Loading branch information
icculus committed Mar 15, 2013
1 parent b6e2635 commit 26a91d2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 30 deletions.
10 changes: 5 additions & 5 deletions include/SDL_atomic.h
Expand Up @@ -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 {
Expand All @@ -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();
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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();
Expand Down
7 changes: 1 addition & 6 deletions include/SDL_bits.h
Expand Up @@ -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.
*/

/**
Expand All @@ -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__)
Expand Down
33 changes: 14 additions & 19 deletions include/SDL_endian.h
Expand Up @@ -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;
Expand All @@ -97,36 +92,36 @@ 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)));
}
#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;
Expand All @@ -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) |
Expand All @@ -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
Expand All @@ -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;
Expand All @@ -195,7 +190,7 @@ SDL_Swap64(Uint64 x)
#endif


static __inline__ float
SDL_FORCE_INLINE float
SDL_SwapFloat(float x)
{
union
Expand Down

0 comments on commit 26a91d2

Please sign in to comment.