···311311 if (event.type == SDL_EVENT_KEY_DOWN && !event.key.repeat) {
312312 SDL_Log("Initial SDL_EVENT_KEY_DOWN: %s", SDL_GetScancodeName(event.key.keysym.scancode));
313313 }
314314-#if defined(__XBOXONE__) || defined(__XBOXSERIES__)
314314+#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
315315 /* On Xbox, ignore the keydown event because the features aren't supported */
316316 if (event.type != SDL_EVENT_KEY_DOWN) {
317317 SDLTest_CommonEvent(state, &event, &done);
+2-2
WhatsNew.txt
···88General:
99* SDL headers should now be included as `#include <SDL3/SDL.h>`
1010* Many functions and symbols have changed since SDL 2.0, see the [migration guide](docs/README-migration.md) for details
1111-* The preprocessor symbol __MACOSX__ has been renamed __MACOS__
1212-* The preprocessor symbol __IPHONEOS__ has been renamed __IOS__
1111+* The preprocessor symbol __MACOSX__ has been renamed SDL_PLATFORM_MACOS
1212+* The preprocessor symbol __IPHONEOS__ has been renamed SDL_PLATFORM_IOS
1313* SDL_stdinc.h no longer includes stdio.h, stdlib.h, etc., it only provides the SDL C runtime functionality
1414* SDL_intrin.h now includes the intrinsics headers that were in SDL_cpuinfo.h
1515* Added SDL_GetSystemTheme() to return whether the system is using a dark or light color theme, and SDL_EVENT_SYSTEM_THEME_CHANGED is sent when this changes
···2121The Windows GDK port supports the full set of Win32 APIs, renderers, controllers, input devices, etc., as the normal Windows x64 build of SDL.
22222323* Additionally, the GDK port adds the following:
2424- * Compile-time platform detection for SDL programs. The `__GDK__` is `#define`d on every GDK platform, and the `__WINGDK__` is `#define`d on Windows GDK, specifically. (This distinction exists because other GDK platforms support a smaller subset of functionality. This allows you to mark code for "any" GDK separate from Windows GDK.)
2424+ * Compile-time platform detection for SDL programs. The `SDL_PLATFORM_GDK` is `#define`d on every GDK platform, and the `SDL_PLATFORM_WINGDK` is `#define`d on Windows GDK, specifically. (This distinction exists because other GDK platforms support a smaller subset of functionality. This allows you to mark code for "any" GDK separate from Windows GDK.)
2525 * GDK-specific setup:
2626 * Initializing/uninitializing the game runtime, and initializing Xbox Live services
2727 * Creating a global task queue and setting it as the default for the process. When running any async operations, passing in `NULL` as the task queue will make the task get added to the global task queue.
···149149In general, the same process in the Windows GDK instructions work. There are just a few additional notes:
150150* For Xbox One consoles, use the Gaming.Xbox.XboxOne.x64 target
151151* For Xbox Series consoles, use the Gaming.Xbox.Scarlett.x64 target
152152-* The Xbox One target sets the `__XBOXONE__` define and the Xbox Series target sets the `__XBOXSERIES__` define
152152+* The Xbox One target sets the `SDL_PLATFORM_XBOXONE` define and the Xbox Series target sets the `SDL_PLATFORM_XBOXSERIES` define
153153* You don't need to link against the Xbox.Services Thunks lib nor include that dll in your package (it doesn't exist for Xbox)
154154* The shader blobs for Xbox are created in a pre-build step for the Xbox targets, rather than included in the source (due to NDA and version compatability reasons)
155155* To create a package, use:
+1-1
docs/README-ios.md
···238238 {
239239 ... initialize game ...
240240241241- #ifdef __IOS__
241241+ #ifdef SDL_PLATFORM_IOS
242242 // Initialize the Game Center for scoring and matchmaking
243243 InitGameCenter();
244244
+54-6
docs/README-migration.md
···13131414It's also possible to apply a semantic patch to migrate more easily to SDL3: [SDL_migration.cocci](https://github.com/libsdl-org/SDL/blob/main/build-scripts/SDL_migration.cocci)
15151616-SDL headers should now be included as `#include <SDL3/SDL.h>`. Typically that's the only header you'll need in your application unless you are using OpenGL or Vulkan functionality. We have provided a handy Python script [rename_headers.py](https://github.com/libsdl-org/SDL/blob/main/build-scripts/rename_headers.py) to rename SDL2 headers to their SDL3 counterparts:
1616+SDL headers should now be included as `#include <SDL3/SDL.h>`. Typically that's the only SDL header you'll need in your application unless you are using OpenGL or Vulkan functionality. SDL_image, SDL_mixer, SDL_net, SDL_ttf and SDL_rtf have also their preferred include path changed: for SDL_image, it becomes `#include <SDL3_image/SDL_image.h>`. We have provided a handy Python script [rename_headers.py](https://github.com/libsdl-org/SDL/blob/main/build-scripts/rename_headers.py) to rename SDL2 headers to their SDL3 counterparts:
1717```sh
1818rename_headers.py source_code_path
1919```
2020+2121+Some macros are renamed and/or removed in SDL3. We have provided a handy Python script [rename_macros.py](https://github.com/libsdl-org/SDL/blob/main/build-scripts/rename_macros.py) to replace these, and also add fixme comments on how to further improve the code:
2222+```sh
2323+rename_macros.py source_code_path
2424+```
2525+20262127CMake users should use this snippet to include SDL support in their project:
2228```
···932938933939## SDL_platform.h
934940935935-The preprocessor symbol `__MACOSX__` has been renamed `__MACOS__`, and `__IPHONEOS__` has been renamed `__IOS__`
941941+The following platform preprocessor macros have been removed:
942942+* __DREAMCAST__
943943+* __NACL__
944944+* __PNACL__
945945+946946+The following platform preprocessor macros have been renamed:
947947+948948+| SDL2 | SDL3 |
949949+|-------------------|---------------------------|
950950+| `__3DS__` | `SDL_PLATFORM_3DS` |
951951+| `__AIX__` | `SDL_PLATFORM_AIX` |
952952+| `__ANDROID__` | `SDL_PLATFORM_ANDROID` |
953953+| `__APPLE__` | `SDL_PLATFORM_APPLE` |
954954+| `__BSDI__` | `SDL_PLATFORM_BSDI` |
955955+| `__CYGWIN_` | `SDL_PLATFORM_CYGWIN` |
956956+| `__EMSCRIPTEN__` | `SDL_PLATFORM_EMSCRIPTEN` |
957957+| `__FREEBSD__` | `SDL_PLATFORM_FREEBSD` |
958958+| `__GDK__` | `SDL_PLATFORM_GDK` |
959959+| `__HAIKU__` | `SDL_PLATFORM_HAIKU` |
960960+| `__HPUX__` | `SDL_PLATFORM_HPUX` |
961961+| `__IPHONEOS__` | `SDL_PLATFORM_IOS` |
962962+| `__IRIX__` | `SDL_PLATFORM_IRIX` |
963963+| `__LINUX__` | `SDL_PLATFORM_LINUX` |
964964+| `__MACOSX__` | `SDL_PLATFORM_MACOS` |
965965+| `__NETBSD__` | `SDL_PLATFORM_NETBSD` |
966966+| `__NGAGE__` | `SDL_PLATFORM_NGAGE` |
967967+| `__OPENBSD__` | `SDL_PLATFORM_OPENBSD` |
968968+| `__OS2__` | `SDL_PLATFORM_OS2` |
969969+| `__OSF__` | `SDL_PLATFORM_OSF` |
970970+| `__PS2__` | `SDL_PLATFORM_PS2` |
971971+| `__PSP__` | `SDL_PLATFORM_PSP` |
972972+| `__QNXNTO__` | `SDL_PLATFORM_QNXNTO` |
973973+| `__RISCOS__` | `SDL_PLATFORM_RISCOS` |
974974+| `__SOLARIS__` | `SDL_PLATFORM_SOLARIS` |
975975+| `__TVOS__` | `SDL_PLATFORM_TVOS` |
976976+| `__unix__` | `SDL_PLATFORM_UNI` |
977977+| `__VITA__` | `SDL_PLATFORM_VITA` |
978978+| `__WIN32__` | `SDL_PLATFORM_WINRT` |
979979+| `__WINDOWS__` | `SDL_PLATFORM_WINDOWS` |
980980+| `__WINGDK__` | `SDL_PLATFORM_WINGDK` |
981981+| `__WINRT__` | `SDL_PLATFORM_WINRT` |
982982+| `__XBOXONE__` | `SDL_PLATFORM_XBOXONE` |
983983+| `__XBOXSERIES__` | `SDL_PLATFORM_XBOXSERIES` |
936984937985## SDL_rect.h
938986···13601408 if (nswindow) {
13611409 ...
13621410 }
13631363-#elif defined(__LINUX__)
14111411+#elif defined(SDL_PLATFORM_LINUX)
13641412 if (SDL_GetWindowWMInfo(window, &info)) {
13651413 if (info.subsystem == SDL_SYSWM_X11) {
13661414 Display *xdisplay = info.info.x11.display;
···13801428```
13811429becomes:
13821430```c
13831383-#if defined(__WIN32__)
14311431+#if defined(SDL_PLATFORM_WIN32)
13841432 HWND hwnd = (HWND)SDL_GetProperty(SDL_GetWindowProperties(window), SDL_PROPERTY_WINDOW_WIN32_HWND_POINTER, NULL);
13851433 if (hwnd) {
13861434 ...
13871435 }
13881388-#elif defined(__MACOS__)
14361436+#elif defined(SDL_PLATFORM_MACOS)
13891437 NSWindow *nswindow = (__bridge NSWindow *)SDL_GetProperty(SDL_GetWindowProperties(window), SDL_PROPERTY_WINDOW_COCOA_WINDOW_POINTER, NULL);
13901438 if (nswindow) {
13911439 ...
13921440 }
13931393-#elif defined(__LINUX__)
14411441+#elif defined(SDL_PLATFORM_LINUX)
13941442 if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0) {
13951443 Display *xdisplay = (Display *)SDL_GetProperty(SDL_GetWindowProperties(window), SDL_PROPERTY_WINDOW_X11_DISPLAY_POINTER, NULL);
13961444 Window xwindow = (Window)SDL_GetNumberProperty(SDL_GetWindowProperties(window), SDL_PROPERTY_WINDOW_X11_WINDOW_NUMBER, 0);
+1-1
docs/README-winrt.md
···3333* What works:
3434 * compilation via Visual C++ 2019.
3535 * compile-time platform detection for SDL programs. The C/C++ #define,
3636- `__WINRT__`, will be set to 1 (by SDL) when compiling for WinRT.
3636+ `SDL_PLATFORM_WINRT`, will be set to 1 (by SDL) when compiling for WinRT.
3737 * GPU-accelerated 2D rendering, via SDL_Renderer.
3838 * OpenGL ES 2, via the ANGLE library (included separately from SDL)
3939 * software rendering, via either SDL_Surface (optionally in conjunction with
+3-3
include/SDL3/SDL_assert.h
···6666 #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" )
6767#elif (defined(__GNUC__) || defined(__clang__)) && defined(__riscv)
6868 #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "ebreak\n\t" )
6969-#elif ( defined(__APPLE__) && (defined(__arm64__) || defined(__aarch64__)) ) /* this might work on other ARM targets, but this is a known quantity... */
6969+#elif ( defined(SDL_PLATFORM_APPLE) && (defined(__arm64__) || defined(__aarch64__)) ) /* this might work on other ARM targets, but this is a known quantity... */
7070 #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #22\n\t" )
7171-#elif defined(__APPLE__) && defined(__arm__)
7171+#elif defined(SDL_PLATFORM_APPLE) && defined(__arm__)
7272 #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "bkpt #22\n\t" )
7373#elif defined(__386__) && defined(__WATCOMC__)
7474 #define SDL_TriggerBreakpoint() { _asm { int 0x03 } }
···167167#ifndef SDL_AssertBreakpoint
168168#if defined(ANDROID) && defined(assert)
169169/* Define this as empty in case assert() is defined as SDL_assert */
170170-#define SDL_AssertBreakpoint()
170170+#define SDL_AssertBreakpoint()
171171#else
172172#define SDL_AssertBreakpoint() SDL_TriggerBreakpoint()
173173#endif
···2222#ifndef SDL_main_h_
2323#define SDL_main_h_
24242525+#include <SDL3/SDL_platform_defines.h>
2526#include <SDL3/SDL_stdinc.h>
2627#include <SDL3/SDL_events.h>
2728···4041 */
41424243#ifndef SDL_MAIN_HANDLED
4343-#ifdef __WIN32__
4444+#ifdef SDL_PLATFORM_WIN32
4445/* On Windows SDL provides WinMain(), which parses the command line and passes
4546 the arguments to your main function.
4647···4849 */
4950#define SDL_MAIN_AVAILABLE
50515151-#elif defined(__WINRT__)
5252+#elif defined(SDL_PLATFORM_WINRT)
5253/* On WinRT, SDL provides a main function that initializes CoreApplication,
5354 creating an instance of IFrameworkView in the process.
5455···6263*/
6364#define SDL_MAIN_NEEDED
64656565-#elif defined(__GDK__)
6666+#elif defined(SDL_PLATFORM_GDK)
6667/* On GDK, SDL provides a main function that initializes the game runtime.
67686869 If you prefer to write your own WinMain-function instead of having SDL
···7273*/
7374#define SDL_MAIN_NEEDED
74757575-#elif defined(__IOS__)
7676+#elif defined(SDL_PLATFORM_IOS)
7677/* On iOS SDL provides a main function that creates an application delegate
7778 and starts the iOS application run loop.
7879···8384 */
8485#define SDL_MAIN_NEEDED
85868686-#elif defined(__ANDROID__)
8787+#elif defined(SDL_PLATFORM_ANDROID)
8788/* On Android SDL provides a Java class in SDLActivity.java that is the
8889 main activity entry point.
8990···9495/* We need to export SDL_main so it can be launched from Java */
9596#define SDLMAIN_DECLSPEC DECLSPEC
96979797-#elif defined(__PSP__)
9898+#elif defined(SDL_PLATFORM_PSP)
9899/* On PSP SDL provides a main function that sets the module info,
99100 activates the GPU and starts the thread required to be able to exit
100101 the software.
···103104 */
104105#define SDL_MAIN_AVAILABLE
105106106106-#elif defined(__PS2__)
107107+#elif defined(SDL_PLATFORM_PS2)
107108#define SDL_MAIN_AVAILABLE
108109109110#define SDL_PS2_SKIP_IOP_RESET() \
110111 void reset_IOP(); \
111112 void reset_IOP() {}
112113113113-#elif defined(__3DS__)
114114+#elif defined(SDL_PLATFORM_3DS)
114115/*
115116 On N3DS, SDL provides a main function that sets up the screens
116117 and storage.
···119120*/
120121#define SDL_MAIN_AVAILABLE
121122122122-#elif defined(__NGAGE__)
123123+#elif defined(SDL_PLATFORM_NGAGE)
123124124125/*
125126 TODO: not sure if it should be SDL_MAIN_NEEDED, in SDL2 ngage had a
···422423extern DECLSPEC int SDLCALL SDL_EnterAppMainCallbacks(int argc, char* argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit);
423424424425425425-#if defined(__WIN32__) || defined(__GDK__)
426426+#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)
426427427428/**
428429 * Register a win32 window class for SDL's use.
···467468 */
468469extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
469470470470-#endif /* defined(__WIN32__) || defined(__GDK__) */
471471+#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) */
471472472473473473-#ifdef __WINRT__
474474+#ifdef SDL_PLATFORM_WINRT
474475475476/* for compatibility with SDL2's function of this name */
476477#define SDL_WinRTRunApp(MAIN_FUNC, RESERVED) SDL_RunApp(0, NULL, MAIN_FUNC, RESERVED)
477478478478-#endif /* __WINRT__ */
479479+#endif /* SDL_PLATFORM_WINRT */
479480480480-#ifdef __IOS__
481481+#ifdef SDL_PLATFORM_IOS
481482482483/* for compatibility with SDL2's function of this name */
483484#define SDL_UIKitRunApp(ARGC, ARGV, MAIN_FUNC) SDL_RunApp(ARGC, ARGV, MAIN_FUNC, NULL)
484485485485-#endif /* __IOS__ */
486486+#endif /* SDL_PLATFORM_IOS */
486487487487-#ifdef __GDK__
488488+#ifdef SDL_PLATFORM_GDK
488489489490/* for compatibility with SDL2's function of this name */
490491#define SDL_GDKRunApp(MAIN_FUNC, RESERVED) SDL_RunApp(0, NULL, MAIN_FUNC, RESERVED)
···496497 */
497498extern DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void);
498499499499-#endif /* __GDK__ */
500500+#endif /* SDL_PLATFORM_GDK */
500501501502#ifdef __cplusplus
502503}
···507508#if !defined(SDL_MAIN_HANDLED) && !defined(SDL_MAIN_NOIMPL)
508509/* include header-only SDL_main implementations */
509510#if defined(SDL_MAIN_USE_CALLBACKS) \
510510- || defined(__WIN32__) || defined(__GDK__) || defined(__IOS__) || defined(__TVOS__) \
511511- || defined(__3DS__) || defined(__NGAGE__) || defined(__PS2__) || defined(__PSP__)
511511+ || defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS) \
512512+ || defined(SDL_PLATFORM_3DS) || defined(SDL_PLATFORM_NGAGE) || defined(SDL_PLATFORM_PS2) || defined(SDL_PLATFORM_PSP)
512513513514/* platforms which main (-equivalent) can be implemented in plain C */
514515#include <SDL3/SDL_main_impl.h>
515516516516-#elif defined(__WINRT__) /* C++ platforms */
517517+#elif defined(SDL_PLATFORM_WINRT) /* C++ platforms */
517518518519#ifdef __cplusplus
519520#include <SDL3/SDL_main_impl.h>
···528529#endif /* __GNUC__ */
529530#endif /* __cplusplus */
530531531531-#endif /* C++ platforms like __WINRT__ etc */
532532+#endif /* C++ platforms like SDL_PLATFORM_WINRT etc */
532533533534#endif /* SDL_MAIN_HANDLED */
534535
+9-9
include/SDL3/SDL_main_impl.h
···6565/* set up the usual SDL_main stuff if we're not using callbacks or if we are but need the normal entry point. */
6666#if !defined(SDL_MAIN_USE_CALLBACKS) || defined(SDL_MAIN_CALLBACK_STANDARD)
67676868-#if defined(__WIN32__) || defined(__GDK__)
6868+#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)
69697070/* these defines/typedefs are needed for the WinMain() definition */
7171#ifndef WINAPI
···7777typedef wchar_t* PWSTR;
78787979/* The VC++ compiler needs main/wmain defined, but not for GDK */
8080-#if defined(_MSC_VER) && !defined(__GDK__)
8080+#if defined(_MSC_VER) && !defined(SDL_PLATFORM_GDK)
81818282/* This is where execution begins [console apps] */
8383#if defined( UNICODE ) && UNICODE
···9797}
9898#endif /* UNICODE */
9999100100-#endif /* _MSC_VER && ! __GDK__ */
100100+#endif /* _MSC_VER && ! SDL_PLATFORM_GDK */
101101102102/* This is where execution begins [windowed apps and GDK] */
103103···120120} /* extern "C" */
121121#endif
122122123123-/* end of __WIN32__ and __GDK__ impls */
124124-#elif defined(__WINRT__)
123123+/* end of SDL_PLATFORM_WIN32 and SDL_PLATFORM_GDK impls */
124124+#elif defined(SDL_PLATFORM_WINRT)
125125126126/* WinRT main based on SDL_winrt_main_NonXAML.cpp, placed in the public domain by David Ludwig 3/13/14 */
127127···182182#endif
183183184184/* end of WinRT impl */
185185-#elif defined(__NGAGE__)
185185+#elif defined(SDL_PLATFORM_NGAGE)
186186187187/* same typedef as in ngage SDKs e32def.h */
188188typedef signed int TInt;
189189/* TODO: if it turns out that this only works when built as C++,
190190- move __NGAGE__ into the C++ section in SDL_main.h */
190190+ move SDL_PLATFORM_NGAGE into the C++ section in SDL_main.h */
191191TInt E32Main()
192192{
193193 return SDL_RunApp(0, NULL, SDL_main, NULL);
194194}
195195196196-/* end of __NGAGE__ impl */
196196+/* end of SDL_PLATFORM_NGAGE impl */
197197198198#else /* platforms that use a standard main() and just call SDL_RunApp(), like iOS and 3DS */
199199···204204205205/* end of impls for standard-conforming platforms */
206206207207-#endif /* __WIN32__ etc */
207207+#endif /* SDL_PLATFORM_WIN32 etc */
208208209209#endif /* !defined(SDL_MAIN_USE_CALLBACKS) || defined(SDL_MAIN_CALLBACK_STANDARD) */
210210
···3131 */
32323333/* Add any platform that doesn't build using the configure system. */
3434-#if defined(__WIN32__)
3434+#if defined(SDL_PLATFORM_WIN32)
3535#include "SDL_build_config_windows.h"
3636-#elif defined(__WINRT__)
3636+#elif defined(SDL_PLATFORM_WINRT)
3737#include "SDL_build_config_winrt.h"
3838-#elif defined(__WINGDK__)
3838+#elif defined(SDL_PLATFORM_WINGDK)
3939#include "SDL_build_config_wingdk.h"
4040-#elif defined(__XBOXONE__) || defined(__XBOXSERIES__)
4040+#elif defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
4141#include "SDL_build_config_xbox.h"
4242-#elif defined(__MACOS__)
4242+#elif defined(SDL_PLATFORM_MACOS)
4343#include "SDL_build_config_macos.h"
4444-#elif defined(__IOS__)
4444+#elif defined(SDL_PLATFORM_IOS)
4545#include "SDL_build_config_ios.h"
4646-#elif defined(__ANDROID__)
4646+#elif defined(SDL_PLATFORM_ANDROID)
4747#include "SDL_build_config_android.h"
4848-#elif defined(__EMSCRIPTEN__)
4848+#elif defined(SDL_PLATFORM_EMSCRIPTEN)
4949#include "SDL_build_config_emscripten.h"
5050-#elif defined(__NGAGE__)
5050+#elif defined(SDL_PLATFORM_NGAGE)
5151#include "SDL_build_config_ngage.h"
5252#else
5353/* This is a minimal configuration just to get SDL running on new platforms. */
+1-1
include/build_config/SDL_build_config.h.cmake
···7676#cmakedefine HAVE_CALLOC 1
7777#cmakedefine HAVE_REALLOC 1
7878#cmakedefine HAVE_FREE 1
7979-#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */
7979+#ifndef SDL_PLATFORM_WIN32 /* Don't use C runtime versions of these on Windows */
8080#cmakedefine HAVE_GETENV 1
8181#cmakedefine HAVE_SETENV 1
8282#cmakedefine HAVE_PUTENV 1
···753753754754 // Make sure we can feed the device a minimum amount of time
755755 double MINIMUM_AUDIO_BUFFER_TIME_MS = 15.0;
756756- #ifdef __IOS__
756756+ #ifdef SDL_PLATFORM_IOS
757757 if (SDL_floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1) {
758758 // Older iOS hardware, use 40 ms as a minimum time
759759 MINIMUM_AUDIO_BUFFER_TIME_MS = 40.0;
+1-1
src/audio/wasapi/SDL_wasapi.c
···564564 IAudioClient *client = device->hidden->client;
565565 SDL_assert(client != NULL);
566566567567-#if defined(__WINRT__) || defined(__GDK__) // CreateEventEx() arrived in Vista, so we need an #ifdef for XP.
567567+#if defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK) // CreateEventEx() arrived in Vista, so we need an #ifdef for XP.
568568 device->hidden->event = CreateEventEx(NULL, NULL, 0, EVENT_ALL_ACCESS);
569569#else
570570 device->hidden->event = CreateEventW(NULL, 0, 0, NULL);
+2-2
src/audio/wasapi/SDL_wasapi_win32.c
···2626 The code in SDL_wasapi.c is used by both standard Windows and WinRT builds
2727 to deal with audio and calls into these functions. */
28282929-#if defined(SDL_AUDIO_DRIVER_WASAPI) && !defined(__WINRT__)
2929+#if defined(SDL_AUDIO_DRIVER_WASAPI) && !defined(SDL_PLATFORM_WINRT)
30303131#include "../../core/windows/SDL_windows.h"
3232#include "../../core/windows/SDL_immdevice.h"
···202202 SDL_IMMDevice_FreeDeviceHandle(device);
203203}
204204205205-#endif // SDL_AUDIO_DRIVER_WASAPI && !defined(__WINRT__)
205205+#endif // SDL_AUDIO_DRIVER_WASAPI && !defined(SDL_PLATFORM_WINRT)
+2-2
src/audio/wasapi/SDL_wasapi_winrt.cpp
···2525// is in SDL_wasapi_win32.c. The code in SDL_wasapi.c is used by both standard
2626// Windows and WinRT builds to deal with audio and calls into these functions.
27272828-#if defined(SDL_AUDIO_DRIVER_WASAPI) && defined(__WINRT__)
2828+#if defined(SDL_AUDIO_DRIVER_WASAPI) && defined(SDL_PLATFORM_WINRT)
29293030#include <Windows.h>
3131#include <windows.ui.core.h>
···357357 SDL_free(device->handle);
358358}
359359360360-#endif // SDL_AUDIO_DRIVER_WASAPI && defined(__WINRT__)
360360+#endif // SDL_AUDIO_DRIVER_WASAPI && defined(SDL_PLATFORM_WINRT)
···22222323/* Most platforms that use/need SDL_main have their own SDL_RunApp() implementation.
2424 * If not, you can special case it here by appending || defined(__YOUR_PLATFORM__) */
2525-#if ( !defined(SDL_MAIN_NEEDED) && !defined(SDL_MAIN_AVAILABLE) ) || defined(__ANDROID__)
2525+#if ( !defined(SDL_MAIN_NEEDED) && !defined(SDL_MAIN_AVAILABLE) ) || defined(SDL_PLATFORM_ANDROID)
26262727DECLSPEC int
2828SDL_RunApp(int argc, char* argv[], SDL_main_func mainFunction, void * reserved)
···21212222#include "SDL_internal.h"
23232424-#ifdef __PS2__
2424+#ifdef SDL_PLATFORM_PS2
25252626/* SDL_RunApp() code for PS2 based on SDL_ps2_main.c, fjtrujy@gmail.com */
2727···8282 return res;
8383}
84848585-#endif /* __PS2__ */
8585+#endif /* SDL_PLATFORM_PS2 */
+2-2
src/core/psp/SDL_psp.c
···21212222#include "SDL_internal.h"
23232424-#ifdef __PSP__
2424+#ifdef SDL_PLATFORM_PSP
25252626/* SDL_RunApp() for PSP based on SDL_psp_main.c, placed in the public domain by Sam Lantinga 3/13/14 */
2727···7979 return mainFunction(argc, argv);
8080}
81818282-#endif /* __PSP__ */
8282+#endif /* SDL_PLATFORM_PSP */
+4-4
src/core/unix/SDL_appid.c
···30303131 /* TODO: Use a fallback if BSD has no mounted procfs (OpenBSD has no procfs at all) */
3232 if (!proc_name) {
3333-#if defined(__LINUX__) || defined(__FREEBSD__) || defined (__NETBSD__)
3333+#if defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_FREEBSD) || defined (SDL_PLATFORM_NETBSD)
3434 static char linkfile[1024];
3535 int linksize;
36363737-#if defined(__LINUX__)
3737+#if defined(SDL_PLATFORM_LINUX)
3838 const char *proc_path = "/proc/self/exe";
3939-#elif defined(__FREEBSD__)
3939+#elif defined(SDL_PLATFORM_FREEBSD)
4040 const char *proc_path = "/proc/curproc/file";
4141-#elif defined(__NETBSD__)
4141+#elif defined(SDL_PLATFORM_NETBSD)
4242 const char *proc_path = "/proc/curproc/exe";
4343#endif
4444 linksize = readlink(proc_path, linkfile, sizeof(linkfile) - 1);
···2626#include "SDL_windows.h"
27272828#ifdef HAVE_XINPUT_H
2929-#if defined(__XBOXONE__) || defined(__XBOXSERIES__)
2929+#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
3030/* Xbox supports an XInput wrapper which is a C++-only header... */
3131#include <math.h> /* Required to compile with recent MSVC... */
3232#include <XInputOnGameInput.h>
+35-35
src/cpuinfo/SDL_cpuinfo.c
···2020*/
2121#include "SDL_internal.h"
22222323-#if defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__)
2323+#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK)
2424#include "../core/windows/SDL_windows.h"
2525#endif
2626···3333#include <sys/types.h>
3434#include <sys/sysctl.h>
3535#endif
3636-#if defined(__MACOS__) && (defined(__ppc__) || defined(__ppc64__))
3636+#if defined(SDL_PLATFORM_MACOS) && (defined(__ppc__) || defined(__ppc64__))
3737#include <sys/sysctl.h> /* For AltiVec check */
3838-#elif defined(__OpenBSD__) && defined(__powerpc__)
3838+#elif defined(SDL_PLATFORM_OPENBSD) && defined(__powerpc__)
3939#include <sys/types.h>
4040#include <sys/sysctl.h> /* For AltiVec check */
4141#include <machine/cpu.h>
4242-#elif defined(__FreeBSD__) && defined(__powerpc__)
4242+#elif defined(SDL_PLATFORM_FREEBSD) && defined(__powerpc__)
4343#include <machine/cpu.h>
4444#include <sys/auxv.h>
4545#elif defined(SDL_ALTIVEC_BLITTERS) && defined(HAVE_SETJMP)
···4747#include <setjmp.h>
4848#endif
49495050-#if (defined(__LINUX__) || defined(__ANDROID__)) && defined(__arm__)
5050+#if (defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID)) && defined(__arm__)
5151#include <unistd.h>
5252#include <sys/types.h>
5353#include <sys/stat.h>
···6666#endif
6767#endif
68686969-#if defined(__ANDROID__) && defined(__arm__) && !defined(HAVE_GETAUXVAL)
6969+#if defined(SDL_PLATFORM_ANDROID) && defined(__arm__) && !defined(HAVE_GETAUXVAL)
7070#include <cpu-features.h>
7171#endif
7272···7474#include <sys/auxv.h>
7575#endif
76767777-#ifdef __RISCOS__
7777+#ifdef SDL_PLATFORM_RISCOS
7878#include <kernel.h>
7979#include <swis.h>
8080#endif
81818282-#ifdef __PS2__
8282+#ifdef SDL_PLATFORM_PS2
8383#include <kernel.h>
8484#endif
85858686-#ifdef __HAIKU__
8686+#ifdef SDL_PLATFORM_HAIKU
8787#include <kernel/OS.h>
8888#endif
8989···106106#define CPU_CFG2_LSX (1 << 6)
107107#define CPU_CFG2_LASX (1 << 7)
108108109109-#if defined(SDL_ALTIVEC_BLITTERS) && defined(HAVE_SETJMP) && !defined(__MACOS__) && !defined(__OpenBSD__) && !defined(__FreeBSD__)
109109+#if defined(SDL_ALTIVEC_BLITTERS) && defined(HAVE_SETJMP) && !defined(SDL_PLATFORM_MACOS) && !defined(SDL_PLATFORM_OPENBSD) && !defined(SDL_PLATFORM_FREEBSD)
110110/* This is the brute force way of detecting instruction sets...
111111 the idea is borrowed from the libmpeg2 library - thanks!
112112 */
···122122 int has_CPUID = 0;
123123124124/* *INDENT-OFF* */ /* clang-format off */
125125-#ifndef __EMSCRIPTEN__
125125+#ifndef SDL_PLATFORM_EMSCRIPTEN
126126#if (defined(__GNUC__) || defined(__llvm__)) && defined(__i386__)
127127 __asm__ (
128128" pushfl # Get original EFLAGS \n"
···209209"1: \n"
210210 );
211211#endif
212212-#endif /* !__EMSCRIPTEN__ */
212212+#endif /* !SDL_PLATFORM_EMSCRIPTEN */
213213/* *INDENT-ON* */ /* clang-format on */
214214 return has_CPUID;
215215}
···318318{
319319 volatile int altivec = 0;
320320#ifndef SDL_CPUINFO_DISABLED
321321-#if (defined(__MACOS__) && (defined(__ppc__) || defined(__ppc64__))) || (defined(__OpenBSD__) && defined(__powerpc__))
322322-#ifdef __OpenBSD__
321321+#if (defined(SDL_PLATFORM_MACOS) && (defined(__ppc__) || defined(__ppc64__))) || (defined(SDL_PLATFORM_OPENBSD) && defined(__powerpc__))
322322+#ifdef SDL_PLATFORM_OPENBSD
323323 int selectors[2] = { CTL_MACHDEP, CPU_ALTIVEC };
324324#else
325325 int selectors[2] = { CTL_HW, HW_VECTORUNIT };
···330330 if (0 == error) {
331331 altivec = (hasVectorUnit != 0);
332332 }
333333-#elif defined(__FreeBSD__) && defined(__powerpc__)
333333+#elif defined(SDL_PLATFORM_FREEBSD) && defined(__powerpc__)
334334 unsigned long cpufeatures = 0;
335335 elf_aux_info(AT_HWCAP, &cpufeatures, sizeof(cpufeatures));
336336 altivec = cpufeatures & PPC_FEATURE_HAS_ALTIVEC;
···361361 return 0;
362362}
363363364364-#elif defined(__LINUX__)
364364+#elif defined(SDL_PLATFORM_LINUX)
365365static int CPU_haveARMSIMD(void)
366366{
367367 int arm_simd = 0;
···384384 return arm_simd;
385385}
386386387387-#elif defined(__RISCOS__)
387387+#elif defined(SDL_PLATFORM_RISCOS)
388388static int CPU_haveARMSIMD(void)
389389{
390390 _kernel_swi_regs regs;
···414414}
415415#endif
416416417417-#if defined(__LINUX__) && defined(__arm__) && !defined(HAVE_GETAUXVAL)
417417+#if defined(SDL_PLATFORM_LINUX) && defined(__arm__) && !defined(HAVE_GETAUXVAL)
418418static int readProcAuxvForNeon(void)
419419{
420420 int neon = 0;
···439439{
440440/* The way you detect NEON is a privileged instruction on ARM, so you have
441441 query the OS kernel in a platform-specific way. :/ */
442442-#if (defined(__WINDOWS__) || defined(__WINRT__) || defined(__GDK__)) && (defined(_M_ARM) || defined(_M_ARM64))
442442+#if (defined(SDL_PLATFORM_WINDOWS) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK)) && (defined(_M_ARM) || defined(_M_ARM64))
443443/* Visual Studio, for ARM, doesn't define __ARM_ARCH. Handle this first. */
444444/* Seems to have been removed */
445445#ifndef PF_ARM_NEON_INSTRUCTIONS_AVAILABLE
···449449 return IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) != 0;
450450#elif (defined(__ARM_ARCH) && (__ARM_ARCH >= 8)) || defined(__aarch64__)
451451 return 1; /* ARMv8 always has non-optional NEON support. */
452452-#elif defined(__VITA__)
452452+#elif defined(SDL_PLATFORM_VITA)
453453 return 1;
454454-#elif defined(__3DS__)
454454+#elif defined(SDL_PLATFORM_3DS)
455455 return 0;
456456-#elif defined(__APPLE__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 7)
456456+#elif defined(SDL_PLATFORM_APPLE) && defined(__ARM_ARCH) && (__ARM_ARCH >= 7)
457457 /* (note that sysctlbyname("hw.optional.neon") doesn't work!) */
458458 return 1; /* all Apple ARMv7 chips and later have NEON. */
459459-#elif defined(__APPLE__)
459459+#elif defined(SDL_PLATFORM_APPLE)
460460 return 0; /* assume anything else from Apple doesn't have NEON. */
461461#elif !defined(__arm__)
462462 return 0; /* not an ARM CPU at all. */
463463-#elif defined(__OpenBSD__)
463463+#elif defined(SDL_PLATFORM_OPENBSD)
464464 return 1; /* OpenBSD only supports ARMv7 CPUs that have NEON. */
465465#elif defined(HAVE_ELF_AUX_INFO)
466466 unsigned long hasneon = 0;
···468468 return 0;
469469 }
470470 return (hasneon & HWCAP_NEON) == HWCAP_NEON;
471471-#elif (defined(__LINUX__) || defined(__ANDROID__)) && defined(HAVE_GETAUXVAL)
471471+#elif (defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID)) && defined(HAVE_GETAUXVAL)
472472 return (getauxval(AT_HWCAP) & HWCAP_NEON) == HWCAP_NEON;
473473-#elif defined(__LINUX__)
473473+#elif defined(SDL_PLATFORM_LINUX)
474474 return readProcAuxvForNeon();
475475-#elif defined(__ANDROID__)
475475+#elif defined(SDL_PLATFORM_ANDROID)
476476 /* Use NDK cpufeatures to read either /proc/self/auxv or /proc/cpuinfo */
477477 {
478478 AndroidCpuFamily cpu_family = android_getCpuFamily();
···484484 }
485485 return 0;
486486 }
487487-#elif defined(__RISCOS__)
487487+#elif defined(SDL_PLATFORM_RISCOS)
488488 /* Use the VFPSupport_Features SWI to access the MVFR registers */
489489 {
490490 _kernel_swi_regs regs;
···496496 }
497497 return 0;
498498 }
499499-#elif defined(__EMSCRIPTEN__)
499499+#elif defined(SDL_PLATFORM_EMSCRIPTEN)
500500 return 0;
501501#else
502502#warning SDL_HasNEON is not implemented for this ARM platform. Write me.
···629629 sysctlbyname("hw.ncpu", &SDL_CPUCount, &size, NULL, 0);
630630 }
631631#endif
632632-#if defined(__WIN32__) || defined(__GDK__)
632632+#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)
633633 if (SDL_CPUCount <= 0) {
634634 SYSTEM_INFO info;
635635 GetSystemInfo(&info);
···10291029 }
10301030 }
10311031#endif
10321032-#if defined(__WIN32__) || defined(__GDK__)
10321032+#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)
10331033 if (SDL_SystemRAM <= 0) {
10341034 MEMORYSTATUSEX stat;
10351035 stat.dwLength = sizeof(stat);
···10381038 }
10391039 }
10401040#endif
10411041-#ifdef __RISCOS__
10411041+#ifdef SDL_PLATFORM_RISCOS
10421042 if (SDL_SystemRAM <= 0) {
10431043 _kernel_swi_regs regs;
10441044 regs.r[0] = 0x108;
···10471047 }
10481048 }
10491049#endif
10501050-#ifdef __VITA__
10501050+#ifdef SDL_PLATFORM_VITA
10511051 if (SDL_SystemRAM <= 0) {
10521052 /* Vita has 512MiB on SoC, that's split into 256MiB(+109MiB in extended memory mode) for app
10531053 +26MiB of physically continuous memory, +112MiB of CDRAM(VRAM) + system reserved memory. */
10541054 SDL_SystemRAM = 536870912;
10551055 }
10561056#endif
10571057-#ifdef __PS2__
10571057+#ifdef SDL_PLATFORM_PS2
10581058 if (SDL_SystemRAM <= 0) {
10591059 /* PlayStation 2 has 32MiB however there are some special models with 64 and 128 */
10601060 SDL_SystemRAM = GetMemorySize();
10611061 }
10621062#endif
10631063-#ifdef __HAIKU__
10631063+#ifdef SDL_PLATFORM_HAIKU
10641064 if (SDL_SystemRAM <= 0) {
10651065 system_info info;
10661066 if (get_system_info(&info) == B_OK) {
+3-3
src/dynapi/SDL_dynapi.c
···410410411411/* Obviously we can't use SDL_LoadObject() to load SDL. :) */
412412/* Also obviously, we never close the loaded library. */
413413-#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
413413+#if defined(WIN32) || defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN)
414414#ifndef WIN32_LEAN_AND_MEAN
415415#define WIN32_LEAN_AND_MEAN 1
416416#endif
···428428 return retval;
429429}
430430431431-#elif defined(unix) || defined(__unix__) || defined(__APPLE__) || defined(__HAIKU__)
431431+#elif defined(SDL_PLATFORM_UNIX) || defined(SDL_PLATFORM_APPLE) || defined(SDL_PLATFORM_HAIKU)
432432#include <dlfcn.h>
433433static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym)
434434{
···452452 const char *caption = "SDL Dynamic API Failure!";
453453 (void)caption;
454454/* SDL_ShowSimpleMessageBox() is a too heavy for here. */
455455-#if (defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
455455+#if (defined(WIN32) || defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN)) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
456456 MessageBoxA(NULL, msg, caption, MB_OK | MB_ICONERROR);
457457#elif defined(HAVE_STDIO_H)
458458 fprintf(stderr, "\n\n%s\n%s\n\n", caption, msg);
+9-9
src/dynapi/SDL_dynapi.h
···3939#error Nope, you have to edit this file to force this off.
4040#endif
41414242-#ifdef __APPLE__
4242+#ifdef SDL_PLATFORM_APPLE
4343#include "TargetConditionals.h"
4444#endif
45454646#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE /* probably not useful on iOS. */
4747#define SDL_DYNAMIC_API 0
4848-#elif defined(__ANDROID__) /* probably not useful on Android. */
4848+#elif defined(SDL_PLATFORM_ANDROID) /* probably not useful on Android. */
4949#define SDL_DYNAMIC_API 0
5050-#elif defined(__EMSCRIPTEN__) && __EMSCRIPTEN__ /* probably not useful on Emscripten. */
5050+#elif defined(SDL_PLATFORM_EMSCRIPTEN) /* probably not useful on Emscripten. */
5151#define SDL_DYNAMIC_API 0
5252#elif defined(SDL_BUILDING_WINRT) && SDL_BUILDING_WINRT /* probably not useful on WinRT, given current .dll loading restrictions */
5353#define SDL_DYNAMIC_API 0
5454-#elif defined(__PS2__) && __PS2__
5454+#elif defined(SDL_PLATFORM_PS2) && SDL_PLATFORM_PS2
5555#define SDL_DYNAMIC_API 0
5656-#elif defined(__PSP__) && __PSP__
5656+#elif defined(SDL_PLATFORM_PSP) && SDL_PLATFORM_PSP
5757#define SDL_DYNAMIC_API 0
5858-#elif defined(__riscos__) && __riscos__ /* probably not useful on RISC OS, since dlopen() can't be used when using static linking. */
5858+#elif defined(SDL_PLATFORM_RISCOS) /* probably not useful on RISC OS, since dlopen() can't be used when using static linking. */
5959#define SDL_DYNAMIC_API 0
6060#elif defined(__clang_analyzer__) || defined(SDL_THREAD_SAFETY_ANALYSIS)
6161#define SDL_DYNAMIC_API 0 /* Turn off for static analysis, so reports are more clear. */
6262-#elif defined(__VITA__)
6262+#elif defined(SDL_PLATFORM_VITA)
6363#define SDL_DYNAMIC_API 0 /* vitasdk doesn't support dynamic linking */
6464-#elif defined(__NGAGE__)
6464+#elif defined(SDL_PLATFORM_NGAGE)
6565#define SDL_DYNAMIC_API 0 /* The N-Gage doesn't support dynamic linking either */
6666-#elif defined(__3DS__)
6666+#elif defined(SDL_PLATFORM_3DS)
6767#define SDL_DYNAMIC_API 0 /* devkitARM doesn't support dynamic linking */
6868#elif defined(DYNAPI_NEEDS_DLOPEN) && !defined(HAVE_DLOPEN)
6969#define SDL_DYNAMIC_API 0 /* we need dlopen(), but don't have it.... */
···2525# It keeps the dynamic API jump table operating correctly.
2626#
2727# OS-specific API:
2828-# After running the script, you have to manually add #ifdef __WIN32__
2828+# After running the script, you have to manually add #ifdef SDL_PLATFORM_WIN32
2929# or similar around the function in 'SDL_dynapi_procs.h'
3030#
3131
···10531053 wacom_devicetype_id = PEN_WACOM_ID_INVALID; /* force detection to fail */
10541054#endif
1055105510561056-#if defined(__LINUX__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
10561056+#if defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_FREEBSD) || defined(SDL_PLATFORM_NETBSD) || defined(SDL_PLATFORM_OPENBSD)
10571057 /* According to Ping Cheng, the curent Wacom for Linux maintainer, device IDs on Linux
10581058 squeeze a "0" nibble after the 3rd (least significant) nibble.
10591059 This may also affect the *BSDs, so they are heuristically included here.
+1-1
src/events/SDL_touch.c
···255255 /* SDL_HINT_TOUCH_MOUSE_EVENTS: controlling whether touch events should generate synthetic mouse events */
256256 /* SDL_HINT_VITA_TOUCH_MOUSE_DEVICE: controlling which touchpad should generate synthetic mouse events, PSVita-only */
257257 {
258258-#ifdef __vita__
258258+#ifdef SDL_PLATFORM_VITA
259259 if (mouse->touch_mouse_events && ((mouse->vita_touch_mouse_device == id) || (mouse->vita_touch_mouse_device == 2))) {
260260#else
261261 if (mouse->touch_mouse_events) {
···1919 3. This notice may not be removed or altered from any source distribution.
2020*/
21212222-#ifdef __APPLE__
2222+#ifdef SDL_PLATFORM_APPLE
23232424#include <stdio.h>
2525
···3535#include <string.h>
3636#include <unistd.h>
37373838-#if defined(__FREEBSD__) || defined(__OPENBSD__)
3838+#if defined(SDL_PLATFORM_FREEBSD) || defined(SDL_PLATFORM_OPENBSD)
3939#include <sys/sysctl.h>
4040#endif
4141···6868 return NULL;
6969}
70707171-#ifdef __OPENBSD__
7171+#ifdef SDL_PLATFORM_OPENBSD
7272static char *search_path_for_binary(const char *bin)
7373{
7474 char *envr = SDL_getenv("PATH");
···122122{
123123 char *retval = NULL;
124124125125-#ifdef __FREEBSD__
125125+#ifdef SDL_PLATFORM_FREEBSD
126126 char fullpath[PATH_MAX];
127127 size_t buflen = sizeof(fullpath);
128128 const int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
···133133 }
134134 }
135135#endif
136136-#ifdef __OPENBSD__
136136+#ifdef SDL_PLATFORM_OPENBSD
137137 /* Please note that this will fail if the process was launched with a relative path and $PWD + the cwd have changed, or argv is altered. So don't do that. Or add a new sysctl to OpenBSD. */
138138 char **cmdline;
139139 size_t len;
···196196 /* !!! FIXME: after 2.0.6 ships, let's delete this code and just
197197 use the /proc/%llu version. There's no reason to have
198198 two copies of this plus all the #ifdefs. --ryan. */
199199-#ifdef __FREEBSD__
199199+#ifdef SDL_PLATFORM_FREEBSD
200200 retval = readSymLink("/proc/curproc/file");
201201-#elif defined(__NETBSD__)
201201+#elif defined(SDL_PLATFORM_NETBSD)
202202 retval = readSymLink("/proc/curproc/exe");
203203-#elif defined(__SOLARIS__)
203203+#elif defined(SDL_PLATFORM_SOLARIS)
204204 retval = readSymLink("/proc/self/path/a.out");
205205#else
206206 retval = readSymLink("/proc/self/exe"); /* linux. */
···217217#endif
218218 }
219219220220-#ifdef __SOLARIS__ /* try this as a fallback if /proc didn't pan out */
220220+#ifdef SDL_PLATFORM_SOLARIS /* try this as a fallback if /proc didn't pan out */
221221 if (!retval) {
222222 const char *path = getexecname();
223223 if ((path) && (path[0] == '/')) { /* must be absolute path... */
+2-2
src/filesystem/winrt/SDL_sysfilesystem.cpp
···2323/* TODO, WinRT: remove the need to compile this with C++/CX (/ZW) extensions, and if possible, without C++ at all
2424 */
25252626-#ifdef __WINRT__
2626+#ifdef SDL_PLATFORM_WINRT
27272828extern "C" {
2929#include "../../core/windows/SDL_windows.h"
···236236 return NULL;
237237}
238238239239-#endif /* __WINRT__ */
239239+#endif /* SDL_PLATFORM_WINRT */
···7676#define wcsdup SDL_wcsdup
777778787979-#ifndef __FreeBSD__
7979+#ifndef SDL_PLATFORM_FREEBSD
8080/* this is awkwardly inlined, so we need to re-implement it here
8181 * so we can override the libusb_control_transfer call */
8282static int SDL_libusb_get_string_descriptor(libusb_device_handle *dev,
···8787 data, (uint16_t)length, 1000); /* Endpoint 0 IN */
8888}
8989#define libusb_get_string_descriptor SDL_libusb_get_string_descriptor
9090-#endif /* __FreeBSD__ */
9090+#endif /* SDL_PLATFORM_FREEBSD */
91919292#define HIDAPI_THREAD_MODEL_INCLUDE "hidapi_thread_sdl.h"
9393#ifndef LIBUSB_API_VERSION
···3232/*#define DEBUG_LUNA_PROTOCOL*/
33333434/* Sending rumble on macOS blocks for a long time and eventually fails */
3535-#ifndef __MACOS__
3535+#ifndef SDL_PLATFORM_MACOS
3636#define ENABLE_LUNA_BLUETOOTH_RUMBLE
3737#endif
3838
+3-3
src/joystick/hidapi/SDL_hidapi_ps3.c
···6969{
7070 SDL_bool default_value;
71717272-#ifdef __MACOS__
7272+#ifdef SDL_PLATFORM_MACOS
7373 /* This works well on macOS */
7474 default_value = SDL_TRUE;
7575-#elif defined(__WINDOWS__)
7575+#elif defined(SDL_PLATFORM_WINDOWS)
7676 /* You can't initialize the controller with the stock Windows drivers
7777 * See https://github.com/ViGEm/DsHidMini as an alternative driver
7878 */
7979 default_value = SDL_FALSE;
8080-#elif defined(__LINUX__)
8080+#elif defined(SDL_PLATFORM_LINUX)
8181 /* Linux drivers do a better job of managing the transition between
8282 * USB and Bluetooth. There are also some quirks in communicating
8383 * with PS3 controllers that have been implemented in SDL's hidapi
+3-3
src/joystick/hidapi/SDL_hidapi_steam.c
···347347 // On Windows and macOS, BLE devices get 2 copies of the feature report ID, one that is removed by ReadFeatureReport,
348348 // and one that's included in the buffer we receive. We pad the bytes to read and skip over the report ID
349349 // if necessary.
350350-#if defined(__WIN32__) || defined(__MACOS__)
350350+#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_MACOS)
351351 ++ucBytesToRead;
352352 ++ucDataStartOffset;
353353#endif
···980980 }
981981 device->context = ctx;
982982983983-#ifdef __WIN32__
983983+#ifdef SDL_PLATFORM_WIN32
984984 if (device->serial) {
985985 /* We get a garbage serial number on Windows */
986986 SDL_free(device->serial);
987987 device->serial = NULL;
988988 }
989989-#endif /* __WIN32__ */
989989+#endif /* SDL_PLATFORM_WIN32 */
990990991991 HIDAPI_SetDeviceName(device, "Steam Controller");
992992
+1-1
src/joystick/hidapi/SDL_hidapi_wii.c
···454454455455static void ActivateMotionPlusWithMode(SDL_DriverWii_Context *ctx, Uint8 mode)
456456{
457457-#ifdef __LINUX__
457457+#ifdef SDL_PLATFORM_LINUX
458458 /* Linux drivers maintain a lot of state around the Motion Plus
459459 * extension, so don't mess with it here.
460460 */
+3-3
src/joystick/hidapi/SDL_hidapi_xbox360.c
···8080 /* This is the chatpad or other input interface, not the Xbox 360 interface */
8181 return SDL_FALSE;
8282 }
8383-#ifdef __MACOS__
8383+#ifdef SDL_PLATFORM_MACOS
8484 if (vendor_id == USB_VENDOR_MICROSOFT && product_id == USB_PRODUCT_XBOX360_WIRED_CONTROLLER && version == 0) {
8585 /* This is the Steam Virtual Gamepad, which isn't supported by this driver */
8686 return SDL_FALSE;
···197197198198static int HIDAPI_DriverXbox360_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
199199{
200200-#ifdef __MACOS__
200200+#ifdef SDL_PLATFORM_MACOS
201201 if (SDL_IsJoystickBluetoothXboxOne(device->vendor_id, device->product_id)) {
202202 Uint8 rumble_packet[] = { 0x03, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00 };
203203···267267static void HIDAPI_DriverXbox360_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverXbox360_Context *ctx, Uint8 *data, int size)
268268{
269269 Sint16 axis;
270270-#ifdef __MACOS__
270270+#ifdef SDL_PLATFORM_MACOS
271271 const SDL_bool invert_y_axes = SDL_FALSE;
272272#else
273273 const SDL_bool invert_y_axes = SDL_TRUE;
+2-2
src/joystick/hidapi/SDL_hidapi_xboxone.c
···3535/* Define this if you want to log all packets from the controller */
3636/*#define DEBUG_XBOX_PROTOCOL*/
37373838-#if defined(__WIN32__) || defined(__WINGDK__)
3838+#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK)
3939#define XBOX_ONE_DRIVER_ACTIVE 1
4040#else
4141#define XBOX_ONE_DRIVER_ACTIVE 0
···350350351351static SDL_bool HIDAPI_DriverXboxOne_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol)
352352{
353353-#ifdef __MACOS__
353353+#ifdef SDL_PLATFORM_MACOS
354354 /* Wired Xbox One controllers are handled by the 360Controller driver */
355355 if (!SDL_IsJoystickBluetoothXboxOne(vendor_id, product_id)) {
356356 return SDL_FALSE;
+2-2
src/joystick/hidapi/SDL_hidapijoystick.c
···2727#include "SDL_hidapi_rumble.h"
2828#include "../../SDL_hints_c.h"
29293030-#if defined(__WIN32__) || defined(__WINGDK__)
3030+#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK)
3131#include "../windows/SDL_rawinputjoystick_c.h"
3232#endif
3333···451451 /* Wait a little bit for the device to initialize */
452452 SDL_Delay(10);
453453454454-#ifdef __ANDROID__
454454+#ifdef SDL_PLATFORM_ANDROID
455455 /* On Android we need to leave joysticks unlocked because it calls
456456 * out to the main thread for permissions and the main thread can
457457 * be in the process of handling controller input.
···603603 return SDL_SetError("RoInitialize() failed");
604604 }
605605606606-#ifdef __WINRT__
606606+#ifdef SDL_PLATFORM_WINRT
607607 wgi.CoIncrementMTAUsage = CoIncrementMTAUsage;
608608 wgi.RoGetActivationFactory = RoGetActivationFactory;
609609 wgi.WindowsCreateStringReference = WindowsCreateStringReference;
···617617 RESOLVE(WindowsDeleteString);
618618 RESOLVE(WindowsGetStringRawBuffer);
619619#undef RESOLVE
620620-#endif /* __WINRT__ */
620620+#endif /* SDL_PLATFORM_WINRT */
621621622622-#ifndef __WINRT__
622622+#ifndef SDL_PLATFORM_WINRT
623623 {
624624 /* There seems to be a bug in Windows where a dependency of WGI can be unloaded from memory prior to WGI itself.
625625 * This results in Windows_Gaming_Input!GameController::~GameController() invoking an unloaded DLL and crashing.
···376376 result = XINPUTGETBATTERYINFORMATION(joystick->hwdata->userid, BATTERY_DEVTYPE_GAMEPAD, &XBatteryInformation);
377377 }
378378379379-#if defined(__XBOXONE__) || defined(__XBOXSERIES__)
379379+#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
380380 /* XInputOnGameInput doesn't ever change dwPacketNumber, so have to just update every frame */
381381 UpdateXInputJoystickState(joystick, &XInputState, &XBatteryInformation);
382382#else
+1-1
src/libm/math_private.h
···2626#define libm_hidden_def(x)
2727#define strong_alias(x, y)
28282929-#if !defined(__HAIKU__) && !defined(__PSP__) && !defined(__3DS__) && !defined(__PS2__) /* already defined in a system header. */
2929+#if !defined(SDL_PLATFORM_HAIKU) && !defined(SDL_PLATFORM_PSP) && !defined(SDL_PLATFORM_3DS) && !defined(SDL_PLATFORM_PS2) /* already defined in a system header. */
3030typedef unsigned int u_int32_t;
3131#endif
3232
+1-1
src/loadso/windows/SDL_sysloadso.c
···3737 return NULL;
3838 }
3939 tstr = WIN_UTF8ToString(sofile);
4040-#ifdef __WINRT__
4040+#ifdef SDL_PLATFORM_WINRT
4141 /* WinRT only publicly supports LoadPackagedLibrary() for loading .dll
4242 files. LoadLibrary() is a private API, and not available for apps
4343 (that can be published to MS' Windows Store.)
···3333 In all other cases, attempt to use client-side arrays, as they tend to
3434 be dramatically faster when not batching, and about the same when
3535 we are. */
3636-#ifdef __EMSCRIPTEN__
3636+#ifdef SDL_PLATFORM_EMSCRIPTEN
3737#define USE_VERTEX_BUFFER_OBJECTS 1
3838#else
3939#define USE_VERTEX_BUFFER_OBJECTS 0
···21002100 goto error;
21012101 }
2102210221032103-#ifdef __WINRT__
21032103+#ifdef SDL_PLATFORM_WINRT
21042104 /* DLudwig, 2013-11-29: ANGLE for WinRT doesn't seem to work unless VSync
21052105 * is turned on. Not doing so will freeze the screen's contents to that
21062106 * of the first drawn frame.
···496496#define MMAP_CLEARS 0 /* WINCE and some others apparently don't clear */
497497#endif /* WIN32 */
498498499499-#ifdef __OS2__
499499+#ifdef SDL_PLATFORM_OS2
500500#define INCL_DOS
501501#include <os2.h>
502502#define HAVE_MMAP 1
503503#define HAVE_MORECORE 0
504504#define LACKS_SYS_MMAN_H
505505-#endif /* __OS2__ */
505505+#endif /* SDL_PLATFORM_OS2 */
506506507507#if defined(DARWIN) || defined(_DARWIN)
508508/* Mac OSX docs advise not to use sbrk; it seems better to use mmap */
···12381238#ifndef LACKS_UNISTD_H
12391239#include <unistd.h> /* for sbrk */
12401240#else /* LACKS_UNISTD_H */
12411241-#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__)
12411241+#if !defined(SDL_PLATFORM_FREEBSD) && !defined(SDL_PLATFORM_OPENBSD) && !defined(SDL_PLATFORM_NETBSD) && !defined(__DragonFly__)
12421242extern void* sbrk(ptrdiff_t);
12431243#endif /* FreeBSD etc */
12441244#endif /* LACKS_UNISTD_H */
···13421342#define IS_MMAPPED_BIT (SIZE_T_ONE)
13431343#define USE_MMAP_BIT (SIZE_T_ONE)
1344134413451345-#if !defined(WIN32) && !defined(__OS2__)
13451345+#if !defined(WIN32) && !defined(SDL_PLATFORM_OS2)
13461346#define CALL_MUNMAP(a, s) munmap((a), (s))
13471347#define MMAP_PROT (PROT_READ|PROT_WRITE)
13481348#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
···1366136613671367#define DIRECT_MMAP(s) CALL_MMAP(s)
1368136813691369-#elif defined(__OS2__)
13691369+#elif defined(SDL_PLATFORM_OS2)
1370137013711371/* OS/2 MMAP via DosAllocMem */
13721372static void* os2mmap(size_t size) {
···14771477 unique mparams values are initialized only once.
14781478*/
1479147914801480-#if !defined(WIN32) && !defined(__OS2__)
14801480+#if !defined(WIN32) && !defined(SDL_PLATFORM_OS2)
14811481/* By default use posix locks */
14821482#include <pthread.h>
14831483#define MLOCK_T pthread_mutex_t
···1491149114921492static MLOCK_T magic_init_mutex = PTHREAD_MUTEX_INITIALIZER;
1493149314941494-#elif defined(__OS2__)
14941494+#elif defined(SDL_PLATFORM_OS2)
14951495#define MLOCK_T HMTX
14961496#define INITIAL_LOCK(l) DosCreateMutexSem(0, l, 0, FALSE)
14971497#define ACQUIRE_LOCK(l) DosRequestMutexSem(*l, SEM_INDEFINITE_WAIT)
···25592559 }
25602560 RELEASE_MAGIC_INIT_LOCK();
2561256125622562-#if !defined(WIN32) && !defined(__OS2__)
25622562+#if !defined(WIN32) && !defined(SDL_PLATFORM_OS2)
25632563 mparams.page_size = malloc_getpagesize;
25642564 mparams.granularity = ((DEFAULT_GRANULARITY != 0)?
25652565 DEFAULT_GRANULARITY : mparams.page_size);
25662566-#elif defined (__OS2__)
25662566+#elif defined (SDL_PLATFORM_OS2)
25672567 /* if low-memory is used, os2munmap() would break
25682568 if it were anything other than 64k */
25692569 mparams.page_size = 4096u;
+2-2
src/stdlib/SDL_string.c
···24242525#include "SDL_vacopy.h"
26262727-#ifdef __vita__
2727+#ifdef SDL_PLATFORM_VITA
2828#include <psp2/kernel/clib.h>
2929#endif
3030···327327328328int SDL_memcmp(const void *s1, const void *s2, size_t len)
329329{
330330-#ifdef __vita__
330330+#ifdef SDL_PLATFORM_VITA
331331 /*
332332 Using memcmp on NULL is UB per POSIX / C99 7.21.1/2.
333333 But, both linux and bsd allow that, with an exception:
+1-1
src/stdlib/SDL_vacopy.h
···2020*/
21212222/* Do our best to make sure va_copy is working */
2323-#ifdef __NGAGE__
2323+#ifdef SDL_PLATFORM_NGAGE
2424#undef va_copy
2525#define va_copy(dst, src) dst = src
2626
···3939 * Implementation based on Slim Reader/Writer (SRW) Locks for Win 7 and newer.
4040 */
41414242-#ifdef __WINRT__
4242+#ifdef SDL_PLATFORM_WINRT
4343/* Functions are guaranteed to be available */
4444#define pInitializeSRWLock InitializeSRWLock
4545#define pReleaseSRWLockExclusive ReleaseSRWLockExclusive
···143143 if (mutex) {
144144 // Initialize
145145 // On SMP systems, a non-zero spin count generally helps performance
146146-#ifdef __WINRT__
146146+#ifdef SDL_PLATFORM_WINRT
147147 InitializeCriticalSectionEx(&mutex->cs, 2000, 0);
148148#else
149149 InitializeCriticalSectionAndSpinCount(&mutex->cs, 2000);
···197197 const SDL_mutex_impl_t *impl = &SDL_mutex_impl_cs;
198198199199 if (!SDL_GetHintBoolean(SDL_HINT_WINDOWS_FORCE_MUTEX_CRITICAL_SECTIONS, SDL_FALSE)) {
200200-#ifdef __WINRT__
200200+#ifdef SDL_PLATFORM_WINRT
201201 // Link statically on this platform
202202 impl = &SDL_mutex_impl_srw;
203203#else
+3-3
src/thread/windows/SDL_sysrwlock_srw.c
···3535typedef VOID(WINAPI *pfnAcquireSRWLockExclusive)(PSRWLOCK);
3636typedef BOOLEAN(WINAPI *pfnTryAcquireSRWLockExclusive)(PSRWLOCK);
37373838-#ifdef __WINRT__
3838+#ifdef SDL_PLATFORM_WINRT
3939/* Functions are guaranteed to be available */
4040#define pTryAcquireSRWLockExclusive TryAcquireSRWLockExclusive
4141#define pInitializeSRWLock InitializeSRWLock
···163163 &SDL_UnlockRWLock_srw
164164};
165165166166-#ifndef __WINRT__
166166+#ifndef SDL_PLATFORM_WINRT
167167168168#include "../generic/SDL_sysrwlock_c.h"
169169···184184 if (!SDL_rwlock_impl_active.Create) {
185185 const SDL_rwlock_impl_t *impl;
186186187187-#ifdef __WINRT__
187187+#ifdef SDL_PLATFORM_WINRT
188188 /* Link statically on this platform */
189189 impl = &SDL_rwlock_impl_srw;
190190#else
+3-3
src/thread/windows/SDL_syssem.c
···6161/* https://www.microsoft.com/en-us/download/details.aspx?id=47328 */
62626363#if !SDL_WINAPI_FAMILY_PHONE
6464-#ifdef __WINRT__
6464+#ifdef SDL_PLATFORM_WINRT
6565/* Functions are guaranteed to be available */
6666#define pWaitOnAddress WaitOnAddress
6767#define pWakeByAddressSingle WakeByAddressSingle
···223223 if (sem) {
224224 /* Create the semaphore, with max value 32K */
225225// !!! FIXME: CreateSemaphoreEx is available in Vista and later, so if XP support is dropped, we can lose this #ifdef.
226226-#ifdef __WINRT__
226226+#ifdef SDL_PLATFORM_WINRT
227227 sem->id = CreateSemaphoreEx(NULL, initial_value, 32 * 1024, NULL, 0, SEMAPHORE_ALL_ACCESS);
228228#else
229229 sem->id = CreateSemaphore(NULL, initial_value, 32 * 1024, NULL);
···331331332332#if !SDL_WINAPI_FAMILY_PHONE
333333 if (!SDL_GetHintBoolean(SDL_HINT_WINDOWS_FORCE_SEMAPHORE_KERNEL, SDL_FALSE)) {
334334-#ifdef __WINRT__
334334+#ifdef SDL_PLATFORM_WINRT
335335 /* Link statically on this platform */
336336 impl = &SDL_sem_impl_atom;
337337#else
+2-2
src/thread/windows/SDL_systhread.c
···6868 pfnSDL_CurrentBeginThread pfnBeginThread,
6969 pfnSDL_CurrentEndThread pfnEndThread)
7070{
7171-#elif defined(__CYGWIN__) || defined(__WINRT__)
7171+#elif defined(SDL_PLATFORM_CYGWIN) || defined(SDL_PLATFORM_WINRT)
7272int SDL_SYS_CreateThread(SDL_Thread *thread)
7373{
7474 pfnSDL_CurrentBeginThread pfnBeginThread = NULL;
···124124{
125125 if (name) {
126126 PVOID exceptionHandlerHandle;
127127-#ifndef __WINRT__ /* !!! FIXME: There's no LoadLibrary() in WinRT; don't know if SetThreadDescription is available there at all at the moment. */
127127+#ifndef SDL_PLATFORM_WINRT /* !!! FIXME: There's no LoadLibrary() in WinRT; don't know if SetThreadDescription is available there at all at the moment. */
128128 static pfnSetThreadDescription pSetThreadDescription = NULL;
129129 static HMODULE kernel32 = NULL;
130130
···5353#endif
5454#endif
55555656-#ifdef __EMSCRIPTEN__
5656+#ifdef SDL_PLATFORM_EMSCRIPTEN
5757#include <emscripten.h>
5858#endif
59596060-#ifdef __LINUX__
6060+#ifdef SDL_PLATFORM_LINUX
6161#include <sys/types.h>
6262#include <sys/stat.h>
6363#include <unistd.h>
···155155 return retval; \
156156 }
157157158158-#if defined(__MACOS__) && defined(SDL_VIDEO_DRIVER_COCOA)
158158+#if defined(SDL_PLATFORM_MACOS) && defined(SDL_VIDEO_DRIVER_COCOA)
159159/* Support for macOS fullscreen spaces */
160160extern SDL_bool Cocoa_IsWindowInFullscreenSpace(SDL_Window *window);
161161extern SDL_bool Cocoa_SetWindowFullscreenSpace(SDL_Window *window, SDL_bool state, SDL_bool blocking);
···208208209209static Uint32 SDL_DefaultGraphicsBackends(SDL_VideoDevice *_this)
210210{
211211-#if (defined(SDL_VIDEO_OPENGL) && defined(__MACOS__)) || (defined(__IOS__) && !TARGET_OS_MACCATALYST) || defined(__ANDROID__)
211211+#if (defined(SDL_VIDEO_OPENGL) && defined(SDL_PLATFORM_MACOS)) || (defined(SDL_PLATFORM_IOS) && !TARGET_OS_MACCATALYST) || defined(SDL_PLATFORM_ANDROID)
212212 if (_this->GL_CreateContext) {
213213 return SDL_WINDOW_OPENGL;
214214 }
215215#endif
216216-#if defined(SDL_VIDEO_METAL) && (TARGET_OS_MACCATALYST || defined(__MACOS__) || defined(__IOS__))
216216+#if defined(SDL_VIDEO_METAL) && (TARGET_OS_MACCATALYST || defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS))
217217 if (_this->Metal_CreateView) {
218218 return SDL_WINDOW_METAL;
219219 }
···15111511 }
15121512}
1513151315141514-#ifdef __WINRT__
15141514+#ifdef SDL_PLATFORM_WINRT
15151515extern Uint32 WINRT_DetectWindowFlags(SDL_Window *window);
15161516#endif
15171517···15701570 }
15711571 }
1572157215731573-#if defined(__MACOS__) && defined(SDL_VIDEO_DRIVER_COCOA)
15731573+#if defined(SDL_PLATFORM_MACOS) && defined(SDL_VIDEO_DRIVER_COCOA)
15741574 /* if the window is going away and no resolution change is necessary,
15751575 do nothing, or else we may trigger an ugly double-transition
15761576 */
···16061606 }
16071607 }
16081608 }
16091609-#elif defined(__WINRT__) && (NTDDI_VERSION < NTDDI_WIN10)
16091609+#elif defined(SDL_PLATFORM_WINRT) && (NTDDI_VERSION < NTDDI_WIN10)
16101610 /* HACK: WinRT 8.x apps can't choose whether or not they are fullscreen
16111611 or not. The user can choose this, via OS-provided UI, but this can't
16121612 be set programmatically.
···21442144 /* Clear minimized if not on windows, only windows handles it at create rather than FinishWindowCreation,
21452145 * but it's important or window focus will get broken on windows!
21462146 */
21472147-#if !defined(__WIN32__) && !defined(__GDK__)
21472147+#if !defined(SDL_PLATFORM_WIN32) && !defined(SDL_PLATFORM_GDK)
21482148 if (window->flags & SDL_WINDOW_MINIMIZED) {
21492149 window->flags &= ~SDL_WINDOW_MINIMIZED;
21502150 }
21512151#endif
2152215221532153-#if defined(__WINRT__) && (NTDDI_VERSION < NTDDI_WIN10)
21532153+#if defined(SDL_PLATFORM_WINRT) && (NTDDI_VERSION < NTDDI_WIN10)
21542154 /* HACK: WinRT 8.x apps can't choose whether or not they are fullscreen
21552155 or not. The user can choose this, via OS-provided UI, but this can't
21562156 be set programmatically.
···30283028 attempt_texture_framebuffer = SDL_FALSE;
30293029 }
3030303030313031-#ifdef __LINUX__
30313031+#ifdef SDL_PLATFORM_LINUX
30323032 /* On WSL, direct X11 is faster than using OpenGL for window framebuffers, so try to detect WSL and avoid texture framebuffer. */
30333033 else if ((_this->CreateWindowFramebuffer) && (SDL_strcmp(_this->name, "x11") == 0)) {
30343034 struct stat sb;
···30373037 }
30383038 }
30393039#endif
30403040-#if defined(__WIN32__) || defined(__WINGDK__) /* GDI BitBlt() is way faster than Direct3D dynamic textures right now. (!!! FIXME: is this still true?) */
30403040+#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) /* GDI BitBlt() is way faster than Direct3D dynamic textures right now. (!!! FIXME: is this still true?) */
30413041 else if ((_this->CreateWindowFramebuffer) && (SDL_strcmp(_this->name, "windows") == 0)) {
30423042 attempt_texture_framebuffer = SDL_FALSE;
30433043 }
30443044#endif
30453045-#ifdef __EMSCRIPTEN__
30453045+#ifdef SDL_PLATFORM_EMSCRIPTEN
30463046 else {
30473047 attempt_texture_framebuffer = SDL_FALSE;
30483048 }
···35293529 return SDL_FALSE;
35303530 }
3531353135323532-#if defined(__MACOS__) && defined(SDL_VIDEO_DRIVER_COCOA)
35323532+#if defined(SDL_PLATFORM_MACOS) && defined(SDL_VIDEO_DRIVER_COCOA)
35333533 if (SDL_strcmp(_this->name, "cocoa") == 0) { /* don't do this for X11, etc */
35343534 if (Cocoa_IsWindowInFullscreenSpace(window)) {
35353535 return SDL_FALSE;
···35373537 }
35383538#endif
3539353935403540-#ifdef __ANDROID__
35403540+#ifdef SDL_PLATFORM_ANDROID
35413541 {
35423542 extern SDL_bool Android_JNI_ShouldMinimizeOnFocusLoss(void);
35433543 if (!Android_JNI_ShouldMinimizeOnFocusLoss()) {
···4951495149524952int SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window)
49534953{
49544954-#ifdef __EMSCRIPTEN__
49544954+#ifdef SDL_PLATFORM_EMSCRIPTEN
49554955 /* !!! FIXME: propose a browser API for this, get this #ifdef out of here? */
49564956 /* Web browsers don't (currently) have an API for a custom message box
49574957 that can block, but for the most common case (SDL_ShowSimpleMessageBox),
···4141 #define VKAPI_ATTR
4242 #define VKAPI_CALL __stdcall
4343 #define VKAPI_PTR VKAPI_CALL
4444-#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7
4444+#elif defined(SDL_PLATFORM_ANDROID) && defined(__ARM_ARCH) && __ARM_ARCH < 7
4545 #error "Vulkan is not supported for the 'armeabi' NDK ABI"
4646-#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE)
4646+#elif defined(SDL_PLATFORM_ANDROID) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE)
4747 // On Android 32-bit ARM targets, Vulkan functions use the "hardfloat"
4848 // calling convention, i.e. float parameters are passed in registers. This
4949 // is true even if the rest of the application passes floats on the stack,
···3030#ifdef SDL_VIDEO_OPENGL_GLX
3131#include "SDL_x11opengles.h"
32323333-#if defined(__IRIX__) || defined(__NetBSD__) || defined(__OpenBSD__)
3333+#if defined(SDL_PLATFORM_IRIX) || defined(SDL_PLATFORM_NETBSD) || defined(SDL_PLATFORM_OPENBSD)
3434/*
3535 * IRIX doesn't have a GL library versioning system.
3636 * NetBSD and OpenBSD have different GL library versions depending on how
3737 * the library was installed.
3838 */
3939#define DEFAULT_OPENGL "libGL.so"
4040-#elif defined(__MACOS__)
4040+#elif defined(SDL_PLATFORM_MACOS)
4141#define DEFAULT_OPENGL "/opt/X11/lib/libGL.1.dylib"
4242#else
4343#define DEFAULT_OPENGL "libGL.so.1"
+1-1
src/video/x11/SDL_x11sym.h
···247247/*
248248 * These only show up on some variants of Unix.
249249 */
250250-#ifdef __osf__
250250+#ifdef SDL_PLATFORM_OSF
251251SDL_X11_MODULE(OSF_ENTRY_POINTS)
252252SDL_X11_SYM(void,_SmtBufferOverflow,(Display *dpy,register smtDisplayPtr p),(dpy,p),)
253253SDL_X11_SYM(void,_SmtIpError,(Display *dpy,register smtDisplayPtr p,int i),(dpy,p,i),)
···29293030/* WARNING ! those 2 files will be destroyed by this test program */
31313232-#ifdef __IOS__
3232+#ifdef SDL_PLATFORM_IOS
3333#define FBASENAME1 "../Documents/sdldata1" /* this file will be created during tests */
3434#define FBASENAME2 "../Documents/sdldata2" /* this file should not exist before starting test */
3535#else
···2727#endif
28282929#ifdef HAVE_SDL_TTF
3030-#ifdef __MACOS__
3030+#ifdef SDL_PLATFORM_MACOS
3131#define DEFAULT_FONT "/System/Library/Fonts/华文细黑.ttf"
3232-#elif defined(__WIN32__)
3232+#elif defined(SDL_PLATFORM_WIN32)
3333/* Some japanese font present on at least Windows 8.1. */
3434#define DEFAULT_FONT "C:\\Windows\\Fonts\\yugothic.ttf"
3535#else
+7-7
test/testintersections.c
···12121313/* Simple program: draw as many random objects on the screen as possible */
14141515-#include <stdlib.h>
1616-#include <time.h>
1515+#include <SDL3/SDL_test_common.h>
1616+#include <SDL3/SDL_main.h>
17171818-#ifdef __EMSCRIPTEN__
1818+#ifdef SDL_PLATFORM_EMSCRIPTEN
1919#include <emscripten/emscripten.h>
2020#endif
21212222-#include <SDL3/SDL_test_common.h>
2323-#include <SDL3/SDL_main.h>
2222+#include <stdlib.h>
2323+#include <time.h>
24242525#define SWAP(typ, a, b) \
2626 do { \
···273273274274 SDL_RenderPresent(renderer);
275275 }
276276-#ifdef __EMSCRIPTEN__
276276+#ifdef SDL_PLATFORM_EMSCRIPTEN
277277 if (*done) {
278278 emscripten_cancel_main_loop();
279279 }
···368368 then = SDL_GetTicks();
369369 done = 0;
370370371371-#ifdef __EMSCRIPTEN__
371371+#ifdef SDL_PLATFORM_EMSCRIPTEN
372372 emscripten_set_main_loop_arg(loop, &done, 0, 1);
373373#else
374374 while (!done) {