From c540c77756ee0e3f3cc4c1bb79f4b4a5c05d0f00 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 18 Jan 2024 03:51:56 -0800
Subject: [PATCH] Removed SDL_INIT_EVERYTHING
Fixes https://github.com/libsdl-org/SDL/issues/8709
---
cmake/test/inc_sdl_noslash.c | 2 +-
cmake/test/inc_sdl_slash.c | 2 +-
docs/README-migration.md | 1 +
include/SDL3/SDL_init.h | 6 +-----
src/SDL.c | 2 ++
test/testautomation_platform.c | 4 ++--
test/testautomation_subsystems.c | 6 +++---
7 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/cmake/test/inc_sdl_noslash.c b/cmake/test/inc_sdl_noslash.c
index f99129258671..600329cabfbc 100644
--- a/cmake/test/inc_sdl_noslash.c
+++ b/cmake/test/inc_sdl_noslash.c
@@ -3,6 +3,6 @@
void inc_sdl_noslash(void) {
SDL_SetMainReady();
- SDL_Init(SDL_INIT_EVERYTHING);
+ SDL_Init(0);
SDL_Quit();
}
diff --git a/cmake/test/inc_sdl_slash.c b/cmake/test/inc_sdl_slash.c
index e3674993b4dc..7acca152452b 100644
--- a/cmake/test/inc_sdl_slash.c
+++ b/cmake/test/inc_sdl_slash.c
@@ -3,6 +3,6 @@
void inc_sdl_slash(void) {
SDL_SetMainReady();
- SDL_Init(SDL_INIT_EVERYTHING);
+ SDL_Init(0);
SDL_Quit();
}
diff --git a/docs/README-migration.md b/docs/README-migration.md
index d9f33ed536e1..a9266005a04e 100644
--- a/docs/README-migration.md
+++ b/docs/README-migration.md
@@ -716,6 +716,7 @@ The following symbols have been renamed:
The following symbols have been removed:
* SDL_INIT_NOPARACHUTE
+* SDL_INIT_EVERYTHING - you should only initialize the subsystems you are using
## SDL_joystick.h
diff --git a/include/SDL3/SDL_init.h b/include/SDL3/SDL_init.h
index 472afc9947a3..c208b5f7d381 100644
--- a/include/SDL3/SDL_init.h
+++ b/include/SDL3/SDL_init.h
@@ -61,10 +61,6 @@ typedef enum
SDL_INIT_EVENTS = 0x00004000,
SDL_INIT_SENSOR = 0x00008000
} SDL_InitFlags;
-#define SDL_INIT_EVERYTHING ( \
- SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \
- SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMEPAD | SDL_INIT_SENSOR \
- )
/**
* Initialize the SDL library.
@@ -94,7 +90,7 @@ typedef enum
* - `SDL_INIT_GAMEPAD`: gamepad subsystem; automatically initializes the
* joystick subsystem
* - `SDL_INIT_EVENTS`: events subsystem
- * - `SDL_INIT_EVERYTHING`: all of the above subsystems
+ * - `SDL_INIT_SENSOR`: sensor subsystem
*
* Subsystem initialization is ref-counted, you must call SDL_QuitSubSystem()
* for each SDL_InitSubSystem() to correctly shutdown a subsystem manually (or
diff --git a/src/SDL.c b/src/SDL.c
index 7e6f49b9171b..b3820ae6fa0e 100644
--- a/src/SDL.c
+++ b/src/SDL.c
@@ -47,6 +47,8 @@
#include "joystick/SDL_joystick_c.h"
#include "sensor/SDL_sensor_c.h"
+#define SDL_INIT_EVERYTHING ~0U
+
/* Initialization/Cleanup routines */
#include "timer/SDL_timer_c.h"
#ifdef SDL_VIDEO_DRIVER_WINDOWS
diff --git a/test/testautomation_platform.c b/test/testautomation_platform.c
index 0e1ddd1c53cf..2165361f1e90 100644
--- a/test/testautomation_platform.c
+++ b/test/testautomation_platform.c
@@ -256,12 +256,12 @@ static int platform_testDefaultInit(void *arg)
int ret;
int subsystem;
- subsystem = SDL_WasInit(SDL_INIT_EVERYTHING);
+ subsystem = SDL_WasInit(0);
SDLTest_AssertCheck(subsystem != 0,
"SDL_WasInit(0): returned %i, expected != 0",
subsystem);
- ret = SDL_Init(SDL_WasInit(SDL_INIT_EVERYTHING));
+ ret = SDL_Init(0);
SDLTest_AssertCheck(ret == 0,
"SDL_Init(0): returned %i, expected 0, error: %s",
ret,
diff --git a/test/testautomation_subsystems.c b/test/testautomation_subsystems.c
index b60927a0bf7b..e91052519911 100644
--- a/test/testautomation_subsystems.c
+++ b/test/testautomation_subsystems.c
@@ -15,12 +15,12 @@ static void subsystemsSetUp(void *arg)
/* CHECKME: can we use SDL_Quit here, or this will break the flow of tests? */
SDL_Quit();
/* Alternate variant without SDL_Quit:
- while (SDL_WasInit(SDL_INIT_EVERYTHING) != 0) {
- SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
+ while (SDL_WasInit(0) != 0) {
+ SDL_QuitSubSystem(~0U);
}
*/
SDLTest_AssertPass("Reset all subsystems before subsystems test");
- SDLTest_AssertCheck(SDL_WasInit(SDL_INIT_EVERYTHING) == 0, "Check result from SDL_WasInit(SDL_INIT_EVERYTHING)");
+ SDLTest_AssertCheck(SDL_WasInit(0) == 0, "Check result from SDL_WasInit(0)");
}
static void subsystemsTearDown(void *arg)