Skip to content

Commit

Permalink
Fixed bug 2129 - fix for bug 2121 breaks linking for mingw and throws…
Browse files Browse the repository at this point in the history
… multiple warnings

Andreas Ertelt

The problem in question is caused by changeset 7771 (http://hg.libsdl.org/SDL/rev/5486e579872e / https://bugzilla.libsdl.org/show_bug.cgi?id=2121)

The redefinition of __inline__ (introduced by the addition of begin_code.h:128's "|| __STRICT_ANSI__") results in mingw's gcc throwing multiple

   warning: always_inline function might not be inlinable [-Wattributes]

as well as a whole bunch of redefinitions of mingw internals which break linking of projects including the SDL2 headers.
  • Loading branch information
slouken committed Oct 21, 2013
1 parent 4ca34ad commit 08fa8da
Show file tree
Hide file tree
Showing 21 changed files with 63 additions and 76 deletions.
39 changes: 13 additions & 26 deletions include/begin_code.h
Expand Up @@ -99,49 +99,36 @@
#endif #endif
#endif /* Compiler needs structure packing set */ #endif /* Compiler needs structure packing set */


#ifndef __inline__ #ifndef SDL_INLINE
/* Set up compiler-specific options for inlining functions */ /* Set up compiler-specific options for inlining functions */
#ifndef SDL_INLINE_OKAY
/* Add any special compiler-specific cases here */
#if defined(_MSC_VER) || defined(__BORLANDC__) || \ #if defined(_MSC_VER) || defined(__BORLANDC__) || \
defined(__DMC__) || defined(__SC__) || \ defined(__DMC__) || defined(__SC__) || \
defined(__WATCOMC__) || defined(__LCC__) || \ defined(__WATCOMC__) || defined(__LCC__) || \
defined(__DECC) defined(__DECC)
#ifndef __inline__ #define SDL_INLINE __inline
#define __inline__ __inline
#endif
#define SDL_INLINE_OKAY 1
#else #else
#if !defined(__MRC__) && !defined(_SGI_SOURCE) #define SDL_INLINE inline
#ifndef __inline__
#define __inline__ inline
#endif
#define SDL_INLINE_OKAY 1
#endif /* Not a funky compiler */
#endif /* Visual C++ */ #endif /* Visual C++ */
#endif /* SDL_INLINE_OKAY */ #endif /* SDL_INLINE not defined */


/* If inlining isn't supported, remove "__inline__", turning static /* If inlining isn't supported, remove SDL_INLINE, turning static
inlined functions into static functions (resulting in code bloat inlined functions into static functions (potentially resulting in
in all files which include the offending header files) code bloat in all files which include the offending header files)
*/ */
#if !SDL_INLINE_OKAY || __STRICT_ANSI__ #if __STRICT_ANSI__
#ifdef __inline__ #undef SDL_INLINE
#undef __inline__ #define SDL_INLINE
#endif #endif
#define __inline__
#endif
#endif /* __inline__ not defined */


#ifndef SDL_FORCE_INLINE #ifndef SDL_FORCE_INLINE
#if defined(_MSC_VER) #if defined(_MSC_VER)
#define SDL_FORCE_INLINE __forceinline #define SDL_FORCE_INLINE __forceinline
#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) #elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__ #define SDL_FORCE_INLINE __attribute__((always_inline)) static SDL_INLINE
#else #else
#define SDL_FORCE_INLINE static __inline__ #define SDL_FORCE_INLINE static SDL_INLINE
#endif
#endif #endif
#endif /* SDL_FORCE_INLINE not defined */


/* Apparently this is needed by several Windows compilers */ /* Apparently this is needed by several Windows compilers */
#if !defined(__MACH__) #if !defined(__MACH__)
Expand Down
4 changes: 2 additions & 2 deletions src/atomic/SDL_atomic.c
Expand Up @@ -55,15 +55,15 @@


static SDL_SpinLock locks[32]; static SDL_SpinLock locks[32];


static __inline__ void static SDL_INLINE void
enterLock(void *a) enterLock(void *a)
{ {
uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f); uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f);


SDL_AtomicLock(&locks[index]); SDL_AtomicLock(&locks[index]);
} }


