From f2738f5d93f4037f92bfe15d4767ff99f8eb6f16 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[EMAIL REDACTED]>
Date: Wed, 5 Feb 2025 14:17:21 +0000
Subject: [PATCH] SDL_config_unix.h: Define macros for a few GNU extensions if
using glibc
glibc provides getauxval(), strcasestr() and pthread_setname_np(),
and recent versions also provide memfd_create(). Linux games could
conceivably be relying on classic SDL2 checking for these.
I'm checking for `__GLIBC__` rather than `__LINUX__` because these are
really features of the libc, not the kernel.
Signed-off-by: Simon McVittie <smcv@collabora.com>
---
include/SDL2/SDL_config_unix.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/include/SDL2/SDL_config_unix.h b/include/SDL2/SDL_config_unix.h
index b47fbe8..81e3d4c 100644
--- a/include/SDL2/SDL_config_unix.h
+++ b/include/SDL2/SDL_config_unix.h
@@ -24,6 +24,9 @@
#include "SDL_platform.h"
+/* A harmless way to get __GLIBC__ defined on glibc systems */
+#include <limits.h>
+
/* C datatypes */
#if defined(__SIZEOF_POINTER__)
#define SIZEOF_VOIDP (__SIZEOF_POINTER__)
@@ -177,6 +180,19 @@
#define HAVE_INDEX 1 /* required by POSIX until 2008 */
#define HAVE_RINDEX 1 /* required by POSIX until 2008 */
+/* GNU extensions, known to be provided by glibc, probably not provided
+ * by other libc implementations */
+#if defined(__GLIBC__)
+#define HAVE_GETAUXVAL 1
+#define HAVE_STRCASESTR 1
+#define HAVE_PTHREAD_SETNAME_NP 1
+#endif
+
+#if defined(__GLIBC__) && \
+ (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 27))
+#define HAVE_MEMFD_CREATE 1
+#endif
+
#define SDL_VIDEO_DRIVER_X11 1
#if defined(__LINUX__)