File: Add-GNU-Hurd-as-platform.patch

package info (click to toggle)
libsdl3 3.2.26%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 42,540 kB
  • sloc: ansic: 390,896; objc: 12,361; xml: 9,084; cpp: 5,729; perl: 4,589; python: 3,372; sh: 1,032; makefile: 265; cs: 56
file content (123 lines) | stat: -rw-r--r-- 4,775 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
From: Pino Toscano <toscano.pino@tiscali.it>
Date: Thu, 7 Aug 2025 23:35:39 +0200
Subject: Add GNU/Hurd as platform

SDL has been building on GNU/Hurd for a long time, using either drivers
based on external libraries (e.g. X11, pulseaudio, sndio, etc) or dummy
drivers. This commit introduces it explicitly as platform, so it can be
recognized, and tweaked as needed. In particular:
- introduce the SDL_PLATFORM_HURD define
- tighten/improve the platform detection in cmake, and use "Hurd" as
  identifier
- return the platform name in SDL_GetPlatform()
- tweak the CFLAGS/LDFLAGS so pthreads can be used properly
- implement SDL_GetExeName(), using /proc/self/exe as provided by the
  basic Linux-like procfs
- enable GLES 2 in tests (mostly for consistency with Linux)

[smcv: Add a note that availability of SDL_PLATFORM_HURD in 3.2.x is
Debian-specific]

Origin: upstream, 3.4.0, commit:5ff9935e021bd22f36de69f193a948c2138b854b
Bug-Debian: https://salsa.debian.org/sdl-team/libsdl3/-/merge_requests/3
---
 cmake/sdlchecks.cmake               |  3 +++
 cmake/sdlplatform.cmake             |  4 ++--
 include/SDL3/SDL_platform_defines.h | 10 ++++++++++
 src/SDL.c                           |  2 ++
 src/core/unix/SDL_appid.c           |  4 ++--
 test/testgles2.c                    |  2 +-
 6 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake
index d321e71..59f2159 100644
--- a/cmake/sdlchecks.cmake
+++ b/cmake/sdlchecks.cmake
@@ -842,6 +842,9 @@ macro(CheckPTHREAD)
       set(PTHREAD_LDFLAGS "-pthread")
     elseif(QNX)
       # pthread support is baked in
+    elseif(HURD)
+      set(PTHREAD_CFLAGS "-D_REENTRANT")
+      set(PTHREAD_LDFLAGS "-pthread")
     else()
       set(PTHREAD_CFLAGS "-D_REENTRANT")
       set(PTHREAD_LDFLAGS "-lpthread")
diff --git a/cmake/sdlplatform.cmake b/cmake/sdlplatform.cmake
index 677b187..c5904be 100644
--- a/cmake/sdlplatform.cmake
+++ b/cmake/sdlplatform.cmake
@@ -34,8 +34,8 @@ function(SDL_DetectCMakePlatform)
     set(sdl_cmake_platform NetBSD)
   elseif(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*")
     set(sdl_cmake_platform OpenBSD)
-  elseif(CMAKE_SYSTEM_NAME MATCHES ".*GNU.*")
-    set(sdl_cmake_platform GNU)
+  elseif(CMAKE_SYSTEM_NAME STREQUAL "GNU")
+    set(sdl_cmake_platform Hurd)
   elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
     set(sdl_cmake_platform BSDi)
   elseif(CMAKE_SYSTEM_NAME MATCHES "DragonFly.*|FreeBSD")
diff --git a/include/SDL3/SDL_platform_defines.h b/include/SDL3/SDL_platform_defines.h
index 6b240a8..44c0898 100644
--- a/include/SDL3/SDL_platform_defines.h
+++ b/include/SDL3/SDL_platform_defines.h
@@ -473,4 +473,14 @@
 #define SDL_PLATFORM_3DS 1
 #endif
 
+#ifdef __GNU__
+
+/**
+ * A preprocessor macro that is only defined if compiling for GNU/Hurd.
+ *
+ * \since This macro is available since SDL 3.4.0, and was added to 3.2.x as a Debian-specific backport.
+ */
+#define SDL_PLATFORM_HURD 1
+#endif
+
 #endif /* SDL_platform_defines_h_ */
diff --git a/src/SDL.c b/src/SDL.c
index 46a74aa..5fda0f8 100644
--- a/src/SDL.c
+++ b/src/SDL.c
@@ -760,6 +760,8 @@ const char *SDL_GetPlatform(void)
     return "PlayStation Vita";
 #elif defined(SDL_PLATFORM_3DS)
     return "Nintendo 3DS";
+#elif defined(SDL_PLATFORM_HURD)
+    return "GNU/Hurd";
 #elif defined(__managarm__)
     return "Managarm";
 #else
diff --git a/src/core/unix/SDL_appid.c b/src/core/unix/SDL_appid.c
index 996e216..8bf3349 100644
--- a/src/core/unix/SDL_appid.c
+++ b/src/core/unix/SDL_appid.c
@@ -30,11 +30,11 @@ const char *SDL_GetExeName(void)
 
     // TODO: Use a fallback if BSD has no mounted procfs (OpenBSD has no procfs at all)
     if (!proc_name) {
-#if defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_FREEBSD) || defined (SDL_PLATFORM_NETBSD)
+#if defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_FREEBSD) || defined (SDL_PLATFORM_NETBSD) || defined(SDL_PLATFORM_HURD)
         static char linkfile[1024];
         int linksize;
 
-#if defined(SDL_PLATFORM_LINUX)
+#if defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_HURD)
         const char *proc_path = "/proc/self/exe";
 #elif defined(SDL_PLATFORM_FREEBSD)
         const char *proc_path = "/proc/curproc/file";
diff --git a/test/testgles2.c b/test/testgles2.c
index 5fad872..2f054fc 100644
--- a/test/testgles2.c
+++ b/test/testgles2.c
@@ -19,7 +19,7 @@
 
 #include <stdlib.h>
 
-#if defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_EMSCRIPTEN) || defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_LINUX)
+#if defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_EMSCRIPTEN) || defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_HURD)
 #define HAVE_OPENGLES2
 #endif