static __inline__ void static SDL_INLINE void
leaveLock(void *a) leaveLock(void *a)
{ {
uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f); uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f);
Expand Down
2 changes: 1 addition & 1 deletion src/audio/SDL_audiodev.c
Expand Up @@ -46,7 +46,7 @@
#define _PATH_DEV_AUDIO "/dev/audio" #define _PATH_DEV_AUDIO "/dev/audio"
#endif #endif


static inline void static SDL_INLINE void
test_device(const char *fname, int flags, int (*test) (int fd), test_device(const char *fname, int flags, int (*test) (int fd),
SDL_AddAudioDevice addfn) SDL_AddAudioDevice addfn)
{ {
Expand Down
10 changes: 5 additions & 5 deletions src/audio/alsa/SDL_alsa_audio.c
Expand Up @@ -241,25 +241,25 @@ ALSA_WaitDevice(_THIS)
tmp = ptr[3]; ptr[3] = ptr[5]; ptr[5] = tmp; \ tmp = ptr[3]; ptr[3] = ptr[5]; ptr[5] = tmp; \
} }


static __inline__ void static SDL_INLINE void
swizzle_alsa_channels_6_64bit(_THIS) swizzle_alsa_channels_6_64bit(_THIS)
{ {
SWIZ6(Uint64); SWIZ6(Uint64);
} }


static __inline__ void static SDL_INLINE void
swizzle_alsa_channels_6_32bit(_THIS) swizzle_alsa_channels_6_32bit(_THIS)
{ {
SWIZ6(Uint32); SWIZ6(Uint32);
} }


static __inline__ void static SDL_INLINE void
swizzle_alsa_channels_6_16bit(_THIS) swizzle_alsa_channels_6_16bit(_THIS)
{ {
SWIZ6(Uint16); SWIZ6(Uint16);
} }


