sdl2-compat: Improve support for GNU/Hurd

From 2b68c8b2f2f498a6a16dce885a12e54f9aa20274 Mon Sep 17 00:00:00 2001
From: Pino Toscano <[EMAIL REDACTED]>
Date: Fri, 19 Dec 2025 09:12:27 +0100
Subject: [PATCH] Improve support for GNU/Hurd

SDL already supports GNU/Hurd, so improves the integration for it in
this SDL2 compatibility layer:
- tighten/improve the platform detection in cmake, and use "Hurd" as
  identifier
- use the Linux OS_GetExeName() using /proc/self/exe as provided by the
  basic Linux-like procfs
---
 cmake/sdlplatform.cmake | 4 ++--
 src/sdl2_compat.c       | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/cmake/sdlplatform.cmake b/cmake/sdlplatform.cmake
index ebb2077f..13da4c22 100644
--- a/cmake/sdlplatform.cmake
+++ b/cmake/sdlplatform.cmake
@@ -31,8 +31,8 @@ macro(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/src/sdl2_compat.c b/src/sdl2_compat.c
index f3f6247a..17713e9e 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -96,7 +96,7 @@ This breaks the build when creating SDL_ ## DisableScreenSaver
 #undef snprintf
 #undef vsnprintf
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
 #include <unistd.h> /* for readlink() */
 #endif
 
@@ -539,7 +539,7 @@ static QuirkEntryType quirks[] = {
 #endif
 };
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GNU__)
 static void OS_GetExeName(char *buf, const unsigned maxpath, bool *use_base_path)
 {
     int ret;