Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

SDL: Expand configuration macros, update patches

Thaddeus Crewsc5966021b4e4
diff --git a/drivers/sdl/SDL_build_config_private.h b/drivers/sdl/SDL_build_config_private.h
index f2eee256e2a..8bfed71bd24 100644
--- a/drivers/sdl/SDL_build_config_private.h
+++ b/drivers/sdl/SDL_build_config_private.h
@@ -30,15 +30,45 @@
#pragma once
-#define SDL_build_config_h_
-
-#include <SDL3/SDL_platform_defines.h>
+// Always use standard library to avoid built-in functions changing (see GH-110198).
+#define HAVE_LIBC 1
+// Standard library headers.
+#define HAVE_FLOAT_H 1
+#define HAVE_LIMITS_H 1
+#define HAVE_MATH_H 1
+#define HAVE_MEMORY_H 1
#define HAVE_STDARG_H 1
#define HAVE_STDDEF_H 1
+#define HAVE_STDINT_H 1
+#define HAVE_STDIO_H 1
#define HAVE_STDLIB_H 1
+#define HAVE_STRING_H 1
+#define HAVE_WCHAR_H 1
+
+// Non-standard headers.
+#if __has_include(<alloca.h>)
+#define HAVE_ALLOCA_H 1
+#endif
+#if __has_include(<inttypes.h>)
+#define HAVE_INTTYPES_H 1
+#endif
+#if __has_include(<malloc.h>)
+#define HAVE_MALLOC_H 1
+#endif
+#if __has_include(<strings.h>)
+#define HAVE_STRINGS_H 1
+#endif
+#if __has_include(<sys/types.h>)
+#define HAVE_SYS_TYPES_H 1
+#endif
+
+// Compiler-specific defines.
+#ifdef __GNUC__
+#define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1
+#endif
-// Here we disable SDL subsystems that are not going to be used
+// Here we disable SDL subsystems that are not going to be used.
#define SDL_CPUINFO_DISABLED 1
#define SDL_AUDIO_DISABLED 1
#define SDL_PROCESS_DUMMY 1
@@ -51,14 +81,13 @@
#define SDL_POWER_DISABLED 1
#define SDL_LEAN_AND_MEAN 1
-// Windows defines
+// Windows defines.
#if defined(WINDOWS_ENABLED)
#define SDL_PLATFORM_PRIVATE_NAME "Windows"
-#define HAVE_LIBC 1
#define HAVE_DINPUT_H 1
#define HAVE_XINPUT_H 1
-#if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0A00 /* Windows 10 SDK */
+#if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0A00 // Windows 10 SDK.
#define HAVE_WINDOWS_GAMING_INPUT_H 1
#define SDL_JOYSTICK_WGI 1
#endif
@@ -72,24 +101,22 @@
#define SDL_THREAD_WINDOWS 1
#define SDL_TIMER_WINDOWS 1
#define SDL_SENSOR_WINDOWS 1
-#define SDL_FILESYSTEM_WINDOWS 1 // Used by thirdparty/sdl/joystick/windows/SDL_dinputjoystick.c
+#define SDL_FILESYSTEM_WINDOWS 1 // Used by `thirdparty/sdl/joystick/windows/SDL_dinputjoystick.c`.
#define SDL_FSOPS_WINDOWS 1
-// Linux defines
+// Linux defines.
#elif defined(LINUXBSD_ENABLED)
#define SDL_PLATFORM_PRIVATE_NAME "Linux"
-#define HAVE_STDIO_H 1
-#define HAVE_LIBC 1
#define HAVE_LINUX_INPUT_H 1
-#define HAVE_POLL 1
+#define HAVE_PPOLL 1
#ifdef __linux__
#define HAVE_INOTIFY 1
#define HAVE_INOTIFY_INIT1 1
// Don't add these defines, for some reason they mess with C#'s ability
-// to use environment variables (see GH-109024)
+// to use environment variables (see GH-109024).
//#define HAVE_GETENV 1
//#define HAVE_SETENV 1
//#define HAVE_UNSETENV 1
@@ -98,7 +125,7 @@
#ifdef DBUS_ENABLED
#define HAVE_DBUS_DBUS_H 1
#define SDL_USE_LIBDBUS 1
-// SOWRAP_ENABLED is handled in thirdparty/sdl/core/linux/SDL_dbus.c
+// SOWRAP_ENABLED is handled in `thirdparty/sdl/core/linux/SDL_dbus.c`.
#endif
#ifdef UDEV_ENABLED
@@ -119,12 +146,10 @@
#define SDL_FILESYSTEM_DUMMY 1
#define SDL_FSOPS_DUMMY 1
-// macOS defines
+// macOS defines.
#elif defined(MACOS_ENABLED)
#define SDL_PLATFORM_PRIVATE_NAME "macOS"
-#define HAVE_STDIO_H 1
-#define HAVE_LIBC 1
#define SDL_HAPTIC_IOKIT 1
#define SDL_JOYSTICK_IOKIT 1
#define SDL_JOYSTICK_MFI 1
@@ -135,7 +160,7 @@
#define SDL_FILESYSTEM_DUMMY 1
#define SDL_FSOPS_DUMMY 1
-// iOS/visionOS defines
+// iOS/visionOS defines.
#elif defined(IOS_ENABLED) || defined(VISIONOS_ENABLED)
#ifdef IOS_ENABLED
@@ -144,9 +169,6 @@
#define SDL_PLATFORM_PRIVATE_NAME "visionOS"
#endif
-#define HAVE_STDIO_H 1
-#define HAVE_LIBC 1
-
#define SDL_JOYSTICK_MFI 1
#define SDL_HAPTIC_DUMMY 1
#define SDL_TIMER_UNIX 1
@@ -156,15 +178,7 @@
#define SDL_MAIN_HANDLED 1
-// Other platforms are not supported (for now)
+// Other platforms are not supported (for now).
#else
#error "No SDL build config was found for this platform. Setup one before compiling the engine."
#endif
-
-#if !defined(HAVE_STDINT_H) && !defined(_STDINT_H_)
-#define HAVE_STDINT_H 1
-#endif /* !_STDINT_H_ && !HAVE_STDINT_H */
-
-#ifdef __GNUC__
-#define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1
-#endif
diff --git a/thirdparty/README.md b/thirdparty/README.md
index 59488cd16a8..54d7228e0b8 100644
--- a/thirdparty/README.md
+++ b/thirdparty/README.md
@@ -1032,7 +1032,7 @@ Files extracted from upstream source:
## sdl
- Upstream: https://github.com/libsdl-org/SDL
-- Version: 3.4.12 (f87239e71e42da91ca317a12eefb82cfbf3393eb, 2026)
+- Version: 3.4.16 (fa2c02bb6e21974a89ea9824bc53c9932abe5f9c, 2026)
- License: Zlib
- Vendored: hidapi 0.14.0, license BSD-3-Clause
@@ -1043,14 +1043,12 @@ Files extracted from upstream source:
Patches:
- `0001-remove-unnecessary-subsystems.patch` ([GH-106218](https://github.com/godotengine/godot/pull/106218))
-- `0003-std-include.patch` ([GH-108144](https://github.com/godotengine/godot/pull/108144))
-- `0004-errno-include.patch` ([GH-108354](https://github.com/godotengine/godot/pull/108354))
-- `0005-fix-libudev-dbus.patch` ([GH-108373](https://github.com/godotengine/godot/pull/108373))
-- `0006-fix-cs-environ.patch` ([GH-109283](https://github.com/godotengine/godot/pull/109283))
-- `0007-ios-accelerometer.patch` ([GH-120373](https://github.com/godotengine/godot/pull/120373))
-- `0008-ios-link.patch` ([GH-123903](https://github.com/godotengine/godot/pull/123903))
-- `0009-ios-iostream-no-prefpath.patch` ([GH-123899](https://github.com/godotengine/godot/pull/123899))
-- `0010-fix-linux-getenv-unsafe.patch` ([GH-124017](https://github.com/godotengine/godot/pull/124017))
+- `0002-fix-libudev-dbus.patch` ([GH-108373](https://github.com/godotengine/godot/pull/108373))
+- `0003-fix-cs-environ.patch` ([GH-109283](https://github.com/godotengine/godot/pull/109283))
+- `0004-ios-accelerometer.patch` ([GH-120373](https://github.com/godotengine/godot/pull/120373))
+- `0005-ios-link.patch` ([GH-123903](https://github.com/godotengine/godot/pull/123903))
+- `0006-ios-iostream-no-prefpath.patch` ([GH-123899](https://github.com/godotengine/godot/pull/123899))
+- `0007-fix-linux-getenv-unsafe.patch` ([GH-124017](https://github.com/godotengine/godot/pull/124017))
## spirv-cross
diff --git a/thirdparty/sdl/joystick/SDL_sysjoystick.h b/thirdparty/sdl/joystick/SDL_sysjoystick.h
index 888ef82a790..47ce42cdfae 100644
--- a/thirdparty/sdl/joystick/SDL_sysjoystick.h
+++ b/thirdparty/sdl/joystick/SDL_sysjoystick.h
@@ -26,8 +26,6 @@
// This is the system specific header for the SDL joystick API
#include "SDL_joystick_c.h"
-#include <stdlib.h>
-
// Set up for C function definitions, even when using C++
#ifdef __cplusplus
extern "C" {
diff --git a/thirdparty/sdl/patches/0005-fix-libudev-dbus.patch b/thirdparty/sdl/patches/0002-fix-libudev-dbus.patch
similarity index 100%
rename from thirdparty/sdl/patches/0005-fix-libudev-dbus.patch
rename to thirdparty/sdl/patches/0002-fix-libudev-dbus.patch
diff --git a/thirdparty/sdl/patches/0006-fix-cs-environ.patch b/thirdparty/sdl/patches/0003-fix-cs-environ.patch
similarity index 70%
rename from thirdparty/sdl/patches/0006-fix-cs-environ.patch
rename to thirdparty/sdl/patches/0003-fix-cs-environ.patch
index 27672cfb61f..3ec90f59107 100644
--- a/thirdparty/sdl/patches/0006-fix-cs-environ.patch
+++ b/thirdparty/sdl/patches/0003-fix-cs-environ.patch
@@ -1,18 +1,8 @@
diff --git a/thirdparty/sdl/stdlib/SDL_getenv.c b/thirdparty/sdl/stdlib/SDL_getenv.c
-index 1517b5974b..17220c69ae 100644
+index 2626b62717b..d66751a2105 100644
--- a/thirdparty/sdl/stdlib/SDL_getenv.c
+++ b/thirdparty/sdl/stdlib/SDL_getenv.c
-@@ -55,6 +55,9 @@ extern char **environ;
- static char **environ;
- #endif
-
-+#if defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_FREEBSD)
-+#include <stdlib.h>
-+#endif
-
- struct SDL_Environment
- {
-@@ -154,6 +157,9 @@ SDL_Environment *SDL_CreateEnvironment(bool populated)
+@@ -153,6 +153,9 @@ SDL_Environment *SDL_CreateEnvironment(bool populated)
const char *SDL_GetEnvironmentVariable(SDL_Environment *env, const char *name)
{
@@ -22,7 +12,7 @@ index 1517b5974b..17220c69ae 100644
const char *result = NULL;
if (!env) {
-@@ -173,6 +179,7 @@ const char *SDL_GetEnvironmentVariable(SDL_Environment *env, const char *name)
+@@ -172,6 +175,7 @@ const char *SDL_GetEnvironmentVariable(SDL_Environment *env, const char *name)
SDL_UnlockMutex(env->lock);
return result;
@@ -30,7 +20,7 @@ index 1517b5974b..17220c69ae 100644
}
typedef struct CountEnvStringsData
-@@ -251,6 +258,9 @@ char **SDL_GetEnvironmentVariables(SDL_Environment *env)
+@@ -250,6 +254,9 @@ char **SDL_GetEnvironmentVariables(SDL_Environment *env)
bool SDL_SetEnvironmentVariable(SDL_Environment *env, const char *name, const char *value, bool overwrite)
{
@@ -40,7 +30,7 @@ index 1517b5974b..17220c69ae 100644
bool result = false;
CHECK_PARAM(!env) {
-@@ -288,10 +298,14 @@ bool SDL_SetEnvironmentVariable(SDL_Environment *env, const char *name, const ch
+@@ -287,10 +294,14 @@ bool SDL_SetEnvironmentVariable(SDL_Environment *env, const char *name, const ch
SDL_UnlockMutex(env->lock);
return result;
@@ -55,7 +45,7 @@ index 1517b5974b..17220c69ae 100644
bool result = false;
CHECK_PARAM(!env) {
-@@ -313,6 +327,7 @@ bool SDL_UnsetEnvironmentVariable(SDL_Environment *env, const char *name)
+@@ -312,6 +323,7 @@ bool SDL_UnsetEnvironmentVariable(SDL_Environment *env, const char *name)
SDL_UnlockMutex(env->lock);
return result;
diff --git a/thirdparty/sdl/patches/0003-std-include.patch b/thirdparty/sdl/patches/0003-std-include.patch
deleted file mode 100644
index 273cdabc8f5..00000000000
--- a/thirdparty/sdl/patches/0003-std-include.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/thirdparty/sdl/joystick/SDL_sysjoystick.h b/thirdparty/sdl/joystick/SDL_sysjoystick.h
-index 041ebc3b50..9b6ea65e9c 100644
---- a/thirdparty/sdl/joystick/SDL_sysjoystick.h
-+++ b/thirdparty/sdl/joystick/SDL_sysjoystick.h
-@@ -26,6 +26,8 @@
- // This is the system specific header for the SDL joystick API
- #include "SDL_joystick_c.h"
-
-+#include <stdlib.h>
-+
- // Set up for C function definitions, even when using C++
- #ifdef __cplusplus
- extern "C" {
diff --git a/thirdparty/sdl/patches/0004-errno-include.patch b/thirdparty/sdl/patches/0004-errno-include.patch
deleted file mode 100644
index 50e3d4212d9..00000000000
--- a/thirdparty/sdl/patches/0004-errno-include.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/thirdparty/sdl/stdlib/SDL_malloc.c b/thirdparty/sdl/stdlib/SDL_malloc.c
-index 008675f312..00118b8ae6 100644
---- a/thirdparty/sdl/stdlib/SDL_malloc.c
-+++ b/thirdparty/sdl/stdlib/SDL_malloc.c
-@@ -586,7 +586,7 @@ MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP
- #define LACKS_STRING_H
- #define LACKS_STRINGS_H
- #define LACKS_SYS_TYPES_H
--#define LACKS_ERRNO_H
-+// #define LACKS_ERRNO_H // File uses `EINVAL` and `ENOMEM` defines, so include is required. Legacy exclusion?
- #define LACKS_SCHED_H
- #ifndef MALLOC_FAILURE_ACTION
- #define MALLOC_FAILURE_ACTION
diff --git a/thirdparty/sdl/patches/0007-ios-accelerometer.patch b/thirdparty/sdl/patches/0004-ios-accelerometer.patch
similarity index 100%
rename from thirdparty/sdl/patches/0007-ios-accelerometer.patch
rename to thirdparty/sdl/patches/0004-ios-accelerometer.patch
diff --git a/thirdparty/sdl/patches/0008-ios-link.patch b/thirdparty/sdl/patches/0005-ios-link.patch
similarity index 100%
rename from thirdparty/sdl/patches/0008-ios-link.patch
rename to thirdparty/sdl/patches/0005-ios-link.patch
diff --git a/thirdparty/sdl/patches/0009-ios-iostream-no-prefpath.patch b/thirdparty/sdl/patches/0006-ios-iostream-no-prefpath.patch
similarity index 100%
rename from thirdparty/sdl/patches/0009-ios-iostream-no-prefpath.patch
rename to thirdparty/sdl/patches/0006-ios-iostream-no-prefpath.patch
diff --git a/thirdparty/sdl/patches/0010-fix-linux-getenv-unsafe.patch b/thirdparty/sdl/patches/0007-fix-linux-getenv-unsafe.patch
similarity index 100%
rename from thirdparty/sdl/patches/0010-fix-linux-getenv-unsafe.patch
rename to thirdparty/sdl/patches/0007-fix-linux-getenv-unsafe.patch
diff --git a/thirdparty/sdl/stdlib/SDL_getenv.c b/thirdparty/sdl/stdlib/SDL_getenv.c
index 50a511262b9..fdf28e659bd 100644
--- a/thirdparty/sdl/stdlib/SDL_getenv.c
+++ b/thirdparty/sdl/stdlib/SDL_getenv.c
@@ -55,10 +55,6 @@ extern char **environ;
static char **environ;
#endif
-#if defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_FREEBSD)
-#include <stdlib.h>
-#endif
-
struct SDL_Environment
{
SDL_Mutex *lock; // !!! FIXME: reuse SDL_HashTable's lock.
diff --git a/thirdparty/sdl/stdlib/SDL_malloc.c b/thirdparty/sdl/stdlib/SDL_malloc.c
index ebbe8ec0f2c..5fb7c1c9b00 100644
--- a/thirdparty/sdl/stdlib/SDL_malloc.c
+++ b/thirdparty/sdl/stdlib/SDL_malloc.c
@@ -586,7 +586,7 @@ MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP
#define LACKS_STRING_H
#define LACKS_STRINGS_H
#define LACKS_SYS_TYPES_H
-// #define LACKS_ERRNO_H // File uses `EINVAL` and `ENOMEM` defines, so include is required. Legacy exclusion?
+#define LACKS_ERRNO_H
#define LACKS_SCHED_H
#ifndef MALLOC_FAILURE_ACTION
#define MALLOC_FAILURE_ACTION