From 74e1dd4c6f8def7534381325584057802af0439a Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 11 Nov 2016 13:14:00 -0800 Subject: [PATCH] Define _GNU_SOURCE when building SDL --- src/SDL_internal.h | 11 ++++++++++- src/stdlib/SDL_string.c | 7 +------ src/test/SDL_test_fuzzer.c | 1 - src/thread/pthread/SDL_sysmutex.c | 3 --- src/thread/pthread/SDL_syssem.c | 3 --- src/video/wayland/SDL_waylanddatamanager.c | 2 -- src/video/wayland/SDL_waylandmouse.c | 4 ---- src/video/x11/SDL_x11modes.c | 4 ---- 8 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/SDL_internal.h b/src/SDL_internal.h index 7e928501a92f0..e3083fe727998 100644 --- a/src/SDL_internal.h +++ b/src/SDL_internal.h @@ -21,6 +21,15 @@ #ifndef _SDL_internal_h #define _SDL_internal_h +/* Many of SDL's features require _GNU_SOURCE on various platforms + You can turn this off if necessary by using -D_GNU_SOURCE=0 + */ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#elif !_GNU_SOURCE +#undef _GNU_SOURCE +#endif + #include "dynapi/SDL_dynapi.h" #if SDL_DYNAMIC_API @@ -33,6 +42,6 @@ #include "SDL_config.h" -#endif +#endif /* _SDL_internal_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c index debbebaed87ae..3e856b5f76582 100644 --- a/src/stdlib/SDL_string.c +++ b/src/stdlib/SDL_string.c @@ -18,15 +18,10 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ - -#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS) +#if defined(__clang_analyzer__) #define SDL_DISABLE_ANALYZE_MACROS 1 #endif -#ifndef _GNU_SOURCE -#define _GNU_SOURCE 1 -#endif - #include "../SDL_internal.h" /* This file contains portable string manipulation functions for SDL */ diff --git a/src/test/SDL_test_fuzzer.c b/src/test/SDL_test_fuzzer.c index 1bd8dfa188fcb..9ae653643b587 100644 --- a/src/test/SDL_test_fuzzer.c +++ b/src/test/SDL_test_fuzzer.c @@ -34,7 +34,6 @@ #define UINT32_MAX ~(Uint32)0 #define UINT64_MAX ~(Uint64)0 #else -#define _GNU_SOURCE #include #endif #include diff --git a/src/thread/pthread/SDL_sysmutex.c b/src/thread/pthread/SDL_sysmutex.c index f24cfdab01eb0..ee7f58389e938 100644 --- a/src/thread/pthread/SDL_sysmutex.c +++ b/src/thread/pthread/SDL_sysmutex.c @@ -20,9 +20,6 @@ */ #include "../../SDL_internal.h" -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif #include #include diff --git a/src/thread/pthread/SDL_syssem.c b/src/thread/pthread/SDL_syssem.c index b7547e699ca40..caadf4ec67610 100644 --- a/src/thread/pthread/SDL_syssem.c +++ b/src/thread/pthread/SDL_syssem.c @@ -20,9 +20,6 @@ */ #include "../../SDL_internal.h" -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif #include #include #include diff --git a/src/video/wayland/SDL_waylanddatamanager.c b/src/video/wayland/SDL_waylanddatamanager.c index afcec1a99cd0c..323eff7b7546a 100644 --- a/src/video/wayland/SDL_waylanddatamanager.c +++ b/src/video/wayland/SDL_waylanddatamanager.c @@ -23,8 +23,6 @@ #if SDL_VIDEO_DRIVER_WAYLAND -/* _GNU_SOURCE for pipe2 declaration. */ -#define _GNU_SOURCE #include #include #include diff --git a/src/video/wayland/SDL_waylandmouse.c b/src/video/wayland/SDL_waylandmouse.c index 8dfc9eea37ab1..73b2b581f005c 100644 --- a/src/video/wayland/SDL_waylandmouse.c +++ b/src/video/wayland/SDL_waylandmouse.c @@ -23,10 +23,6 @@ #if SDL_VIDEO_DRIVER_WAYLAND -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - #include #include #include diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index b1e3ff478daf3..29307b3a60631 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -18,10 +18,6 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - #include "../../SDL_internal.h" #if SDL_VIDEO_DRIVER_X11