Browse Source

Define _GNU_SOURCE when building SDL

Sam Lantinga 8 years ago
parent
commit
74e1dd4c6f

+ 10 - 1
src/SDL_internal.h

@@ -21,6 +21,15 @@
 #ifndef _SDL_internal_h
 #ifndef _SDL_internal_h
 #define _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"
 #include "dynapi/SDL_dynapi.h"
 
 
 #if SDL_DYNAMIC_API
 #if SDL_DYNAMIC_API
@@ -33,6 +42,6 @@
 
 
 #include "SDL_config.h"
 #include "SDL_config.h"
 
 
-#endif
+#endif /* _SDL_internal_h */
 
 
 /* vi: set ts=4 sw=4 expandtab: */
 /* vi: set ts=4 sw=4 expandtab: */

+ 1 - 6
src/stdlib/SDL_string.c

@@ -18,15 +18,10 @@
      misrepresented as being the original software.
      misrepresented as being the original software.
   3. This notice may not be removed or altered from any source distribution.
   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
 #define SDL_DISABLE_ANALYZE_MACROS 1
 #endif
 #endif
 
 
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE 1
-#endif
-
 #include "../SDL_internal.h"
 #include "../SDL_internal.h"
 
 
 /* This file contains portable string manipulation functions for SDL */
 /* This file contains portable string manipulation functions for SDL */

+ 0 - 1
src/test/SDL_test_fuzzer.c

@@ -34,7 +34,6 @@
 #define UINT32_MAX  ~(Uint32)0
 #define UINT32_MAX  ~(Uint32)0
 #define UINT64_MAX  ~(Uint64)0
 #define UINT64_MAX  ~(Uint64)0
 #else
 #else
-#define _GNU_SOURCE
 #include <stdint.h>
 #include <stdint.h>
 #endif
 #endif
 #include <stdio.h>
 #include <stdio.h>

+ 0 - 3
src/thread/pthread/SDL_sysmutex.c

@@ -20,9 +20,6 @@
 */
 */
 #include "../../SDL_internal.h"
 #include "../../SDL_internal.h"
 
 
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
 #include <errno.h>
 #include <errno.h>
 #include <pthread.h>
 #include <pthread.h>
 
 

+ 0 - 3
src/thread/pthread/SDL_syssem.c

@@ -20,9 +20,6 @@
 */
 */
 #include "../../SDL_internal.h"
 #include "../../SDL_internal.h"
 
 
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
 #include <errno.h>
 #include <errno.h>
 #include <pthread.h>
 #include <pthread.h>
 #include <semaphore.h>
 #include <semaphore.h>

+ 0 - 2
src/video/wayland/SDL_waylanddatamanager.c

@@ -23,8 +23,6 @@
 
 
 #if SDL_VIDEO_DRIVER_WAYLAND
 #if SDL_VIDEO_DRIVER_WAYLAND
 
 
-/* _GNU_SOURCE for pipe2 declaration. */
-#define _GNU_SOURCE
 #include <fcntl.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <unistd.h>
 #include <limits.h>
 #include <limits.h>

+ 0 - 4
src/video/wayland/SDL_waylandmouse.c

@@ -23,10 +23,6 @@
 
 
 #if SDL_VIDEO_DRIVER_WAYLAND
 #if SDL_VIDEO_DRIVER_WAYLAND
 
 
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
 #include <sys/types.h>
 #include <sys/types.h>
 #include <sys/mman.h>
 #include <sys/mman.h>
 #include <fcntl.h>
 #include <fcntl.h>

+ 0 - 4
src/video/x11/SDL_x11modes.c

@@ -18,10 +18,6 @@
      misrepresented as being the original software.
      misrepresented as being the original software.
   3. This notice may not be removed or altered from any source distribution.
   3. This notice may not be removed or altered from any source distribution.
 */
 */
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
 #include "../../SDL_internal.h"
 #include "../../SDL_internal.h"
 
 
 #if SDL_VIDEO_DRIVER_X11
 #if SDL_VIDEO_DRIVER_X11