static __inline__ void static SDL_INLINE void
swizzle_alsa_channels_6_8bit(_THIS) swizzle_alsa_channels_6_8bit(_THIS)
{ {
SWIZ6(Uint8); SWIZ6(Uint8);
Expand All @@ -272,7 +272,7 @@ swizzle_alsa_channels_6_8bit(_THIS)
* Called right before feeding this->hidden->mixbuf to the hardware. Swizzle * Called right before feeding this->hidden->mixbuf to the hardware. Swizzle
* channels from Windows/Mac order to the format alsalib will want. * channels from Windows/Mac order to the format alsalib will want.
*/ */
static __inline__ void static SDL_INLINE void
swizzle_alsa_channels(_THIS) swizzle_alsa_channels(_THIS)
{ {
if (this->spec.channels == 6) { if (this->spec.channels == 6) {
Expand Down
6 changes: 3 additions & 3 deletions src/audio/pulseaudio/SDL_pulseaudio.c
Expand Up @@ -49,15 +49,15 @@


#if (PA_API_VERSION < 12) #if (PA_API_VERSION < 12)
/** Return non-zero if the passed state is one of the connected states */ /** Return non-zero if the passed state is one of the connected states */
static __inline__ int PA_CONTEXT_IS_GOOD(pa_context_state_t x) { static SDL_INLINE int PA_CONTEXT_IS_GOOD(pa_context_state_t x) {
return return
x == PA_CONTEXT_CONNECTING || x == PA_CONTEXT_CONNECTING ||
x == PA_CONTEXT_AUTHORIZING || x == PA_CONTEXT_AUTHORIZING ||
x == PA_CONTEXT_SETTING_NAME || x == PA_CONTEXT_SETTING_NAME ||
x == PA_CONTEXT_READY; x == PA_CONTEXT_READY;
} }
/** Return non-zero if the passed state is one of the connected states */ /** Return non-zero if the passed state is one of the connected states */
static __inline__ int PA_STREAM_IS_GOOD(pa_stream_state_t x) { static SDL_INLINE int PA_STREAM_IS_GOOD(pa_stream_state_t x) {
return return
x == PA_STREAM_CREATING || x == PA_STREAM_CREATING ||
x == PA_STREAM_READY; x == PA_STREAM_READY;
Expand Down Expand Up @@ -322,7 +322,7 @@ PULSEAUDIO_CloseDevice(_THIS)
} }




static __inline__ int static SDL_INLINE int
squashVersion(const int major, const int minor, const int patch) squashVersion(const int major, const int minor, const int patch)
{ {
return ((major & 0xFF) << 16) | ((minor & 0xFF) << 8) | (patch & 0xFF); return ((major & 0xFF) << 16) | ((minor & 0xFF) << 8) | (patch & 0xFF);
Expand Down
2 changes: 1 addition & 1 deletion src/audio/qsa/SDL_qsa_audio.c
Expand Up @@ -83,7 +83,7 @@ uint32_t qsa_playback_devices;
QSA_Device qsa_capture_device[QSA_MAX_DEVICES]; QSA_Device qsa_capture_device[QSA_MAX_DEVICES];
uint32_t qsa_capture_devices; uint32_t qsa_capture_devices;


static inline int static SDL_INLINE int
QSA_SetError(const char *fn, int status) QSA_SetError(const char *fn, int status)
{ {
return SDL_SetError("QSA: %s() failed: %s", fn, snd_strerror(status)); return SDL_SetError("QSA: %s() failed: %s", fn, snd_strerror(status));
Expand Down
22 changes: 11 additions & 11 deletions src/cpuinfo/SDL_cpuinfo.c
Expand Up @@ -68,7 +68,7 @@ illegal_instruction(int sig)
} }
#endif /* HAVE_SETJMP */ #endif /* HAVE_SETJMP */


static __inline__ int static SDL_INLINE int
CPU_haveCPUID(void) CPU_haveCPUID(void)
{ {
int has_CPUID = 0; int has_CPUID = 0;
Expand Down Expand Up @@ -192,7 +192,7 @@ CPUid by definition. But it's nice to be able to prove it. :) */
a = b = c = d = 0 a = b = c = d = 0
#endif #endif


static __inline__ int static SDL_INLINE int
CPU_getCPUIDFeatures(void) CPU_getCPUIDFeatures(void)
{ {
int features = 0; int features = 0;
Expand All @@ -206,7 +206,7 @@ CPU_getCPUIDFeatures(void)
return features; return features;
} }


static __inline__ int static SDL_INLINE int
CPU_haveRDTSC(void) CPU_haveRDTSC(void)
{ {
if (CPU_haveCPUID()) { if (CPU_haveCPUID()) {
Expand All @@ -215,7 +215,7 @@ CPU_haveRDTSC(void)
return 0; return 0;
} }


static __inline__ int static SDL_INLINE int
CPU_haveAltiVec(void) CPU_haveAltiVec(void)
{ {
volatile int altivec = 0; volatile int altivec = 0;
Expand All @@ -242,7 +242,7 @@ CPU_haveAltiVec(void)
return altivec; return altivec;
} }


static __inline__ int static SDL_INLINE int
CPU_haveMMX(void) CPU_haveMMX(void)
{ {
if (CPU_haveCPUID()) { if (CPU_haveCPUID()) {
Expand All @@ -251,7 +251,7 @@ CPU_haveMMX(void)
return 0; return 0;
} }


static __inline__ int static SDL_INLINE int
CPU_have3DNow(void) CPU_have3DNow(void)
{ {
if (CPU_haveCPUID()) { if (CPU_haveCPUID()) {
Expand All @@ -266,7 +266,7 @@ CPU_have3DNow(void)
return 0; return 0;
} }


static __inline__ int static SDL_INLINE int
CPU_haveSSE(void) CPU_haveSSE(void)
{ {
if (CPU_haveCPUID()) { if (CPU_haveCPUID()) {
Expand All @@ -275,7 +275,7 @@ CPU_haveSSE(void)
return 0; return 0;
} }


static __inline__ int static SDL_INLINE int
CPU_haveSSE2(void) CPU_haveSSE2(void)
{ {
if (CPU_haveCPUID()) { if (CPU_haveCPUID()) {
Expand All @@ -284,7 +284,7 @@ CPU_haveSSE2(void)
return 0; return 0;
} }


static __inline__ int static SDL_INLINE int
CPU_haveSSE3(void) CPU_haveSSE3(void)
{ {
if (CPU_haveCPUID()) { if (CPU_haveCPUID()) {
Expand All @@ -299,7 +299,7 @@ CPU_haveSSE3(void)
return 0; return 0;
} }


static __inline__ int static SDL_INLINE int
CPU_haveSSE41(void) CPU_haveSSE41(void)
{ {
if (CPU_haveCPUID()) { if (CPU_haveCPUID()) {
Expand All @@ -314,7 +314,7 @@ CPU_haveSSE41(void)
return 0; return 0;
} }


static __inline__ int static SDL_INLINE int
CPU_haveSSE42(void) CPU_haveSSE42(void)
{ {
if (CPU_haveCPUID()) { if (CPU_haveCPUID()) {
Expand Down
2 changes: 1 addition & 1 deletion src/events/SDL_events.c
Expand Up @@ -83,7 +83,7 @@ static struct
} SDL_EventQ = { NULL, SDL_TRUE }; } SDL_EventQ = { NULL, SDL_TRUE };




static __inline__ SDL_bool static SDL_INLINE SDL_bool
SDL_ShouldPollJoystick() SDL_ShouldPollJoystick()
{ {
#if !SDL_JOYSTICK_DISABLED #if !SDL_JOYSTICK_DISABLED
Expand Down
10 changes: 5 additions & 5 deletions src/joystick/linux/SDL_sysjoystick.c
Expand Up @@ -617,7 +617,7 @@ SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
return !joystick->closed && (joystick->hwdata->item != NULL); return !joystick->closed && (joystick->hwdata->item != NULL);
} }


static __inline__ void static SDL_INLINE void
HandleHat(SDL_Joystick * stick, Uint8 hat, int axis, int value) HandleHat(SDL_Joystick * stick, Uint8 hat, int axis, int value)
{ {
struct hwdata_hat *the_hat; struct hwdata_hat *the_hat;
Expand All @@ -643,14 +643,14 @@ HandleHat(SDL_Joystick * stick, Uint8 hat, int axis, int value)
} }
} }


static __inline__ void static SDL_INLINE void
HandleBall(SDL_Joystick * stick, Uint8 ball, int axis, int value) HandleBall(SDL_Joystick * stick, Uint8 ball, int axis, int value)
{ {
stick->hwdata->balls[ball].axis[axis] += value; stick->hwdata->balls[ball].axis[axis] += value;
} }




static __inline__ int static SDL_INLINE int
AxisCorrect(SDL_Joystick * joystick, int which, int value) AxisCorrect(SDL_Joystick * joystick, int which, int value)
{ {
struct axis_correct *correct; struct axis_correct *correct;
Expand Down Expand Up @@ -679,7 +679,7 @@ AxisCorrect(SDL_Joystick * joystick, int which, int value)
return value; return value;
} }


static __inline__ void static SDL_INLINE void
PollAllValues(SDL_Joystick * joystick) PollAllValues(SDL_Joystick * joystick)
{ {
struct input_absinfo absinfo; struct input_absinfo absinfo;
Expand Down Expand Up @@ -717,7 +717,7 @@ PollAllValues(SDL_Joystick * joystick)
} }
} }


static __inline__ void static SDL_INLINE void
HandleInputEvents(SDL_Joystick * joystick) HandleInputEvents(SDL_Joystick * joystick)
{ {
struct input_event events[32]; struct input_event events[32];
Expand Down
2 changes: 1 addition & 1 deletion src/joystick/psp/SDL_sysjoystick.c
Expand Up @@ -60,7 +60,7 @@ static point c = { 78, 32767 };
static point d = { 128, 32767 }; static point d = { 128, 32767 };


/* simple linear interpolation between two points */ /* simple linear interpolation between two points */
static __inline__ void lerp (point *dest, point *a, point *b, float t) static SDL_INLINE void lerp (point *dest, point *a, point *b, float t)
{ {
dest->x = a->x + (b->x - a->x)*t; dest->x = a->x + (b->x - a->x)*t;
dest->y = a->y + (b->y - a->y)*t; dest->y = a->y + (b->y - a->y)*t;
Expand Down
2 changes: 1 addition & 1 deletion src/render/opengles/SDL_render_gles.c
Expand Up @@ -414,7 +414,7 @@ GLES_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
} }
} }


static __inline__ int static SDL_INLINE int
power_of_2(int input) power_of_2(int input)
{ {
int value = 1; int value = 1;
Expand Down
4 changes: 2 additions & 2 deletions src/video/SDL_blit_copy.c
Expand Up @@ -27,7 +27,7 @@


#ifdef __SSE__ #ifdef __SSE__
/* This assumes 16-byte aligned src and dst */ /* This assumes 16-byte aligned src and dst */
static __inline__ void static SDL_INLINE void
SDL_memcpySSE(Uint8 * dst, const Uint8 * src, int len) SDL_memcpySSE(Uint8 * dst, const Uint8 * src, int len)
{ {
int i; int i;
Expand Down Expand Up @@ -56,7 +56,7 @@ SDL_memcpySSE(Uint8 * dst, const Uint8 * src, int len)
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable:4799) #pragma warning(disable:4799)
#endif #endif
static __inline__ void static SDL_INLINE void
SDL_memcpyMMX(Uint8 * dst, const Uint8 * src, int len) SDL_memcpyMMX(Uint8 * dst, const Uint8 * src, int len)
{ {
const int remain = (len & 63); const int remain = (len & 63);
Expand Down
2 changes: 1 addition & 1 deletion src/video/SDL_surface.c
Expand Up @@ -951,7 +951,7 @@ SDL_ConvertSurfaceFormat(SDL_Surface * surface, Uint32 pixel_format,
/* /*
* Create a surface on the stack for quick blit operations * Create a surface on the stack for quick blit operations
*/ */
static __inline__ SDL_bool static SDL_INLINE SDL_bool
SDL_CreateSurfaceOnStack(int width, int height, Uint32 pixel_format, SDL_CreateSurfaceOnStack(int width, int height, Uint32 pixel_format,
void * pixels, int pitch, SDL_Surface * surface, void * pixels, int pitch, SDL_Surface * surface,
SDL_PixelFormat * format, SDL_BlitMap * blitmap) SDL_PixelFormat * format, SDL_BlitMap * blitmap)
Expand Down
2 changes: 1 addition & 1 deletion src/video/SDL_video.c
Expand Up @@ -2382,7 +2382,7 @@ SDL_GL_UnloadLibrary(void)
} }
} }


static __inline__ SDL_bool static SDL_INLINE SDL_bool
isAtLeastGL3(const char *verstr) isAtLeastGL3(const char *verstr)
{ {
return ( verstr && (SDL_atoi(verstr) >= 3) ); return ( verstr && (SDL_atoi(verstr) >= 3) );
Expand Down
4 changes: 2 additions & 2 deletions src/video/bwindow/SDL_bframebuffer.cc
Expand Up @@ -37,11 +37,11 @@ extern "C" {


int32 BE_UpdateOnce(SDL_Window *window); int32 BE_UpdateOnce(SDL_Window *window);


static inline SDL_BWin *_ToBeWin(SDL_Window *window) { static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) {
return ((SDL_BWin*)(window->driverdata)); return ((SDL_BWin*)(window->driverdata));
} }


static inline SDL_BApp *_GetBeApp() { static SDL_INLINE SDL_BApp *_GetBeApp() {
return ((SDL_BApp*)be_app); return ((SDL_BApp*)be_app);
} }


Expand Down

0 comments on commit 08fa8da

Please sign in to comment.