diff --git a/VisualC-GDK/tests/testgdk/src/testgdk.cpp b/VisualC-GDK/tests/testgdk/src/testgdk.cpp index bc4895bdc..bddecf3c5 100644 --- a/VisualC-GDK/tests/testgdk/src/testgdk.cpp +++ b/VisualC-GDK/tests/testgdk/src/testgdk.cpp @@ -311,7 +311,7 @@ loop() if (event.type == SDL_EVENT_KEY_DOWN && !event.key.repeat) { SDL_Log("Initial SDL_EVENT_KEY_DOWN: %s", SDL_GetScancodeName(event.key.keysym.scancode)); } -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) /* On Xbox, ignore the keydown event because the features aren't supported */ if (event.type != SDL_EVENT_KEY_DOWN) { SDLTest_CommonEvent(state, &event, &done); diff --git a/WhatsNew.txt b/WhatsNew.txt index a84f59b7e..2c4b517cd 100644 --- a/WhatsNew.txt +++ b/WhatsNew.txt @@ -8,8 +8,8 @@ This is a list of major changes in SDL's version history. General: * SDL headers should now be included as `#include ` * Many functions and symbols have changed since SDL 2.0, see the [migration guide](docs/README-migration.md) for details -* The preprocessor symbol __MACOSX__ has been renamed __MACOS__ -* The preprocessor symbol __IPHONEOS__ has been renamed __IOS__ +* The preprocessor symbol __MACOSX__ has been renamed SDL_PLATFORM_MACOS +* The preprocessor symbol __IPHONEOS__ has been renamed SDL_PLATFORM_IOS * SDL_stdinc.h no longer includes stdio.h, stdlib.h, etc., it only provides the SDL C runtime functionality * SDL_intrin.h now includes the intrinsics headers that were in SDL_cpuinfo.h * 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 diff --git a/build-scripts/SDL_migration.cocci b/build-scripts/SDL_migration.cocci index e0b90e91e..9b732532f 100644 --- a/build-scripts/SDL_migration.cocci +++ b/build-scripts/SDL_migration.cocci @@ -2903,3 +2903,4 @@ expression e1, e2, e3, e4; @@ - SDL_threadID + SDL_ThreadID + (...) diff --git a/build-scripts/rename_headers.py b/build-scripts/rename_headers.py index e09d8dade..b61e47730 100755 --- a/build-scripts/rename_headers.py +++ b/build-scripts/rename_headers.py @@ -7,17 +7,22 @@ import pathlib import re -def main(): +def do_include_replacements(paths): replacements = [ + ( re.compile(r"(?:[\"<])(?:SDL2/)?SDL_image.h(?:[\">])"), r"" ), + ( re.compile(r"(?:[\"<])(?:SDL2/)?SDL_mixer.h(?:[\">])"), r"" ), + ( re.compile(r"(?:[\"<])(?:SDL2/)?SDL_net.h(?:[\">])"), r"" ), + ( re.compile(r"(?:[\"<])(?:SDL2/)?SDL_rtf.h(?:[\">])"), r"" ), + ( re.compile(r"(?:[\"<])(?:SDL2/)?SDL_ttf.h(?:[\">])"), r"" ), ( re.compile(r"(?:[\"<])(?:SDL2/)?SDL_gamecontroller.h(?:[\">])"), r"" ), ( re.compile(r"(?:[\"<])(?:SDL2/)?begin_code.h(?:[\">])"), r"" ), ( re.compile(r"(?:[\"<])(?:SDL2/)?close_code.h(?:[\">])"), r"" ), ( re.compile(r"(?:[\"<])(?:SDL2/)?(SDL[_a-z0-9]*\.h)(?:[\">])"), r"" ) ] - for entry in args.args: + for entry in paths: path = pathlib.Path(entry) if not path.exists(): - print("%s doesn't exist, skipping" % entry) + print("{} does not exist, skipping".format(entry)) continue replace_headers_in_path(path, replacements) @@ -55,17 +60,16 @@ def replace_headers_in_path(path, replacements): replace_headers_in_file(path, replacements) -if __name__ == "__main__": - - parser = argparse.ArgumentParser(fromfile_prefix_chars='@') - parser.add_argument("args", nargs="*") +def main(): + parser = argparse.ArgumentParser(fromfile_prefix_chars='@', description="Rename #include's for SDL3.") + parser.add_argument("args", metavar="PATH", nargs="*", help="Input source file") args = parser.parse_args() try: - main() + do_include_replacements(args.args) except Exception as e: print(e) - exit(-1) - - exit(0) + return 1 +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/build-scripts/rename_macros.py b/build-scripts/rename_macros.py new file mode 100755 index 000000000..66243fcd0 --- /dev/null +++ b/build-scripts/rename_macros.py @@ -0,0 +1,139 @@ +#!/usr/bin/env python3 +# +# This script renames SDL macros in the specified paths + +import argparse +import pathlib +import re + + +class PlatformMacrosCheck: + RENAMED_MACROS = { + "__AIX__": "SDL_PLATFORM_AIX", + "__HAIKU__": "SDL_PLATFORM_HAIKU", + "__BSDI__": "SDL_PLATFORM_BSDI", + "__FREEBSD__": "SDL_PLATFORM_FREEBSD", + "__HPUX__": "SDL_PLATFORM_HPUX", + "__IRIX__": "SDL_PLATFORM_IRIX", + "__LINUX__": "SDL_PLATFORM_LINUX", + "__OS2__": "SDL_PLATFORM_OS2", + # "__ANDROID__": "SDL_PLATFORM_ANDROID, + "__NGAGE__": "SDL_PLATFORM_NGAGE", + "__APPLE__": "SDL_PLATFORM_APPLE", + "__TVOS__": "SDL_PLATFORM_TVOS", + "__IPHONEOS__": "SDL_PLATFORM_IOS", + "__MACOSX__": "SDL_PLATFORM_MACOS", + "__NETBSD__": "SDL_PLATFORM_NETBSD", + "__OPENBSD__": "SDL_PLATFORM_OPENBSD", + "__OSF__": "SDL_PLATFORM_OSF", + "__QNXNTO__": "SDL_PLATFORM_QNXNTO", + "__RISCOS__": "SDL_PLATFORM_RISCOS", + "__SOLARIS__": "SDL_PLATFORM_SOLARIS", + "__PSP__": "SDL_PLATFORM_PSP", + "__PS2__": "SDL_PLATFORM_PS2", + "__VITA__": "SDL_PLATFORM_VITA", + "__3DS__": "SDL_PLATFORM_3DS", + # "__unix__": "SDL_PLATFORM_UNIX, + "__WINRT__": "SDL_PLATFORM_WINRT", + "__XBOXSERIES__": "SDL_PLATFORM_XBOXSERIES", + "__XBOXONE__": "SDL_PLATFORM_XBOXONE", + "__WINDOWS__": "SDL_PLATFORM_WINDOWS", + "__WIN32__": "SDL_PLATFORM_WINRT", + # "__CYGWIN_": "SDL_PLATFORM_CYGWIN", + "__WINGDK__": "SDL_PLATFORM_WINGDK", + "__GDK__": "SDL_PLATFORM_GDK", + # "__EMSCRIPTEN__": "SDL_PLATFORM_EMSCRIPTEN", + } + + DEPRECATED_MACROS = { + "__DREAMCAST__", + "__NACL__", + "__PNACL__", + } + + def __init__(self): + self.re_pp_command = re.compile(r"^[ \t]*#[ \t]*(\w+).*") + self.re_platform_macros = re.compile(r"\W(" + "|".join(self.RENAMED_MACROS.keys()) + r")(?:\W|$)") + self.re_deprecated_macros = re.compile(r"\W(" + "|".join(self.DEPRECATED_MACROS) + r")(?:\W|$)") + + def run(self, contents): + def cb(m): + macro = m.group(1) + original = m.group(0) + match_start, _ = m.span(0) + platform_start, platform_end = m.span(1) + new_text = "{0} /* FIXME: use '#ifdef {0}' or 'defined({0})' */".format(self.RENAMED_MACROS[macro]) + r = original[:(platform_start-match_start)] + new_text + original[platform_end-match_start:] + return r + contents, _ = self.re_platform_macros.subn(cb, contents) + + def cb(m): + macro = m.group(1) + original = m.group(0) + match_start, _ = m.span(0) + platform_start, platform_end = m.span(1) + new_text = "{0} /* FIXME: {0} has been removed in SDL3 */".format(macro) + r = original[:(platform_start-match_start)] + new_text + original[platform_end-match_start:] + return r + contents, _ = self.re_deprecated_macros.subn(cb, contents) + return contents + + +def apply_checks(paths): + checks = ( + PlatformMacrosCheck(), + ) + + for entry in paths: + path = pathlib.Path(entry) + if not path.exists(): + print("{} does not exist, skipping".format(entry)) + continue + apply_checks_in_path(path, checks) + + +def apply_checks_in_file(file, checks): + try: + with file.open("r", encoding="UTF-8", newline="") as rfp: + original = rfp.read() + contents = original + for check in checks: + contents = check.run(contents) + if contents != original: + with file.open("w", encoding="UTF-8", newline="") as wfp: + wfp.write(contents) + except UnicodeDecodeError: + print("%s is not text, skipping" % file) + except Exception as err: + print("%s" % err) + + +def apply_checks_in_dir(path, checks): + for entry in path.glob("*"): + if entry.is_dir(): + apply_checks_in_dir(entry, checks) + else: + print("Processing %s" % entry) + apply_checks_in_file(entry, checks) + + +def apply_checks_in_path(path, checks): + if path.is_dir(): + apply_checks_in_dir(path, checks) + else: + apply_checks_in_file(path, checks) + + +def main(): + parser = argparse.ArgumentParser(fromfile_prefix_chars='@', description="Rename macros for SDL3") + parser.add_argument("args", nargs="*", help="Input source files") + args = parser.parse_args() + + try: + apply_checks(args.args) + except Exception as e: + print(e) + return 1 + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake index c91df3f39..b40464210 100644 --- a/cmake/sdlchecks.cmake +++ b/cmake/sdlchecks.cmake @@ -849,7 +849,7 @@ macro(CheckPTHREAD) check_c_source_compiles(" #include int main(int argc, char **argv) { - #ifdef __APPLE__ + #ifdef SDL_PLATFORM_APPLE pthread_setname_np(\"\"); #else pthread_setname_np(pthread_self(),\"\"); diff --git a/docs/README-gdk.md b/docs/README-gdk.md index 9a948583f..7c447039c 100644 --- a/docs/README-gdk.md +++ b/docs/README-gdk.md @@ -21,7 +21,7 @@ Windows GDK Status The Windows GDK port supports the full set of Win32 APIs, renderers, controllers, input devices, etc., as the normal Windows x64 build of SDL. * Additionally, the GDK port adds the following: - * 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.) + * 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.) * GDK-specific setup: * Initializing/uninitializing the game runtime, and initializing Xbox Live services * 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. @@ -149,7 +149,7 @@ Xbox GDKX Setup In general, the same process in the Windows GDK instructions work. There are just a few additional notes: * For Xbox One consoles, use the Gaming.Xbox.XboxOne.x64 target * For Xbox Series consoles, use the Gaming.Xbox.Scarlett.x64 target -* The Xbox One target sets the `__XBOXONE__` define and the Xbox Series target sets the `__XBOXSERIES__` define +* The Xbox One target sets the `SDL_PLATFORM_XBOXONE` define and the Xbox Series target sets the `SDL_PLATFORM_XBOXSERIES` define * 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) * 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) * To create a package, use: diff --git a/docs/README-ios.md b/docs/README-ios.md index 221cb27d6..ff991ad00 100644 --- a/docs/README-ios.md +++ b/docs/README-ios.md @@ -238,7 +238,7 @@ e.g. { ... initialize game ... - #ifdef __IOS__ + #ifdef SDL_PLATFORM_IOS // Initialize the Game Center for scoring and matchmaking InitGameCenter(); diff --git a/docs/README-migration.md b/docs/README-migration.md index aaff18c24..7cd385f0f 100644 --- a/docs/README-migration.md +++ b/docs/README-migration.md @@ -13,11 +13,17 @@ rename_symbols.py --all-symbols source_code_path It'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) -SDL headers should now be included as `#include `. 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: +SDL headers should now be included as `#include `. 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 `. 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: ```sh rename_headers.py source_code_path ``` +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: +```sh +rename_macros.py source_code_path +``` + + CMake users should use this snippet to include SDL support in their project: ``` find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3) @@ -932,7 +938,49 @@ The following symbols have been renamed: ## SDL_platform.h -The preprocessor symbol `__MACOSX__` has been renamed `__MACOS__`, and `__IPHONEOS__` has been renamed `__IOS__` +The following platform preprocessor macros have been removed: +* __DREAMCAST__ +* __NACL__ +* __PNACL__ + +The following platform preprocessor macros have been renamed: + +| SDL2 | SDL3 | +|-------------------|---------------------------| +| `__3DS__` | `SDL_PLATFORM_3DS` | +| `__AIX__` | `SDL_PLATFORM_AIX` | +| `__ANDROID__` | `SDL_PLATFORM_ANDROID` | +| `__APPLE__` | `SDL_PLATFORM_APPLE` | +| `__BSDI__` | `SDL_PLATFORM_BSDI` | +| `__CYGWIN_` | `SDL_PLATFORM_CYGWIN` | +| `__EMSCRIPTEN__` | `SDL_PLATFORM_EMSCRIPTEN` | +| `__FREEBSD__` | `SDL_PLATFORM_FREEBSD` | +| `__GDK__` | `SDL_PLATFORM_GDK` | +| `__HAIKU__` | `SDL_PLATFORM_HAIKU` | +| `__HPUX__` | `SDL_PLATFORM_HPUX` | +| `__IPHONEOS__` | `SDL_PLATFORM_IOS` | +| `__IRIX__` | `SDL_PLATFORM_IRIX` | +| `__LINUX__` | `SDL_PLATFORM_LINUX` | +| `__MACOSX__` | `SDL_PLATFORM_MACOS` | +| `__NETBSD__` | `SDL_PLATFORM_NETBSD` | +| `__NGAGE__` | `SDL_PLATFORM_NGAGE` | +| `__OPENBSD__` | `SDL_PLATFORM_OPENBSD` | +| `__OS2__` | `SDL_PLATFORM_OS2` | +| `__OSF__` | `SDL_PLATFORM_OSF` | +| `__PS2__` | `SDL_PLATFORM_PS2` | +| `__PSP__` | `SDL_PLATFORM_PSP` | +| `__QNXNTO__` | `SDL_PLATFORM_QNXNTO` | +| `__RISCOS__` | `SDL_PLATFORM_RISCOS` | +| `__SOLARIS__` | `SDL_PLATFORM_SOLARIS` | +| `__TVOS__` | `SDL_PLATFORM_TVOS` | +| `__unix__` | `SDL_PLATFORM_UNI` | +| `__VITA__` | `SDL_PLATFORM_VITA` | +| `__WIN32__` | `SDL_PLATFORM_WINRT` | +| `__WINDOWS__` | `SDL_PLATFORM_WINDOWS` | +| `__WINGDK__` | `SDL_PLATFORM_WINGDK` | +| `__WINRT__` | `SDL_PLATFORM_WINRT` | +| `__XBOXONE__` | `SDL_PLATFORM_XBOXONE` | +| `__XBOXSERIES__` | `SDL_PLATFORM_XBOXSERIES` | ## SDL_rect.h @@ -1360,7 +1408,7 @@ The information previously available in SDL_GetWindowWMInfo() is now available a if (nswindow) { ... } -#elif defined(__LINUX__) +#elif defined(SDL_PLATFORM_LINUX) if (SDL_GetWindowWMInfo(window, &info)) { if (info.subsystem == SDL_SYSWM_X11) { Display *xdisplay = info.info.x11.display; @@ -1380,17 +1428,17 @@ The information previously available in SDL_GetWindowWMInfo() is now available a ``` becomes: ```c -#if defined(__WIN32__) +#if defined(SDL_PLATFORM_WIN32) HWND hwnd = (HWND)SDL_GetProperty(SDL_GetWindowProperties(window), SDL_PROPERTY_WINDOW_WIN32_HWND_POINTER, NULL); if (hwnd) { ... } -#elif defined(__MACOS__) +#elif defined(SDL_PLATFORM_MACOS) NSWindow *nswindow = (__bridge NSWindow *)SDL_GetProperty(SDL_GetWindowProperties(window), SDL_PROPERTY_WINDOW_COCOA_WINDOW_POINTER, NULL); if (nswindow) { ... } -#elif defined(__LINUX__) +#elif defined(SDL_PLATFORM_LINUX) if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0) { Display *xdisplay = (Display *)SDL_GetProperty(SDL_GetWindowProperties(window), SDL_PROPERTY_WINDOW_X11_DISPLAY_POINTER, NULL); Window xwindow = (Window)SDL_GetNumberProperty(SDL_GetWindowProperties(window), SDL_PROPERTY_WINDOW_X11_WINDOW_NUMBER, 0); diff --git a/docs/README-winrt.md b/docs/README-winrt.md index a41b21eb6..6e73c93f5 100644 --- a/docs/README-winrt.md +++ b/docs/README-winrt.md @@ -33,7 +33,7 @@ Here is a rough list of what works, and what doesn't: * What works: * compilation via Visual C++ 2019. * compile-time platform detection for SDL programs. The C/C++ #define, - `__WINRT__`, will be set to 1 (by SDL) when compiling for WinRT. + `SDL_PLATFORM_WINRT`, will be set to 1 (by SDL) when compiling for WinRT. * GPU-accelerated 2D rendering, via SDL_Renderer. * OpenGL ES 2, via the ANGLE library (included separately from SDL) * software rendering, via either SDL_Surface (optionally in conjunction with diff --git a/include/SDL3/SDL_assert.h b/include/SDL3/SDL_assert.h index e4f553e4f..c2ecadbcf 100644 --- a/include/SDL3/SDL_assert.h +++ b/include/SDL3/SDL_assert.h @@ -66,9 +66,9 @@ assert can have unique static variables associated with it. #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" ) #elif (defined(__GNUC__) || defined(__clang__)) && defined(__riscv) #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "ebreak\n\t" ) -#elif ( defined(__APPLE__) && (defined(__arm64__) || defined(__aarch64__)) ) /* this might work on other ARM targets, but this is a known quantity... */ +#elif ( defined(SDL_PLATFORM_APPLE) && (defined(__arm64__) || defined(__aarch64__)) ) /* this might work on other ARM targets, but this is a known quantity... */ #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #22\n\t" ) -#elif defined(__APPLE__) && defined(__arm__) +#elif defined(SDL_PLATFORM_APPLE) && defined(__arm__) #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "bkpt #22\n\t" ) #elif defined(__386__) && defined(__WATCOMC__) #define SDL_TriggerBreakpoint() { _asm { int 0x03 } } @@ -167,7 +167,7 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *data #ifndef SDL_AssertBreakpoint #if defined(ANDROID) && defined(assert) /* Define this as empty in case assert() is defined as SDL_assert */ -#define SDL_AssertBreakpoint() +#define SDL_AssertBreakpoint() #else #define SDL_AssertBreakpoint() SDL_TriggerBreakpoint() #endif diff --git a/include/SDL3/SDL_atomic.h b/include/SDL3/SDL_atomic.h index 82e54b32e..849ccc244 100644 --- a/include/SDL3/SDL_atomic.h +++ b/include/SDL3/SDL_atomic.h @@ -153,7 +153,7 @@ extern DECLSPEC void SDLCALL SDL_UnlockSpinlock(SDL_SpinLock *lock); void _ReadWriteBarrier(void); #pragma intrinsic(_ReadWriteBarrier) #define SDL_CompilerBarrier() _ReadWriteBarrier() -#elif (defined(__GNUC__) && !defined(__EMSCRIPTEN__)) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120)) +#elif (defined(__GNUC__) && !defined(SDL_PLATFORM_EMSCRIPTEN)) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120)) /* This is correct for all CPUs when using GCC or Solaris Studio 12.1+. */ #define SDL_CompilerBarrier() __asm__ __volatile__ ("" : : : "memory") #elif defined(__WATCOMC__) @@ -199,7 +199,7 @@ extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void); #define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory") #define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory") #elif defined(__GNUC__) && defined(__arm__) -#if 0 /* defined(__LINUX__) || defined(__ANDROID__) */ +#if 0 /* defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID) */ /* Information from: https://chromium.googlesource.com/chromium/chromium/+/trunk/base/atomicops_internals_arm_gcc.h#19 @@ -226,7 +226,7 @@ typedef void (*SDL_KernelMemoryBarrierFunc)(); #else #define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("" : : : "memory") #define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("" : : : "memory") -#endif /* __LINUX__ || __ANDROID__ */ +#endif /* SDL_PLATFORM_LINUX || SDL_PLATFORM_ANDROID */ #endif /* __GNUC__ && __arm__ */ #else #if (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120)) diff --git a/include/SDL3/SDL_begin_code.h b/include/SDL3/SDL_begin_code.h index 128038251..c53ad79e2 100644 --- a/include/SDL3/SDL_begin_code.h +++ b/include/SDL3/SDL_begin_code.h @@ -53,7 +53,7 @@ /* Some compilers use a special export keyword */ #ifndef DECLSPEC -# if defined(__WIN32__) || defined(__WINRT__) || defined(__CYGWIN__) || defined(__GDK__) +# if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_CYGWIN) || defined(SDL_PLATFORM_GDK) # ifdef DLL_EXPORT # define DECLSPEC __declspec(dllexport) # else @@ -70,7 +70,7 @@ /* By default SDL uses the C calling convention */ #ifndef SDLCALL -#if (defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__)) && !defined(__GNUC__) +#if (defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK)) && !defined(__GNUC__) #define SDLCALL __cdecl #else #define SDLCALL diff --git a/include/SDL3/SDL_egl.h b/include/SDL3/SDL_egl.h index 1945a8fda..1e6f73678 100644 --- a/include/SDL3/SDL_egl.h +++ b/include/SDL3/SDL_egl.h @@ -25,9 +25,11 @@ * This is a simple file to encapsulate the EGL API headers. */ -#if !defined(_MSC_VER) && !defined(__ANDROID__) && !defined(SDL_USE_BUILTIN_OPENGL_DEFINITIONS) +#include "SDL_platform_defines.h" -#if defined(__vita__) || defined(__psp2__) +#if !defined(_MSC_VER) && !defined(SDL_PLATFORM_ANDROID) && !defined(SDL_USE_BUILTIN_OPENGL_DEFINITIONS) + +#if defined(SDL_PLATFORM_VITA) #include #include #include @@ -419,7 +421,7 @@ typedef HDC EGLNativeDisplayType; typedef HBITMAP EGLNativePixmapType; typedef HWND EGLNativeWindowType; -#elif defined(__EMSCRIPTEN__) +#elif defined(SDL_PLATFORM_EMSCRIPTEN) typedef int EGLNativeDisplayType; typedef int EGLNativePixmapType; diff --git a/include/SDL3/SDL_endian.h b/include/SDL3/SDL_endian.h index 480fe5ff5..b787ea83d 100644 --- a/include/SDL3/SDL_endian.h +++ b/include/SDL3/SDL_endian.h @@ -56,13 +56,13 @@ _m_prefetch(void *__P) /* @} */ #ifndef SDL_BYTEORDER -#ifdef __linux__ +#ifdef SDL_PLATFORM_LINUX #include #define SDL_BYTEORDER __BYTE_ORDER -#elif defined(__OpenBSD__) || defined(__DragonFly__) +#elif defined(SDL_PLATFORM_OPENBSD) || defined(__DragonFly__) #include #define SDL_BYTEORDER BYTE_ORDER -#elif defined(__FreeBSD__) || defined(__NetBSD__) +#elif defined(SDL_PLATFORM_FREEBSD) || defined(SDL_PLATFORM_NETBSD) #include #define SDL_BYTEORDER BYTE_ORDER /* predefs from newer gcc and clang versions: */ @@ -84,7 +84,7 @@ _m_prefetch(void *__P) #else #define SDL_BYTEORDER SDL_LIL_ENDIAN #endif -#endif /* __linux__ */ +#endif /* SDL_PLATFORM_LINUX */ #endif /* !SDL_BYTEORDER */ #ifndef SDL_FLOATWORDORDER diff --git a/include/SDL3/SDL_intrin.h b/include/SDL3/SDL_intrin.h index d75ce7887..7665e124a 100644 --- a/include/SDL3/SDL_intrin.h +++ b/include/SDL3/SDL_intrin.h @@ -64,7 +64,7 @@ _m_prefetch(void *__P) # ifdef __ARM_NEON # define SDL_NEON_INTRINSICS 1 # include -# elif defined(__WINDOWS__) || defined(__WINRT__) || defined(__GDK__) +# elif defined(SDL_PLATFORM_WINDOWS) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK) /* Visual Studio doesn't define __ARM_ARCH, but _M_ARM (if set, always 7), and _M_ARM64 (if set, always 1). */ # ifdef _M_ARM # define SDL_NEON_INTRINSICS 1 diff --git a/include/SDL3/SDL_main.h b/include/SDL3/SDL_main.h index 76f08f100..7e65fc44d 100644 --- a/include/SDL3/SDL_main.h +++ b/include/SDL3/SDL_main.h @@ -22,6 +22,7 @@ #ifndef SDL_main_h_ #define SDL_main_h_ +#include #include #include @@ -40,7 +41,7 @@ */ #ifndef SDL_MAIN_HANDLED -#ifdef __WIN32__ +#ifdef SDL_PLATFORM_WIN32 /* On Windows SDL provides WinMain(), which parses the command line and passes the arguments to your main function. @@ -48,7 +49,7 @@ */ #define SDL_MAIN_AVAILABLE -#elif defined(__WINRT__) +#elif defined(SDL_PLATFORM_WINRT) /* On WinRT, SDL provides a main function that initializes CoreApplication, creating an instance of IFrameworkView in the process. @@ -62,7 +63,7 @@ */ #define SDL_MAIN_NEEDED -#elif defined(__GDK__) +#elif defined(SDL_PLATFORM_GDK) /* On GDK, SDL provides a main function that initializes the game runtime. If you prefer to write your own WinMain-function instead of having SDL @@ -72,7 +73,7 @@ */ #define SDL_MAIN_NEEDED -#elif defined(__IOS__) +#elif defined(SDL_PLATFORM_IOS) /* On iOS SDL provides a main function that creates an application delegate and starts the iOS application run loop. @@ -83,7 +84,7 @@ */ #define SDL_MAIN_NEEDED -#elif defined(__ANDROID__) +#elif defined(SDL_PLATFORM_ANDROID) /* On Android SDL provides a Java class in SDLActivity.java that is the main activity entry point. @@ -94,7 +95,7 @@ /* We need to export SDL_main so it can be launched from Java */ #define SDLMAIN_DECLSPEC DECLSPEC -#elif defined(__PSP__) +#elif defined(SDL_PLATFORM_PSP) /* On PSP SDL provides a main function that sets the module info, activates the GPU and starts the thread required to be able to exit the software. @@ -103,14 +104,14 @@ */ #define SDL_MAIN_AVAILABLE -#elif defined(__PS2__) +#elif defined(SDL_PLATFORM_PS2) #define SDL_MAIN_AVAILABLE #define SDL_PS2_SKIP_IOP_RESET() \ void reset_IOP(); \ void reset_IOP() {} -#elif defined(__3DS__) +#elif defined(SDL_PLATFORM_3DS) /* On N3DS, SDL provides a main function that sets up the screens and storage. @@ -119,7 +120,7 @@ */ #define SDL_MAIN_AVAILABLE -#elif defined(__NGAGE__) +#elif defined(SDL_PLATFORM_NGAGE) /* TODO: not sure if it should be SDL_MAIN_NEEDED, in SDL2 ngage had a @@ -422,7 +423,7 @@ extern DECLSPEC int SDLCALL SDL_RunApp(int argc, char* argv[], SDL_main_func mai extern 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); -#if defined(__WIN32__) || defined(__GDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) /** * Register a win32 window class for SDL's use. @@ -467,24 +468,24 @@ extern DECLSPEC int SDLCALL SDL_RegisterApp(const char *name, Uint32 style, void */ extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); -#endif /* defined(__WIN32__) || defined(__GDK__) */ +#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) */ -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT /* for compatibility with SDL2's function of this name */ #define SDL_WinRTRunApp(MAIN_FUNC, RESERVED) SDL_RunApp(0, NULL, MAIN_FUNC, RESERVED) -#endif /* __WINRT__ */ +#endif /* SDL_PLATFORM_WINRT */ -#ifdef __IOS__ +#ifdef SDL_PLATFORM_IOS /* for compatibility with SDL2's function of this name */ #define SDL_UIKitRunApp(ARGC, ARGV, MAIN_FUNC) SDL_RunApp(ARGC, ARGV, MAIN_FUNC, NULL) -#endif /* __IOS__ */ +#endif /* SDL_PLATFORM_IOS */ -#ifdef __GDK__ +#ifdef SDL_PLATFORM_GDK /* for compatibility with SDL2's function of this name */ #define SDL_GDKRunApp(MAIN_FUNC, RESERVED) SDL_RunApp(0, NULL, MAIN_FUNC, RESERVED) @@ -496,7 +497,7 @@ extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); */ extern DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void); -#endif /* __GDK__ */ +#endif /* SDL_PLATFORM_GDK */ #ifdef __cplusplus } @@ -507,13 +508,13 @@ extern DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void); #if !defined(SDL_MAIN_HANDLED) && !defined(SDL_MAIN_NOIMPL) /* include header-only SDL_main implementations */ #if defined(SDL_MAIN_USE_CALLBACKS) \ - || defined(__WIN32__) || defined(__GDK__) || defined(__IOS__) || defined(__TVOS__) \ - || defined(__3DS__) || defined(__NGAGE__) || defined(__PS2__) || defined(__PSP__) + || defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS) \ + || defined(SDL_PLATFORM_3DS) || defined(SDL_PLATFORM_NGAGE) || defined(SDL_PLATFORM_PS2) || defined(SDL_PLATFORM_PSP) /* platforms which main (-equivalent) can be implemented in plain C */ #include -#elif defined(__WINRT__) /* C++ platforms */ +#elif defined(SDL_PLATFORM_WINRT) /* C++ platforms */ #ifdef __cplusplus #include @@ -528,7 +529,7 @@ extern DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void); #endif /* __GNUC__ */ #endif /* __cplusplus */ -#endif /* C++ platforms like __WINRT__ etc */ +#endif /* C++ platforms like SDL_PLATFORM_WINRT etc */ #endif /* SDL_MAIN_HANDLED */ diff --git a/include/SDL3/SDL_main_impl.h b/include/SDL3/SDL_main_impl.h index 2ba34271f..43936a83e 100644 --- a/include/SDL3/SDL_main_impl.h +++ b/include/SDL3/SDL_main_impl.h @@ -65,7 +65,7 @@ int SDL_main(int argc, char **argv) /* set up the usual SDL_main stuff if we're not using callbacks or if we are but need the normal entry point. */ #if !defined(SDL_MAIN_USE_CALLBACKS) || defined(SDL_MAIN_CALLBACK_STANDARD) -#if defined(__WIN32__) || defined(__GDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) /* these defines/typedefs are needed for the WinMain() definition */ #ifndef WINAPI @@ -77,7 +77,7 @@ typedef char* LPSTR; typedef wchar_t* PWSTR; /* The VC++ compiler needs main/wmain defined, but not for GDK */ -#if defined(_MSC_VER) && !defined(__GDK__) +#if defined(_MSC_VER) && !defined(SDL_PLATFORM_GDK) /* This is where execution begins [console apps] */ #if defined( UNICODE ) && UNICODE @@ -97,7 +97,7 @@ int main(int argc, char *argv[]) } #endif /* UNICODE */ -#endif /* _MSC_VER && ! __GDK__ */ +#endif /* _MSC_VER && ! SDL_PLATFORM_GDK */ /* This is where execution begins [windowed apps and GDK] */ @@ -120,8 +120,8 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) } /* extern "C" */ #endif -/* end of __WIN32__ and __GDK__ impls */ -#elif defined(__WINRT__) +/* end of SDL_PLATFORM_WIN32 and SDL_PLATFORM_GDK impls */ +#elif defined(SDL_PLATFORM_WINRT) /* WinRT main based on SDL_winrt_main_NonXAML.cpp, placed in the public domain by David Ludwig 3/13/14 */ @@ -182,18 +182,18 @@ int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int) #endif /* end of WinRT impl */ -#elif defined(__NGAGE__) +#elif defined(SDL_PLATFORM_NGAGE) /* same typedef as in ngage SDKs e32def.h */ typedef signed int TInt; /* TODO: if it turns out that this only works when built as C++, - move __NGAGE__ into the C++ section in SDL_main.h */ + move SDL_PLATFORM_NGAGE into the C++ section in SDL_main.h */ TInt E32Main() { return SDL_RunApp(0, NULL, SDL_main, NULL); } -/* end of __NGAGE__ impl */ +/* end of SDL_PLATFORM_NGAGE impl */ #else /* platforms that use a standard main() and just call SDL_RunApp(), like iOS and 3DS */ @@ -204,7 +204,7 @@ int main(int argc, char *argv[]) /* end of impls for standard-conforming platforms */ -#endif /* __WIN32__ etc */ +#endif /* SDL_PLATFORM_WIN32 etc */ #endif /* !defined(SDL_MAIN_USE_CALLBACKS) || defined(SDL_MAIN_CALLBACK_STANDARD) */ diff --git a/include/SDL3/SDL_oldnames.h b/include/SDL3/SDL_oldnames.h index 02b1d83df..0a7a47cae 100644 --- a/include/SDL3/SDL_oldnames.h +++ b/include/SDL3/SDL_oldnames.h @@ -377,14 +377,6 @@ #define SDL_PIXELFORMAT_RGB888 SDL_PIXELFORMAT_XRGB8888 #define SDL_PixelFormatEnumToMasks SDL_GetMasksForPixelFormatEnum -/* ##SDL_platform.h */ -#ifdef __IOS__ -#define __IPHONEOS__ __IOS__ -#endif -#ifdef __MACOS__ -#define __MACOSX__ __MACOS__ -#endif - /* ##SDL_rect.h */ #define SDL_EncloseFPoints SDL_GetRectEnclosingPointsFloat #define SDL_EnclosePoints SDL_GetRectEnclosingPoints @@ -853,14 +845,6 @@ #define SDL_PIXELFORMAT_RGB888 SDL_PIXELFORMAT_RGB888_renamed_SDL_PIXELFORMAT_XRGB8888 #define SDL_PixelFormatEnumToMasks SDL_PixelFormatEnumToMasks_renamed_SDL_GetMasksForPixelFormatEnum -/* ##SDL_platform.h */ -#ifdef __IOS__ -#define __IPHONEOS__ __IPHONEOS___renamed___IOS__ -#endif -#ifdef __MACOS__ -#define __MACOSX__ __MACOSX___renamed___MACOS__ -#endif - /* ##SDL_rect.h */ #define SDL_EncloseFPoints SDL_EncloseFPoints_renamed_SDL_GetRectEnclosingPointsFloat #define SDL_EnclosePoints SDL_EnclosePoints_renamed_SDL_GetRectEnclosingPoints diff --git a/include/SDL3/SDL_opengl.h b/include/SDL3/SDL_opengl.h index 9fb298f90..575f64616 100644 --- a/include/SDL3/SDL_opengl.h +++ b/include/SDL3/SDL_opengl.h @@ -37,7 +37,7 @@ #include -#ifndef __IOS__ /* No OpenGL on iOS. */ +#ifndef SDL_PLATFORM_IOS /* No OpenGL on iOS. */ /* * Mesa 3-D graphics library @@ -77,11 +77,7 @@ * Begin system-specific stuff. */ -#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) -#define __WIN32__ -#endif - -#if defined(__WIN32__) && !defined(__CYGWIN__) +#if defined(_WIN32) && !defined(__CYGWIN__) # if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ # define GLAPI __declspec(dllexport) # elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ @@ -90,7 +86,7 @@ # define GLAPI extern # endif /* _STATIC_MESA support */ # if defined(__MINGW32__) && defined(GL_NO_STDCALL) || defined(UNDER_CE) /* The generated DLLs by MingW with STDCALL are not compatible with the ones done by Microsoft's compilers */ -# define GLAPIENTRY +# define GLAPIENTRY # else # define GLAPIENTRY __stdcall # endif @@ -2118,6 +2114,6 @@ typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLsh #endif /* __gl_h_ */ -#endif /* !__IOS__ */ +#endif /* !SDL_PLATFORM_IOS */ #endif /* SDL_opengl_h_ */ diff --git a/include/SDL3/SDL_opengles.h b/include/SDL3/SDL_opengles.h index 8f4b66764..d17346393 100644 --- a/include/SDL3/SDL_opengles.h +++ b/include/SDL3/SDL_opengles.h @@ -26,7 +26,7 @@ */ #include -#ifdef __IOS__ +#ifdef SDL_PLATFORM_IOS #include #include #else diff --git a/include/SDL3/SDL_opengles2.h b/include/SDL3/SDL_opengles2.h index a3b378852..85abf2b81 100644 --- a/include/SDL3/SDL_opengles2.h +++ b/include/SDL3/SDL_opengles2.h @@ -28,7 +28,7 @@ #if !defined(_MSC_VER) && !defined(SDL_USE_BUILTIN_OPENGL_DEFINITIONS) -#ifdef __IOS__ +#ifdef SDL_PLATFORM_IOS #include #include #else diff --git a/include/SDL3/SDL_platform_defines.h b/include/SDL3/SDL_platform_defines.h index 55a55c306..d55f8a9d8 100644 --- a/include/SDL3/SDL_platform_defines.h +++ b/include/SDL3/SDL_platform_defines.h @@ -29,48 +29,40 @@ #define SDL_platform_defines_h_ #ifdef _AIX -#undef __AIX__ -#define __AIX__ 1 +#define SDL_PLATFORM_AIX 1 #endif #ifdef __HAIKU__ -#undef __HAIKU__ -#define __HAIKU__ 1 +#define SDL_PLATFORM_HAIKU 1 #endif #if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) -#undef __BSDI__ -#define __BSDI__ 1 -#endif -#ifdef _arch_dreamcast -#undef __DREAMCAST__ -#define __DREAMCAST__ 1 +#define SDL_PLATFORM_BSDI 1 #endif #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) -#undef __FREEBSD__ -#define __FREEBSD__ 1 +#define SDL_PLATFORM_FREEBSD 1 #endif #if defined(hpux) || defined(__hpux) || defined(__hpux__) -#undef __HPUX__ -#define __HPUX__ 1 +#define SDL_PLATFORM_HPUX 1 #endif #if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) -#undef __IRIX__ -#define __IRIX__ 1 +#define SDL_PLATFORM_IRIX 1 #endif #if (defined(linux) || defined(__linux) || defined(__linux__)) -#undef __LINUX__ -#define __LINUX__ 1 +#define SDL_PLATFORM_LINUX 1 #endif #if defined(ANDROID) || defined(__ANDROID__) -#undef __ANDROID__ -#undef __LINUX__ /* do we need to do this? */ -#define __ANDROID__ 1 +#undef SDL_PLATFORM_LINUX /* do we need to do this? */ +#define SDL_PLATFORM_ANDROID 1 #endif #ifdef __NGAGE__ -#undef __NGAGE__ -#define __NGAGE__ 1 +#define SDL_PLATFORM_NGAGE 1 +#endif + +#if defined(__unix__) || defined(__unix) || defined(unix) +#define SDL_PLATFORM_UNIX 1 #endif #ifdef __APPLE__ +#define SDL_PLATFORM_APPLE 1 /* lets us know what version of macOS we're compiling on */ #include #include @@ -99,51 +91,48 @@ #endif #if TARGET_OS_TV -#undef __TVOS__ -#define __TVOS__ 1 +#define SDL_PLATFORM_TVOS 1 #endif #if TARGET_OS_IPHONE -#undef __IOS__ -#define __IOS__ 1 +#define SDL_PLATFORM_IOS 1 #else -#undef __MACOS__ -#define __MACOS__ 1 +#define SDL_PLATFORM_MACOS 1 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 # error SDL for macOS only supports deploying on 10.7 and above. #endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1070 */ #endif /* TARGET_OS_IPHONE */ -#endif /* defined(__APPLE__) */ +#endif /* defined(SDL_PLATFORM_APPLE) */ +#ifdef __EMSCRIPTEN__ +#define SDL_PLATFORM_EMSCRIPTEN 1 +#endif #ifdef __NetBSD__ -#undef __NETBSD__ -#define __NETBSD__ 1 +#define SDL_PLATFORM_NETBSD 1 #endif #ifdef __OpenBSD__ -#undef __OPENBSD__ -#define __OPENBSD__ 1 +#define SDL_PLATFORM_OPENBSD 1 #endif #if defined(__OS2__) || defined(__EMX__) -#undef __OS2__ -#define __OS2__ 1 +#define SDL_PLATFORM_OS2 1 #endif #if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) -#undef __OSF__ -#define __OSF__ 1 +#define SDL_PLATFORM_OSF 1 #endif #ifdef __QNXNTO__ -#undef __QNXNTO__ -#define __QNXNTO__ 1 +#define SDL_PLATFORM_QNXNTO 1 #endif #if defined(riscos) || defined(__riscos) || defined(__riscos__) -#undef __RISCOS__ -#define __RISCOS__ 1 +#define SDL_PLATFORM_RISCOS 1 #endif #if defined(__sun) && defined(__SVR4) -#undef __SOLARIS__ -#define __SOLARIS__ 1 +#define SDL_PLATFORM_SOLARIS 1 #endif -#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) +#if defined(__CYGWIN__) +#define SDL_PLATFORM_CYGWIN 1 +#endif + +#if defined(WIN32) || defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN) || defined(__MINGW32__) /* Try to find out if we're compiling for WinRT, GDK or non-WinRT/GDK */ #if defined(_MSC_VER) && defined(__has_include) #if __has_include() @@ -173,47 +162,39 @@ #endif #if WINAPI_FAMILY_WINRT -#undef __WINRT__ -#define __WINRT__ 1 +#define SDL_PLATFORM_WINRT 1 #elif defined(_GAMING_DESKTOP) /* GDK project configuration always defines _GAMING_XXX */ -#undef __WINGDK__ -#define __WINGDK__ 1 +#define SDL_PLATFORM_WINGDK 1 #elif defined(_GAMING_XBOX_XBOXONE) -#undef __XBOXONE__ -#define __XBOXONE__ 1 +#define SDL_PLATFORM_XBOXONE 1 #elif defined(_GAMING_XBOX_SCARLETT) -#undef __XBOXSERIES__ -#define __XBOXSERIES__ 1 +#define SDL_PLATFORM_XBOXSERIES 1 #else -#undef __WINDOWS__ -#define __WINDOWS__ 1 +#define SDL_PLATFORM_WINDOWS 1 #endif -#endif /* defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) */ +#endif /* defined(WIN32) || defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN) */ -#ifdef __WINDOWS__ -#undef __WIN32__ -#define __WIN32__ 1 +#ifdef SDL_PLATFORM_WINDOWS +#define SDL_PLATFORM_WIN32 1 #endif /* This is to support generic "any GDK" separate from a platform-specific GDK */ -#if defined(__WINGDK__) || defined(__XBOXONE__) || defined(__XBOXSERIES__) -#undef __GDK__ -#define __GDK__ 1 +#if defined(SDL_PLATFORM_WINGDK) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) +#define SDL_PLATFORM_GDK 1 #endif #ifdef __PSP__ -#undef __PSP__ -#define __PSP__ 1 +#define SDL_PLATFORM_PSP 1 #endif -#ifdef PS2 -#define __PS2__ 1 +#if defined(__PS2__) || defined(PS2) +#define SDL_PLATFORM_PS2 1 #endif -#ifdef __vita__ -#define __VITA__ 1 +#if defined(__vita__) || defined(__psp2__) +#define SDL_PLATFORM_VITA 1 #endif #ifdef __3DS__ #undef __3DS__ -#define __3DS__ 1 +#define SDL_PLATFORM_3DS 1 #endif #endif /* SDL_platform_defines_h_ */ diff --git a/include/SDL3/SDL_rwops.h b/include/SDL3/SDL_rwops.h index 557bdb811..169c91bb9 100644 --- a/include/SDL3/SDL_rwops.h +++ b/include/SDL3/SDL_rwops.h @@ -103,13 +103,13 @@ typedef struct SDL_RWops SDL_PropertiesID props; union { -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID struct { void *asset; } androidio; -#elif defined(__WIN32__) || defined(__GDK__) || defined(__WINRT__) +#elif defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) || defined(SDL_PLATFORM_WINRT) struct { SDL_bool append; diff --git a/include/SDL3/SDL_stdinc.h b/include/SDL3/SDL_stdinc.h index 78227f3da..e8da4026e 100644 --- a/include/SDL3/SDL_stdinc.h +++ b/include/SDL3/SDL_stdinc.h @@ -42,7 +42,7 @@ # ifndef alloca # ifdef HAVE_ALLOCA_H # include -# elif defined(__NETBSD__) +# elif defined(SDL_PLATFORM_NETBSD) # if defined(__STRICT_ANSI__) # define SDL_DISABLE_ALLOCA # else @@ -59,7 +59,7 @@ # include # elif defined(__DMC__) # include -# elif defined(__AIX__) +# elif defined(SDL_PLATFORM_AIX) # pragma alloca # elif defined(__MRC__) void *alloca(unsigned); @@ -207,9 +207,9 @@ typedef uint64_t Uint64; #ifndef SDL_PRIs64 #ifdef PRIs64 #define SDL_PRIs64 PRIs64 -#elif defined(__WIN32__) || defined(__GDK__) +#elif defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) #define SDL_PRIs64 "I64d" -#elif defined(__LP64__) && !defined(__APPLE__) +#elif defined(__LP64__) && !defined(SDL_PLATFORM_APPLE) #define SDL_PRIs64 "ld" #else #define SDL_PRIs64 "lld" @@ -218,9 +218,9 @@ typedef uint64_t Uint64; #ifndef SDL_PRIu64 #ifdef PRIu64 #define SDL_PRIu64 PRIu64 -#elif defined(__WIN32__) || defined(__GDK__) +#elif defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) #define SDL_PRIu64 "I64u" -#elif defined(__LP64__) && !defined(__APPLE__) +#elif defined(__LP64__) && !defined(SDL_PLATFORM_APPLE) #define SDL_PRIu64 "lu" #else #define SDL_PRIu64 "llu" @@ -229,9 +229,9 @@ typedef uint64_t Uint64; #ifndef SDL_PRIx64 #ifdef PRIx64 #define SDL_PRIx64 PRIx64 -#elif defined(__WIN32__) || defined(__GDK__) +#elif defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) #define SDL_PRIx64 "I64x" -#elif defined(__LP64__) && !defined(__APPLE__) +#elif defined(__LP64__) && !defined(SDL_PLATFORM_APPLE) #define SDL_PRIx64 "lx" #else #define SDL_PRIx64 "llx" @@ -240,9 +240,9 @@ typedef uint64_t Uint64; #ifndef SDL_PRIX64 #ifdef PRIX64 #define SDL_PRIX64 PRIX64 -#elif defined(__WIN32__) || defined(__GDK__) +#elif defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) #define SDL_PRIX64 "I64X" -#elif defined(__LP64__) && !defined(__APPLE__) +#elif defined(__LP64__) && !defined(SDL_PLATFORM_APPLE) #define SDL_PRIX64 "lX" #else #define SDL_PRIX64 "llX" @@ -370,7 +370,7 @@ SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8); /** \cond */ #ifndef DOXYGEN_SHOULD_IGNORE_THIS -#if !defined(__ANDROID__) && !defined(__VITA__) && !defined(__3DS__) +#if !defined(SDL_PLATFORM_ANDROID) && !defined(SDL_PLATFORM_VITA) && !defined(SDL_PLATFORM_3DS) /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */ typedef enum { diff --git a/include/SDL3/SDL_system.h b/include/SDL3/SDL_system.h index 2b20dbe7f..11deb0d8c 100644 --- a/include/SDL3/SDL_system.h +++ b/include/SDL3/SDL_system.h @@ -43,7 +43,7 @@ extern "C" { /* * Platform specific functions for Windows */ -#if defined(__WIN32__) || defined(__GDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) typedef struct tagMSG MSG; typedef SDL_bool (SDLCALL *SDL_WindowsMessageHook)(void *userdata, MSG *msg); @@ -62,9 +62,9 @@ typedef SDL_bool (SDLCALL *SDL_WindowsMessageHook)(void *userdata, MSG *msg); */ extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata); -#endif /* defined(__WIN32__) || defined(__GDK__) */ +#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) */ -#if defined(__WIN32__) || defined(__WINGDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) /** * Get the D3D9 adapter index that matches the specified display. @@ -80,9 +80,9 @@ extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook ca */ extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex(SDL_DisplayID displayID); -#endif /* defined(__WIN32__) || defined(__WINGDK__) */ +#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) */ -#if defined(__WIN32__) || defined(__WINGDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) /** * Get the DXGI Adapter and Output indices for the specified display. @@ -101,7 +101,7 @@ extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex(SDL_DisplayID displayID */ extern DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int *outputIndex); -#endif /* defined(__WIN32__) || defined(__WINGDK__) */ +#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) */ /* * Platform specific functions for UNIX @@ -127,7 +127,7 @@ extern DECLSPEC void SDLCALL SDL_SetX11EventHook(SDL_X11EventHook callback, void /* * Platform specific functions for Linux */ -#ifdef __LINUX__ +#ifdef SDL_PLATFORM_LINUX /** * Sets the UNIX nice value for a thread. @@ -158,12 +158,12 @@ extern DECLSPEC int SDLCALL SDL_LinuxSetThreadPriority(Sint64 threadID, int prio */ extern DECLSPEC int SDLCALL SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy); -#endif /* __LINUX__ */ +#endif /* SDL_PLATFORM_LINUX */ /* * Platform specific functions for iOS */ -#ifdef __IOS__ +#ifdef SDL_PLATFORM_IOS #define SDL_iOSSetAnimationCallback(window, interval, callback, callbackParam) SDL_iPhoneSetAnimationCallback(window, interval, callback, callbackParam) @@ -219,13 +219,13 @@ extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, */ extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled); -#endif /* __IOS__ */ +#endif /* SDL_PLATFORM_IOS */ /* * Platform specific functions for Android */ -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID /** * Get the Android Java Native Interface Environment of the current thread. @@ -451,12 +451,12 @@ extern DECLSPEC int SDLCALL SDL_AndroidShowToast(const char* message, int durati */ extern DECLSPEC int SDLCALL SDL_AndroidSendMessage(Uint32 command, int param); -#endif /* __ANDROID__ */ +#endif /* SDL_PLATFORM_ANDROID */ /* * Platform specific functions for WinRT */ -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT /** * WinRT / Windows Phone path types @@ -556,7 +556,7 @@ extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathT */ extern DECLSPEC SDL_WinRT_DeviceFamily SDLCALL SDL_WinRTGetDeviceFamily(); -#endif /* __WINRT__ */ +#endif /* SDL_PLATFORM_WINRT */ /** * Query if the current device is a tablet. @@ -610,7 +610,7 @@ extern DECLSPEC void SDLCALL SDL_OnApplicationWillEnterForeground(void); */ extern DECLSPEC void SDLCALL SDL_OnApplicationDidBecomeActive(void); -#ifdef __IOS__ +#ifdef SDL_PLATFORM_IOS /* * \since This function is available since SDL 3.0.0. */ @@ -620,7 +620,7 @@ extern DECLSPEC void SDLCALL SDL_OnApplicationDidChangeStatusBarOrientation(void /* * Functions used only by GDK */ -#ifdef __GDK__ +#ifdef SDL_PLATFORM_GDK typedef struct XTaskQueueObject *XTaskQueueHandle; typedef struct XUser *XUserHandle; diff --git a/include/SDL3/SDL_test_common.h b/include/SDL3/SDL_test_common.h index 0d428e1cf..74eb46ac3 100644 --- a/include/SDL3/SDL_test_common.h +++ b/include/SDL3/SDL_test_common.h @@ -34,10 +34,10 @@ #include -#ifdef __PSP__ +#ifdef SDL_PLATFORM_PSP #define DEFAULT_WINDOW_WIDTH 480 #define DEFAULT_WINDOW_HEIGHT 272 -#elif defined(__VITA__) +#elif defined(SDL_PLATFORM_VITA) #define DEFAULT_WINDOW_WIDTH 960 #define DEFAULT_WINDOW_HEIGHT 544 #else diff --git a/include/SDL3/SDL_thread.h b/include/SDL3/SDL_thread.h index bf3e33aaf..9dfb68668 100644 --- a/include/SDL3/SDL_thread.h +++ b/include/SDL3/SDL_thread.h @@ -35,7 +35,7 @@ #include #include -#if (defined(__WIN32__) || defined(__GDK__)) && !defined(__WINRT__) +#if (defined(SDL_PLATFORM_WIN32) || defined(__GDK__)) && !defined(SDL_PLATFORM_WINRT) #include /* _beginthreadex() and _endthreadex() */ #endif @@ -81,7 +81,7 @@ typedef enum { typedef int (SDLCALL * SDL_ThreadFunction) (void *data); -#if (defined(__WIN32__) || defined(__GDK__)) && !defined(__WINRT__) +#if (defined(SDL_PLATFORM_WIN32) || defined(__GDK__)) && !defined(__WINRT__) /** * \file SDL_thread.h * diff --git a/include/build_config/SDL_build_config.h b/include/build_config/SDL_build_config.h index 6fa6d899b..beaceb584 100644 --- a/include/build_config/SDL_build_config.h +++ b/include/build_config/SDL_build_config.h @@ -31,23 +31,23 @@ */ /* Add any platform that doesn't build using the configure system. */ -#if defined(__WIN32__) +#if defined(SDL_PLATFORM_WIN32) #include "SDL_build_config_windows.h" -#elif defined(__WINRT__) +#elif defined(SDL_PLATFORM_WINRT) #include "SDL_build_config_winrt.h" -#elif defined(__WINGDK__) +#elif defined(SDL_PLATFORM_WINGDK) #include "SDL_build_config_wingdk.h" -#elif defined(__XBOXONE__) || defined(__XBOXSERIES__) +#elif defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) #include "SDL_build_config_xbox.h" -#elif defined(__MACOS__) +#elif defined(SDL_PLATFORM_MACOS) #include "SDL_build_config_macos.h" -#elif defined(__IOS__) +#elif defined(SDL_PLATFORM_IOS) #include "SDL_build_config_ios.h" -#elif defined(__ANDROID__) +#elif defined(SDL_PLATFORM_ANDROID) #include "SDL_build_config_android.h" -#elif defined(__EMSCRIPTEN__) +#elif defined(SDL_PLATFORM_EMSCRIPTEN) #include "SDL_build_config_emscripten.h" -#elif defined(__NGAGE__) +#elif defined(SDL_PLATFORM_NGAGE) #include "SDL_build_config_ngage.h" #else /* This is a minimal configuration just to get SDL running on new platforms. */ diff --git a/include/build_config/SDL_build_config.h.cmake b/include/build_config/SDL_build_config.h.cmake index 819a41895..2b4df4815 100644 --- a/include/build_config/SDL_build_config.h.cmake +++ b/include/build_config/SDL_build_config.h.cmake @@ -76,7 +76,7 @@ #cmakedefine HAVE_CALLOC 1 #cmakedefine HAVE_REALLOC 1 #cmakedefine HAVE_FREE 1 -#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */ +#ifndef SDL_PLATFORM_WIN32 /* Don't use C runtime versions of these on Windows */ #cmakedefine HAVE_GETENV 1 #cmakedefine HAVE_SETENV 1 #cmakedefine HAVE_PUTENV 1 diff --git a/include/build_config/SDL_build_config_ios.h b/include/build_config/SDL_build_config_ios.h index a6691465e..fe5dea8af 100644 --- a/include/build_config/SDL_build_config_ios.h +++ b/include/build_config/SDL_build_config_ios.h @@ -148,7 +148,7 @@ #define SDL_JOYSTICK_MFI 1 #define SDL_JOYSTICK_VIRTUAL 1 -#ifdef __TVOS__ +#ifdef SDL_PLATFORM_TVOS #define SDL_SENSOR_DUMMY 1 #else /* Enable the CoreMotion sensor driver */ diff --git a/include/build_config/SDL_build_config_windows.h b/include/build_config/SDL_build_config_windows.h index 96f98fac1..d2846abc8 100644 --- a/include/build_config/SDL_build_config_windows.h +++ b/include/build_config/SDL_build_config_windows.h @@ -236,7 +236,7 @@ typedef unsigned int uintptr_t; /* Enable various input drivers */ #define SDL_JOYSTICK_DINPUT 1 #define SDL_JOYSTICK_HIDAPI 1 -#ifndef __WINRT__ +#ifndef SDL_PLATFORM_WINRT #define SDL_JOYSTICK_RAWINPUT 1 #endif #define SDL_JOYSTICK_VIRTUAL 1 diff --git a/src/SDL.c b/src/SDL.c index b3820ae6f..b6e78cf10 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -21,16 +21,16 @@ #include "SDL_internal.h" #include "SDL3/SDL_revision.h" -#if defined(__WIN32__) || defined(__GDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) #include "core/windows/SDL_windows.h" -#elif !defined(__WINRT__) +#elif !defined(SDL_PLATFORM_WINRT) #include /* _exit(), etc. */ #endif /* this checks for HAVE_DBUS_DBUS_H internally. */ #include "core/linux/SDL_dbus.h" -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN #include #endif @@ -83,7 +83,7 @@ SDL_COMPILE_TIME_ASSERT(SDL_PATCHLEVEL_max, SDL_PATCHLEVEL <= 99); extern SDL_NORETURN void SDL_ExitProcess(int exitcode); SDL_NORETURN void SDL_ExitProcess(int exitcode) { -#if defined(__WIN32__) || defined(__GDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) /* "if you do not know the state of all threads in your process, it is better to call TerminateProcess than ExitProcess" https://msdn.microsoft.com/en-us/library/windows/desktop/ms682658(v=vs.85).aspx */ @@ -91,11 +91,11 @@ SDL_NORETURN void SDL_ExitProcess(int exitcode) /* MingW doesn't have TerminateProcess marked as noreturn, so add an ExitProcess here that will never be reached but make MingW happy. */ ExitProcess(exitcode); -#elif defined(__EMSCRIPTEN__) +#elif defined(SDL_PLATFORM_EMSCRIPTEN) emscripten_cancel_main_loop(); /* this should "kill" the app. */ emscripten_force_exit(exitcode); /* this should "kill" the app. */ exit(exitcode); -#elif defined(__HAIKU__) /* Haiku has _Exit, but it's not marked noreturn. */ +#elif defined(SDL_PLATFORM_HAIKU) /* Haiku has _Exit, but it's not marked noreturn. */ _exit(exitcode); #elif defined(HAVE__EXIT) /* Upper case _Exit() */ _Exit(exitcode); @@ -567,69 +567,65 @@ const char *SDL_GetRevision(void) /* Get the name of the platform */ const char *SDL_GetPlatform(void) { -#ifdef __AIX__ +#if defined(SDL_PLATFORM_AIX) return "AIX"; -#elif defined(__ANDROID__) +#elif defined(SDL_PLATFORM_ANDROID) return "Android"; -#elif defined(__BSDI__) +#elif defined(SDL_PLATFORM_BSDI) return "BSDI"; -#elif defined(__DREAMCAST__) - return "Dreamcast"; -#elif defined(__EMSCRIPTEN__) +#elif defined(SDL_PLATFORM_EMSCRIPTEN) return "Emscripten"; -#elif defined(__FREEBSD__) +#elif defined(SDL_PLATFORM_FREEBSD) return "FreeBSD"; -#elif defined(__HAIKU__) +#elif defined(SDL_PLATFORM_HAIKU) return "Haiku"; -#elif defined(__HPUX__) +#elif defined(SDL_PLATFORM_HPUX) return "HP-UX"; -#elif defined(__IRIX__) +#elif defined(SDL_PLATFORM_IRIX) return "Irix"; -#elif defined(__LINUX__) +#elif defined(SDL_PLATFORM_LINUX) return "Linux"; #elif defined(__MINT__) return "Atari MiNT"; -#elif defined(__MACOS__) +#elif defined(SDL_PLATFORM_MACOS) return "macOS"; -#elif defined(__NACL__) - return "NaCl"; -#elif defined(__NETBSD__) +#elif defined(SDL_PLATFORM_NETBSD) return "NetBSD"; -#elif defined(__OPENBSD__) +#elif defined(SDL_PLATFORM_OPENBSD) return "OpenBSD"; -#elif defined(__OS2__) +#elif defined(SDL_PLATFORM_OS2) return "OS/2"; -#elif defined(__OSF__) +#elif defined(SDL_PLATFORM_OSF) return "OSF/1"; -#elif defined(__QNXNTO__) +#elif defined(SDL_PLATFORM_QNXNTO) return "QNX Neutrino"; -#elif defined(__RISCOS__) +#elif defined(SDL_PLATFORM_RISCOS) return "RISC OS"; -#elif defined(__SOLARIS__) +#elif defined(SDL_PLATFORM_SOLARIS) return "Solaris"; -#elif defined(__WIN32__) +#elif defined(SDL_PLATFORM_WIN32) return "Windows"; -#elif defined(__WINRT__) +#elif defined(SDL_PLATFORM_WINRT) return "WinRT"; -#elif defined(__WINGDK__) +#elif defined(SDL_PLATFORM_WINGDK) return "WinGDK"; -#elif defined(__XBOXONE__) +#elif defined(SDL_PLATFORM_XBOXONE) return "Xbox One"; -#elif defined(__XBOXSERIES__) +#elif defined(SDL_PLATFORM_XBOXSERIES) return "Xbox Series X|S"; -#elif defined(__IOS__) +#elif defined(SDL_PLATFORM_IOS) return "iOS"; -#elif defined(__TVOS__) +#elif defined(SDL_PLATFORM_TVOS) return "tvOS"; -#elif defined(__PS2__) +#elif defined(SDL_PLATFORM_PS2) return "PlayStation 2"; -#elif defined(__PSP__) +#elif defined(SDL_PLATFORM_PSP) return "PlayStation Portable"; -#elif defined(__VITA__) +#elif defined(SDL_PLATFORM_VITA) return "PlayStation Vita"; -#elif defined(__NGAGE__) +#elif defined(SDL_PLATFORM_NGAGE) return "Nokia N-Gage"; -#elif defined(__3DS__) +#elif defined(SDL_PLATFORM_3DS) return "Nintendo 3DS"; #elif defined(__managarm__) return "Managarm"; @@ -640,10 +636,10 @@ const char *SDL_GetPlatform(void) SDL_bool SDL_IsTablet(void) { -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID extern SDL_bool SDL_IsAndroidTablet(void); return SDL_IsAndroidTablet(); -#elif defined(__IOS__) +#elif defined(SDL_PLATFORM_IOS) extern SDL_bool SDL_IsIPad(void); return SDL_IsIPad(); #else @@ -651,7 +647,7 @@ SDL_bool SDL_IsTablet(void) #endif } -#ifdef __WIN32__ +#ifdef SDL_PLATFORM_WIN32 #if (!defined(HAVE_LIBC) || defined(__WATCOMC__)) && !defined(SDL_STATIC_LIB) /* FIXME: Still need to include DllMain() on Watcom C ? */ @@ -669,4 +665,4 @@ BOOL APIENTRY MINGW32_FORCEALIGN _DllMainCRTStartup(HANDLE hModule, DWORD ul_rea } #endif /* Building DLL */ -#endif /* defined(__WIN32__) || defined(__GDK__) */ +#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) */ diff --git a/src/SDL_assert.c b/src/SDL_assert.c index cfc5f9a05..3f0d50905 100644 --- a/src/SDL_assert.c +++ b/src/SDL_assert.c @@ -20,20 +20,20 @@ */ #include "SDL_internal.h" -#if defined(__WIN32__) || defined(__GDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) #include "core/windows/SDL_windows.h" #endif #include "SDL_assert_c.h" #include "video/SDL_sysvideo.h" -#if defined(__WIN32__) || defined(__GDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) #ifndef WS_OVERLAPPEDWINDOW #define WS_OVERLAPPEDWINDOW 0 #endif #endif -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN #include /* older Emscriptens don't have this, but we need to for wasm64 compatibility. */ #ifndef MAIN_THREAD_EM_ASM_PTR @@ -86,7 +86,7 @@ static void SDL_AddAssertionToReport(SDL_AssertData *data) } } -#if defined(__WIN32__) || defined(__GDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) #define ENDLINE "\r\n" #else #define ENDLINE "\n" @@ -246,7 +246,7 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v state = (SDL_AssertState)selected; } } else { -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN /* This is nasty, but we can't block on a custom UI. */ for (;;) { SDL_bool okay = SDL_TRUE; diff --git a/src/SDL_internal.h b/src/SDL_internal.h index bfca0782c..a7740f13d 100644 --- a/src/SDL_internal.h +++ b/src/SDL_internal.h @@ -74,7 +74,7 @@ #define DECLSPEC #endif -#ifdef __APPLE__ +#ifdef SDL_PLATFORM_APPLE #ifndef _DARWIN_C_SOURCE #define _DARWIN_C_SOURCE 1 /* for memset_pattern4() */ #endif diff --git a/src/SDL_log.c b/src/SDL_log.c index 198be0220..694aa0cb8 100644 --- a/src/SDL_log.c +++ b/src/SDL_log.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#if defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK) #include "core/windows/SDL_windows.h" #endif @@ -32,7 +32,7 @@ #include #endif -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID #include #endif @@ -84,7 +84,7 @@ static const char *SDL_priority_prefixes[SDL_NUM_LOG_PRIORITIES] = { #pragma GCC diagnostic pop #endif -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID static const char *SDL_category_prefixes[] = { "APP", "ERROR", @@ -108,7 +108,7 @@ static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = { ANDROID_LOG_ERROR, ANDROID_LOG_FATAL }; -#endif /* __ANDROID__ */ +#endif /* SDL_PLATFORM_ANDROID */ void SDL_InitLog(void) { @@ -269,7 +269,7 @@ void SDL_LogMessage(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_ST va_end(ap); } -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID static const char *GetCategoryPrefix(int category) { if (category < SDL_LOG_CATEGORY_RESERVED1) { @@ -280,7 +280,7 @@ static const char *GetCategoryPrefix(int category) } return "CUSTOM"; } -#endif /* __ANDROID__ */ +#endif /* SDL_PLATFORM_ANDROID */ void SDL_LogMessageV(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) { @@ -351,7 +351,7 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_S } } -#if defined(__WIN32__) && !defined(HAVE_STDIO_H) && !defined(__WINRT__) && !defined(__GDK__) +#if defined(SDL_PLATFORM_WIN32) && !defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK) /* Flag tracking the attachment of the console: 0=unattached, 1=attached to a console, 2=attached to a file, -1=error */ static int consoleAttached = 0; @@ -362,7 +362,7 @@ static HANDLE stderrHandle = NULL; static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, const char *message) { -#if defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK) /* Way too many allocations here, urgh */ /* Note: One can't call SDL_SetError here, since that function itself logs. */ { @@ -371,7 +371,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority LPTSTR tstr; SDL_bool isstack; -#if !defined(HAVE_STDIO_H) && !defined(__WINRT__) && !defined(__GDK__) +#if !defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK) BOOL attachResult; DWORD attachError; DWORD charsWritten; @@ -410,7 +410,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority } } } -#endif /* !defined(HAVE_STDIO_H) && !defined(__WINRT__) && !defined(__GDK__) */ +#endif /* !defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK) */ length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1 + 1 + 1; output = SDL_small_alloc(char, length, &isstack); @@ -420,7 +420,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority /* Output to debugger */ OutputDebugString(tstr); -#if !defined(HAVE_STDIO_H) && !defined(__WINRT__) && !defined(__GDK__) +#if !defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK) /* Screen output to stderr, if console was attached. */ if (consoleAttached == 1) { if (!WriteConsole(stderrHandle, tstr, (DWORD)SDL_tcslen(tstr), &charsWritten, NULL)) { @@ -435,19 +435,19 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority OutputDebugString(TEXT("Error calling WriteFile\r\n")); } } -#endif /* !defined(HAVE_STDIO_H) && !defined(__WINRT__) && !defined(__GDK__) */ +#endif /* !defined(HAVE_STDIO_H) && !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_GDK) */ SDL_free(tstr); SDL_small_free(output, isstack); } -#elif defined(__ANDROID__) +#elif defined(SDL_PLATFORM_ANDROID) { char tag[32]; SDL_snprintf(tag, SDL_arraysize(tag), "SDL/%s", GetCategoryPrefix(category)); __android_log_write(SDL_android_priority[priority], tag, message); } -#elif defined(__APPLE__) && (defined(SDL_VIDEO_DRIVER_COCOA) || defined(SDL_VIDEO_DRIVER_UIKIT)) +#elif defined(SDL_PLATFORM_APPLE) && (defined(SDL_VIDEO_DRIVER_COCOA) || defined(SDL_VIDEO_DRIVER_UIKIT)) /* Technically we don't need Cocoa/UIKit, but that's where this function is defined for now. */ extern void SDL_NSLog(const char *prefix, const char *text); @@ -455,7 +455,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority SDL_NSLog(SDL_priority_prefixes[priority], message); return; } -#elif defined(__PSP__) || defined(__PS2__) +#elif defined(SDL_PLATFORM_PSP) || defined(SDL_PLATFORM_PS2) { FILE *pFile; pFile = fopen("SDL_Log.txt", "a"); @@ -464,7 +464,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority (void)fclose(pFile); } } -#elif defined(__VITA__) +#elif defined(SDL_PLATFORM_VITA) { FILE *pFile; pFile = fopen("ux0:/data/SDL_Log.txt", "a"); @@ -473,7 +473,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority (void)fclose(pFile); } } -#elif defined(__3DS__) +#elif defined(SDL_PLATFORM_3DS) { FILE *pFile; pFile = fopen("sdmc:/3ds/SDL_Log.txt", "a"); @@ -484,7 +484,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority } #endif #if defined(HAVE_STDIO_H) && \ - !(defined(__APPLE__) && (defined(SDL_VIDEO_DRIVER_COCOA) || defined(SDL_VIDEO_DRIVER_UIKIT))) + !(defined(SDL_PLATFORM_APPLE) && (defined(SDL_VIDEO_DRIVER_COCOA) || defined(SDL_VIDEO_DRIVER_UIKIT))) (void)fprintf(stderr, "%s: %s\n", SDL_priority_prefixes[priority], message); #endif } diff --git a/src/atomic/SDL_atomic.c b/src/atomic/SDL_atomic.c index f2e457917..e350c15b1 100644 --- a/src/atomic/SDL_atomic.c +++ b/src/atomic/SDL_atomic.c @@ -25,11 +25,11 @@ #define HAVE_MSC_ATOMICS 1 #endif -#ifdef __MACOS__ /* !!! FIXME: should we favor gcc atomics? */ +#ifdef SDL_PLATFORM_MACOS /* !!! FIXME: should we favor gcc atomics? */ #include #endif -#if !defined(HAVE_GCC_ATOMICS) && defined(__SOLARIS__) +#if !defined(HAVE_GCC_ATOMICS) && defined(SDL_PLATFORM_SOLARIS) #include #endif @@ -38,7 +38,7 @@ #if __has_builtin(__atomic_load_n) || defined(HAVE_GCC_ATOMICS) /* !!! FIXME: this advertises as available in the NDK but uses an external symbol we don't have. It might be in a later NDK or we might need an extra library? --ryan. */ -#ifndef __ANDROID__ +#ifndef SDL_PLATFORM_ANDROID #define HAVE_ATOMIC_LOAD_N 1 #endif #endif @@ -100,7 +100,7 @@ extern __inline int _SDL_xadd_watcom(volatile int *a, int v); Contributed by Bob Pendleton, bob@pendleton.com */ -#if !defined(HAVE_MSC_ATOMICS) && !defined(HAVE_GCC_ATOMICS) && !defined(__MACOS__) && !defined(__SOLARIS__) && !defined(HAVE_WATCOM_ATOMICS) +#if !defined(HAVE_MSC_ATOMICS) && !defined(HAVE_GCC_ATOMICS) && !defined(SDL_PLATFORM_MACOS) && !defined(SDL_PLATFORM_SOLARIS) && !defined(HAVE_WATCOM_ATOMICS) #define EMULATE_CAS 1 #endif @@ -131,9 +131,9 @@ SDL_bool SDL_AtomicCompareAndSwap(SDL_AtomicInt *a, int oldval, int newval) return _SDL_cmpxchg_watcom(&a->value, newval, oldval); #elif defined(HAVE_GCC_ATOMICS) return __sync_bool_compare_and_swap(&a->value, oldval, newval); -#elif defined(__MACOS__) /* this is deprecated in 10.12 sdk; favor gcc atomics. */ +#elif defined(SDL_PLATFORM_MACOS) /* this is deprecated in 10.12 sdk; favor gcc atomics. */ return OSAtomicCompareAndSwap32Barrier(oldval, newval, &a->value); -#elif defined(__SOLARIS__) +#elif defined(SDL_PLATFORM_SOLARIS) return ((int)atomic_cas_uint((volatile uint_t *)&a->value, (uint_t)oldval, (uint_t)newval) == oldval); #elif defined(EMULATE_CAS) SDL_bool retval = SDL_FALSE; @@ -159,11 +159,11 @@ SDL_bool SDL_AtomicCompareAndSwapPointer(void **a, void *oldval, void *newval) return _SDL_cmpxchg_watcom((int *)a, (long)newval, (long)oldval); #elif defined(HAVE_GCC_ATOMICS) return __sync_bool_compare_and_swap(a, oldval, newval); -#elif defined(__MACOS__) && defined(__LP64__) /* this is deprecated in 10.12 sdk; favor gcc atomics. */ +#elif defined(SDL_PLATFORM_MACOS) && defined(__LP64__) /* this is deprecated in 10.12 sdk; favor gcc atomics. */ return OSAtomicCompareAndSwap64Barrier((int64_t)oldval, (int64_t)newval, (int64_t *)a); -#elif defined(__MACOS__) && !defined(__LP64__) /* this is deprecated in 10.12 sdk; favor gcc atomics. */ +#elif defined(SDL_PLATFORM_MACOS) && !defined(__LP64__) /* this is deprecated in 10.12 sdk; favor gcc atomics. */ return OSAtomicCompareAndSwap32Barrier((int32_t)oldval, (int32_t)newval, (int32_t *)a); -#elif defined(__SOLARIS__) +#elif defined(SDL_PLATFORM_SOLARIS) return (atomic_cas_ptr(a, oldval, newval) == oldval); #elif defined(EMULATE_CAS) SDL_bool retval = SDL_FALSE; @@ -190,7 +190,7 @@ int SDL_AtomicSet(SDL_AtomicInt *a, int v) return _SDL_xchg_watcom(&a->value, v); #elif defined(HAVE_GCC_ATOMICS) return __sync_lock_test_and_set(&a->value, v); -#elif defined(__SOLARIS__) +#elif defined(SDL_PLATFORM_SOLARIS) return (int)atomic_swap_uint((volatile uint_t *)&a->value, v); #else int value; @@ -209,7 +209,7 @@ void *SDL_AtomicSetPtr(void **a, void *v) return (void *)_SDL_xchg_watcom((int *)a, (long)v); #elif defined(HAVE_GCC_ATOMICS) return __sync_lock_test_and_set(a, v); -#elif defined(__SOLARIS__) +#elif defined(SDL_PLATFORM_SOLARIS) return atomic_swap_ptr(a, v); #else void *value; @@ -229,7 +229,7 @@ int SDL_AtomicAdd(SDL_AtomicInt *a, int v) return _SDL_xadd_watcom(&a->value, v); #elif defined(HAVE_GCC_ATOMICS) return __sync_fetch_and_add(&a->value, v); -#elif defined(__SOLARIS__) +#elif defined(SDL_PLATFORM_SOLARIS) int pv = a->value; membar_consumer(); atomic_add_int((volatile uint_t *)&a->value, v); @@ -254,9 +254,9 @@ int SDL_AtomicGet(SDL_AtomicInt *a) return _SDL_xadd_watcom(&a->value, 0); #elif defined(HAVE_GCC_ATOMICS) return __sync_or_and_fetch(&a->value, 0); -#elif defined(__MACOS__) /* this is deprecated in 10.12 sdk; favor gcc atomics. */ +#elif defined(SDL_PLATFORM_MACOS) /* this is deprecated in 10.12 sdk; favor gcc atomics. */ return sizeof(a->value) == sizeof(uint32_t) ? OSAtomicOr32Barrier(0, (volatile uint32_t *)&a->value) : OSAtomicAdd64Barrier(0, (volatile int64_t *)&a->value); -#elif defined(__SOLARIS__) +#elif defined(SDL_PLATFORM_SOLARIS) return atomic_or_uint((volatile uint_t *)&a->value, 0); #else int value; @@ -275,7 +275,7 @@ void *SDL_AtomicGetPtr(void **a) return _InterlockedCompareExchangePointer(a, NULL, NULL); #elif defined(HAVE_GCC_ATOMICS) return __sync_val_compare_and_swap(a, (void *)0, (void *)0); -#elif defined(__SOLARIS__) +#elif defined(SDL_PLATFORM_SOLARIS) return atomic_cas_ptr(a, (void *)0, (void *)0); #else void *value; diff --git a/src/atomic/SDL_spinlock.c b/src/atomic/SDL_spinlock.c index 1abed587c..0896b41cc 100644 --- a/src/atomic/SDL_spinlock.c +++ b/src/atomic/SDL_spinlock.c @@ -20,15 +20,15 @@ */ #include "SDL_internal.h" -#if defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK) #include "../core/windows/SDL_windows.h" #endif -#if !defined(HAVE_GCC_ATOMICS) && defined(__SOLARIS__) +#if !defined(HAVE_GCC_ATOMICS) && defined(SDL_PLATFORM_SOLARIS) #include #endif -#if !defined(HAVE_GCC_ATOMICS) && defined(__RISCOS__) +#if !defined(HAVE_GCC_ATOMICS) && defined(SDL_PLATFORM_RISCOS) #include #endif @@ -40,7 +40,7 @@ #include #endif -#if !defined(HAVE_GCC_ATOMICS) && defined(__MACOS__) +#if !defined(HAVE_GCC_ATOMICS) && defined(SDL_PLATFORM_MACOS) #include #endif @@ -79,7 +79,7 @@ SDL_bool SDL_TryLockSpinlock(SDL_SpinLock *lock) defined(__ARM_ARCH_5TEJ__)) int result; -#ifdef __RISCOS__ +#ifdef SDL_PLATFORM_RISCOS if (__cpucap_have_rex()) { __asm__ __volatile__( "ldrex %0, [%2]\nteq %0, #0\nstrexeq %0, %1, [%2]" @@ -115,15 +115,15 @@ SDL_bool SDL_TryLockSpinlock(SDL_SpinLock *lock) : "cc", "memory"); return result == 0; -#elif defined(__MACOS__) || defined(__IOS__) || defined(__TVOS__) +#elif defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS) /* Maybe used for PowerPC, but the Intel asm or gcc atomics are favored. */ return OSAtomicCompareAndSwap32Barrier(0, 1, lock); -#elif defined(__SOLARIS__) && defined(_LP64) +#elif defined(SDL_PLATFORM_SOLARIS) && defined(_LP64) /* Used for Solaris with non-gcc compilers. */ return ((int)atomic_cas_64((volatile uint64_t *)lock, 0, 1) == 0); -#elif defined(__SOLARIS__) && !defined(_LP64) +#elif defined(SDL_PLATFORM_SOLARIS) && !defined(_LP64) /* Used for Solaris with non-gcc compilers. */ return ((int)atomic_cas_32((volatile uint32_t *)lock, 0, 1) == 0); #elif defined(PS2) @@ -192,7 +192,7 @@ void SDL_UnlockSpinlock(SDL_SpinLock *lock) SDL_CompilerBarrier(); *lock = 0; -#elif defined(__SOLARIS__) +#elif defined(SDL_PLATFORM_SOLARIS) /* Used for Solaris when not using gcc. */ *lock = 0; membar_producer(); diff --git a/src/audio/SDL_audiodev.c b/src/audio/SDL_audiodev.c index ad8a2ad09..7b21a1ce5 100644 --- a/src/audio/SDL_audiodev.c +++ b/src/audio/SDL_audiodev.c @@ -32,7 +32,7 @@ #include "SDL_audiodev_c.h" #ifndef SDL_PATH_DEV_DSP -#if defined(__NETBSD__) || defined(__OPENBSD__) +#if defined(SDL_PLATFORM_NETBSD) || defined(SDL_PLATFORM_OPENBSD) #define SDL_PATH_DEV_DSP "/dev/audio" #else #define SDL_PATH_DEV_DSP "/dev/dsp" diff --git a/src/audio/SDL_audiotypecvt.c b/src/audio/SDL_audiotypecvt.c index 73dd79659..cabf8ab72 100644 --- a/src/audio/SDL_audiotypecvt.c +++ b/src/audio/SDL_audiotypecvt.c @@ -25,17 +25,17 @@ // TODO: NEON is disabled until https://github.com/libsdl-org/SDL/issues/8352 can be fixed #undef SDL_NEON_INTRINSICS -#ifndef __EMSCRIPTEN__ +#ifndef SDL_PLATFORM_EMSCRIPTEN #if defined(__x86_64__) && defined(SDL_SSE2_INTRINSICS) #define NEED_SCALAR_CONVERTER_FALLBACKS 0 // x86_64 guarantees SSE2. -#elif defined(__MACOS__) && defined(SDL_SSE2_INTRINSICS) +#elif defined(SDL_PLATFORM_MACOS) && defined(SDL_SSE2_INTRINSICS) #define NEED_SCALAR_CONVERTER_FALLBACKS 0 // macOS/Intel guarantees SSE2. #elif defined(__ARM_ARCH) && (__ARM_ARCH >= 8) && defined(SDL_NEON_INTRINSICS) #define NEED_SCALAR_CONVERTER_FALLBACKS 0 // ARMv8+ promise NEON. -#elif defined(__APPLE__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 7) && defined(SDL_NEON_INTRINSICS) +#elif defined(SDL_PLATFORM_APPLE) && defined(__ARM_ARCH) && (__ARM_ARCH >= 7) && defined(SDL_NEON_INTRINSICS) #define NEED_SCALAR_CONVERTER_FALLBACKS 0 // All Apple ARMv7 chips promise NEON support. #endif -#endif /* __EMSCRIPTEN__ */ +#endif /* SDL_PLATFORM_EMSCRIPTEN */ // Set to zero if platform is guaranteed to use a SIMD codepath here. #if !defined(NEED_SCALAR_CONVERTER_FALLBACKS) diff --git a/src/audio/coreaudio/SDL_coreaudio.h b/src/audio/coreaudio/SDL_coreaudio.h index ffa221fef..cd64e3038 100644 --- a/src/audio/coreaudio/SDL_coreaudio.h +++ b/src/audio/coreaudio/SDL_coreaudio.h @@ -25,7 +25,7 @@ #include "../SDL_sysaudio.h" -#ifndef __IOS__ +#ifndef SDL_PLATFORM_IOS #define MACOSX_COREAUDIO #endif diff --git a/src/audio/coreaudio/SDL_coreaudio.m b/src/audio/coreaudio/SDL_coreaudio.m index 79fc65aa4..73762acf4 100644 --- a/src/audio/coreaudio/SDL_coreaudio.m +++ b/src/audio/coreaudio/SDL_coreaudio.m @@ -753,7 +753,7 @@ static int PrepareAudioQueue(SDL_AudioDevice *device) // Make sure we can feed the device a minimum amount of time double MINIMUM_AUDIO_BUFFER_TIME_MS = 15.0; - #ifdef __IOS__ + #ifdef SDL_PLATFORM_IOS if (SDL_floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1) { // Older iOS hardware, use 40 ms as a minimum time MINIMUM_AUDIO_BUFFER_TIME_MS = 40.0; diff --git a/src/audio/wasapi/SDL_wasapi.c b/src/audio/wasapi/SDL_wasapi.c index 23acd00d7..dda63d0f5 100644 --- a/src/audio/wasapi/SDL_wasapi.c +++ b/src/audio/wasapi/SDL_wasapi.c @@ -564,7 +564,7 @@ static int mgmtthrtask_PrepDevice(void *userdata) IAudioClient *client = device->hidden->client; SDL_assert(client != NULL); -#if defined(__WINRT__) || defined(__GDK__) // CreateEventEx() arrived in Vista, so we need an #ifdef for XP. +#if defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK) // CreateEventEx() arrived in Vista, so we need an #ifdef for XP. device->hidden->event = CreateEventEx(NULL, NULL, 0, EVENT_ALL_ACCESS); #else device->hidden->event = CreateEventW(NULL, 0, 0, NULL); diff --git a/src/audio/wasapi/SDL_wasapi_win32.c b/src/audio/wasapi/SDL_wasapi_win32.c index fd84394fb..c72c54b4d 100644 --- a/src/audio/wasapi/SDL_wasapi_win32.c +++ b/src/audio/wasapi/SDL_wasapi_win32.c @@ -26,7 +26,7 @@ The code in SDL_wasapi.c is used by both standard Windows and WinRT builds to deal with audio and calls into these functions. */ -#if defined(SDL_AUDIO_DRIVER_WASAPI) && !defined(__WINRT__) +#if defined(SDL_AUDIO_DRIVER_WASAPI) && !defined(SDL_PLATFORM_WINRT) #include "../../core/windows/SDL_windows.h" #include "../../core/windows/SDL_immdevice.h" @@ -202,4 +202,4 @@ void WASAPI_PlatformFreeDeviceHandle(SDL_AudioDevice *device) SDL_IMMDevice_FreeDeviceHandle(device); } -#endif // SDL_AUDIO_DRIVER_WASAPI && !defined(__WINRT__) +#endif // SDL_AUDIO_DRIVER_WASAPI && !defined(SDL_PLATFORM_WINRT) diff --git a/src/audio/wasapi/SDL_wasapi_winrt.cpp b/src/audio/wasapi/SDL_wasapi_winrt.cpp index 0af821d7b..700f5cf51 100644 --- a/src/audio/wasapi/SDL_wasapi_winrt.cpp +++ b/src/audio/wasapi/SDL_wasapi_winrt.cpp @@ -25,7 +25,7 @@ // is in SDL_wasapi_win32.c. The code in SDL_wasapi.c is used by both standard // Windows and WinRT builds to deal with audio and calls into these functions. -#if defined(SDL_AUDIO_DRIVER_WASAPI) && defined(__WINRT__) +#if defined(SDL_AUDIO_DRIVER_WASAPI) && defined(SDL_PLATFORM_WINRT) #include #include @@ -357,4 +357,4 @@ void WASAPI_PlatformFreeDeviceHandle(SDL_AudioDevice *device) SDL_free(device->handle); } -#endif // SDL_AUDIO_DRIVER_WASAPI && defined(__WINRT__) +#endif // SDL_AUDIO_DRIVER_WASAPI && defined(SDL_PLATFORM_WINRT) diff --git a/src/core/SDL_core_unsupported.c b/src/core/SDL_core_unsupported.c index b9e339742..2bef98abc 100644 --- a/src/core/SDL_core_unsupported.c +++ b/src/core/SDL_core_unsupported.c @@ -28,7 +28,7 @@ DECLSPEC void SDLCALL SDL_SetX11EventHook(SDL_X11EventHook callback, void *userd #endif -#ifndef __LINUX__ +#ifndef SDL_PLATFORM_LINUX DECLSPEC int SDLCALL SDL_LinuxSetThreadPriority(Sint64 threadID, int priority); int SDL_LinuxSetThreadPriority(Sint64 threadID, int priority) @@ -49,7 +49,7 @@ int SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int sc #endif -#ifndef __GDK__ +#ifndef SDL_PLATFORM_GDK DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void); void SDL_GDKSuspendComplete(void) @@ -65,7 +65,7 @@ int SDL_GDKGetDefaultUser(void *outUserHandle) #endif -#if !(defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__)) +#if !(defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK)) DECLSPEC int SDLCALL SDL_RegisterApp(const char *name, Uint32 style, void *hInst); int SDL_RegisterApp(const char *name, Uint32 style, void *hInst) @@ -92,7 +92,7 @@ void SDL_UnregisterApp(void) #endif -#ifndef __WINRT__ +#ifndef SDL_PLATFORM_WINRT /* Returns SDL_WinRT_DeviceFamily enum */ DECLSPEC int SDLCALL SDL_WinRTGetDeviceFamily(void); @@ -119,7 +119,7 @@ const char *SDL_WinRTGetFSPathUTF8(int pathType) } #endif -#ifndef __ANDROID__ +#ifndef SDL_PLATFORM_ANDROID DECLSPEC void SDLCALL SDL_AndroidBackButton(void); void SDL_AndroidBackButton() @@ -225,7 +225,7 @@ Sint32 JNI_OnLoad(void *vm, void *reserved) } #endif -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) char *SDL_GetUserFolder(SDL_Folder folder) { (void)folder; diff --git a/src/core/SDL_runapp.c b/src/core/SDL_runapp.c index 52c7ede11..753dafbc1 100644 --- a/src/core/SDL_runapp.c +++ b/src/core/SDL_runapp.c @@ -22,7 +22,7 @@ /* Most platforms that use/need SDL_main have their own SDL_RunApp() implementation. * If not, you can special case it here by appending || defined(__YOUR_PLATFORM__) */ -#if ( !defined(SDL_MAIN_NEEDED) && !defined(SDL_MAIN_AVAILABLE) ) || defined(__ANDROID__) +#if ( !defined(SDL_MAIN_NEEDED) && !defined(SDL_MAIN_AVAILABLE) ) || defined(SDL_PLATFORM_ANDROID) DECLSPEC int SDL_RunApp(int argc, char* argv[], SDL_main_func mainFunction, void * reserved) diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index b4ee8b7a0..1abb8b720 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID #include "SDL_android.h" @@ -2741,4 +2741,4 @@ int Android_JNI_OpenURL(const char *url) return ret; } -#endif /* __ANDROID__ */ +#endif /* SDL_PLATFORM_ANDROID */ diff --git a/src/core/gdk/SDL_gdk.cpp b/src/core/gdk/SDL_gdk.cpp index 2c4469b40..af018d36b 100644 --- a/src/core/gdk/SDL_gdk.cpp +++ b/src/core/gdk/SDL_gdk.cpp @@ -190,7 +190,7 @@ SDL_RunApp(int, char**, SDL_main_func mainFunction, void *reserved) XGameRuntimeUninitialize(); } else { -#ifdef __WINGDK__ +#ifdef SDL_PLATFORM_WINGDK SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fatal Error", "[GDK] Could not initialize - aborting", NULL); #else SDL_assert_always(0 && "[GDK] Could not initialize - aborting"); diff --git a/src/core/haiku/SDL_BeApp.cc b/src/core/haiku/SDL_BeApp.cc index ccb9a4db3..68a79f4e3 100644 --- a/src/core/haiku/SDL_BeApp.cc +++ b/src/core/haiku/SDL_BeApp.cc @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#ifdef __HAIKU__ +#ifdef SDL_PLATFORM_HAIKU /* Handle the BeApp specific portions of the application */ @@ -192,4 +192,4 @@ void SDL_BLooper::ClearID(SDL_BWin *bwin) { } } -#endif /* __HAIKU__ */ +#endif /* SDL_PLATFORM_HAIKU */ diff --git a/src/core/linux/SDL_fcitx.c b/src/core/linux/SDL_fcitx.c index a3de3c688..5c51ac15e 100644 --- a/src/core/linux/SDL_fcitx.c +++ b/src/core/linux/SDL_fcitx.c @@ -54,15 +54,15 @@ static FcitxClient fcitx_client; static char *GetAppName(void) { -#if defined(__LINUX__) || defined(__FREEBSD__) +#if defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_FREEBSD) char *spot; char procfile[1024]; char linkfile[1024]; int linksize; -#ifdef __LINUX__ +#ifdef SDL_PLATFORM_LINUX (void)SDL_snprintf(procfile, sizeof(procfile), "/proc/%d/exe", getpid()); -#elif defined(__FREEBSD__) +#elif defined(SDL_PLATFORM_FREEBSD) (void)SDL_snprintf(procfile, sizeof(procfile), "/proc/%d/file", getpid()); #endif linksize = readlink(procfile, linkfile, sizeof(linkfile) - 1); @@ -75,7 +75,7 @@ static char *GetAppName(void) return SDL_strdup(linkfile); } } -#endif /* __LINUX__ || __FREEBSD__ */ +#endif /* SDL_PLATFORM_LINUX || SDL_PLATFORM_FREEBSD */ return SDL_strdup("SDL_App"); } diff --git a/src/core/linux/SDL_threadprio.c b/src/core/linux/SDL_threadprio.c index cc8d6e477..106894947 100644 --- a/src/core/linux/SDL_threadprio.c +++ b/src/core/linux/SDL_threadprio.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#ifdef __LINUX__ +#ifdef SDL_PLATFORM_LINUX #ifndef SDL_THREADS_DISABLED #include @@ -342,4 +342,4 @@ int SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int sc #endif } -#endif /* __LINUX__ */ +#endif /* SDL_PLATFORM_LINUX */ diff --git a/src/core/n3ds/SDL_n3ds.c b/src/core/n3ds/SDL_n3ds.c index 46610d19b..ac404675d 100644 --- a/src/core/n3ds/SDL_n3ds.c +++ b/src/core/n3ds/SDL_n3ds.c @@ -21,7 +21,7 @@ #include "SDL_internal.h" -#ifdef __3DS__ +#ifdef SDL_PLATFORM_3DS #include <3ds.h> diff --git a/src/core/ngage/SDL_ngage_runapp.cpp b/src/core/ngage/SDL_ngage_runapp.cpp index b2eca9889..6b7f3f82d 100644 --- a/src/core/ngage/SDL_ngage_runapp.cpp +++ b/src/core/ngage/SDL_ngage_runapp.cpp @@ -4,7 +4,7 @@ #include "SDL_internal.h" -#ifdef __NGAGE__ +#ifdef SDL_PLATFORM_NGAGE #include #include @@ -75,4 +75,4 @@ cleanup: return ret; } -#endif // __NGAGE__ +#endif // SDL_PLATFORM_NGAGE diff --git a/src/core/openbsd/SDL_wscons_kbd.c b/src/core/openbsd/SDL_wscons_kbd.c index 6832cc83e..8b08f05d0 100644 --- a/src/core/openbsd/SDL_wscons_kbd.c +++ b/src/core/openbsd/SDL_wscons_kbd.c @@ -34,7 +34,7 @@ #include "../../events/SDL_events_c.h" -#ifdef __NetBSD__ +#ifdef SDL_PLATFORM_NETBSD #define KS_GROUP_Ascii KS_GROUP_Plain #define KS_Cmd_ScrollBack KS_Cmd_ScrollFastUp #define KS_Cmd_ScrollFwd KS_Cmd_ScrollFastDown @@ -224,7 +224,7 @@ static struct SDL_wscons_compose_tab_s { { KS_asciicircum, KS_u }, KS_ucircumflex }, { { KS_grave, KS_u }, KS_ugrave }, { { KS_acute, KS_y }, KS_yacute }, -#ifndef __NetBSD__ +#ifndef SDL_PLATFORM_NETBSD { { KS_dead_caron, KS_space }, KS_L2_caron }, { { KS_dead_caron, KS_S }, KS_L2_Scaron }, { { KS_dead_caron, KS_Z }, KS_L2_Zcaron }, @@ -319,7 +319,7 @@ static struct wscons_keycode_to_SDL { KS_f18, SDL_SCANCODE_F18 }, { KS_f19, SDL_SCANCODE_F19 }, { KS_f20, SDL_SCANCODE_F20 }, -#ifndef __NetBSD__ +#ifndef SDL_PLATFORM_NETBSD { KS_f21, SDL_SCANCODE_F21 }, { KS_f22, SDL_SCANCODE_F22 }, { KS_f23, SDL_SCANCODE_F23 }, @@ -620,7 +620,7 @@ static void updateKeyboard(SDL_WSCONS_input_data *input) input->lockheldstate[2] = 1; break; } -#ifndef __NetBSD__ +#ifndef SDL_PLATFORM_NETBSD case KS_Mode_Lock: { if (input->lockheldstate[3] >= 1) { @@ -728,7 +728,7 @@ static void updateKeyboard(SDL_WSCONS_input_data *input) input->lockheldstate[2] = 0; } } break; -#ifndef __NetBSD__ +#ifndef SDL_PLATFORM_NETBSD case KS_Mode_Lock: { if (input->lockheldstate[3]) { diff --git a/src/core/ps2/SDL_ps2.c b/src/core/ps2/SDL_ps2.c index b0a6f5493..6be9a2ad5 100644 --- a/src/core/ps2/SDL_ps2.c +++ b/src/core/ps2/SDL_ps2.c @@ -21,7 +21,7 @@ #include "SDL_internal.h" -#ifdef __PS2__ +#ifdef SDL_PLATFORM_PS2 /* SDL_RunApp() code for PS2 based on SDL_ps2_main.c, fjtrujy@gmail.com */ @@ -82,4 +82,4 @@ SDL_RunApp(int argc, char* argv[], SDL_main_func mainFunction, void * reserved) return res; } -#endif /* __PS2__ */ +#endif /* SDL_PLATFORM_PS2 */ diff --git a/src/core/psp/SDL_psp.c b/src/core/psp/SDL_psp.c index 2b47c5b10..2350e88ea 100644 --- a/src/core/psp/SDL_psp.c +++ b/src/core/psp/SDL_psp.c @@ -21,7 +21,7 @@ #include "SDL_internal.h" -#ifdef __PSP__ +#ifdef SDL_PLATFORM_PSP /* SDL_RunApp() for PSP based on SDL_psp_main.c, placed in the public domain by Sam Lantinga 3/13/14 */ @@ -79,4 +79,4 @@ SDL_RunApp(int argc, char* argv[], SDL_main_func mainFunction, void * reserved) return mainFunction(argc, argv); } -#endif /* __PSP__ */ +#endif /* SDL_PLATFORM_PSP */ diff --git a/src/core/unix/SDL_appid.c b/src/core/unix/SDL_appid.c index fd2f2dc35..67a44330d 100644 --- a/src/core/unix/SDL_appid.c +++ b/src/core/unix/SDL_appid.c @@ -30,15 +30,15 @@ const char *SDL_GetExeName() /* TODO: Use a fallback if BSD has no mounted procfs (OpenBSD has no procfs at all) */ if (!proc_name) { -#if defined(__LINUX__) || defined(__FREEBSD__) || defined (__NETBSD__) +#if defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_FREEBSD) || defined (SDL_PLATFORM_NETBSD) static char linkfile[1024]; int linksize; -#if defined(__LINUX__) +#if defined(SDL_PLATFORM_LINUX) const char *proc_path = "/proc/self/exe"; -#elif defined(__FREEBSD__) +#elif defined(SDL_PLATFORM_FREEBSD) const char *proc_path = "/proc/curproc/file"; -#elif defined(__NETBSD__) +#elif defined(SDL_PLATFORM_NETBSD) const char *proc_path = "/proc/curproc/exe"; #endif linksize = readlink(proc_path, linkfile, sizeof(linkfile) - 1); diff --git a/src/core/windows/SDL_hid.c b/src/core/windows/SDL_hid.c index 6cea5344e..9c86b69d5 100644 --- a/src/core/windows/SDL_hid.c +++ b/src/core/windows/SDL_hid.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#ifndef __WINRT__ +#ifndef SDL_PLATFORM_WINRT #include "SDL_hid.h" @@ -81,4 +81,4 @@ void WIN_UnloadHIDDLL(void) } } -#endif /* !__WINRT__ */ +#endif /* !SDL_PLATFORM_WINRT */ diff --git a/src/core/windows/SDL_hid.h b/src/core/windows/SDL_hid.h index 4dbdd7577..e747e46ea 100644 --- a/src/core/windows/SDL_hid.h +++ b/src/core/windows/SDL_hid.h @@ -25,7 +25,7 @@ #include "SDL_windows.h" -#ifndef __WINRT__ +#ifndef SDL_PLATFORM_WINRT typedef LONG NTSTATUS; typedef USHORT USAGE; @@ -208,6 +208,6 @@ extern HidP_GetValueCaps_t SDL_HidP_GetValueCaps; extern HidP_MaxDataListLength_t SDL_HidP_MaxDataListLength; extern HidP_GetData_t SDL_HidP_GetData; -#endif /* !__WINRT__ */ +#endif /* !SDL_PLATFORM_WINRT */ #endif /* SDL_hid_h_ */ diff --git a/src/core/windows/SDL_immdevice.c b/src/core/windows/SDL_immdevice.c index 2e956b473..98a692590 100644 --- a/src/core/windows/SDL_immdevice.c +++ b/src/core/windows/SDL_immdevice.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#if (defined(__WIN32__) || defined(__GDK__)) && defined(HAVE_MMDEVICEAPI_H) +#if (defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)) && defined(HAVE_MMDEVICEAPI_H) #include "SDL_windows.h" #include "SDL_immdevice.h" @@ -429,4 +429,4 @@ void SDL_IMMDevice_EnumerateEndpoints(SDL_AudioDevice **default_output, SDL_Audi IMMDeviceEnumerator_RegisterEndpointNotificationCallback(enumerator, (IMMNotificationClient *)¬ification_client); } -#endif /* (defined(__WIN32__) || defined(__GDK__)) && defined(HAVE_MMDEVICEAPI_H) */ +#endif /* (defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)) && defined(HAVE_MMDEVICEAPI_H) */ diff --git a/src/core/windows/SDL_windows.c b/src/core/windows/SDL_windows.c index 616af55c5..732b3e994 100644 --- a/src/core/windows/SDL_windows.c +++ b/src/core/windows/SDL_windows.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#if defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK) #include "SDL_windows.h" @@ -86,14 +86,14 @@ WIN_CoInitialize(void) If you need multi-threaded mode, call CoInitializeEx() before SDL_Init() */ -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT /* DLudwig: On WinRT, it is assumed that COM was initialized in main(). CoInitializeEx is available (not CoInitialize though), however on WinRT, main() is typically declared with the [MTAThread] attribute, which, AFAIK, should initialize COM. */ return S_OK; -#elif defined(__XBOXONE__) || defined(__XBOXSERIES__) +#elif defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) /* On Xbox, there's no need to call CoInitializeEx (and it's not implemented) */ return S_OK; #else @@ -114,12 +114,12 @@ WIN_CoInitialize(void) void WIN_CoUninitialize(void) { -#ifndef __WINRT__ +#ifndef SDL_PLATFORM_WINRT CoUninitialize(); #endif } -#ifndef __WINRT__ +#ifndef SDL_PLATFORM_WINRT FARPROC WIN_LoadComBaseFunction(const char *name) { static SDL_bool s_bLoaded; @@ -140,7 +140,7 @@ FARPROC WIN_LoadComBaseFunction(const char *name) HRESULT WIN_RoInitialize(void) { -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT return S_OK; #else typedef HRESULT(WINAPI * RoInitialize_t)(RO_INIT_TYPE initType); @@ -167,7 +167,7 @@ WIN_RoInitialize(void) void WIN_RoUninitialize(void) { -#ifndef __WINRT__ +#ifndef SDL_PLATFORM_WINRT typedef void(WINAPI * RoUninitialize_t)(void); RoUninitialize_t RoUninitializeFunc = (RoUninitialize_t)WIN_LoadComBaseFunction("RoUninitialize"); if (RoUninitializeFunc) { @@ -176,7 +176,7 @@ void WIN_RoUninitialize(void) #endif } -#if !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) static BOOL IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor) { OSVERSIONINFOEXW osvi; @@ -199,7 +199,7 @@ static BOOL IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WO BOOL WIN_IsWindowsVistaOrGreater(void) { -#if defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) return TRUE; #else return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0); @@ -208,7 +208,7 @@ BOOL WIN_IsWindowsVistaOrGreater(void) BOOL WIN_IsWindows7OrGreater(void) { -#if defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) return TRUE; #else return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 0); @@ -217,7 +217,7 @@ BOOL WIN_IsWindows7OrGreater(void) BOOL WIN_IsWindows8OrGreater(void) { -#if defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) return TRUE; #else return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN8), LOBYTE(_WIN32_WINNT_WIN8), 0); @@ -247,7 +247,7 @@ WASAPI doesn't need this. This is just for DirectSound/WinMM. */ char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid) { -#if defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) return WIN_StringToUTF8(name); /* No registry access on WinRT/UWP and Xbox, go with what we've got. */ #else static const GUID nullguid = { 0 }; @@ -300,7 +300,7 @@ char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid) retval = WIN_StringToUTF8(strw); SDL_free(strw); return retval ? retval : WIN_StringToUTF8(name); -#endif /* if __WINRT__ / else */ +#endif /* if SDL_PLATFORM_WINRT / else */ } BOOL WIN_IsEqualGUID(const GUID *a, const GUID *b) @@ -364,7 +364,7 @@ SDL_AudioFormat SDL_WaveFormatExToSDLFormat(WAVEFORMATEX *waveformat) /* Win32-specific SDL_RunApp(), which does most of the SDL_main work, based on SDL_windows_main.c, placed in the public domain by Sam Lantinga 4/13/98 */ -#ifdef __WIN32__ +#ifdef SDL_PLATFORM_WIN32 #include /* CommandLineToArgvW() */ @@ -433,6 +433,6 @@ DECLSPEC int MINGW32_FORCEALIGN SDL_RunApp(int _argc, char* _argv[], SDL_main_fu return result; } -#endif /* __WIN32__ */ +#endif /* SDL_PLATFORM_WIN32 */ -#endif /* defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__) */ +#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK) */ diff --git a/src/core/windows/SDL_windows.h b/src/core/windows/SDL_windows.h index 67333ac34..c12f9c432 100644 --- a/src/core/windows/SDL_windows.h +++ b/src/core/windows/SDL_windows.h @@ -24,7 +24,7 @@ #ifndef _INCLUDED_WINDOWS_H #define _INCLUDED_WINDOWS_H -#ifdef __WIN32__ +#ifdef SDL_PLATFORM_WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif @@ -45,7 +45,7 @@ #endif #define WINVER _WIN32_WINNT -#elif defined(__WINGDK__) +#elif defined(SDL_PLATFORM_WINGDK) #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif @@ -60,7 +60,7 @@ #define _WIN32_WINNT 0xA00 #define WINVER _WIN32_WINNT -#elif defined(__XBOXONE__) || defined(__XBOXSERIES__) +#elif defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif @@ -132,7 +132,7 @@ extern int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr); /* Sets an error message based on GetLastError(). Always return -1. */ extern int WIN_SetError(const char *prefix); -#ifndef __WINRT__ +#ifndef SDL_PLATFORM_WINRT /* Load a function from combase.dll */ FARPROC WIN_LoadComBaseFunction(const char *name); #endif diff --git a/src/core/windows/SDL_xinput.c b/src/core/windows/SDL_xinput.c index 36c9d8186..13c06bde4 100644 --- a/src/core/windows/SDL_xinput.c +++ b/src/core/windows/SDL_xinput.c @@ -37,7 +37,7 @@ DWORD SDL_XInputVersion = 0; static HMODULE s_pXInputDLL = NULL; static int s_XInputDLLRefCount = 0; -#if defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) int WIN_LoadXInputDLL(void) { @@ -68,7 +68,7 @@ void WIN_UnloadXInputDLL(void) { } -#else /* !(defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__)) */ +#else /* !(defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) */ int WIN_LoadXInputDLL(void) { @@ -136,7 +136,7 @@ void WIN_UnloadXInputDLL(void) } } -#endif /* __WINRT__ */ +#endif /* SDL_PLATFORM_WINRT */ /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/src/core/windows/SDL_xinput.h b/src/core/windows/SDL_xinput.h index d9c840db9..85e97ff71 100644 --- a/src/core/windows/SDL_xinput.h +++ b/src/core/windows/SDL_xinput.h @@ -26,7 +26,7 @@ #include "SDL_windows.h" #ifdef HAVE_XINPUT_H -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) /* Xbox supports an XInput wrapper which is a C++-only header... */ #include /* Required to compile with recent MSVC... */ #include diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index 8469b4e79..e94b35ecb 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#if defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK) #include "../core/windows/SDL_windows.h" #endif @@ -33,13 +33,13 @@ #include #include #endif -#if defined(__MACOS__) && (defined(__ppc__) || defined(__ppc64__)) +#if defined(SDL_PLATFORM_MACOS) && (defined(__ppc__) || defined(__ppc64__)) #include /* For AltiVec check */ -#elif defined(__OpenBSD__) && defined(__powerpc__) +#elif defined(SDL_PLATFORM_OPENBSD) && defined(__powerpc__) #include #include /* For AltiVec check */ #include -#elif defined(__FreeBSD__) && defined(__powerpc__) +#elif defined(SDL_PLATFORM_FREEBSD) && defined(__powerpc__) #include #include #elif defined(SDL_ALTIVEC_BLITTERS) && defined(HAVE_SETJMP) @@ -47,7 +47,7 @@ #include #endif -#if (defined(__LINUX__) || defined(__ANDROID__)) && defined(__arm__) +#if (defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID)) && defined(__arm__) #include #include #include @@ -66,7 +66,7 @@ #endif #endif -#if defined(__ANDROID__) && defined(__arm__) && !defined(HAVE_GETAUXVAL) +#if defined(SDL_PLATFORM_ANDROID) && defined(__arm__) && !defined(HAVE_GETAUXVAL) #include #endif @@ -74,16 +74,16 @@ #include #endif -#ifdef __RISCOS__ +#ifdef SDL_PLATFORM_RISCOS #include #include #endif -#ifdef __PS2__ +#ifdef SDL_PLATFORM_PS2 #include #endif -#ifdef __HAIKU__ +#ifdef SDL_PLATFORM_HAIKU #include #endif @@ -106,7 +106,7 @@ #define CPU_CFG2_LSX (1 << 6) #define CPU_CFG2_LASX (1 << 7) -#if defined(SDL_ALTIVEC_BLITTERS) && defined(HAVE_SETJMP) && !defined(__MACOS__) && !defined(__OpenBSD__) && !defined(__FreeBSD__) +#if defined(SDL_ALTIVEC_BLITTERS) && defined(HAVE_SETJMP) && !defined(SDL_PLATFORM_MACOS) && !defined(SDL_PLATFORM_OPENBSD) && !defined(SDL_PLATFORM_FREEBSD) /* This is the brute force way of detecting instruction sets... the idea is borrowed from the libmpeg2 library - thanks! */ @@ -122,7 +122,7 @@ static int CPU_haveCPUID(void) int has_CPUID = 0; /* *INDENT-OFF* */ /* clang-format off */ -#ifndef __EMSCRIPTEN__ +#ifndef SDL_PLATFORM_EMSCRIPTEN #if (defined(__GNUC__) || defined(__llvm__)) && defined(__i386__) __asm__ ( " pushfl # Get original EFLAGS \n" @@ -209,7 +209,7 @@ done: "1: \n" ); #endif -#endif /* !__EMSCRIPTEN__ */ +#endif /* !SDL_PLATFORM_EMSCRIPTEN */ /* *INDENT-ON* */ /* clang-format on */ return has_CPUID; } @@ -318,8 +318,8 @@ static int CPU_haveAltiVec(void) { volatile int altivec = 0; #ifndef SDL_CPUINFO_DISABLED -#if (defined(__MACOS__) && (defined(__ppc__) || defined(__ppc64__))) || (defined(__OpenBSD__) && defined(__powerpc__)) -#ifdef __OpenBSD__ +#if (defined(SDL_PLATFORM_MACOS) && (defined(__ppc__) || defined(__ppc64__))) || (defined(SDL_PLATFORM_OPENBSD) && defined(__powerpc__)) +#ifdef SDL_PLATFORM_OPENBSD int selectors[2] = { CTL_MACHDEP, CPU_ALTIVEC }; #else int selectors[2] = { CTL_HW, HW_VECTORUNIT }; @@ -330,7 +330,7 @@ static int CPU_haveAltiVec(void) if (0 == error) { altivec = (hasVectorUnit != 0); } -#elif defined(__FreeBSD__) && defined(__powerpc__) +#elif defined(SDL_PLATFORM_FREEBSD) && defined(__powerpc__) unsigned long cpufeatures = 0; elf_aux_info(AT_HWCAP, &cpufeatures, sizeof(cpufeatures)); altivec = cpufeatures & PPC_FEATURE_HAS_ALTIVEC; @@ -361,7 +361,7 @@ static int CPU_haveARMSIMD(void) return 0; } -#elif defined(__LINUX__) +#elif defined(SDL_PLATFORM_LINUX) static int CPU_haveARMSIMD(void) { int arm_simd = 0; @@ -384,7 +384,7 @@ static int CPU_haveARMSIMD(void) return arm_simd; } -#elif defined(__RISCOS__) +#elif defined(SDL_PLATFORM_RISCOS) static int CPU_haveARMSIMD(void) { _kernel_swi_regs regs; @@ -414,7 +414,7 @@ static int CPU_haveARMSIMD(void) } #endif -#if defined(__LINUX__) && defined(__arm__) && !defined(HAVE_GETAUXVAL) +#if defined(SDL_PLATFORM_LINUX) && defined(__arm__) && !defined(HAVE_GETAUXVAL) static int readProcAuxvForNeon(void) { int neon = 0; @@ -439,7 +439,7 @@ static int CPU_haveNEON(void) { /* The way you detect NEON is a privileged instruction on ARM, so you have query the OS kernel in a platform-specific way. :/ */ -#if (defined(__WINDOWS__) || defined(__WINRT__) || defined(__GDK__)) && (defined(_M_ARM) || defined(_M_ARM64)) +#if (defined(SDL_PLATFORM_WINDOWS) || defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_GDK)) && (defined(_M_ARM) || defined(_M_ARM64)) /* Visual Studio, for ARM, doesn't define __ARM_ARCH. Handle this first. */ /* Seems to have been removed */ #ifndef PF_ARM_NEON_INSTRUCTIONS_AVAILABLE @@ -449,18 +449,18 @@ static int CPU_haveNEON(void) return IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) != 0; #elif (defined(__ARM_ARCH) && (__ARM_ARCH >= 8)) || defined(__aarch64__) return 1; /* ARMv8 always has non-optional NEON support. */ -#elif defined(__VITA__) +#elif defined(SDL_PLATFORM_VITA) return 1; -#elif defined(__3DS__) +#elif defined(SDL_PLATFORM_3DS) return 0; -#elif defined(__APPLE__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 7) +#elif defined(SDL_PLATFORM_APPLE) && defined(__ARM_ARCH) && (__ARM_ARCH >= 7) /* (note that sysctlbyname("hw.optional.neon") doesn't work!) */ return 1; /* all Apple ARMv7 chips and later have NEON. */ -#elif defined(__APPLE__) +#elif defined(SDL_PLATFORM_APPLE) return 0; /* assume anything else from Apple doesn't have NEON. */ #elif !defined(__arm__) return 0; /* not an ARM CPU at all. */ -#elif defined(__OpenBSD__) +#elif defined(SDL_PLATFORM_OPENBSD) return 1; /* OpenBSD only supports ARMv7 CPUs that have NEON. */ #elif defined(HAVE_ELF_AUX_INFO) unsigned long hasneon = 0; @@ -468,11 +468,11 @@ static int CPU_haveNEON(void) return 0; } return (hasneon & HWCAP_NEON) == HWCAP_NEON; -#elif (defined(__LINUX__) || defined(__ANDROID__)) && defined(HAVE_GETAUXVAL) +#elif (defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID)) && defined(HAVE_GETAUXVAL) return (getauxval(AT_HWCAP) & HWCAP_NEON) == HWCAP_NEON; -#elif defined(__LINUX__) +#elif defined(SDL_PLATFORM_LINUX) return readProcAuxvForNeon(); -#elif defined(__ANDROID__) +#elif defined(SDL_PLATFORM_ANDROID) /* Use NDK cpufeatures to read either /proc/self/auxv or /proc/cpuinfo */ { AndroidCpuFamily cpu_family = android_getCpuFamily(); @@ -484,7 +484,7 @@ static int CPU_haveNEON(void) } return 0; } -#elif defined(__RISCOS__) +#elif defined(SDL_PLATFORM_RISCOS) /* Use the VFPSupport_Features SWI to access the MVFR registers */ { _kernel_swi_regs regs; @@ -496,7 +496,7 @@ static int CPU_haveNEON(void) } return 0; } -#elif defined(__EMSCRIPTEN__) +#elif defined(SDL_PLATFORM_EMSCRIPTEN) return 0; #else #warning SDL_HasNEON is not implemented for this ARM platform. Write me. @@ -629,7 +629,7 @@ int SDL_GetCPUCount(void) sysctlbyname("hw.ncpu", &SDL_CPUCount, &size, NULL, 0); } #endif -#if defined(__WIN32__) || defined(__GDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) if (SDL_CPUCount <= 0) { SYSTEM_INFO info; GetSystemInfo(&info); @@ -1029,7 +1029,7 @@ int SDL_GetSystemRAM(void) } } #endif -#if defined(__WIN32__) || defined(__GDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) if (SDL_SystemRAM <= 0) { MEMORYSTATUSEX stat; stat.dwLength = sizeof(stat); @@ -1038,7 +1038,7 @@ int SDL_GetSystemRAM(void) } } #endif -#ifdef __RISCOS__ +#ifdef SDL_PLATFORM_RISCOS if (SDL_SystemRAM <= 0) { _kernel_swi_regs regs; regs.r[0] = 0x108; @@ -1047,20 +1047,20 @@ int SDL_GetSystemRAM(void) } } #endif -#ifdef __VITA__ +#ifdef SDL_PLATFORM_VITA if (SDL_SystemRAM <= 0) { /* Vita has 512MiB on SoC, that's split into 256MiB(+109MiB in extended memory mode) for app +26MiB of physically continuous memory, +112MiB of CDRAM(VRAM) + system reserved memory. */ SDL_SystemRAM = 536870912; } #endif -#ifdef __PS2__ +#ifdef SDL_PLATFORM_PS2 if (SDL_SystemRAM <= 0) { /* PlayStation 2 has 32MiB however there are some special models with 64 and 128 */ SDL_SystemRAM = GetMemorySize(); } #endif -#ifdef __HAIKU__ +#ifdef SDL_PLATFORM_HAIKU if (SDL_SystemRAM <= 0) { system_info info; if (get_system_info(&info) == B_OK) { diff --git a/src/dynapi/SDL_dynapi.c b/src/dynapi/SDL_dynapi.c index 5edc6aa94..300ddaba1 100644 --- a/src/dynapi/SDL_dynapi.c +++ b/src/dynapi/SDL_dynapi.c @@ -410,7 +410,7 @@ Sint32 SDL_DYNAPI_entry(Uint32 apiver, void *table, Uint32 tablesize) /* Obviously we can't use SDL_LoadObject() to load SDL. :) */ /* Also obviously, we never close the loaded library. */ -#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) +#if defined(WIN32) || defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN) #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif @@ -428,7 +428,7 @@ static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym) return retval; } -#elif defined(unix) || defined(__unix__) || defined(__APPLE__) || defined(__HAIKU__) +#elif defined(SDL_PLATFORM_UNIX) || defined(SDL_PLATFORM_APPLE) || defined(SDL_PLATFORM_HAIKU) #include static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym) { @@ -452,7 +452,7 @@ static void dynapi_warn(const char *msg) const char *caption = "SDL Dynamic API Failure!"; (void)caption; /* SDL_ShowSimpleMessageBox() is a too heavy for here. */ -#if (defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if (defined(WIN32) || defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN)) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) MessageBoxA(NULL, msg, caption, MB_OK | MB_ICONERROR); #elif defined(HAVE_STDIO_H) fprintf(stderr, "\n\n%s\n%s\n\n", caption, msg); diff --git a/src/dynapi/SDL_dynapi.h b/src/dynapi/SDL_dynapi.h index 579cdf498..43a642419 100644 --- a/src/dynapi/SDL_dynapi.h +++ b/src/dynapi/SDL_dynapi.h @@ -39,31 +39,31 @@ #error Nope, you have to edit this file to force this off. #endif -#ifdef __APPLE__ +#ifdef SDL_PLATFORM_APPLE #include "TargetConditionals.h" #endif #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE /* probably not useful on iOS. */ #define SDL_DYNAMIC_API 0 -#elif defined(__ANDROID__) /* probably not useful on Android. */ +#elif defined(SDL_PLATFORM_ANDROID) /* probably not useful on Android. */ #define SDL_DYNAMIC_API 0 -#elif defined(__EMSCRIPTEN__) && __EMSCRIPTEN__ /* probably not useful on Emscripten. */ +#elif defined(SDL_PLATFORM_EMSCRIPTEN) /* probably not useful on Emscripten. */ #define SDL_DYNAMIC_API 0 #elif defined(SDL_BUILDING_WINRT) && SDL_BUILDING_WINRT /* probably not useful on WinRT, given current .dll loading restrictions */ #define SDL_DYNAMIC_API 0 -#elif defined(__PS2__) && __PS2__ +#elif defined(SDL_PLATFORM_PS2) && SDL_PLATFORM_PS2 #define SDL_DYNAMIC_API 0 -#elif defined(__PSP__) && __PSP__ +#elif defined(SDL_PLATFORM_PSP) && SDL_PLATFORM_PSP #define SDL_DYNAMIC_API 0 -#elif defined(__riscos__) && __riscos__ /* probably not useful on RISC OS, since dlopen() can't be used when using static linking. */ +#elif defined(SDL_PLATFORM_RISCOS) /* probably not useful on RISC OS, since dlopen() can't be used when using static linking. */ #define SDL_DYNAMIC_API 0 #elif defined(__clang_analyzer__) || defined(SDL_THREAD_SAFETY_ANALYSIS) #define SDL_DYNAMIC_API 0 /* Turn off for static analysis, so reports are more clear. */ -#elif defined(__VITA__) +#elif defined(SDL_PLATFORM_VITA) #define SDL_DYNAMIC_API 0 /* vitasdk doesn't support dynamic linking */ -#elif defined(__NGAGE__) +#elif defined(SDL_PLATFORM_NGAGE) #define SDL_DYNAMIC_API 0 /* The N-Gage doesn't support dynamic linking either */ -#elif defined(__3DS__) +#elif defined(SDL_PLATFORM_3DS) #define SDL_DYNAMIC_API 0 /* devkitARM doesn't support dynamic linking */ #elif defined(DYNAPI_NEEDS_DLOPEN) && !defined(HAVE_DLOPEN) #define SDL_DYNAMIC_API 0 /* we need dlopen(), but don't have it.... */ diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index ffe420ecc..984f82011 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -50,7 +50,7 @@ SDL_DYNAPI_PROC(size_t,SDL_RWprintf,(SDL_RWops *a, SDL_PRINTF_FORMAT_STRING cons #undef SDL_CreateThread #endif -#if defined(__WIN32__) || defined(__GDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThread,(SDL_ThreadFunction a, const char *b, void *c, pfnSDL_CurrentBeginThread d, pfnSDL_CurrentEndThread e),(a,b,c,d,e),return) #else SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThread,(SDL_ThreadFunction a, const char *b, void *c),(a,b,c),return) @@ -60,7 +60,7 @@ SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThread,(SDL_ThreadFunction a, const char * #undef SDL_CreateThreadWithStackSize #endif -#if defined(__WIN32__) || defined(__GDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThreadWithStackSize,(SDL_ThreadFunction a, const char *b, const size_t c, void *d, pfnSDL_CurrentBeginThread e, pfnSDL_CurrentEndThread f),(a,b,c,d,e,f),return) #else SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThreadWithStackSize,(SDL_ThreadFunction a, const char *b, const size_t c, void *d),(a,b,c,d),return) diff --git a/src/dynapi/SDL_dynapi_unsupported.h b/src/dynapi/SDL_dynapi_unsupported.h index 5bad9e5a2..805e77fa2 100644 --- a/src/dynapi/SDL_dynapi_unsupported.h +++ b/src/dynapi/SDL_dynapi_unsupported.h @@ -23,25 +23,25 @@ #define SDL_dynapi_unsupported_h_ -#if !(defined(__WIN32__) || defined(__GDK__)) +#if !(defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)) typedef struct ID3D12Device ID3D12Device; typedef void *SDL_WindowsMessageHook; #endif -#if !(defined(__WIN32__) || defined(__WINGDK__)) +#if !(defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK)) typedef struct ID3D11Device ID3D11Device; typedef struct IDirect3DDevice9 IDirect3DDevice9; #endif -#ifndef __GDK__ +#ifndef SDL_PLATFORM_GDK typedef struct XTaskQueueHandle XTaskQueueHandle; #endif -#ifndef __WINRT__ +#ifndef SDL_PLATFORM_WINRT typedef int SDL_WinRT_DeviceFamily; typedef int SDL_WinRT_Path; #endif -#ifndef __GDK__ +#ifndef SDL_PLATFORM_GDK typedef struct XUserHandle XUserHandle; #endif diff --git a/src/dynapi/gendynapi.py b/src/dynapi/gendynapi.py index 6f78afc52..08b2c1dc8 100755 --- a/src/dynapi/gendynapi.py +++ b/src/dynapi/gendynapi.py @@ -25,7 +25,7 @@ # It keeps the dynamic API jump table operating correctly. # # OS-specific API: -# After running the script, you have to manually add #ifdef __WIN32__ +# After running the script, you have to manually add #ifdef SDL_PLATFORM_WIN32 # or similar around the function in 'SDL_dynapi_procs.h' # diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c index 3ba5376eb..71ce50133 100644 --- a/src/events/SDL_events.c +++ b/src/events/SDL_events.c @@ -35,7 +35,7 @@ #include "../video/SDL_sysvideo.h" #undef SDL_PRIs64 -#if (defined(__WIN32__) || defined(__GDK__)) && !defined(__CYGWIN__) +#if (defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)) && !defined(SDL_PLATFORM_CYGWIN) #define SDL_PRIs64 "I64d" #else #define SDL_PRIs64 "lld" diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index 2f14cacf4..88cf267b5 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -27,7 +27,7 @@ #include "SDL_events_c.h" #include "SDL_mouse_c.h" #include "SDL_pen_c.h" -#if defined(__WIN32__) || defined(__GDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) #include "../core/windows/SDL_windows.h" // For GetDoubleClickTime() #endif @@ -48,7 +48,7 @@ static void SDLCALL SDL_MouseDoubleClickTimeChanged(void *userdata, const char * if (hint && *hint) { mouse->double_click_time = SDL_atoi(hint); } else { -#if defined(__WIN32__) || defined(__WINGDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) mouse->double_click_time = GetDoubleClickTime(); #else mouse->double_click_time = 500; @@ -107,7 +107,7 @@ static void SDLCALL SDL_TouchMouseEventsChanged(void *userdata, const char *name mouse->touch_mouse_events = SDL_GetStringBoolean(hint, SDL_TRUE); } -#ifdef __vita__ +#ifdef SDL_PLATFORM_VITA static void SDLCALL SDL_VitaTouchMouseDeviceChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_Mouse *mouse = (SDL_Mouse *)userdata; @@ -133,7 +133,7 @@ static void SDLCALL SDL_MouseTouchEventsChanged(void *userdata, const char *name SDL_Mouse *mouse = (SDL_Mouse *)userdata; SDL_bool default_value; -#if defined(__ANDROID__) || (defined(__IOS__) && !defined(__TVOS__)) +#if defined(SDL_PLATFORM_ANDROID) || (defined(SDL_PLATFORM_IOS) && !defined(SDL_PLATFORM_TVOS)) default_value = SDL_TRUE; #else default_value = SDL_FALSE; @@ -188,7 +188,7 @@ int SDL_PreInitMouse(void) SDL_AddHintCallback(SDL_HINT_TOUCH_MOUSE_EVENTS, SDL_TouchMouseEventsChanged, mouse); -#ifdef __vita__ +#ifdef SDL_PLATFORM_VITA SDL_AddHintCallback(SDL_HINT_VITA_TOUCH_MOUSE_DEVICE, SDL_VitaTouchMouseDeviceChanged, mouse); #endif @@ -438,7 +438,7 @@ static float CalculateSystemScale(SDL_Mouse *mouse, SDL_Window *window, const fl scale = v[i + 1] + (coef * (v[i + 3] - v[i + 1])); } } -#ifdef __WIN32__ +#ifdef SDL_PLATFORM_WIN32 { /* On Windows the mouse speed is affected by the content scale */ SDL_VideoDisplay *display; @@ -1209,7 +1209,7 @@ int SDL_CaptureMouse(SDL_bool enabled) return SDL_Unsupported(); } -#if defined(__WIN32__) || defined(__WINGDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) /* Windows mouse capture is tied to the current thread, and must be called * from the thread that created the window being captured. Since we update * the mouse capture state from the event processing, any application state @@ -1218,7 +1218,7 @@ int SDL_CaptureMouse(SDL_bool enabled) if (!SDL_OnVideoThread()) { return SDL_SetError("SDL_CaptureMouse() must be called on the main thread"); } -#endif /* defined(__WIN32__) || defined(__WINGDK__) */ +#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) */ if (enabled && SDL_GetKeyboardFocus() == NULL) { return SDL_SetError("No window has focus"); @@ -1238,12 +1238,12 @@ SDL_Cursor *SDL_CreateCursor(const Uint8 *data, const Uint8 *mask, int w, int h, const Uint32 black = 0xFF000000; const Uint32 white = 0xFFFFFFFF; const Uint32 transparent = 0x00000000; -#if defined(__WIN32__) +#if defined(SDL_PLATFORM_WIN32) /* Only Windows backend supports inverted pixels in mono cursors. */ const Uint32 inverted = 0x00FFFFFF; #else const Uint32 inverted = 0xFF000000; -#endif /* defined(__WIN32__) */ +#endif /* defined(SDL_PLATFORM_WIN32) */ /* Make sure the width is a multiple of 8 */ w = ((w + 7) & ~7); diff --git a/src/events/SDL_mouse_c.h b/src/events/SDL_mouse_c.h index e024534fa..ac3334e03 100644 --- a/src/events/SDL_mouse_c.h +++ b/src/events/SDL_mouse_c.h @@ -98,7 +98,7 @@ typedef struct SDL_bool touch_mouse_events; SDL_bool mouse_touch_events; SDL_bool was_touch_mouse_events; /* Was a touch-mouse event pending? */ -#ifdef __vita__ +#ifdef SDL_PLATFORM_VITA Uint8 vita_touch_mouse_device; #endif SDL_bool auto_capture; diff --git a/src/events/SDL_pen.c b/src/events/SDL_pen.c index 5907eeaf8..99e6dd97f 100644 --- a/src/events/SDL_pen.c +++ b/src/events/SDL_pen.c @@ -1053,7 +1053,7 @@ int SDL_PenModifyForWacomID(SDL_Pen *pen, Uint32 wacom_devicetype_id, Uint32 *ax wacom_devicetype_id = PEN_WACOM_ID_INVALID; /* force detection to fail */ #endif -#if defined(__LINUX__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) +#if defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_FREEBSD) || defined(SDL_PLATFORM_NETBSD) || defined(SDL_PLATFORM_OPENBSD) /* According to Ping Cheng, the curent Wacom for Linux maintainer, device IDs on Linux squeeze a "0" nibble after the 3rd (least significant) nibble. This may also affect the *BSDs, so they are heuristically included here. diff --git a/src/events/SDL_touch.c b/src/events/SDL_touch.c index 9924b84e3..a96a5e7ce 100644 --- a/src/events/SDL_touch.c +++ b/src/events/SDL_touch.c @@ -255,7 +255,7 @@ int SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_W /* SDL_HINT_TOUCH_MOUSE_EVENTS: controlling whether touch events should generate synthetic mouse events */ /* SDL_HINT_VITA_TOUCH_MOUSE_DEVICE: controlling which touchpad should generate synthetic mouse events, PSVita-only */ { -#ifdef __vita__ +#ifdef SDL_PLATFORM_VITA if (mouse->touch_mouse_events && ((mouse->vita_touch_mouse_device == id) || (mouse->vita_touch_mouse_device == 2))) { #else if (mouse->touch_mouse_events) { diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c index b1a2e8305..ab37994a9 100644 --- a/src/file/SDL_rwops.c +++ b/src/file/SDL_rwops.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#if defined(__WIN32__) || defined(__GDK__) || defined(__WINRT__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) || defined(SDL_PLATFORM_WINRT) #include "../core/windows/SDL_windows.h" #endif @@ -35,19 +35,19 @@ data sources. It can easily be extended to files, memory, etc. */ -#ifdef __APPLE__ +#ifdef SDL_PLATFORM_APPLE #include "cocoa/SDL_rwopsbundlesupport.h" -#endif /* __APPLE__ */ +#endif /* SDL_PLATFORM_APPLE */ -#ifdef __3DS__ +#ifdef SDL_PLATFORM_3DS #include "n3ds/SDL_rwopsromfs.h" -#endif /* __3DS__ */ +#endif /* SDL_PLATFORM_3DS */ -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID #include "../core/android/SDL_android.h" #endif -#if defined(__WIN32__) || defined(__GDK__) || defined(__WINRT__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) || defined(SDL_PLATFORM_WINRT) /* Functions to read/write Win32 API file pointers */ #ifndef INVALID_SET_FILE_POINTER @@ -58,7 +58,7 @@ static int SDLCALL windows_file_open(SDL_RWops *context, const char *filename, const char *mode) { -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) && !defined(__WINRT__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) && !defined(SDL_PLATFORM_WINRT) UINT old_error_mode; #endif HANDLE h; @@ -94,7 +94,7 @@ static int SDLCALL windows_file_open(SDL_RWops *context, const char *filename, c if (!context->hidden.windowsio.buffer.data) { return -1; } -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) && !defined(__WINRT__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) && !defined(SDL_PLATFORM_WINRT) /* Do not open a dialog box if failure */ old_error_mode = SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS); @@ -102,7 +102,7 @@ static int SDLCALL windows_file_open(SDL_RWops *context, const char *filename, c { LPTSTR tstr = WIN_UTF8ToString(filename); -#if defined(__WINRT__) +#if defined(SDL_PLATFORM_WINRT) CREATEFILE2_EXTENDED_PARAMETERS extparams; SDL_zero(extparams); extparams.dwSize = sizeof(extparams); @@ -124,7 +124,7 @@ static int SDLCALL windows_file_open(SDL_RWops *context, const char *filename, c SDL_free(tstr); } -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) && !defined(__WINRT__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) && !defined(SDL_PLATFORM_WINRT) /* restore old behavior */ SetErrorMode(old_error_mode); #endif @@ -274,9 +274,9 @@ static int SDLCALL windows_file_close(SDL_RWops *context) SDL_DestroyRW(context); return 0; } -#endif /* defined(__WIN32__) || defined(__GDK__) */ +#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) */ -#if defined(HAVE_STDIO_H) && !(defined(__WIN32__) || defined(__GDK__)) +#if defined(HAVE_STDIO_H) && !(defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)) /* Functions to read/write stdio file pointers. Not used for windows. */ @@ -400,7 +400,7 @@ static SDL_RWops *SDL_RWFromFP(void *fp, SDL_bool autoclose) } return rwops; } -#endif /* !HAVE_STDIO_H && !(__WIN32__ || __GDK__) */ +#endif /* !HAVE_STDIO_H && !(SDL_PLATFORM_WIN32 || SDL_PLATFORM_GDK) */ /* Functions to read/write memory pointers */ @@ -466,7 +466,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode) SDL_SetError("SDL_RWFromFile(): No file or no mode specified"); return NULL; } -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID #ifdef HAVE_STDIO_H /* Try to open the file on the filesystem first */ if (*file == '/') { @@ -510,7 +510,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode) rwops->close = Android_JNI_FileClose; rwops->type = SDL_RWOPS_JNIFILE; -#elif defined(__WIN32__) || defined(__GDK__) || defined(__WINRT__) +#elif defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) || defined(SDL_PLATFORM_WINRT) rwops = SDL_CreateRW(); if (!rwops) { return NULL; /* SDL_SetError already setup by SDL_CreateRW() */ @@ -528,12 +528,12 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode) rwops->type = SDL_RWOPS_WINFILE; #elif defined(HAVE_STDIO_H) { -#if defined(__APPLE__) +#if defined(SDL_PLATFORM_APPLE) FILE *fp = SDL_OpenFPFromBundleOrFallback(file, mode); -#elif defined(__WINRT__) +#elif defined(SDL_PLATFORM_WINRT) FILE *fp = NULL; fopen_s(&fp, file, mode); -#elif defined(__3DS__) +#elif defined(SDL_PLATFORM_3DS) FILE *fp = N3DS_FileOpen(file, mode); #else FILE *fp = fopen(file, mode); diff --git a/src/file/cocoa/SDL_rwopsbundlesupport.h b/src/file/cocoa/SDL_rwopsbundlesupport.h index c57ce4529..25f84f266 100644 --- a/src/file/cocoa/SDL_rwopsbundlesupport.h +++ b/src/file/cocoa/SDL_rwopsbundlesupport.h @@ -19,7 +19,7 @@ 3. This notice may not be removed or altered from any source distribution. */ -#ifdef __APPLE__ +#ifdef SDL_PLATFORM_APPLE #include diff --git a/src/file/cocoa/SDL_rwopsbundlesupport.m b/src/file/cocoa/SDL_rwopsbundlesupport.m index a6f763b41..d9d184ca7 100644 --- a/src/file/cocoa/SDL_rwopsbundlesupport.m +++ b/src/file/cocoa/SDL_rwopsbundlesupport.m @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#ifdef __APPLE__ +#ifdef SDL_PLATFORM_APPLE #import #include "SDL_rwopsbundlesupport.h" @@ -62,4 +62,4 @@ FILE *SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode) } } -#endif /* __APPLE__ */ +#endif /* SDL_PLATFORM_APPLE */ diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c index 91baf4373..c752d37f5 100644 --- a/src/filesystem/unix/SDL_sysfilesystem.c +++ b/src/filesystem/unix/SDL_sysfilesystem.c @@ -35,7 +35,7 @@ #include #include -#if defined(__FREEBSD__) || defined(__OPENBSD__) +#if defined(SDL_PLATFORM_FREEBSD) || defined(SDL_PLATFORM_OPENBSD) #include #endif @@ -68,7 +68,7 @@ static char *readSymLink(const char *path) return NULL; } -#ifdef __OPENBSD__ +#ifdef SDL_PLATFORM_OPENBSD static char *search_path_for_binary(const char *bin) { char *envr = SDL_getenv("PATH"); @@ -122,7 +122,7 @@ char *SDL_GetBasePath(void) { char *retval = NULL; -#ifdef __FREEBSD__ +#ifdef SDL_PLATFORM_FREEBSD char fullpath[PATH_MAX]; size_t buflen = sizeof(fullpath); const int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; @@ -133,7 +133,7 @@ char *SDL_GetBasePath(void) } } #endif -#ifdef __OPENBSD__ +#ifdef SDL_PLATFORM_OPENBSD /* 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. */ char **cmdline; size_t len; @@ -196,11 +196,11 @@ char *SDL_GetBasePath(void) /* !!! FIXME: after 2.0.6 ships, let's delete this code and just use the /proc/%llu version. There's no reason to have two copies of this plus all the #ifdefs. --ryan. */ -#ifdef __FREEBSD__ +#ifdef SDL_PLATFORM_FREEBSD retval = readSymLink("/proc/curproc/file"); -#elif defined(__NETBSD__) +#elif defined(SDL_PLATFORM_NETBSD) retval = readSymLink("/proc/curproc/exe"); -#elif defined(__SOLARIS__) +#elif defined(SDL_PLATFORM_SOLARIS) retval = readSymLink("/proc/self/path/a.out"); #else retval = readSymLink("/proc/self/exe"); /* linux. */ @@ -217,7 +217,7 @@ char *SDL_GetBasePath(void) #endif } -#ifdef __SOLARIS__ /* try this as a fallback if /proc didn't pan out */ +#ifdef SDL_PLATFORM_SOLARIS /* try this as a fallback if /proc didn't pan out */ if (!retval) { const char *path = getexecname(); if ((path) && (path[0] == '/')) { /* must be absolute path... */ diff --git a/src/filesystem/winrt/SDL_sysfilesystem.cpp b/src/filesystem/winrt/SDL_sysfilesystem.cpp index d5b7c020f..a21679993 100644 --- a/src/filesystem/winrt/SDL_sysfilesystem.cpp +++ b/src/filesystem/winrt/SDL_sysfilesystem.cpp @@ -23,7 +23,7 @@ /* TODO, WinRT: remove the need to compile this with C++/CX (/ZW) extensions, and if possible, without C++ at all */ -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT extern "C" { #include "../../core/windows/SDL_windows.h" @@ -236,4 +236,4 @@ char *SDL_GetUserFolder(SDL_Folder folder) return NULL; } -#endif /* __WINRT__ */ +#endif /* SDL_PLATFORM_WINRT */ diff --git a/src/hidapi/SDL_hidapi.c b/src/hidapi/SDL_hidapi.c index e215c826f..407bf8155 100644 --- a/src/hidapi/SDL_hidapi.c +++ b/src/hidapi/SDL_hidapi.c @@ -39,11 +39,11 @@ #ifndef SDL_HIDAPI_DISABLED -#if defined(__WIN32__) || defined(__WINGDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) #include "../core/windows/SDL_windows.h" #endif -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS #include #include #include @@ -100,7 +100,7 @@ static struct SDL_bool m_bCanGetNotifications; Uint64 m_unLastDetect; -#if defined(__WIN32__) || defined(__WINGDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) SDL_ThreadID m_nThreadID; WNDCLASSEXA m_wndClass; HWND m_hwndMsg; @@ -108,7 +108,7 @@ static struct double m_flLastWin32MessageCheck; #endif -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS IONotificationPortRef m_notificationPort; mach_port_t m_notificationMach; #endif @@ -120,7 +120,7 @@ static struct #endif } SDL_HIDAPI_discovery; -#if defined(__WIN32__) || defined(__WINGDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) struct _DEV_BROADCAST_HDR { DWORD dbch_size; @@ -166,9 +166,9 @@ static LRESULT CALLBACK ControllerWndProc(HWND hwnd, UINT message, WPARAM wParam return DefWindowProc(hwnd, message, wParam, lParam); } -#endif /* defined(__WIN32__) || defined(__WINGDK__) */ +#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) */ -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS static void CallbackIOServiceFunc(void *context, io_iterator_t portIterator) { /* Must drain the iterator, or we won't receive new notifications */ @@ -178,7 +178,7 @@ static void CallbackIOServiceFunc(void *context, io_iterator_t portIterator) ++SDL_HIDAPI_discovery.m_unDeviceChangeCounter; } } -#endif /* __MACOS__ */ +#endif /* SDL_PLATFORM_MACOS */ #ifdef HAVE_INOTIFY #ifdef HAVE_INOTIFY_INIT1 @@ -229,7 +229,7 @@ static void HIDAPI_InitializeDiscovery(void) SDL_HIDAPI_discovery.m_bCanGetNotifications = SDL_FALSE; SDL_HIDAPI_discovery.m_unLastDetect = 0; -#if defined(__WIN32__) || defined(__WINGDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) SDL_HIDAPI_discovery.m_nThreadID = SDL_GetCurrentThreadID(); SDL_zero(SDL_HIDAPI_discovery.m_wndClass); @@ -256,9 +256,9 @@ static void HIDAPI_InitializeDiscovery(void) SDL_HIDAPI_discovery.m_hNotify = RegisterDeviceNotification(SDL_HIDAPI_discovery.m_hwndMsg, &devBroadcast, DEVICE_NOTIFY_WINDOW_HANDLE | DEVICE_NOTIFY_ALL_INTERFACE_CLASSES); SDL_HIDAPI_discovery.m_bCanGetNotifications = (SDL_HIDAPI_discovery.m_hNotify != 0); } -#endif /* defined(__WIN32__) || defined(__WINGDK__) */ +#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) */ -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS SDL_HIDAPI_discovery.m_notificationPort = IONotificationPortCreate(kIOMainPortDefault); if (SDL_HIDAPI_discovery.m_notificationPort) { { @@ -308,7 +308,7 @@ static void HIDAPI_InitializeDiscovery(void) SDL_HIDAPI_discovery.m_bCanGetNotifications = (SDL_HIDAPI_discovery.m_notificationMach != MACH_PORT_NULL); -#endif /* __MACOS__ */ +#endif /* SDL_PLATFORM_MACOS */ #ifdef SDL_USE_LIBUDEV if (linux_enumeration_method == ENUMERATION_LIBUDEV) { @@ -377,7 +377,7 @@ static void HIDAPI_UpdateDiscovery(void) return; } -#if defined(__WIN32__) || defined(__WINGDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) #if 0 /* just let the usual SDL_PumpEvents loop dispatch these, fixing bug 4286. --ryan. */ /* We'll only get messages on the same thread that created the window */ if (SDL_GetCurrentThreadID() == SDL_HIDAPI_discovery.m_nThreadID) { @@ -390,9 +390,9 @@ static void HIDAPI_UpdateDiscovery(void) } } #endif -#endif /* defined(__WIN32__) || defined(__WINGDK__) */ +#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) */ -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS if (SDL_HIDAPI_discovery.m_notificationPort) { struct { @@ -484,7 +484,7 @@ static void HIDAPI_ShutdownDiscovery(void) return; } -#if defined(__WIN32__) || defined(__WINGDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) if (SDL_HIDAPI_discovery.m_hNotify) { UnregisterDeviceNotification(SDL_HIDAPI_discovery.m_hNotify); } @@ -496,7 +496,7 @@ static void HIDAPI_ShutdownDiscovery(void) UnregisterClassA(SDL_HIDAPI_discovery.m_wndClass.lpszClassName, SDL_HIDAPI_discovery.m_wndClass.hInstance); #endif -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS if (SDL_HIDAPI_discovery.m_notificationPort) { IONotificationPortDestroy(SDL_HIDAPI_discovery.m_notificationPort); } @@ -571,17 +571,17 @@ typedef struct PLATFORM_hid_device_ PLATFORM_hid_device; #define read_thread PLATFORM_read_thread #define return_data PLATFORM_return_data -#ifdef __LINUX__ +#ifdef SDL_PLATFORM_LINUX #include "SDL_hidapi_linux.h" -#elif defined(__NETBSD__) +#elif defined(SDL_PLATFORM_NETBSD) #include "SDL_hidapi_netbsd.h" -#elif defined(__MACOS__) +#elif defined(SDL_PLATFORM_MACOS) #include "SDL_hidapi_mac.h" -#elif defined(__WINDOWS__) || defined(__WINGDK__) +#elif defined(SDL_PLATFORM_WINDOWS) || defined(SDL_PLATFORM_WINGDK) #include "SDL_hidapi_windows.h" -#elif defined(__ANDROID__) +#elif defined(SDL_PLATFORM_ANDROID) #include "SDL_hidapi_android.h" -#elif defined(__IOS__) || defined(__TVOS__) +#elif defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS) #include "SDL_hidapi_ios.h" #endif @@ -1099,7 +1099,7 @@ SDL_bool SDL_HIDAPI_ShouldIgnoreDevice(int bus, Uint16 vendor_id, Uint16 product if (vendor_id == USB_VENDOR_VALVE) { /* Ignore the mouse/keyboard interface on Steam Controllers */ if ( -#ifdef __WIN32__ +#ifdef SDL_PLATFORM_WIN32 /* Check the usage page and usage on both USB and Bluetooth */ #else /* Only check the usage page and usage on USB */ @@ -1232,7 +1232,7 @@ int SDL_hid_init(void) #ifdef HAVE_PLATFORM_BACKEND ++attempts; -#ifdef __LINUX__ +#ifdef SDL_PLATFORM_LINUX udev_ctx = SDL_UDEV_GetUdevSyms(); #endif /* __LINUX __ */ if (udev_ctx && PLATFORM_hid_init() == 0) { @@ -1244,7 +1244,7 @@ int SDL_hid_init(void) return -1; } -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS hid_darwin_set_open_exclusive(0); #endif @@ -1273,7 +1273,7 @@ int SDL_hid_exit(void) if (udev_ctx) { result |= PLATFORM_hid_exit(); } -#ifdef __LINUX__ +#ifdef SDL_PLATFORM_LINUX SDL_UDEV_ReleaseUdevSyms(); #endif /* __LINUX __ */ #endif /* HAVE_PLATFORM_BACKEND */ @@ -1688,7 +1688,7 @@ int SDL_hid_get_report_descriptor(SDL_hid_device *device, unsigned char *buf, si void SDL_hid_ble_scan(SDL_bool active) { -#if !defined(SDL_HIDAPI_DISABLED) && (defined(__IOS__) || defined(__TVOS__)) +#if !defined(SDL_HIDAPI_DISABLED) && (defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS)) extern void hid_ble_scan(int bStart); hid_ble_scan(active); #endif diff --git a/src/hidapi/SDL_hidapi_libusb.h b/src/hidapi/SDL_hidapi_libusb.h index 9f62be520..3c5847225 100644 --- a/src/hidapi/SDL_hidapi_libusb.h +++ b/src/hidapi/SDL_hidapi_libusb.h @@ -76,7 +76,7 @@ #define wcsdup SDL_wcsdup -#ifndef __FreeBSD__ +#ifndef SDL_PLATFORM_FREEBSD /* this is awkwardly inlined, so we need to re-implement it here * so we can override the libusb_control_transfer call */ static int SDL_libusb_get_string_descriptor(libusb_device_handle *dev, @@ -87,7 +87,7 @@ static int SDL_libusb_get_string_descriptor(libusb_device_handle *dev, data, (uint16_t)length, 1000); /* Endpoint 0 IN */ } #define libusb_get_string_descriptor SDL_libusb_get_string_descriptor -#endif /* __FreeBSD__ */ +#endif /* SDL_PLATFORM_FREEBSD */ #define HIDAPI_THREAD_MODEL_INCLUDE "hidapi_thread_sdl.h" #ifndef LIBUSB_API_VERSION diff --git a/src/hidapi/ios/hid.m b/src/hidapi/ios/hid.m index eef4297ab..8f9e5fe84 100644 --- a/src/hidapi/ios/hid.m +++ b/src/hidapi/ios/hid.m @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#if defined(__IOS__) || defined(__TVOS__) +#if defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS) #ifndef SDL_HIDAPI_DISABLED @@ -1034,4 +1034,4 @@ HID_API_EXPORT const wchar_t* HID_API_CALL hid_error(hid_device *dev) #endif /* !SDL_HIDAPI_DISABLED */ -#endif /* __IOS__ || __TVOS__ */ +#endif /* SDL_PLATFORM_IOS || SDL_PLATFORM_TVOS */ diff --git a/src/joystick/SDL_gamepad.c b/src/joystick/SDL_gamepad.c index da02b1b9b..ef8a93c0a 100644 --- a/src/joystick/SDL_gamepad.c +++ b/src/joystick/SDL_gamepad.c @@ -34,7 +34,7 @@ #include "../events/SDL_events_c.h" -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID #endif /* Many gamepads turn the center button into an instantaneous button press */ @@ -582,7 +582,7 @@ static void PopMappingChangeTracking(void) SDL_free(tracker); } -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID /* * Helper function to guess at a mapping based on the elements reported for this gamepad */ @@ -683,7 +683,7 @@ static GamepadMapping_t *SDL_CreateMappingForAndroidGamepad(SDL_JoystickGUID gui return SDL_PrivateAddMappingForGUID(guid, mapping_string, &existing, SDL_GAMEPAD_MAPPING_PRIORITY_DEFAULT); } -#endif /* __ANDROID__ */ +#endif /* SDL_PLATFORM_ANDROID */ /* * Helper function to guess at a mapping for HIDAPI gamepads @@ -963,7 +963,7 @@ static GamepadMapping_t *SDL_PrivateGetGamepadMappingForGUID(SDL_JoystickGUID gu mapping = SDL_CreateMappingForWGIGamepad(guid); } else if (SDL_IsJoystickVIRTUAL(guid)) { /* We'll pick up a robust mapping in VIRTUAL_JoystickGetGamepadMapping */ -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID } else { mapping = SDL_CreateMappingForAndroidGamepad(guid); #endif @@ -1441,7 +1441,7 @@ static char *SDL_PrivateGetGamepadGUIDFromMappingString(const char *pMapping) pchGUID[pFirstComma - pMapping] = '\0'; /* Convert old style GUIDs to the new style in 2.0.5 */ -#if defined(__WIN32__) || defined(__WINGDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) if (SDL_strlen(pchGUID) == 32 && SDL_memcmp(&pchGUID[20], "504944564944", 12) == 0) { SDL_memcpy(&pchGUID[20], "000000000000", 12); @@ -1449,7 +1449,7 @@ static char *SDL_PrivateGetGamepadGUIDFromMappingString(const char *pMapping) SDL_memcpy(&pchGUID[8], &pchGUID[0], 4); SDL_memcpy(&pchGUID[0], "03000000", 8); } -#elif defined(__MACOS__) +#elif defined(SDL_PLATFORM_MACOS) if (SDL_strlen(pchGUID) == 32 && SDL_memcmp(&pchGUID[4], "000000000000", 12) == 0 && SDL_memcmp(&pchGUID[20], "000000000000", 12) == 0) { @@ -1664,7 +1664,7 @@ static GamepadMapping_t *SDL_PrivateGetGamepadMappingForNameAndGUID(const char * SDL_AssertJoysticksLocked(); mapping = SDL_PrivateGetGamepadMappingForGUID(guid, SDL_FALSE); -#ifdef __LINUX__ +#ifdef SDL_PLATFORM_LINUX if (!mapping && name) { if (SDL_strstr(name, "Xbox 360 Wireless Receiver")) { /* The Linux driver xpad.c maps the wireless dpad to buttons */ @@ -1674,7 +1674,7 @@ static GamepadMapping_t *SDL_PrivateGetGamepadMappingForNameAndGUID(const char * &existing, SDL_GAMEPAD_MAPPING_PRIORITY_DEFAULT); } } -#endif /* __LINUX__ */ +#endif /* SDL_PLATFORM_LINUX */ if (!mapping) { mapping = s_pDefaultMapping; @@ -2242,7 +2242,7 @@ static SDL_bool SDL_GetGamepadMappingFilePath(char *path, size_t size) return SDL_strlcpy(path, hint, size) < size; } -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID return SDL_snprintf(path, size, "%s/gamepad_map.txt", SDL_AndroidGetInternalStoragePath()) < size; #else return SDL_FALSE; @@ -2496,7 +2496,7 @@ SDL_bool SDL_ShouldIgnoreGamepad(const char *name, SDL_JoystickGUID guid) Uint16 product; Uint16 version; -#ifdef __LINUX__ +#ifdef SDL_PLATFORM_LINUX if (SDL_endswith(name, " Motion Sensors")) { /* Don't treat the PS3 and PS4 motion controls as a separate gamepad */ return SDL_TRUE; @@ -2530,11 +2530,11 @@ SDL_bool SDL_ShouldIgnoreGamepad(const char *name, SDL_JoystickGUID guid) /* We shouldn't ignore Steam's virtual gamepad since it's using the hints to filter out the real gamepads so it can remap input for the virtual gamepad */ /* https://partner.steamgames.com/doc/features/steam_gamepad/steam_input_gamepad_emulation_bestpractices */ SDL_bool bSteamVirtualGamepad = SDL_FALSE; -#ifdef __LINUX__ +#ifdef SDL_PLATFORM_LINUX bSteamVirtualGamepad = (vendor == USB_VENDOR_VALVE && product == USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD); -#elif defined(__MACOS__) +#elif defined(SDL_PLATFORM_MACOS) bSteamVirtualGamepad = (vendor == USB_VENDOR_MICROSOFT && product == USB_PRODUCT_XBOX360_WIRED_CONTROLLER && version == 0); -#elif defined(__WIN32__) +#elif defined(SDL_PLATFORM_WIN32) /* We can't tell on Windows, but Steam will block others in input hooks */ bSteamVirtualGamepad = SDL_TRUE; #endif diff --git a/src/joystick/SDL_gamepad_db.h b/src/joystick/SDL_gamepad_db.h index 971cc0e9b..559f52465 100644 --- a/src/joystick/SDL_gamepad_db.h +++ b/src/joystick/SDL_gamepad_db.h @@ -334,7 +334,7 @@ static const char *s_GamepadMappings[] = { "030000004f04000003d0000000000000,run'n'drive,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b7,leftshoulder:a3,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:a4,rightstick:b11,righttrigger:b5,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000101c0000171c000000000000,uRage Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", #endif -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS "03000000c82d00000090000001000000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", "03000000c82d00001038000000010000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", "03000000c82d00000650000001000000,8BitDo M30 Gamepad,a:b1,b:b0,back:b10,guide:b2,leftshoulder:b6,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a5,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", @@ -470,7 +470,7 @@ static const char *s_GamepadMappings[] = { "03000000830500006020000000010000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", "03000000830500006020000000000000,iBuffalo USB 2-axis 8-button Gamepad,a:b1,b:b0,back:b6,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b3,y:b2,", #endif -#if defined(SDL_JOYSTICK_LINUX) || defined(__OpenBSD__) +#if defined(SDL_JOYSTICK_LINUX) || defined(SDL_PLATFORM_OPENBSD) "03000000c82d00000090000011010000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", "05000000c82d00001038000000010000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", "05000000c82d00005106000000010000,8BitDo M30 Gamepad,a:b1,b:b0,back:b10,guide:b2,leftshoulder:b6,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", @@ -775,12 +775,12 @@ static const char *s_GamepadMappings[] = { "030000009b2800008000000020020000,raphnet technologies 1-player WUSBMote v2.2,a:b1,b:b4,back:b2,dpdown:b13,dpleft:b14,dpright:b15,dpup:b12,leftshoulder:b6,rightshoulder:b7,start:b3,x:b0,y:b5,", "030000009b2800000300000001010000,raphnet.net 4nes4snes v1.5,a:b0,b:b4,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b1,y:b5,", #endif -#ifdef __OpenBSD__ +#ifdef SDL_PLATFORM_OPENBSD "030000004c050000c405000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000004c050000e60c000000010000,PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000005e0400008e02000010010000,Xbox 360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1~,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4~,start:b7,x:b2,y:b3,", #endif -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID "05000000c82d000006500000ffff3f00,8BitDo M30 Gamepad,a:b1,b:b0,back:b4,guide:b17,leftshoulder:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,righttrigger:a4,start:b6,x:b3,y:b2,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", "05000000c82d000051060000ffff3f00,8BitDo M30 Gamepad,a:b1,b:b0,back:b4,guide:b17,leftshoulder:b9,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,righttrigger:a5,start:b6,x:b3,y:b2,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", "05000000c82d000015900000ffff3f00,8BitDo N30 Pro 2,a:b1,b:b0,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b3,y:b2,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 643d7dcc2..63af60e8d 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -36,7 +36,7 @@ /* This is included in only one place because it has a large static list of controllers */ #include "controller_type.h" -#if defined(__WIN32__) || defined(__WINGDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) /* Needed for checking for input remapping programs */ #include "../core/windows/SDL_windows.h" @@ -70,7 +70,7 @@ static SDL_JoystickDriver *SDL_joystick_drivers[] = { #ifdef SDL_JOYSTICK_IOKIT &SDL_DARWIN_JoystickDriver, #endif -#if (defined(__MACOS__) || defined(__IOS__) || defined(__TVOS__)) && !defined(SDL_JOYSTICK_DISABLED) +#if (defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS)) && !defined(SDL_JOYSTICK_DISABLED) &SDL_IOS_JoystickDriver, #endif #ifdef SDL_JOYSTICK_ANDROID @@ -774,7 +774,7 @@ int SDL_GetJoystickInstancePlayerIndex(SDL_JoystickID instance_id) */ static SDL_bool SDL_JoystickAxesCenteredAtZero(SDL_Joystick *joystick) { -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT return SDL_TRUE; #else /*printf("JOYSTICK '%s' VID/PID 0x%.4x/0x%.4x AXES: %d\n", joystick->name, vendor, product, joystick->naxes);*/ @@ -785,7 +785,7 @@ static SDL_bool SDL_JoystickAxesCenteredAtZero(SDL_Joystick *joystick) } return SDL_VIDPIDInList(SDL_GetJoystickVendor(joystick), SDL_GetJoystickProduct(joystick), &zero_centered_devices); -#endif /* __WINRT__ */ +#endif /* SDL_PLATFORM_WINRT */ } static SDL_bool IsROGAlly(SDL_Joystick *joystick) diff --git a/src/joystick/SDL_steam_virtual_gamepad.c b/src/joystick/SDL_steam_virtual_gamepad.c index b8b2038ad..2c76adbba 100644 --- a/src/joystick/SDL_steam_virtual_gamepad.c +++ b/src/joystick/SDL_steam_virtual_gamepad.c @@ -23,7 +23,7 @@ #include "SDL_joystick_c.h" #include "SDL_steam_virtual_gamepad.h" -#ifdef __WIN32__ +#ifdef SDL_PLATFORM_WIN32 #include "../core/windows/SDL_windows.h" #else #include @@ -43,7 +43,7 @@ static Uint64 GetFileModificationTime(const char *file) { Uint64 modification_time = 0; -#ifdef __WIN32__ +#ifdef SDL_PLATFORM_WIN32 WCHAR *wFile = WIN_UTF8ToStringW(file); if (wFile) { HANDLE hFile = CreateFileW(wFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); diff --git a/src/joystick/apple/SDL_mfijoystick.m b/src/joystick/apple/SDL_mfijoystick.m index dfefe1aca..eae3ef415 100644 --- a/src/joystick/apple/SDL_mfijoystick.m +++ b/src/joystick/apple/SDL_mfijoystick.m @@ -35,13 +35,13 @@ #import #endif -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS #include #include #ifndef NSAppKitVersionNumber10_15 #define NSAppKitVersionNumber10_15 1894 #endif -#endif /* __MACOS__ */ +#endif /* SDL_PLATFORM_MACOS */ #ifdef SDL_JOYSTICK_MFI #import @@ -68,7 +68,7 @@ static id disconnectObserver = nil; * they are only ever used indirectly through objc_msgSend */ @interface GCController (SDL) -#if defined(__MACOS__) && (__MAC_OS_X_VERSION_MAX_ALLOWED <= 101600) +#if defined(SDL_PLATFORM_MACOS) && (__MAC_OS_X_VERSION_MAX_ALLOWED <= 101600) + (BOOL)supportsHIDDevice:(IOHIDDeviceRef)device; #endif #if !((__IPHONE_OS_VERSION_MAX_ALLOWED >= 130000) || (__APPLETV_OS_VERSION_MAX_ALLOWED >= 130000) || (__MAC_OS_VERSION_MAX_ALLOWED >= 1500000)) @@ -807,7 +807,7 @@ static int IOS_JoystickInit(void) return 0; } -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS #if SDL_HAS_BUILTIN(__builtin_available) if (@available(macOS 10.16, *)) { /* Continue with initialization on macOS 11+ */ @@ -1960,7 +1960,7 @@ static SDL_bool IOS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMappi return SDL_FALSE; } -#if defined(SDL_JOYSTICK_MFI) && defined(__MACOS__) +#if defined(SDL_JOYSTICK_MFI) && defined(SDL_PLATFORM_MACOS) SDL_bool IOS_SupportedHIDDevice(IOHIDDeviceRef device) { if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_MFI, SDL_TRUE)) { diff --git a/src/joystick/bsd/SDL_bsdjoystick.c b/src/joystick/bsd/SDL_bsdjoystick.c index dcc2980c5..ecdc3132a 100644 --- a/src/joystick/bsd/SDL_bsdjoystick.c +++ b/src/joystick/bsd/SDL_bsdjoystick.c @@ -59,7 +59,7 @@ #include #endif -#if defined(__FREEBSD__) || defined(__FreeBSD_kernel__) +#if defined(SDL_PLATFORM_FREEBSD) #include #if __FreeBSD_kernel_version > 800063 #include @@ -77,7 +77,7 @@ #include "../SDL_joystick_c.h" #include "../hidapi/SDL_hidapijoystick_c.h" -#if defined(__FREEBSD__) || SDL_HAVE_MACHINE_JOYSTICK_H || defined(__FreeBSD_kernel__) || defined(__DragonFly_) +#if defined(SDL_PLATFORM_FREEBSD) || SDL_HAVE_MACHINE_JOYSTICK_H || defined(__FreeBSD_kernel__) || defined(__DragonFly_) #define SUPPORT_JOY_GAMEPORT #endif @@ -85,7 +85,7 @@ #define MAX_JOY_JOYS 2 #define MAX_JOYS (MAX_UHID_JOYS + MAX_JOY_JOYS) -#ifdef __OpenBSD__ +#ifdef SDL_PLATFORM_OPENBSD #define HUG_DPAD_UP 0x90 #define HUG_DPAD_DOWN 0x91 @@ -101,10 +101,10 @@ struct report { -#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 900000) || \ +#if defined(SDL_PLATFORM_FREEBSD) && (__FreeBSD_kernel_version > 900000) || \ defined(__DragonFly__) void *buf; /* Buffer */ -#elif defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) +#elif defined(SDL_PLATFORM_FREEBSD) && (__FreeBSD_kernel_version > 800063) struct usb_gen_descriptor *buf; /* Buffer */ #else struct usb_ctl_report *buf; /* Buffer */ @@ -187,10 +187,10 @@ static void report_free(struct report *); #if defined(USBHID_UCR_DATA) || (defined(__FreeBSD_kernel__) && __FreeBSD_kernel_version <= 800063) #define REP_BUF_DATA(rep) ((rep)->buf->ucr_data) -#elif (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 900000)) || \ +#elif (defined(SDL_PLATFORM_FREEBSD) && (__FreeBSD_kernel_version > 900000)) || \ defined(__DragonFly__) #define REP_BUF_DATA(rep) ((rep)->buf) -#elif (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)) +#elif (defined(SDL_PLATFORM_FREEBSD) && (__FreeBSD_kernel_version > 800063)) #define REP_BUF_DATA(rep) ((rep)->buf->ugd_data) #else #define REP_BUF_DATA(rep) ((rep)->buf->data) @@ -296,7 +296,7 @@ CreateHwData(const char *path) goto usberr; } rep = &hw->inreport; -#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +#if defined(SDL_PLATFORM_FREEBSD) && (__FreeBSD_kernel_version > 800063) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) rep->rid = hid_get_report_id(fd); if (rep->rid < 0) { #else @@ -312,7 +312,7 @@ CreateHwData(const char *path) path); goto usberr; } -#if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +#if defined(USBHID_NEW) || (defined(SDL_PLATFORM_FREEBSD) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) hdata = hid_start_parse(hw->repdesc, 1 << hid_input, rep->rid); #else hdata = hid_start_parse(hw->repdesc, 1 << hid_input); @@ -336,7 +336,7 @@ CreateHwData(const char *path) if (joyaxe >= 0) { hw->axis_map[joyaxe] = 1; } else if (usage == HUG_HAT_SWITCH -#ifdef __OpenBSD__ +#ifdef SDL_PLATFORM_OPENBSD || usage == HUG_DPAD_UP #endif ) { @@ -374,7 +374,7 @@ CreateHwData(const char *path) /* The poll blocks the event thread. */ fcntl(fd, F_SETFL, O_NONBLOCK); -#ifdef __NetBSD__ +#ifdef SDL_PLATFORM_NETBSD /* Flush pending events */ if (rep) { while (read(fd, REP_BUF_DATA(rep), rep->size) == rep->size) @@ -487,7 +487,7 @@ static int BSD_JoystickInit(void) int i; for (i = 0; i < MAX_UHID_JOYS; i++) { -#if defined(__OpenBSD__) && (OpenBSD >= 202105) +#if defined(SDL_PLATFORM_OPENBSD) && (OpenBSD >= 202105) SDL_snprintf(s, SDL_arraysize(s), "/dev/ujoy/%d", i); #else SDL_snprintf(s, SDL_arraysize(s), "/dev/uhid%d", i); @@ -612,7 +612,7 @@ static void BSD_JoystickUpdate(SDL_Joystick *joy) struct report *rep; int nbutton, naxe = -1; Sint32 v; -#ifdef __OpenBSD__ +#ifdef SDL_PLATFORM_OPENBSD Sint32 dpad[4] = { 0, 0, 0, 0 }; #endif Uint64 timestamp = SDL_GetTicksNS(); @@ -663,7 +663,7 @@ static void BSD_JoystickUpdate(SDL_Joystick *joy) rep = &joy->hwdata->inreport; while (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) == rep->size) { -#if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +#if defined(USBHID_NEW) || (defined(SDL_PLATFORM_FREEBSD) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid); #else hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input); @@ -693,7 +693,7 @@ static void BSD_JoystickUpdate(SDL_Joystick *joy) hatval_to_sdl(v) - hitem.logical_minimum); } -#ifdef __OpenBSD__ +#ifdef SDL_PLATFORM_OPENBSD /* here D-pad directions are reported like separate buttons. * calculate the SDL hat value from the 4 separate values. */ @@ -767,7 +767,7 @@ static int report_alloc(struct report *r, struct report_desc *rd, int repind) #ifdef __DragonFly__ len = hid_report_size(rd, repinfo[repind].kind, r->rid); -#elif defined __FREEBSD__ +#elif defined(SDL_PLATFORM_FREEBSD) #if (__FreeBSD_kernel_version >= 460000) || defined(__FreeBSD_kernel__) #if (__FreeBSD_kernel_version <= 500111) len = hid_report_size(rd, r->rid, repinfo[repind].kind); @@ -791,7 +791,7 @@ static int report_alloc(struct report *r, struct report_desc *rd, int repind) r->size = len; if (r->size > 0) { -#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 900000) || defined(__DragonFly__) +#if defined(SDL_PLATFORM_FREEBSD) && (__FreeBSD_kernel_version > 900000) || defined(__DragonFly__) r->buf = SDL_malloc(r->size); #else r->buf = SDL_malloc(sizeof(*r->buf) - sizeof(REP_BUF_DATA(r)) + diff --git a/src/joystick/hidapi/SDL_hidapi_luna.c b/src/joystick/hidapi/SDL_hidapi_luna.c index 4ad81c14c..dfc821da4 100644 --- a/src/joystick/hidapi/SDL_hidapi_luna.c +++ b/src/joystick/hidapi/SDL_hidapi_luna.c @@ -32,7 +32,7 @@ /*#define DEBUG_LUNA_PROTOCOL*/ /* Sending rumble on macOS blocks for a long time and eventually fails */ -#ifndef __MACOS__ +#ifndef SDL_PLATFORM_MACOS #define ENABLE_LUNA_BLUETOOTH_RUMBLE #endif diff --git a/src/joystick/hidapi/SDL_hidapi_ps3.c b/src/joystick/hidapi/SDL_hidapi_ps3.c index 79bdc50fa..c20f61491 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps3.c +++ b/src/joystick/hidapi/SDL_hidapi_ps3.c @@ -69,15 +69,15 @@ static SDL_bool HIDAPI_DriverPS3_IsEnabled(void) { SDL_bool default_value; -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS /* This works well on macOS */ default_value = SDL_TRUE; -#elif defined(__WINDOWS__) +#elif defined(SDL_PLATFORM_WINDOWS) /* You can't initialize the controller with the stock Windows drivers * See https://github.com/ViGEm/DsHidMini as an alternative driver */ default_value = SDL_FALSE; -#elif defined(__LINUX__) +#elif defined(SDL_PLATFORM_LINUX) /* Linux drivers do a better job of managing the transition between * USB and Bluetooth. There are also some quirks in communicating * with PS3 controllers that have been implemented in SDL's hidapi diff --git a/src/joystick/hidapi/SDL_hidapi_steam.c b/src/joystick/hidapi/SDL_hidapi_steam.c index 2e09abee8..b59fcc64a 100644 --- a/src/joystick/hidapi/SDL_hidapi_steam.c +++ b/src/joystick/hidapi/SDL_hidapi_steam.c @@ -347,7 +347,7 @@ static int GetFeatureReport(SDL_hid_device *dev, unsigned char uBuffer[65]) // On Windows and macOS, BLE devices get 2 copies of the feature report ID, one that is removed by ReadFeatureReport, // and one that's included in the buffer we receive. We pad the bytes to read and skip over the report ID // if necessary. -#if defined(__WIN32__) || defined(__MACOS__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_MACOS) ++ucBytesToRead; ++ucDataStartOffset; #endif @@ -980,13 +980,13 @@ static SDL_bool HIDAPI_DriverSteam_InitDevice(SDL_HIDAPI_Device *device) } device->context = ctx; -#ifdef __WIN32__ +#ifdef SDL_PLATFORM_WIN32 if (device->serial) { /* We get a garbage serial number on Windows */ SDL_free(device->serial); device->serial = NULL; } -#endif /* __WIN32__ */ +#endif /* SDL_PLATFORM_WIN32 */ HIDAPI_SetDeviceName(device, "Steam Controller"); diff --git a/src/joystick/hidapi/SDL_hidapi_wii.c b/src/joystick/hidapi/SDL_hidapi_wii.c index 501978512..e4e3ce6cd 100644 --- a/src/joystick/hidapi/SDL_hidapi_wii.c +++ b/src/joystick/hidapi/SDL_hidapi_wii.c @@ -454,7 +454,7 @@ static void CheckMotionPlusConnection(SDL_DriverWii_Context *ctx) static void ActivateMotionPlusWithMode(SDL_DriverWii_Context *ctx, Uint8 mode) { -#ifdef __LINUX__ +#ifdef SDL_PLATFORM_LINUX /* Linux drivers maintain a lot of state around the Motion Plus * extension, so don't mess with it here. */ diff --git a/src/joystick/hidapi/SDL_hidapi_xbox360.c b/src/joystick/hidapi/SDL_hidapi_xbox360.c index ac64bce17..a75c199aa 100644 --- a/src/joystick/hidapi/SDL_hidapi_xbox360.c +++ b/src/joystick/hidapi/SDL_hidapi_xbox360.c @@ -80,7 +80,7 @@ static SDL_bool HIDAPI_DriverXbox360_IsSupportedDevice(SDL_HIDAPI_Device *device /* This is the chatpad or other input interface, not the Xbox 360 interface */ return SDL_FALSE; } -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS if (vendor_id == USB_VENDOR_MICROSOFT && product_id == USB_PRODUCT_XBOX360_WIRED_CONTROLLER && version == 0) { /* This is the Steam Virtual Gamepad, which isn't supported by this driver */ return SDL_FALSE; @@ -197,7 +197,7 @@ static SDL_bool HIDAPI_DriverXbox360_OpenJoystick(SDL_HIDAPI_Device *device, SDL static int HIDAPI_DriverXbox360_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS if (SDL_IsJoystickBluetoothXboxOne(device->vendor_id, device->product_id)) { Uint8 rumble_packet[] = { 0x03, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00 }; @@ -267,7 +267,7 @@ static int HIDAPI_DriverXbox360_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *dev static void HIDAPI_DriverXbox360_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverXbox360_Context *ctx, Uint8 *data, int size) { Sint16 axis; -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS const SDL_bool invert_y_axes = SDL_FALSE; #else const SDL_bool invert_y_axes = SDL_TRUE; diff --git a/src/joystick/hidapi/SDL_hidapi_xboxone.c b/src/joystick/hidapi/SDL_hidapi_xboxone.c index 86dbaeef1..440d3e7d2 100644 --- a/src/joystick/hidapi/SDL_hidapi_xboxone.c +++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c @@ -35,7 +35,7 @@ /* Define this if you want to log all packets from the controller */ /*#define DEBUG_XBOX_PROTOCOL*/ -#if defined(__WIN32__) || defined(__WINGDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) #define XBOX_ONE_DRIVER_ACTIVE 1 #else #define XBOX_ONE_DRIVER_ACTIVE 0 @@ -350,7 +350,7 @@ static SDL_bool HIDAPI_DriverXboxOne_IsEnabled(void) static 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) { -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS /* Wired Xbox One controllers are handled by the 360Controller driver */ if (!SDL_IsJoystickBluetoothXboxOne(vendor_id, product_id)) { return SDL_FALSE; diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c index 79dfe5a94..896ec920c 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick.c +++ b/src/joystick/hidapi/SDL_hidapijoystick.c @@ -27,7 +27,7 @@ #include "SDL_hidapi_rumble.h" #include "../../SDL_hints_c.h" -#if defined(__WIN32__) || defined(__WINGDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) #include "../windows/SDL_rawinputjoystick_c.h" #endif @@ -451,7 +451,7 @@ static void HIDAPI_SetupDeviceDriver(SDL_HIDAPI_Device *device, SDL_bool *remove /* Wait a little bit for the device to initialize */ SDL_Delay(10); -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID /* On Android we need to leave joysticks unlocked because it calls * out to the main thread for permissions and the main thread can * be in the process of handling controller input. diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c index 3db293e56..60ae2f3da 100644 --- a/src/joystick/windows/SDL_rawinputjoystick.c +++ b/src/joystick/windows/SDL_rawinputjoystick.c @@ -686,7 +686,7 @@ static void RAWINPUT_InitWindowsGamingInput(RAWINPUT_DeviceContext *ctx) typedef HRESULT(WINAPI * WindowsCreateStringReference_t)(PCWSTR sourceString, UINT32 length, HSTRING_HEADER * hstringHeader, HSTRING * string); typedef HRESULT(WINAPI * RoGetActivationFactory_t)(HSTRING activatableClassId, REFIID iid, void **factory); -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT WindowsCreateStringReference_t WindowsCreateStringReferenceFunc = WindowsCreateStringReference; RoGetActivationFactory_t RoGetActivationFactoryFunc = RoGetActivationFactory; #else diff --git a/src/joystick/windows/SDL_windows_gaming_input.c b/src/joystick/windows/SDL_windows_gaming_input.c index 606d88b3a..71a2c3b38 100644 --- a/src/joystick/windows/SDL_windows_gaming_input.c +++ b/src/joystick/windows/SDL_windows_gaming_input.c @@ -603,7 +603,7 @@ static int WGI_JoystickInit(void) return SDL_SetError("RoInitialize() failed"); } -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT wgi.CoIncrementMTAUsage = CoIncrementMTAUsage; wgi.RoGetActivationFactory = RoGetActivationFactory; wgi.WindowsCreateStringReference = WindowsCreateStringReference; @@ -617,9 +617,9 @@ static int WGI_JoystickInit(void) RESOLVE(WindowsDeleteString); RESOLVE(WindowsGetStringRawBuffer); #undef RESOLVE -#endif /* __WINRT__ */ +#endif /* SDL_PLATFORM_WINRT */ -#ifndef __WINRT__ +#ifndef SDL_PLATFORM_WINRT { /* There seems to be a bug in Windows where a dependency of WGI can be unloaded from memory prior to WGI itself. * This results in Windows_Gaming_Input!GameController::~GameController() invoking an unloaded DLL and crashing. diff --git a/src/joystick/windows/SDL_windowsjoystick.c b/src/joystick/windows/SDL_windowsjoystick.c index 2206267f6..59d851287 100644 --- a/src/joystick/windows/SDL_windowsjoystick.c +++ b/src/joystick/windows/SDL_windowsjoystick.c @@ -35,7 +35,7 @@ #include "../SDL_sysjoystick.h" #include "../../thread/SDL_systhread.h" #include "../../core/windows/SDL_windows.h" -#if !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #include #endif @@ -152,7 +152,7 @@ static GUID GUID_DEVINTERFACE_HID = { 0x4D1E55B2L, 0xF16F, 0x11CF, { 0x88, 0xCB, JoyStick_DeviceData *SYS_Joystick; /* array to hold joystick ID values */ -#if !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) static HMODULE cfgmgr32_lib_handle; static CM_Register_NotificationFunc CM_Register_Notification; static CM_Unregister_NotificationFunc CM_Unregister_Notification; @@ -338,11 +338,11 @@ static SDL_bool SDL_WaitForDeviceNotification(SDL_DeviceNotificationData *data, return (lastret != -1); } -#endif /* !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) */ +#endif /* !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) */ -#ifndef __WINRT__ +#ifndef SDL_PLATFORM_WINRT -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) static SDL_DeviceNotificationData s_notification_data; #endif @@ -354,7 +354,7 @@ static int SDLCALL SDL_JoystickThread(void *_data) SDL_zeroa(bOpenedXInputDevices); #endif -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) if (SDL_CreateDeviceNotification(&s_notification_data) < 0) { return -1; } @@ -362,7 +362,7 @@ static int SDLCALL SDL_JoystickThread(void *_data) SDL_LockMutex(s_mutexJoyStickEnum); while (s_bJoystickThreadQuit == SDL_FALSE) { -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) if (SDL_WaitForDeviceNotification(&s_notification_data, s_mutexJoyStickEnum) == SDL_FALSE) { #else { @@ -392,7 +392,7 @@ static int SDLCALL SDL_JoystickThread(void *_data) SDL_UnlockMutex(s_mutexJoyStickEnum); -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) SDL_CleanupDeviceNotification(&s_notification_data); #endif @@ -447,7 +447,7 @@ static void SDL_StopJoystickThread(void) s_joystickThread = NULL; } -#endif /* !defined(__WINRT__) */ +#endif /* !defined(SDL_PLATFORM_WINRT) */ void WINDOWS_AddJoystickDevice(JoyStick_DeviceData *device) { @@ -480,7 +480,7 @@ static int WINDOWS_JoystickInit(void) WINDOWS_JoystickDetect(); -#if !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) SDL_CreateDeviceNotificationFunc(); s_bJoystickThread = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_THREAD, SDL_FALSE); @@ -495,7 +495,7 @@ static int WINDOWS_JoystickInit(void) } #endif -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) /* On Xbox, force create the joystick thread for device detection (since other methods don't work */ s_bJoystickThread = SDL_TRUE; if (SDL_StartJoystickThread() < 0) { @@ -766,7 +766,7 @@ void WINDOWS_JoystickQuit(void) } SYS_Joystick = NULL; -#if !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) if (s_bJoystickThread) { SDL_StopJoystickThread(); } else { @@ -776,7 +776,7 @@ void WINDOWS_JoystickQuit(void) SDL_CleanupDeviceNotificationFunc(); #endif -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) if (s_bJoystickThread) { SDL_StopJoystickThread(); } diff --git a/src/joystick/windows/SDL_xinputjoystick.c b/src/joystick/windows/SDL_xinputjoystick.c index 6d8fb8afb..e054ad88b 100644 --- a/src/joystick/windows/SDL_xinputjoystick.c +++ b/src/joystick/windows/SDL_xinputjoystick.c @@ -376,7 +376,7 @@ void SDL_XINPUT_JoystickUpdate(SDL_Joystick *joystick) result = XINPUTGETBATTERYINFORMATION(joystick->hwdata->userid, BATTERY_DEVTYPE_GAMEPAD, &XBatteryInformation); } -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) /* XInputOnGameInput doesn't ever change dwPacketNumber, so have to just update every frame */ UpdateXInputJoystickState(joystick, &XInputState, &XBatteryInformation); #else diff --git a/src/libm/math_private.h b/src/libm/math_private.h index ba5d83468..9beb41027 100644 --- a/src/libm/math_private.h +++ b/src/libm/math_private.h @@ -26,7 +26,7 @@ #define libm_hidden_def(x) #define strong_alias(x, y) -#if !defined(__HAIKU__) && !defined(__PSP__) && !defined(__3DS__) && !defined(__PS2__) /* already defined in a system header. */ +#if !defined(SDL_PLATFORM_HAIKU) && !defined(SDL_PLATFORM_PSP) && !defined(SDL_PLATFORM_3DS) && !defined(SDL_PLATFORM_PS2) /* already defined in a system header. */ typedef unsigned int u_int32_t; #endif diff --git a/src/loadso/windows/SDL_sysloadso.c b/src/loadso/windows/SDL_sysloadso.c index 12a7d6956..6ddfb19bb 100644 --- a/src/loadso/windows/SDL_sysloadso.c +++ b/src/loadso/windows/SDL_sysloadso.c @@ -37,7 +37,7 @@ void *SDL_LoadObject(const char *sofile) return NULL; } tstr = WIN_UTF8ToString(sofile); -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT /* WinRT only publicly supports LoadPackagedLibrary() for loading .dll files. LoadLibrary() is a private API, and not available for apps (that can be published to MS' Windows Store.) diff --git a/src/main/generic/SDL_sysmain_callbacks.c b/src/main/generic/SDL_sysmain_callbacks.c index 8adbf6c4a..59bfbad9b 100644 --- a/src/main/generic/SDL_sysmain_callbacks.c +++ b/src/main/generic/SDL_sysmain_callbacks.c @@ -23,7 +23,7 @@ #include "../SDL_main_callbacks.h" #include "../../video/SDL_sysvideo.h" -#ifndef __IOS__ +#ifndef SDL_PLATFORM_IOS static int callback_rate_increment = 0; @@ -80,4 +80,4 @@ int SDL_EnterAppMainCallbacks(int argc, char* argv[], SDL_AppInit_func appinit, return (rc < 0) ? 1 : 0; } -#endif // !__IOS__ +#endif // !SDL_PLATFORM_IOS diff --git a/src/main/ios/SDL_sysmain_callbacks.m b/src/main/ios/SDL_sysmain_callbacks.m index 09bc9932f..ab00d333c 100644 --- a/src/main/ios/SDL_sysmain_callbacks.m +++ b/src/main/ios/SDL_sysmain_callbacks.m @@ -22,7 +22,7 @@ #include "SDL_internal.h" #include "../SDL_main_callbacks.h" -#ifdef __IOS__ +#ifdef SDL_PLATFORM_IOS #import diff --git a/src/misc/ios/SDL_sysurl.m b/src/misc/ios/SDL_sysurl.m index 719e0b2cb..7ec00c858 100644 --- a/src/misc/ios/SDL_sysurl.m +++ b/src/misc/ios/SDL_sysurl.m @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#if defined(__IOS__) || defined(__TVOS__) +#if defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS) #include "../SDL_sysurl.h" @@ -40,4 +40,4 @@ int SDL_SYS_OpenURL(const char *url) } } -#endif /* __IOS__ || __TVOS__ */ +#endif /* SDL_PLATFORM_IOS || SDL_PLATFORM_TVOS */ diff --git a/src/misc/macos/SDL_sysurl.m b/src/misc/macos/SDL_sysurl.m index 2eff382a0..9a098f649 100644 --- a/src/misc/macos/SDL_sysurl.m +++ b/src/misc/macos/SDL_sysurl.m @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#if defined(__MACOS__) +#if defined(SDL_PLATFORM_MACOS) #include "../SDL_sysurl.h" @@ -36,4 +36,4 @@ int SDL_SYS_OpenURL(const char *url) } } -#endif /* __MACOS__ */ +#endif /* SDL_PLATFORM_MACOS */ diff --git a/src/misc/windows/SDL_sysurl.c b/src/misc/windows/SDL_sysurl.c index 11d720cfb..fe4c877bd 100644 --- a/src/misc/windows/SDL_sysurl.c +++ b/src/misc/windows/SDL_sysurl.c @@ -25,7 +25,7 @@ #include -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) int SDL_SYS_OpenURL(const char *url) { /* Not supported */ diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 0643c3e16..18e8bd9c4 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -27,7 +27,7 @@ #include "../video/SDL_pixels_c.h" #include "../video/SDL_video_c.h" -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID #include "../core/android/SDL_android.h" #endif @@ -37,7 +37,7 @@ SDL_AddEventWatch to catch SDL_EVENT_WILL_ENTER_BACKGROUND events and stopped drawing themselves. Other platforms still draw, as the compositor can use it, and more importantly: drawing to render targets isn't lost. But I still think this should probably be removed at some point in the future. --ryan. */ -#if defined(__IOS__) || defined(__TVOS__) || defined(__ANDROID__) +#if defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS) || defined(SDL_PLATFORM_ANDROID) #define DONT_DRAW_WHILE_HIDDEN 1 #else #define DONT_DRAW_WHILE_HIDDEN 0 @@ -817,7 +817,7 @@ SDL_Renderer *SDL_CreateRendererWithProperties(SDL_PropertiesID props) return SDL_CreateSoftwareRenderer(surface); } -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID Android_ActivityMutex_Lock_Running(); #endif @@ -925,14 +925,14 @@ SDL_Renderer *SDL_CreateRendererWithProperties(SDL_PropertiesID props) SDL_LogInfo(SDL_LOG_CATEGORY_RENDER, "Created renderer: %s", renderer->info.name); -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID Android_ActivityMutex_Unlock(); #endif return renderer; error: -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID Android_ActivityMutex_Unlock(); #endif return NULL; diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c index 068ba59ed..5c939bc7b 100644 --- a/src/render/direct3d11/SDL_render_d3d11.c +++ b/src/render/direct3d11/SDL_render_d3d11.c @@ -24,7 +24,7 @@ #define COBJMACROS #include "../../core/windows/SDL_windows.h" -#ifndef __WINRT__ +#ifndef SDL_PLATFORM_WINRT #include "../../video/windows/SDL_windowswindow.h" #endif #include "../SDL_sysrender.h" @@ -34,7 +34,7 @@ #include "SDL_shaders_d3d11.h" -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT #if NTDDI_VERSION > NTDDI_WIN8 #include @@ -48,7 +48,7 @@ extern ISwapChainBackgroundPanelNative *WINRT_GlobalSwapChainBackgroundPanelNative; #endif /* WINAPI_FAMILY == WINAPI_FAMILY_APP */ -#endif /* __WINRT__ */ +#endif /* SDL_PLATFORM_WINRT */ #if defined(_MSC_VER) && !defined(__clang__) #define SDL_COMPOSE_ERROR(str) __FUNCTION__ ", " str @@ -182,7 +182,7 @@ typedef struct static const GUID SDL_IID_IDXGIFactory2 = { 0x50c83a1c, 0xe072, 0x4c48, { 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0 } }; static const GUID SDL_IID_IDXGIDevice1 = { 0x77db970f, 0x6276, 0x48ba, { 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c } }; -#if defined(__WINRT__) && NTDDI_VERSION > NTDDI_WIN8 +#if defined(SDL_PLATFORM_WINRT) && NTDDI_VERSION > NTDDI_WIN8 static const GUID SDL_IID_IDXGIDevice3 = { 0x6007896c, 0x3244, 0x4afd, { 0xbf, 0x18, 0xa6, 0xd3, 0xbe, 0xda, 0x50, 0x23 } }; #endif static const GUID SDL_IID_ID3D11Texture2D = { 0x6f15aaf2, 0xd208, 0x4e89, { 0x9a, 0xb4, 0x48, 0x95, 0x35, 0xd3, 0x4f, 0x9c } }; @@ -442,7 +442,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer) D3D11_SAMPLER_DESC samplerDesc; D3D11_RASTERIZER_DESC rasterDesc; -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT CreateDXGIFactoryFunc = CreateDXGIFactory1; D3D11CreateDeviceFunc = D3D11CreateDevice; #else @@ -469,7 +469,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer) result = E_FAIL; goto done; } -#endif /* __WINRT__ */ +#endif /* SDL_PLATFORM_WINRT */ result = CreateDXGIFactoryFunc(&SDL_IID_IDXGIFactory2, (void **)&data->dxgiFactory); if (FAILED(result)) { @@ -674,7 +674,7 @@ done: return result; } -#if defined(__WIN32__) || defined(__WINGDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) static DXGI_MODE_ROTATION D3D11_GetCurrentRotation() { @@ -682,7 +682,7 @@ static DXGI_MODE_ROTATION D3D11_GetCurrentRotation() return DXGI_MODE_ROTATION_IDENTITY; } -#endif /* defined(__WIN32__) || defined(__WINGDK__) */ +#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) */ static BOOL D3D11_IsDisplayRotated90Degrees(DXGI_MODE_ROTATION rotation) { @@ -751,7 +751,7 @@ static int D3D11_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rec static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h) { D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT IUnknown *coreWindow = D3D11_GetCoreWindowFromSDLRenderer(renderer); const BOOL usingXAML = (!coreWindow); #else @@ -828,7 +828,7 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h) goto done; #endif } else { -#if defined(__WIN32__) || defined(__WINGDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) HWND hwnd = (HWND)SDL_GetProperty(SDL_GetWindowProperties(renderer->window), SDL_PROPERTY_WINDOW_WIN32_HWND_POINTER, NULL); result = IDXGIFactory2_CreateSwapChainForHwnd(data->dxgiFactory, @@ -847,7 +847,7 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h) #else SDL_SetError(__FUNCTION__ ", Unable to find something to attach a swap chain to"); goto done; -#endif /* defined(__WIN32__) || defined(__WINGDK__) / else */ +#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) / else */ } data->swapEffect = swapChainDesc.SwapEffect; @@ -908,7 +908,7 @@ static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer) /* The width and height of the swap chain must be based on the display's * non-rotated size. */ -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT SDL_GetWindowSize(renderer->window, &w, &h); #else SDL_GetWindowSizeInPixels(renderer->window, &w, &h); @@ -923,7 +923,7 @@ static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer) if (data->swapChain) { /* IDXGISwapChain::ResizeBuffers is not available on Windows Phone 8. */ -#if !defined(__WINRT__) || !SDL_WINAPI_FAMILY_PHONE +#if !defined(SDL_PLATFORM_WINRT) || !SDL_WINAPI_FAMILY_PHONE /* If the swap chain already exists, resize it. */ result = IDXGISwapChain_ResizeBuffers(data->swapChain, 0, @@ -1021,7 +1021,7 @@ static HRESULT D3D11_UpdateForWindowSizeChange(SDL_Renderer *renderer) void D3D11_Trim(SDL_Renderer *renderer) { -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT #if NTDDI_VERSION > NTDDI_WIN8 D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; HRESULT result = S_OK; diff --git a/src/render/direct3d12/SDL_render_d3d12.c b/src/render/direct3d12/SDL_render_d3d12.c index f87fcb917..5f0305f39 100644 --- a/src/render/direct3d12/SDL_render_d3d12.c +++ b/src/render/direct3d12/SDL_render_d3d12.c @@ -32,7 +32,7 @@ #include "../SDL_sysrender.h" #include "../SDL_d3dmath.h" -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) #include "SDL_render_d3d12_xbox.h" #ifndef D3D12_TEXTURE_DATA_PITCH_ALIGNMENT #define D3D12_TEXTURE_DATA_PITCH_ALIGNMENT 256 @@ -160,7 +160,7 @@ typedef struct { void *hDXGIMod; void *hD3D12Mod; -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) UINT64 frameToken; #else IDXGIFactory6 *dxgiFactory; @@ -336,7 +336,7 @@ static void D3D12_ReleaseAll(SDL_Renderer *renderer) if (data) { int i; -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) SAFE_RELEASE(data->dxgiFactory); SAFE_RELEASE(data->dxgiAdapter); SAFE_RELEASE(data->swapChain); @@ -378,7 +378,7 @@ static void D3D12_ReleaseAll(SDL_Renderer *renderer) data->currentRenderTargetView.ptr = 0; data->currentSampler.ptr = 0; -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) /* Check for any leaks if in debug mode */ if (data->dxgiDebug) { DXGI_DEBUG_RLO_FLAGS rloFlags = (DXGI_DEBUG_RLO_FLAGS)(DXGI_DEBUG_RLO_SUMMARY | DXGI_DEBUG_RLO_IGNORE_INTERNAL); @@ -709,7 +709,7 @@ static HRESULT D3D12_CreateVertexBuffer(D3D12_RenderData *data, size_t vbidx, si /* Create resources that depend on the device. */ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) { -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) typedef HRESULT(WINAPI * PFN_CREATE_DXGI_FACTORY)(UINT flags, REFIID riid, void **ppFactory); PFN_CREATE_DXGI_FACTORY CreateDXGIFactoryFunc; PFN_D3D12_CREATE_DEVICE D3D12CreateDeviceFunc; @@ -745,7 +745,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) /* See if we need debug interfaces */ createDebug = SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D11_DEBUG, SDL_FALSE); -#ifdef __GDK__ +#ifdef SDL_PLATFORM_GDK CreateEventExFunc = CreateEventExW; #else /* CreateEventEx() arrived in Vista, so we need to load it with GetProcAddress for XP. */ @@ -762,7 +762,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) goto done; } -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) data->hDXGIMod = SDL_LoadObject("dxgi.dll"); if (!data->hDXGIMod) { result = E_FAIL; @@ -799,9 +799,9 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) D3D_CALL(data->debugInterface, EnableDebugLayer); } } -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) result = D3D12_XBOX_CreateDevice(&d3dDevice, createDebug); if (FAILED(result)) { /* SDL Error is set by D3D12_XBOX_CreateDevice */ @@ -887,7 +887,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) SAFE_RELEASE(infoQueue); } -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ result = D3D_CALL(d3dDevice, QueryInterface, D3D_GUID(SDL_IID_ID3D12Device1), (void **)&data->d3dDevice); if (FAILED(result)) { @@ -1152,7 +1152,7 @@ static int D3D12_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rec return 0; } -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) static HRESULT D3D12_CreateSwapChain(SDL_Renderer *renderer, int w, int h) { D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata; @@ -1281,7 +1281,7 @@ static HRESULT D3D12_CreateWindowSizeDependentResources(SDL_Renderer *renderer) h = tmp; } -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) if (data->swapChain) { /* If the swap chain already exists, resize it. */ result = D3D_CALL(data->swapChain, ResizeBuffers, @@ -1318,11 +1318,11 @@ static HRESULT D3D12_CreateWindowSizeDependentResources(SDL_Renderer *renderer) } } } -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ /* Get each back buffer render target and create render target views */ for (i = 0; i < SDL_D3D12_NUM_BUFFERS; ++i) { -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) result = D3D12_XBOX_CreateBackBufferTarget(data->d3dDevice, renderer->window->w, renderer->window->h, (void **)&data->renderTargets[i]); if (FAILED(result)) { WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D12_XBOX_CreateBackBufferTarget"), result); @@ -1350,7 +1350,7 @@ static HRESULT D3D12_CreateWindowSizeDependentResources(SDL_Renderer *renderer) } /* Set back buffer index to current buffer */ -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) data->currentBackBufferIndex = 0; #else data->currentBackBufferIndex = D3D_CALL(data->swapChain, GetCurrentBackBufferIndex); @@ -1369,7 +1369,7 @@ static HRESULT D3D12_CreateWindowSizeDependentResources(SDL_Renderer *renderer) data->viewportDirty = SDL_TRUE; -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) D3D12_XBOX_StartFrame(data->d3dDevice, &data->frameToken); #endif @@ -2891,7 +2891,7 @@ done: static int D3D12_RenderPresent(SDL_Renderer *renderer) { D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata; -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) UINT syncInterval; UINT presentFlags; #endif @@ -2907,7 +2907,7 @@ static int D3D12_RenderPresent(SDL_Renderer *renderer) result = D3D_CALL(data->commandList, Close); D3D_CALL(data->commandQueue, ExecuteCommandLists, 1, (ID3D12CommandList *const *)&data->commandList); -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) result = D3D12_XBOX_PresentFrame(data->commandQueue, data->frameToken, data->renderTargets[data->currentBackBufferIndex]); #else if (renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) { @@ -2949,7 +2949,7 @@ static int D3D12_RenderPresent(SDL_Renderer *renderer) } data->fenceValue++; -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) data->currentBackBufferIndex++; data->currentBackBufferIndex %= SDL_D3D12_NUM_BUFFERS; #else @@ -2963,7 +2963,7 @@ static int D3D12_RenderPresent(SDL_Renderer *renderer) D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET); -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) D3D12_XBOX_StartFrame(data->d3dDevice, &data->frameToken); #endif return 0; diff --git a/src/render/direct3d12/SDL_render_d3d12_xbox.cpp b/src/render/direct3d12/SDL_render_d3d12_xbox.cpp index 0c4605561..b8bdab186 100644 --- a/src/render/direct3d12/SDL_render_d3d12_xbox.cpp +++ b/src/render/direct3d12/SDL_render_d3d12_xbox.cpp @@ -20,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && (defined(__XBOXONE__) || defined(__XBOXSERIES__)) +#if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && (defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) #include "SDL_render_d3d12_xbox.h" #include "../../core/windows/SDL_windows.h" #include @@ -74,7 +74,7 @@ D3D12_XBOX_CreateDevice(ID3D12Device **device, SDL_bool createDebug) WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] dxgiAdapter->EnumOutputs"), result); goto done; } - + /* Set frame interval */ result = (*device)->SetFrameIntervalX(dxgiOutput, D3D12XBOX_FRAME_INTERVAL_60_HZ, 1, D3D12XBOX_FRAME_INTERVAL_FLAG_NONE); if (FAILED(result)) { diff --git a/src/render/direct3d12/SDL_render_d3d12_xbox.h b/src/render/direct3d12/SDL_render_d3d12_xbox.h index 6db955a42..cd9552699 100644 --- a/src/render/direct3d12/SDL_render_d3d12_xbox.h +++ b/src/render/direct3d12/SDL_render_d3d12_xbox.h @@ -24,9 +24,9 @@ #include "../../SDL_internal.h" -#if defined(__XBOXONE__) +#if defined(SDL_PLATFORM_XBOXONE) #include -#else /* __XBOXSERIES__ */ +#else /* SDL_PLATFORM_XBOXSERIES */ #include #endif diff --git a/src/render/direct3d12/SDL_shaders_d3d12.c b/src/render/direct3d12/SDL_shaders_d3d12.c index ea5ef3194..8b7a0156b 100644 --- a/src/render/direct3d12/SDL_shaders_d3d12.c +++ b/src/render/direct3d12/SDL_shaders_d3d12.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#if defined(SDL_VIDEO_RENDER_D3D12) && !defined(SDL_RENDER_DISABLED) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if defined(SDL_VIDEO_RENDER_D3D12) && !defined(SDL_RENDER_DISABLED) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #include "../../core/windows/SDL_windows.h" #include @@ -6932,4 +6932,4 @@ void D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECO outBytecode->BytecodeLength = D3D12_rootsigs[rootSig].rs_shader_size; } -#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) */ +#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) */ diff --git a/src/render/direct3d12/SDL_shaders_d3d12_xboxone.cpp b/src/render/direct3d12/SDL_shaders_d3d12_xboxone.cpp index e224ffc2b..fe15a68d2 100644 --- a/src/render/direct3d12/SDL_shaders_d3d12_xboxone.cpp +++ b/src/render/direct3d12/SDL_shaders_d3d12_xboxone.cpp @@ -20,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(__XBOXONE__) +#if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(SDL_PLATFORM_XBOXONE) #include @@ -139,6 +139,6 @@ D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE *o outBytecode->BytecodeLength = D3D12_rootsigs[rootSig].rs_shader_size; } -#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(__XBOXONE__) */ +#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(SDL_PLATFORM_XBOXONE) */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/direct3d12/SDL_shaders_d3d12_xboxseries.cpp b/src/render/direct3d12/SDL_shaders_d3d12_xboxseries.cpp index 29c20cd69..7d96f9337 100644 --- a/src/render/direct3d12/SDL_shaders_d3d12_xboxseries.cpp +++ b/src/render/direct3d12/SDL_shaders_d3d12_xboxseries.cpp @@ -20,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(__XBOXSERIES__) +#if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(SDL_PLATFORM_XBOXSERIES) #include @@ -139,6 +139,6 @@ D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE *o outBytecode->BytecodeLength = D3D12_rootsigs[rootSig].rs_shader_size; } -#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(__XBOXSERIES__) */ +#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(SDL_PLATFORM_XBOXSERIES) */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/metal/SDL_render_metal.m b/src/render/metal/SDL_render_metal.m index b471cfba5..516124e57 100644 --- a/src/render/metal/SDL_render_metal.m +++ b/src/render/metal/SDL_render_metal.m @@ -37,9 +37,9 @@ #endif /* Regenerate these with build-metal-shaders.sh */ -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS #include "SDL_shaders_metal_macos.h" -#elif defined(__TVOS__) +#elif defined(SDL_PLATFORM_TVOS) #if TARGET_OS_SIMULATOR #include "SDL_shaders_metal_tvsimulator.h" #else @@ -57,7 +57,7 @@ /* macOS requires constants in a buffer to have a 256 byte alignment. */ /* Use native type alignments from https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf */ -#if defined(__MACOS__) || TARGET_OS_SIMULATOR || TARGET_OS_MACCATALYST +#if defined(SDL_PLATFORM_MACOS) || TARGET_OS_SIMULATOR || TARGET_OS_MACCATALYST #define CONSTANT_ALIGN(x) (256) #else #define CONSTANT_ALIGN(x) (x < 4 ? 4 : x) @@ -161,7 +161,7 @@ typedef struct METAL_ShaderPipelines static SDL_bool IsMetalAvailable() { -#if (defined(__MACOS__) && (MAC_OS_X_VERSION_MIN_REQUIRED < 101100)) +#if (defined(SDL_PLATFORM_MACOS) && (MAC_OS_X_VERSION_MIN_REQUIRED < 101100)) // this checks a weak symbol. if (MTLCreateSystemDefaultDevice == NULL) { // probably on 10.10 or lower. SDL_SetError("Metal framework not available on this system"); @@ -1480,7 +1480,7 @@ static int METAL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, [data.mtlcmdencoder endEncoding]; mtltexture = data.mtlpassdesc.colorAttachments[0].texture; -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS /* on macOS with managed-storage textures, we need to tell the driver to * update the CPU-side copy of the texture data. * NOTE: Currently all of our textures are managed on macOS. We'll need some @@ -1611,7 +1611,7 @@ static void *METAL_GetMetalCommandEncoder(SDL_Renderer *renderer) static int METAL_SetVSync(SDL_Renderer *renderer, const int vsync) { -#if (defined(__MACOS__) && defined(MAC_OS_X_VERSION_10_13)) || TARGET_OS_MACCATALYST +#if (defined(SDL_PLATFORM_MACOS) && defined(MAC_OS_X_VERSION_10_13)) || TARGET_OS_MACCATALYST if (@available(macOS 10.13, *)) { METAL_RenderData *data = (__bridge METAL_RenderData *)renderer->driverdata; if (vsync) { @@ -1749,7 +1749,7 @@ static SDL_Renderer *METAL_CreateRenderer(SDL_Window *window, SDL_PropertiesID c return NULL; } -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS if (SDL_GetHintBoolean(SDL_HINT_RENDER_METAL_PREFER_LOW_POWER_DEVICE, SDL_TRUE)) { NSArray> *devices = MTLCopyAllDevices(); @@ -1801,7 +1801,7 @@ static SDL_Renderer *METAL_CreateRenderer(SDL_Window *window, SDL_PropertiesID c data.mtlview = view; -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS layer = (CAMetalLayer *)[(__bridge NSView *)view layer]; #else layer = (CAMetalLayer *)[(__bridge UIView *)view layer]; @@ -1922,7 +1922,7 @@ static SDL_Renderer *METAL_CreateRenderer(SDL_Window *window, SDL_PropertiesID c renderer->info = METAL_RenderDriver.info; renderer->info.flags = SDL_RENDERER_ACCELERATED; -#if (defined(__MACOS__) && defined(MAC_OS_X_VERSION_10_13)) || TARGET_OS_MACCATALYST +#if (defined(SDL_PLATFORM_MACOS) && defined(MAC_OS_X_VERSION_10_13)) || TARGET_OS_MACCATALYST if (@available(macOS 10.13, *)) { data.mtllayer.displaySyncEnabled = SDL_GetBooleanProperty(create_props, SDL_PROPERTY_RENDERER_CREATE_PRESENT_VSYNC_BOOLEAN, SDL_FALSE); if (data.mtllayer.displaySyncEnabled) { @@ -1936,9 +1936,9 @@ static SDL_Renderer *METAL_CreateRenderer(SDL_Window *window, SDL_PropertiesID c /* https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf */ maxtexsize = 4096; -#if defined(__MACOS__) || TARGET_OS_MACCATALYST +#if defined(SDL_PLATFORM_MACOS) || TARGET_OS_MACCATALYST maxtexsize = 16384; -#elif defined(__TVOS__) +#elif defined(SDL_PLATFORM_TVOS) maxtexsize = 8192; #ifdef __TVOS_11_0 if (@available(tvOS 11.0, *)) { diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index 9e57f550a..e47247907 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -27,7 +27,7 @@ #include "SDL_shaders_gl.h" #include "../../SDL_utils_c.h" -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS #include #endif @@ -427,7 +427,7 @@ static SDL_bool convert_format(GL_RenderData *renderdata, Uint32 pixel_format, *format = GL_LUMINANCE; *type = GL_UNSIGNED_BYTE; break; -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS case SDL_PIXELFORMAT_UYVY: *internalFormat = GL_RGB8; *format = GL_YCBCR_422_APPLE; @@ -552,7 +552,7 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr renderdata->glTexParameteri(textype, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS #ifndef GL_TEXTURE_STORAGE_HINT_APPLE #define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC #endif @@ -1238,7 +1238,7 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo } } -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS // On macOS on older systems, the OpenGL view change and resize events aren't // necessarily synchronized, so just always reset it. // Workaround for: https://discourse.libsdl.org/t/sdl-2-0-22-prerelease/35306/6 @@ -1642,13 +1642,13 @@ static SDL_bool GL_IsProbablyAccelerated(const GL_RenderData *data) /*const char *vendor = (const char *) data->glGetString(GL_VENDOR);*/ const char *renderer = (const char *)data->glGetString(GL_RENDERER); -#if defined(__WINDOWS__) || defined(__WINGDK__) +#if defined(SDL_PLATFORM_WINDOWS) || defined(SDL_PLATFORM_WINGDK) if (SDL_strcmp(renderer, "GDI Generic") == 0) { return SDL_FALSE; /* Microsoft's fallback software renderer. Fix your system! */ } #endif -#ifdef __APPLE__ +#ifdef SDL_PLATFORM_APPLE if (SDL_strcmp(renderer, "Apple Software Renderer") == 0) { return SDL_FALSE; /* (a probably very old) Apple software-based OpenGL. */ } @@ -1760,7 +1760,7 @@ static SDL_Renderer *GL_CreateRenderer(SDL_Window *window, SDL_PropertiesID crea renderer->info.flags |= SDL_RENDERER_ACCELERATED; } -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS /* Enable multi-threaded rendering */ /* Disabled until Ryan finishes his VBO/PBO code... CGLEnable(CGLGetCurrentContext(), kCGLCEMPEngine); @@ -1867,7 +1867,7 @@ static SDL_Renderer *GL_CreateRenderer(SDL_Window *window, SDL_PropertiesID crea renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_NV21; } #endif -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_UYVY; #endif diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index 5e63a4214..df1bb44b0 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -33,7 +33,7 @@ In all other cases, attempt to use client-side arrays, as they tend to be dramatically faster when not batching, and about the same when we are. */ -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN #define USE_VERTEX_BUFFER_OBJECTS 1 #else #define USE_VERTEX_BUFFER_OBJECTS 0 @@ -2100,7 +2100,7 @@ static SDL_Renderer *GLES2_CreateRenderer(SDL_Window *window, SDL_PropertiesID c goto error; } -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT /* DLudwig, 2013-11-29: ANGLE for WinRT doesn't seem to work unless VSync * is turned on. Not doing so will freeze the screen's contents to that * of the first drawn frame. diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c index 7689b68a5..bfb23a2ea 100644 --- a/src/render/software/SDL_rotate.c +++ b/src/render/software/SDL_rotate.c @@ -32,7 +32,7 @@ Andreas Schiffler -- aschiffler at ferzkopp dot net #if SDL_VIDEO_RENDER_SW && !defined(SDL_RENDER_DISABLED) -#if defined(__WIN32__) || defined(__GDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) #include "../../core/windows/SDL_windows.h" #endif diff --git a/src/stdlib/SDL_getenv.c b/src/stdlib/SDL_getenv.c index b8bceabaf..0eec441fc 100644 --- a/src/stdlib/SDL_getenv.c +++ b/src/stdlib/SDL_getenv.c @@ -20,15 +20,15 @@ */ #include "SDL_internal.h" -#if defined(__WIN32__) || defined(__WINGDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) #include "../core/windows/SDL_windows.h" #endif -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID #include "../core/android/SDL_android.h" #endif -#if (defined(__WIN32__) || defined(__WINGDK__)) && (!defined(HAVE_SETENV) || !defined(HAVE_GETENV)) +#if (defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK)) && (!defined(HAVE_SETENV) || !defined(HAVE_GETENV)) /* Note this isn't thread-safe! */ static char *SDL_envmem = NULL; /* Ugh, memory leak */ static size_t SDL_envmemlen = 0; @@ -46,7 +46,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite) return setenv(name, value, overwrite); } -#elif defined(__WIN32__) || defined(__WINGDK__) +#elif defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) int SDL_setenv(const char *name, const char *value, int overwrite) { /* Input validation */ @@ -163,7 +163,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite) #ifdef HAVE_GETENV char *SDL_getenv(const char *name) { -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID /* Make sure variables from the application manifest are available */ Android_JNI_GetManifestEnvironmentVariables(); #endif @@ -175,7 +175,7 @@ char *SDL_getenv(const char *name) return getenv(name); } -#elif defined(__WIN32__) || defined(__WINGDK__) +#elif defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) char *SDL_getenv(const char *name) { size_t bufferlen; diff --git a/src/stdlib/SDL_iconv.c b/src/stdlib/SDL_iconv.c index b4c444bdd..74dc965c0 100644 --- a/src/stdlib/SDL_iconv.c +++ b/src/stdlib/SDL_iconv.c @@ -120,7 +120,7 @@ static struct { "US-ASCII", ENCODING_ASCII }, { "8859-1", ENCODING_LATIN1 }, { "ISO-8859-1", ENCODING_LATIN1 }, -#if defined(__WIN32__) || defined(__OS2__) || defined(__GDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_OS2) || defined(SDL_PLATFORM_GDK) { "WCHAR_T", ENCODING_UTF16LE }, #else { "WCHAR_T", ENCODING_UCS4NATIVE }, diff --git a/src/stdlib/SDL_malloc.c b/src/stdlib/SDL_malloc.c index 3f6a8240a..895d8293f 100644 --- a/src/stdlib/SDL_malloc.c +++ b/src/stdlib/SDL_malloc.c @@ -496,13 +496,13 @@ DEFAULT_MMAP_THRESHOLD default: 256K #define MMAP_CLEARS 0 /* WINCE and some others apparently don't clear */ #endif /* WIN32 */ -#ifdef __OS2__ +#ifdef SDL_PLATFORM_OS2 #define INCL_DOS #include #define HAVE_MMAP 1 #define HAVE_MORECORE 0 #define LACKS_SYS_MMAN_H -#endif /* __OS2__ */ +#endif /* SDL_PLATFORM_OS2 */ #if defined(DARWIN) || defined(_DARWIN) /* Mac OSX docs advise not to use sbrk; it seems better to use mmap */ @@ -1238,7 +1238,7 @@ int mspace_mallopt(int, int); #ifndef LACKS_UNISTD_H #include /* for sbrk */ #else /* LACKS_UNISTD_H */ -#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__) +#if !defined(SDL_PLATFORM_FREEBSD) && !defined(SDL_PLATFORM_OPENBSD) && !defined(SDL_PLATFORM_NETBSD) && !defined(__DragonFly__) extern void* sbrk(ptrdiff_t); #endif /* FreeBSD etc */ #endif /* LACKS_UNISTD_H */ @@ -1342,7 +1342,7 @@ extern void* sbrk(ptrdiff_t); #define IS_MMAPPED_BIT (SIZE_T_ONE) #define USE_MMAP_BIT (SIZE_T_ONE) -#if !defined(WIN32) && !defined(__OS2__) +#if !defined(WIN32) && !defined(SDL_PLATFORM_OS2) #define CALL_MUNMAP(a, s) munmap((a), (s)) #define MMAP_PROT (PROT_READ|PROT_WRITE) #if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) @@ -1366,7 +1366,7 @@ static int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */ #define DIRECT_MMAP(s) CALL_MMAP(s) -#elif defined(__OS2__) +#elif defined(SDL_PLATFORM_OS2) /* OS/2 MMAP via DosAllocMem */ static void* os2mmap(size_t size) { @@ -1477,7 +1477,7 @@ static int win32munmap(void* ptr, size_t size) { unique mparams values are initialized only once. */ -#if !defined(WIN32) && !defined(__OS2__) +#if !defined(WIN32) && !defined(SDL_PLATFORM_OS2) /* By default use posix locks */ #include #define MLOCK_T pthread_mutex_t @@ -1491,7 +1491,7 @@ static MLOCK_T morecore_mutex = PTHREAD_MUTEX_INITIALIZER; static MLOCK_T magic_init_mutex = PTHREAD_MUTEX_INITIALIZER; -#elif defined(__OS2__) +#elif defined(SDL_PLATFORM_OS2) #define MLOCK_T HMTX #define INITIAL_LOCK(l) DosCreateMutexSem(0, l, 0, FALSE) #define ACQUIRE_LOCK(l) DosRequestMutexSem(*l, SEM_INDEFINITE_WAIT) @@ -2559,11 +2559,11 @@ static int init_mparams(void) { } RELEASE_MAGIC_INIT_LOCK(); -#if !defined(WIN32) && !defined(__OS2__) +#if !defined(WIN32) && !defined(SDL_PLATFORM_OS2) mparams.page_size = malloc_getpagesize; mparams.granularity = ((DEFAULT_GRANULARITY != 0)? DEFAULT_GRANULARITY : mparams.page_size); -#elif defined (__OS2__) +#elif defined (SDL_PLATFORM_OS2) /* if low-memory is used, os2munmap() would break if it were anything other than 64k */ mparams.page_size = 4096u; diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c index 3a54e2553..b702f09b0 100644 --- a/src/stdlib/SDL_string.c +++ b/src/stdlib/SDL_string.c @@ -24,7 +24,7 @@ #include "SDL_vacopy.h" -#ifdef __vita__ +#ifdef SDL_PLATFORM_VITA #include #endif @@ -327,7 +327,7 @@ static size_t SDL_ScanFloat(const char *text, double *valuep) int SDL_memcmp(const void *s1, const void *s2, size_t len) { -#ifdef __vita__ +#ifdef SDL_PLATFORM_VITA /* Using memcmp on NULL is UB per POSIX / C99 7.21.1/2. But, both linux and bsd allow that, with an exception: diff --git a/src/stdlib/SDL_vacopy.h b/src/stdlib/SDL_vacopy.h index e557b489d..e2c990222 100644 --- a/src/stdlib/SDL_vacopy.h +++ b/src/stdlib/SDL_vacopy.h @@ -20,7 +20,7 @@ */ /* Do our best to make sure va_copy is working */ -#ifdef __NGAGE__ +#ifdef SDL_PLATFORM_NGAGE #undef va_copy #define va_copy(dst, src) dst = src diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index 366e28da8..b2f587d50 100644 --- a/src/test/SDL_test_common.c +++ b/src/test/SDL_test_common.c @@ -1361,7 +1361,7 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state) } SDL_free((void *)modes); -#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) /* Print the D3D9 adapter index */ adapterIndex = SDL_Direct3D9GetAdapterIndex(displayID); SDL_Log("D3D9 Adapter Index: %d", adapterIndex); diff --git a/src/test/SDL_test_memory.c b/src/test/SDL_test_memory.c index f8c8d7b3b..aef696138 100644 --- a/src/test/SDL_test_memory.c +++ b/src/test/SDL_test_memory.c @@ -25,7 +25,7 @@ #include #endif -#ifdef __WINDOWS__ +#ifdef SDL_PLATFORM_WINDOWS #include #include @@ -153,7 +153,7 @@ static void SDL_TrackAllocation(void *mem, size_t size) } } } -#elif defined(__WINDOWS__) +#elif defined(SDL_PLATFORM_WINDOWS) { Uint32 count; PVOID frames[63]; @@ -295,7 +295,7 @@ void SDLTest_TrackAllocations(void) if (s_previous_allocations != 0) { SDL_Log("SDLTest_TrackAllocations(): There are %d previous allocations, disabling free() validation", s_previous_allocations); } -#ifdef __WINDOWS__ +#ifdef SDL_PLATFORM_WINDOWS { s_dbghelp = SDL_LoadObject("dbghelp.dll"); if (s_dbghelp) { diff --git a/src/thread/pthread/SDL_syssem.c b/src/thread/pthread/SDL_syssem.c index d41377279..738bb866f 100644 --- a/src/thread/pthread/SDL_syssem.c +++ b/src/thread/pthread/SDL_syssem.c @@ -28,7 +28,7 @@ /* Wrapper around POSIX 1003.1b semaphores */ -#if defined(__MACOS__) || defined(__IOS__) +#if defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) /* macOS doesn't support sem_getvalue() as of version 10.4 */ #include "../generic/SDL_syssem.c" #else @@ -177,4 +177,4 @@ int SDL_PostSemaphore(SDL_Semaphore *sem) return retval; } -#endif /* __MACOS__ */ +#endif /* SDL_PLATFORM_MACOS */ diff --git a/src/thread/pthread/SDL_systhread.c b/src/thread/pthread/SDL_systhread.c index 0ed72f23b..1d0fe77e4 100644 --- a/src/thread/pthread/SDL_systhread.c +++ b/src/thread/pthread/SDL_systhread.c @@ -29,16 +29,16 @@ #include #include -#ifdef __LINUX__ +#ifdef SDL_PLATFORM_LINUX #include #include #include #include #include "../../core/linux/SDL_dbus.h" -#endif /* __LINUX__ */ +#endif /* SDL_PLATFORM_LINUX */ -#if (defined(__LINUX__) || defined(__MACOS__) || defined(__IOS__)) && defined(HAVE_DLOPEN) +#if (defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS)) && defined(HAVE_DLOPEN) #include #ifndef RTLD_DEFAULT #define RTLD_DEFAULT NULL @@ -47,11 +47,11 @@ #include "../SDL_thread_c.h" #include "../SDL_systhread.h" -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID #include "../../core/android/SDL_android.h" #endif -#ifdef __HAIKU__ +#ifdef SDL_PLATFORM_HAIKU #include #endif @@ -63,17 +63,17 @@ static const int sig_list[] = { static void *RunThread(void *data) { -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID Android_JNI_SetupThread(); #endif SDL_RunThread((SDL_Thread *)data); return NULL; } -#if (defined(__MACOS__) || defined(__IOS__)) && defined(HAVE_DLOPEN) +#if (defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS)) && defined(HAVE_DLOPEN) static SDL_bool checked_setname = SDL_FALSE; static int (*ppthread_setname_np)(const char *) = NULL; -#elif defined(__LINUX__) && defined(HAVE_DLOPEN) +#elif defined(SDL_PLATFORM_LINUX) && defined(HAVE_DLOPEN) static SDL_bool checked_setname = SDL_FALSE; static int (*ppthread_setname_np)(pthread_t, const char *) = NULL; #endif @@ -82,12 +82,12 @@ int SDL_SYS_CreateThread(SDL_Thread *thread) pthread_attr_t type; /* do this here before any threads exist, so there's no race condition. */ -#if (defined(__MACOS__) || defined(__IOS__) || defined(__LINUX__)) && defined(HAVE_DLOPEN) +#if (defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_LINUX)) && defined(HAVE_DLOPEN) if (!checked_setname) { void *fn = dlsym(RTLD_DEFAULT, "pthread_setname_np"); -#if defined(__MACOS__) || defined(__IOS__) +#if defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) ppthread_setname_np = (int (*)(const char *))fn; -#elif defined(__LINUX__) +#elif defined(SDL_PLATFORM_LINUX) ppthread_setname_np = (int (*)(pthread_t, const char *))fn; #endif checked_setname = SDL_TRUE; @@ -119,12 +119,12 @@ void SDL_SYS_SetupThread(const char *name) sigset_t mask; if (name) { -#if (defined(__MACOS__) || defined(__IOS__) || defined(__LINUX__)) && defined(HAVE_DLOPEN) +#if (defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_LINUX)) && defined(HAVE_DLOPEN) SDL_assert(checked_setname); if (ppthread_setname_np) { -#if defined(__MACOS__) || defined(__IOS__) +#if defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) ppthread_setname_np(name); -#elif defined(__LINUX__) +#elif defined(SDL_PLATFORM_LINUX) if (ppthread_setname_np(pthread_self(), name) == ERANGE) { char namebuf[16]; /* Limited to 16 char */ SDL_strlcpy(namebuf, name, sizeof(namebuf)); @@ -133,7 +133,7 @@ void SDL_SYS_SetupThread(const char *name) #endif } #elif defined(HAVE_PTHREAD_SETNAME_NP) -#ifdef __NETBSD__ +#ifdef SDL_PLATFORM_NETBSD pthread_setname_np(pthread_self(), "%s", name); #else if (pthread_setname_np(pthread_self(), name) == ERANGE) { @@ -144,7 +144,7 @@ void SDL_SYS_SetupThread(const char *name) #endif #elif defined(HAVE_PTHREAD_SET_NAME_NP) pthread_set_name_np(pthread_self(), name); -#elif defined(__HAIKU__) +#elif defined(SDL_PLATFORM_HAIKU) /* The docs say the thread name can't be longer than B_OS_NAME_LENGTH. */ char namebuf[B_OS_NAME_LENGTH]; SDL_strlcpy(namebuf, name, sizeof(namebuf)); @@ -175,7 +175,7 @@ SDL_ThreadID SDL_GetCurrentThreadID(void) int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) { -#ifdef __RISCOS__ +#ifdef SDL_PLATFORM_RISCOS /* FIXME: Setting thread priority does not seem to be supported */ return 0; #else @@ -200,7 +200,7 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) break; case SDL_THREAD_PRIORITY_HIGH: case SDL_THREAD_PRIORITY_TIME_CRITICAL: -#if defined(__MACOS__) || defined(__IOS__) || defined(__TVOS__) +#if defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS) /* Apple requires SCHED_RR for high priority threads */ pri_policy = SCHED_RR; break; @@ -233,7 +233,7 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) policy = pri_policy; } -#ifdef __LINUX__ +#ifdef SDL_PLATFORM_LINUX { pid_t linuxTid = syscall(SYS_gettid); return SDL_LinuxSetThreadPriorityAndPolicy(linuxTid, priority, policy); @@ -247,7 +247,7 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) int min_priority = sched_get_priority_min(policy); int max_priority = sched_get_priority_max(policy); -#if defined(__MACOS__) || defined(__IOS__) || defined(__TVOS__) +#if defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS) if (min_priority == 15 && max_priority == 47) { /* Apple has a specific set of thread priorities */ if (priority == SDL_THREAD_PRIORITY_HIGH) { @@ -256,7 +256,7 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) sched.sched_priority = 37; } } else -#endif /* __MACOS__ || __IOS__ || __TVOS__ */ +#endif /* SDL_PLATFORM_MACOS || SDL_PLATFORM_IOS || SDL_PLATFORM_TVOS */ { sched.sched_priority = (min_priority + (max_priority - min_priority) / 2); if (priority == SDL_THREAD_PRIORITY_HIGH) { @@ -269,7 +269,7 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) } return 0; #endif /* linux */ -#endif /* #if __RISCOS__ */ +#endif /* #if SDL_PLATFORM_RISCOS */ } void SDL_SYS_WaitThread(SDL_Thread *thread) diff --git a/src/thread/stdcpp/SDL_systhread.cpp b/src/thread/stdcpp/SDL_systhread.cpp index 0dd8152b8..c3ef90a34 100644 --- a/src/thread/stdcpp/SDL_systhread.cpp +++ b/src/thread/stdcpp/SDL_systhread.cpp @@ -31,7 +31,7 @@ extern "C" { #include #include -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT #include #endif @@ -66,7 +66,7 @@ SDL_SYS_SetupThread(const char *name) extern "C" SDL_ThreadID SDL_GetCurrentThreadID(void) { -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT return GetCurrentThreadId(); #else // HACK: Mimic a thread ID, if one isn't otherwise available. @@ -87,7 +87,7 @@ SDL_GetCurrentThreadID(void) extern "C" int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) { -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT int value; if (priority == SDL_THREAD_PRIORITY_LOW) { diff --git a/src/thread/windows/SDL_syscond_cv.c b/src/thread/windows/SDL_syscond_cv.c index 4dd4d97a6..338e86c58 100644 --- a/src/thread/windows/SDL_syscond_cv.c +++ b/src/thread/windows/SDL_syscond_cv.c @@ -56,7 +56,7 @@ typedef struct CONDITION_VARIABLE } CONDITION_VARIABLE, *PCONDITION_VARIABLE; #endif -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT #define pWakeConditionVariable WakeConditionVariable #define pWakeAllConditionVariable WakeAllConditionVariable #define pSleepConditionVariableSRW SleepConditionVariableSRW @@ -186,7 +186,7 @@ static const SDL_cond_impl_t SDL_cond_impl_cv = { }; -#ifndef __WINRT__ +#ifndef SDL_PLATFORM_WINRT /* Generic Condition Variable implementation using SDL_Mutex and SDL_Semaphore */ static const SDL_cond_impl_t SDL_cond_impl_generic = { &SDL_CreateCondition_generic, @@ -213,7 +213,7 @@ SDL_Condition *SDL_CreateCondition(void) SDL_assert(SDL_mutex_impl_active.Type != SDL_MUTEX_INVALID); } -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT /* Link statically on this platform */ impl = &SDL_cond_impl_cv; #else diff --git a/src/thread/windows/SDL_sysmutex.c b/src/thread/windows/SDL_sysmutex.c index 7272b00e7..6b1083ef4 100644 --- a/src/thread/windows/SDL_sysmutex.c +++ b/src/thread/windows/SDL_sysmutex.c @@ -39,7 +39,7 @@ SDL_mutex_impl_t SDL_mutex_impl_active = { 0 }; * Implementation based on Slim Reader/Writer (SRW) Locks for Win 7 and newer. */ -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT /* Functions are guaranteed to be available */ #define pInitializeSRWLock InitializeSRWLock #define pReleaseSRWLockExclusive ReleaseSRWLockExclusive @@ -143,7 +143,7 @@ static SDL_Mutex *SDL_CreateMutex_cs(void) if (mutex) { // Initialize // On SMP systems, a non-zero spin count generally helps performance -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT InitializeCriticalSectionEx(&mutex->cs, 2000, 0); #else InitializeCriticalSectionAndSpinCount(&mutex->cs, 2000); @@ -197,7 +197,7 @@ SDL_Mutex *SDL_CreateMutex(void) const SDL_mutex_impl_t *impl = &SDL_mutex_impl_cs; if (!SDL_GetHintBoolean(SDL_HINT_WINDOWS_FORCE_MUTEX_CRITICAL_SECTIONS, SDL_FALSE)) { -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT // Link statically on this platform impl = &SDL_mutex_impl_srw; #else diff --git a/src/thread/windows/SDL_sysrwlock_srw.c b/src/thread/windows/SDL_sysrwlock_srw.c index a972f455f..6eb6bd3c0 100644 --- a/src/thread/windows/SDL_sysrwlock_srw.c +++ b/src/thread/windows/SDL_sysrwlock_srw.c @@ -35,7 +35,7 @@ typedef VOID(WINAPI *pfnReleaseSRWLockExclusive)(PSRWLOCK); typedef VOID(WINAPI *pfnAcquireSRWLockExclusive)(PSRWLOCK); typedef BOOLEAN(WINAPI *pfnTryAcquireSRWLockExclusive)(PSRWLOCK); -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT /* Functions are guaranteed to be available */ #define pTryAcquireSRWLockExclusive TryAcquireSRWLockExclusive #define pInitializeSRWLock InitializeSRWLock @@ -163,7 +163,7 @@ static const SDL_rwlock_impl_t SDL_rwlock_impl_srw = { &SDL_UnlockRWLock_srw }; -#ifndef __WINRT__ +#ifndef SDL_PLATFORM_WINRT #include "../generic/SDL_sysrwlock_c.h" @@ -184,7 +184,7 @@ SDL_RWLock *SDL_CreateRWLock(void) if (!SDL_rwlock_impl_active.Create) { const SDL_rwlock_impl_t *impl; -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT /* Link statically on this platform */ impl = &SDL_rwlock_impl_srw; #else diff --git a/src/thread/windows/SDL_syssem.c b/src/thread/windows/SDL_syssem.c index 7ad6f619a..b231a65b1 100644 --- a/src/thread/windows/SDL_syssem.c +++ b/src/thread/windows/SDL_syssem.c @@ -61,7 +61,7 @@ static SDL_sem_impl_t SDL_sem_impl_active = { 0 }; /* https://www.microsoft.com/en-us/download/details.aspx?id=47328 */ #if !SDL_WINAPI_FAMILY_PHONE -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT /* Functions are guaranteed to be available */ #define pWaitOnAddress WaitOnAddress #define pWakeByAddressSingle WakeByAddressSingle @@ -223,7 +223,7 @@ static SDL_Semaphore *SDL_CreateSemaphore_kern(Uint32 initial_value) if (sem) { /* Create the semaphore, with max value 32K */ // !!! FIXME: CreateSemaphoreEx is available in Vista and later, so if XP support is dropped, we can lose this #ifdef. -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT sem->id = CreateSemaphoreEx(NULL, initial_value, 32 * 1024, NULL, 0, SEMAPHORE_ALL_ACCESS); #else sem->id = CreateSemaphore(NULL, initial_value, 32 * 1024, NULL); @@ -331,7 +331,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) #if !SDL_WINAPI_FAMILY_PHONE if (!SDL_GetHintBoolean(SDL_HINT_WINDOWS_FORCE_SEMAPHORE_KERNEL, SDL_FALSE)) { -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT /* Link statically on this platform */ impl = &SDL_sem_impl_atom; #else diff --git a/src/thread/windows/SDL_systhread.c b/src/thread/windows/SDL_systhread.c index e2643f099..b3ae5adc0 100644 --- a/src/thread/windows/SDL_systhread.c +++ b/src/thread/windows/SDL_systhread.c @@ -68,7 +68,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread) { -#elif defined(__CYGWIN__) || defined(__WINRT__) +#elif defined(SDL_PLATFORM_CYGWIN) || defined(SDL_PLATFORM_WINRT) int SDL_SYS_CreateThread(SDL_Thread *thread) { pfnSDL_CurrentBeginThread pfnBeginThread = NULL; @@ -124,7 +124,7 @@ void SDL_SYS_SetupThread(const char *name) { if (name) { PVOID exceptionHandlerHandle; -#ifndef __WINRT__ /* !!! FIXME: There's no LoadLibrary() in WinRT; don't know if SetThreadDescription is available there at all at the moment. */ +#ifndef SDL_PLATFORM_WINRT /* !!! FIXME: There's no LoadLibrary() in WinRT; don't know if SetThreadDescription is available there at all at the moment. */ static pfnSetThreadDescription pSetThreadDescription = NULL; static HMODULE kernel32 = NULL; diff --git a/src/timer/SDL_timer.c b/src/timer/SDL_timer.c index 28cab901a..f7ffe6ba3 100644 --- a/src/timer/SDL_timer.c +++ b/src/timer/SDL_timer.c @@ -25,7 +25,7 @@ /* #define DEBUG_TIMERS */ -#if !defined(__EMSCRIPTEN__) || !defined(SDL_THREADS_DISABLED) +#if !defined(SDL_PLATFORM_EMSCRIPTEN) || !defined(SDL_THREADS_DISABLED) typedef struct SDL_Timer { @@ -461,7 +461,7 @@ SDL_bool SDL_RemoveTimer(SDL_TimerID id) return SDL_FALSE; } -#endif /* !defined(__EMSCRIPTEN__) || !SDL_THREADS_DISABLED */ +#endif /* !defined(SDL_PLATFORM_EMSCRIPTEN) || !SDL_THREADS_DISABLED */ static Uint64 tick_start; static Uint32 tick_numerator_ns; @@ -470,7 +470,7 @@ static Uint32 tick_numerator_ms; static Uint32 tick_denominator_ms; #if defined(SDL_TIMER_WINDOWS) && \ - !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) + !defined(SDL_PLATFORM_WINRT) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #include #define HAVE_TIME_BEGIN_PERIOD #endif diff --git a/src/timer/unix/SDL_systimer.c b/src/timer/unix/SDL_systimer.c index a9c6ccbb8..0a0c5e807 100644 --- a/src/timer/unix/SDL_systimer.c +++ b/src/timer/unix/SDL_systimer.c @@ -29,7 +29,7 @@ #include "../SDL_timer_c.h" -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN #include #endif @@ -47,7 +47,7 @@ #if defined(HAVE_NANOSLEEP) || defined(HAVE_CLOCK_GETTIME) #include #endif -#ifdef __APPLE__ +#ifdef SDL_PLATFORM_APPLE #include #endif @@ -61,7 +61,7 @@ #endif /* The first ticks value of the application */ -#if !defined(HAVE_CLOCK_GETTIME) && defined(__APPLE__) +#if !defined(HAVE_CLOCK_GETTIME) && defined(SDL_PLATFORM_APPLE) mach_timebase_info_data_t mach_base_info; #endif static SDL_bool checked_monotonic_time = SDL_FALSE; @@ -74,7 +74,7 @@ static void CheckMonotonicTime(void) if (clock_gettime(SDL_MONOTONIC_CLOCK, &value) == 0) { has_monotonic_time = SDL_TRUE; } else -#elif defined(__APPLE__) +#elif defined(SDL_PLATFORM_APPLE) if (mach_timebase_info(&mach_base_info) == 0) { has_monotonic_time = SDL_TRUE; } @@ -98,7 +98,7 @@ Uint64 SDL_GetPerformanceCounter(void) ticks = now.tv_sec; ticks *= SDL_NS_PER_SECOND; ticks += now.tv_nsec; -#elif defined(__APPLE__) +#elif defined(SDL_PLATFORM_APPLE) ticks = mach_absolute_time(); #else SDL_assert(SDL_FALSE); @@ -124,7 +124,7 @@ Uint64 SDL_GetPerformanceFrequency(void) if (has_monotonic_time) { #ifdef HAVE_CLOCK_GETTIME return SDL_NS_PER_SECOND; -#elif defined(__APPLE__) +#elif defined(SDL_PLATFORM_APPLE) Uint64 freq = mach_base_info.denom; freq *= SDL_NS_PER_SECOND; freq /= mach_base_info.numer; @@ -146,7 +146,7 @@ void SDL_DelayNS(Uint64 ns) Uint64 then, now, elapsed; #endif -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN if (emscripten_has_asyncify() && SDL_GetHintBoolean(SDL_HINT_EMSCRIPTEN_ASYNCIFY, SDL_TRUE)) { /* pseudo-synchronous pause, used directly or through e.g. SDL_WaitEvent */ emscripten_sleep(ns / SDL_NS_PER_MS); diff --git a/src/timer/windows/SDL_systimer.c b/src/timer/windows/SDL_systimer.c index 54f56de18..d82d6f8bc 100644 --- a/src/timer/windows/SDL_systimer.c +++ b/src/timer/windows/SDL_systimer.c @@ -100,7 +100,7 @@ void SDL_DelayNS(Uint64 ns) ns = max_delay; } -#if defined(__WINRT__) && defined(_MSC_FULL_VER) && (_MSC_FULL_VER <= 180030723) +#if defined(SDL_PLATFORM_WINRT) && defined(_MSC_FULL_VER) && (_MSC_FULL_VER <= 180030723) static HANDLE mutex = 0; if (!mutex) { mutex = CreateEventEx(0, 0, 0, EVENT_ALL_ACCESS); diff --git a/src/video/SDL_blit.c b/src/video/SDL_blit.c index 71854c8ea..350d95843 100644 --- a/src/video/SDL_blit.c +++ b/src/video/SDL_blit.c @@ -99,7 +99,7 @@ static int SDLCALL SDL_SoftBlit(SDL_Surface *src, const SDL_Rect *srcrect, #if SDL_HAVE_BLIT_AUTO -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS #include static SDL_bool SDL_UseAltivecPrefetch(void) @@ -120,7 +120,7 @@ static SDL_bool SDL_UseAltivecPrefetch(void) /* Just guess G4 */ return SDL_TRUE; } -#endif /* __MACOS__ */ +#endif /* SDL_PLATFORM_MACOS */ static SDL_BlitFunc SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, SDL_BlitFuncEntry *entries) diff --git a/src/video/SDL_blit_N.c b/src/video/SDL_blit_N.c index 49d86a74f..dc2f786c1 100644 --- a/src/video/SDL_blit_N.c +++ b/src/video/SDL_blit_N.c @@ -46,7 +46,7 @@ enum blit_features }; #ifdef SDL_ALTIVEC_BLITTERS -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS #include static size_t GetL3CacheSize(void) { @@ -67,9 +67,9 @@ static size_t GetL3CacheSize(void) /* XXX: Just guess G4 */ return 2097152; } -#endif /* __MACOS__ */ +#endif /* SDL_PLATFORM_MACOS */ -#if (defined(__MACOS__) && (__GNUC__ < 4)) +#if (defined(SDL_PLATFORM_MACOS) && (__GNUC__ < 4)) #define VECUINT8_LITERAL(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) \ (vector unsigned char)(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) #define VECUINT16_LITERAL(a, b, c, d, e, f, g, h) \ diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c index 0adf1d77f..41573360a 100644 --- a/src/video/SDL_egl.c +++ b/src/video/SDL_egl.c @@ -89,7 +89,7 @@ #define DEFAULT_OGL_ES_PVR "libGLES_CM.dylib" //??? #define DEFAULT_OGL_ES "libGLESv1_CM.dylib" //??? -#elif defined(__OpenBSD__) +#elif defined(SDL_PLATFORM_OPENBSD) /* OpenBSD */ #define DEFAULT_OGL "libGL.so" #define DEFAULT_EGL "libEGL.so" @@ -260,7 +260,7 @@ SDL_FunctionPointer SDL_EGL_GetProcAddressInternal(SDL_VideoDevice *_this, const retval = _this->egl_data->eglGetProcAddress(proc); } -#if !defined(__EMSCRIPTEN__) && !defined(SDL_VIDEO_DRIVER_VITA) /* LoadFunction isn't needed on Emscripten and will call dlsym(), causing other problems. */ +#if !defined(SDL_PLATFORM_EMSCRIPTEN) && !defined(SDL_VIDEO_DRIVER_VITA) /* LoadFunction isn't needed on Emscripten and will call dlsym(), causing other problems. */ /* Try SDL_LoadFunction() first for EGL <= 1.4, or as a fallback for >= 1.5. */ if (!retval) { retval = SDL_LoadFunction(_this->egl_data->opengl_dll_handle, proc); @@ -512,7 +512,7 @@ int SDL_EGL_LoadLibrary(SDL_VideoDevice *_this, const char *egl_path, NativeDisp _this->egl_data->egl_display = EGL_NO_DISPLAY; -#ifndef __WINRT__ +#ifndef SDL_PLATFORM_WINRT #ifndef SDL_VIDEO_DRIVER_VITA if (platform) { /* EGL 1.5 allows querying for client version with EGL_NO_DISPLAY diff --git a/src/video/SDL_stretch.c b/src/video/SDL_stretch.c index 2566c3988..94551dab9 100644 --- a/src/video/SDL_stretch.c +++ b/src/video/SDL_stretch.c @@ -337,7 +337,7 @@ static int scale_mat(const Uint32 *src, int src_w, int src_h, int src_pitch, #define CAST_uint32x2_t (uint32x2_t) #endif -#if defined(__WINRT__) || defined(_MSC_VER) +#if defined(SDL_PLATFORM_WINRT) || defined(_MSC_VER) #ifdef SDL_NEON_INTRINSICS #undef CAST_uint8x8_t #undef CAST_uint32x2_t diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index be6f8a857..b45281832 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -53,11 +53,11 @@ #endif #endif -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN #include #endif -#ifdef __LINUX__ +#ifdef SDL_PLATFORM_LINUX #include #include #include @@ -155,7 +155,7 @@ static VideoBootStrap *bootstrap[] = { return retval; \ } -#if defined(__MACOS__) && defined(SDL_VIDEO_DRIVER_COCOA) +#if defined(SDL_PLATFORM_MACOS) && defined(SDL_VIDEO_DRIVER_COCOA) /* Support for macOS fullscreen spaces */ extern SDL_bool Cocoa_IsWindowInFullscreenSpace(SDL_Window *window); extern SDL_bool Cocoa_SetWindowFullscreenSpace(SDL_Window *window, SDL_bool state, SDL_bool blocking); @@ -208,12 +208,12 @@ typedef struct static Uint32 SDL_DefaultGraphicsBackends(SDL_VideoDevice *_this) { -#if (defined(SDL_VIDEO_OPENGL) && defined(__MACOS__)) || (defined(__IOS__) && !TARGET_OS_MACCATALYST) || defined(__ANDROID__) +#if (defined(SDL_VIDEO_OPENGL) && defined(SDL_PLATFORM_MACOS)) || (defined(SDL_PLATFORM_IOS) && !TARGET_OS_MACCATALYST) || defined(SDL_PLATFORM_ANDROID) if (_this->GL_CreateContext) { return SDL_WINDOW_OPENGL; } #endif -#if defined(SDL_VIDEO_METAL) && (TARGET_OS_MACCATALYST || defined(__MACOS__) || defined(__IOS__)) +#if defined(SDL_VIDEO_METAL) && (TARGET_OS_MACCATALYST || defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS)) if (_this->Metal_CreateView) { return SDL_WINDOW_METAL; } @@ -1511,7 +1511,7 @@ static void SDL_CheckWindowDisplayScaleChanged(SDL_Window *window) } } -#ifdef __WINRT__ +#ifdef SDL_PLATFORM_WINRT extern Uint32 WINRT_DetectWindowFlags(SDL_Window *window); #endif @@ -1570,7 +1570,7 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen, SDL_bool c } } -#if defined(__MACOS__) && defined(SDL_VIDEO_DRIVER_COCOA) +#if defined(SDL_PLATFORM_MACOS) && defined(SDL_VIDEO_DRIVER_COCOA) /* if the window is going away and no resolution change is necessary, do nothing, or else we may trigger an ugly double-transition */ @@ -1606,7 +1606,7 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen, SDL_bool c } } } -#elif defined(__WINRT__) && (NTDDI_VERSION < NTDDI_WIN10) +#elif defined(SDL_PLATFORM_WINRT) && (NTDDI_VERSION < NTDDI_WIN10) /* HACK: WinRT 8.x apps can't choose whether or not they are fullscreen or not. The user can choose this, via OS-provided UI, but this can't be set programmatically. @@ -2144,13 +2144,13 @@ SDL_Window *SDL_CreateWindowWithProperties(SDL_PropertiesID props) /* Clear minimized if not on windows, only windows handles it at create rather than FinishWindowCreation, * but it's important or window focus will get broken on windows! */ -#if !defined(__WIN32__) && !defined(__GDK__) +#if !defined(SDL_PLATFORM_WIN32) && !defined(SDL_PLATFORM_GDK) if (window->flags & SDL_WINDOW_MINIMIZED) { window->flags &= ~SDL_WINDOW_MINIMIZED; } #endif -#if defined(__WINRT__) && (NTDDI_VERSION < NTDDI_WIN10) +#if defined(SDL_PLATFORM_WINRT) && (NTDDI_VERSION < NTDDI_WIN10) /* HACK: WinRT 8.x apps can't choose whether or not they are fullscreen or not. The user can choose this, via OS-provided UI, but this can't be set programmatically. @@ -3028,7 +3028,7 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window) attempt_texture_framebuffer = SDL_FALSE; } -#ifdef __LINUX__ +#ifdef SDL_PLATFORM_LINUX /* On WSL, direct X11 is faster than using OpenGL for window framebuffers, so try to detect WSL and avoid texture framebuffer. */ else if ((_this->CreateWindowFramebuffer) && (SDL_strcmp(_this->name, "x11") == 0)) { struct stat sb; @@ -3037,12 +3037,12 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window) } } #endif -#if defined(__WIN32__) || defined(__WINGDK__) /* GDI BitBlt() is way faster than Direct3D dynamic textures right now. (!!! FIXME: is this still true?) */ +#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?) */ else if ((_this->CreateWindowFramebuffer) && (SDL_strcmp(_this->name, "windows") == 0)) { attempt_texture_framebuffer = SDL_FALSE; } #endif -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN else { attempt_texture_framebuffer = SDL_FALSE; } @@ -3529,7 +3529,7 @@ static SDL_bool SDL_ShouldMinimizeOnFocusLoss(SDL_Window *window) return SDL_FALSE; } -#if defined(__MACOS__) && defined(SDL_VIDEO_DRIVER_COCOA) +#if defined(SDL_PLATFORM_MACOS) && defined(SDL_VIDEO_DRIVER_COCOA) if (SDL_strcmp(_this->name, "cocoa") == 0) { /* don't do this for X11, etc */ if (Cocoa_IsWindowInFullscreenSpace(window)) { return SDL_FALSE; @@ -3537,7 +3537,7 @@ static SDL_bool SDL_ShouldMinimizeOnFocusLoss(SDL_Window *window) } #endif -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID { extern SDL_bool Android_JNI_ShouldMinimizeOnFocusLoss(void); if (!Android_JNI_ShouldMinimizeOnFocusLoss()) { @@ -4951,7 +4951,7 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) int SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window) { -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN /* !!! FIXME: propose a browser API for this, get this #ifdef out of here? */ /* Web browsers don't (currently) have an API for a custom message box that can block, but for the most common case (SDL_ShowSimpleMessageBox), diff --git a/src/video/SDL_video_capture.c b/src/video/SDL_video_capture.c index 1d05b4423..357240fbb 100644 --- a/src/video/SDL_video_capture.c +++ b/src/video/SDL_video_capture.c @@ -853,15 +853,15 @@ SDL_QuitVideoCapture(void) #ifdef SDL_VIDEO_CAPTURE -#if defined(__linux__) && !defined(__ANDROID__) +#if defined(SDL_PLATFORM_LINUX) && !defined(SDL_PLATFORM_ANDROID) /* See SDL_video_capture_v4l2.c */ -#elif defined(__ANDROID__) && __ANDROID_API__ >= 24 +#elif defined(SDL_PLATFORM_ANDROID) && __ANDROID_API__ >= 24 /* See SDL_android_video_capture.c */ -#elif defined(__IOS__) || defined(__MACOS__) +#elif defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_MACOS) /* See SDL_video_capture_apple.m */ #else diff --git a/src/video/SDL_video_capture_apple.m b/src/video/SDL_video_capture_apple.m index 7e88ea08a..e63ce3099 100644 --- a/src/video/SDL_video_capture_apple.m +++ b/src/video/SDL_video_capture_apple.m @@ -28,7 +28,7 @@ #include "SDL_video_capture_c.h" #include "../thread/SDL_systhread.h" -#if defined(HAVE_COREMEDIA) && defined(__MACOS__) && (__MAC_OS_X_VERSION_MAX_ALLOWED < 101500) +#if defined(HAVE_COREMEDIA) && defined(SDL_PLATFORM_MACOS) && (__MAC_OS_X_VERSION_MAX_ALLOWED < 101500) /* AVCaptureDeviceTypeBuiltInWideAngleCamera requires macOS SDK 10.15 */ #undef HAVE_COREMEDIA #endif @@ -183,7 +183,7 @@ nsfourcc_to_sdlformat(NSString *nsfourcc) * on macos, 1 plane/ YVYU * */ -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS if (SDL_strcmp("420v", str) == 0) return SDL_PIXELFORMAT_YVYU; #else if (SDL_strcmp("420v", str) == 0) return SDL_PIXELFORMAT_NV12; @@ -202,7 +202,7 @@ sdlformat_to_nsfourcc(Uint32 fmt) const char *str = ""; NSString *result; -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS if (fmt == SDL_PIXELFORMAT_YVYU) str = "420v"; #else if (fmt == SDL_PIXELFORMAT_NV12) str = "420v"; @@ -298,7 +298,7 @@ InitDevice(SDL_VideoCaptureDevice *_this) AVCaptureDeviceFormat *spec_format = nil; -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS if (@available(macOS 10.15, *)) { /* good. */ } else { @@ -359,7 +359,7 @@ InitDevice(SDL_VideoCaptureDevice *_this) // Output output = [[AVCaptureVideoDataOutput alloc] init]; -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS // FIXME this now fail on ios ... but not using anything works... // Specify the pixel format diff --git a/src/video/SDL_video_capture_v4l2.c b/src/video/SDL_video_capture_v4l2.c index 3edc26322..01e46d709 100644 --- a/src/video/SDL_video_capture_v4l2.c +++ b/src/video/SDL_video_capture_v4l2.c @@ -34,7 +34,7 @@ #define DEBUG_VIDEO_CAPTURE_CAPTURE 0 -#if defined(__linux__) && !defined(__ANDROID__) +#if defined(SDL_PLATFORM_LINUX) && !defined(SDL_PLATFORM_ANDROID) #define MAX_CAPTURE_DEVICES 128 /* It's doubtful someone has more than that */ diff --git a/src/video/SDL_video_unsupported.c b/src/video/SDL_video_unsupported.c index ce8a808fa..e7a986ee6 100644 --- a/src/video/SDL_video_unsupported.c +++ b/src/video/SDL_video_unsupported.c @@ -22,7 +22,7 @@ #ifndef SDL_VIDEO_DRIVER_WINDOWS -#if defined(__WIN32__) || defined(__GDK__) +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) int SDL_RegisterApp(const char *name, Uint32 style, void *hInst) { @@ -40,7 +40,7 @@ void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata) { } -#endif /* __WIN32__ || __GDK__ */ +#endif /* SDL_PLATFORM_WIN32 || SDL_PLATFORM_GDK */ DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int *outputIndex); SDL_bool SDL_DXGIGetOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int *outputIndex) @@ -59,7 +59,7 @@ int SDL_Direct3D9GetAdapterIndex(SDL_DisplayID displayID) return SDL_Unsupported(); } -#elif defined(__XBOXONE__) || defined(__XBOXSERIES__) +#elif defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex(SDL_DisplayID displayID); int SDL_Direct3D9GetAdapterIndex(SDL_DisplayID displayID) @@ -70,7 +70,7 @@ int SDL_Direct3D9GetAdapterIndex(SDL_DisplayID displayID) #endif /* !SDL_VIDEO_DRIVER_WINDOWS */ -#ifndef __GDK__ +#ifndef SDL_PLATFORM_GDK DECLSPEC int SDLCALL SDL_GDKGetTaskQueue(void *outTaskQueue); int SDL_GDKGetTaskQueue(void *outTaskQueue) diff --git a/src/video/android/SDL_android_video_capture.c b/src/video/android/SDL_android_video_capture.c index 55393b08b..3ec5cd1ba 100644 --- a/src/video/android/SDL_android_video_capture.c +++ b/src/video/android/SDL_android_video_capture.c @@ -29,7 +29,7 @@ #define DEBUG_VIDEO_CAPTURE_CAPTURE 0 -#if defined(__ANDROID__) && __ANDROID_API__ >= 24 +#if defined(SDL_PLATFORM_ANDROID) && __ANDROID_API__ >= 24 /* * APP_PLATFORM=android-24 diff --git a/src/video/arm/pixman-arm-neon-asm.S b/src/video/arm/pixman-arm-neon-asm.S index f9549621a..0df7f5a95 100644 --- a/src/video/arm/pixman-arm-neon-asm.S +++ b/src/video/arm/pixman-arm-neon-asm.S @@ -44,7 +44,7 @@ */ /* Prevent the stack from becoming executable for no reason... */ -#if defined(__linux__) && defined(__ELF__) +#if defined(SDL_PLATFORM_LINUX) && defined(__ELF__) .section .note.GNU-stack,"",%progbits #endif diff --git a/src/video/arm/pixman-arm-simd-asm.S b/src/video/arm/pixman-arm-simd-asm.S index 57449c5f3..57d246a84 100644 --- a/src/video/arm/pixman-arm-simd-asm.S +++ b/src/video/arm/pixman-arm-simd-asm.S @@ -19,7 +19,7 @@ */ /* Prevent the stack from becoming executable */ -#if defined(__linux__) && defined(__ELF__) +#if defined(SDL_PLATFORM_LINUX) && defined(__ELF__) .section .note.GNU-stack,"",%progbits #endif diff --git a/src/video/khronos/EGL/eglplatform.h b/src/video/khronos/EGL/eglplatform.h index 6001eb936..31015a0bd 100644 --- a/src/video/khronos/EGL/eglplatform.h +++ b/src/video/khronos/EGL/eglplatform.h @@ -54,7 +54,7 @@ typedef void *EGLNativeDisplayType; typedef void *EGLNativePixmapType; typedef void *EGLNativeWindowType; -#elif defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */ +#elif defined(_WIN32) || defined(__VC32__) && !defined(SDL_PLATFORM_CYGWIN) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */ #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif @@ -88,7 +88,7 @@ typedef struct gbm_device *EGLNativeDisplayType; typedef struct gbm_bo *EGLNativePixmapType; typedef void *EGLNativeWindowType; -#elif defined(__ANDROID__) || defined(ANDROID) +#elif defined(SDL_PLATFORM_ANDROID) || defined(ANDROID) struct ANativeWindow; struct egl_native_pixmap_t; @@ -125,7 +125,7 @@ typedef int EGLNativeDisplayType; typedef void *EGLNativePixmapType; typedef void *EGLNativeWindowType; -#elif defined(__HAIKU__) +#elif defined(SDL_PLATFORM_HAIKU) #include diff --git a/src/video/khronos/KHR/khrplatform.h b/src/video/khronos/KHR/khrplatform.h index 1ef3e8dc3..810ffac4e 100644 --- a/src/video/khronos/KHR/khrplatform.h +++ b/src/video/khronos/KHR/khrplatform.h @@ -107,7 +107,7 @@ # define KHRONOS_APICALL __declspec(dllimport) #elif defined (__SYMBIAN32__) # define KHRONOS_APICALL IMPORT_C -#elif defined(__ANDROID__) +#elif defined(SDL_PLATFORM_ANDROID) # define KHRONOS_APICALL __attribute__((visibility("default"))) #else # define KHRONOS_APICALL diff --git a/src/video/khronos/vulkan/vk_platform.h b/src/video/khronos/vulkan/vk_platform.h index 3ff8c5d14..94c976e4b 100644 --- a/src/video/khronos/vulkan/vk_platform.h +++ b/src/video/khronos/vulkan/vk_platform.h @@ -41,9 +41,9 @@ extern "C" #define VKAPI_ATTR #define VKAPI_CALL __stdcall #define VKAPI_PTR VKAPI_CALL -#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7 +#elif defined(SDL_PLATFORM_ANDROID) && defined(__ARM_ARCH) && __ARM_ARCH < 7 #error "Vulkan is not supported for the 'armeabi' NDK ABI" -#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE) +#elif defined(SDL_PLATFORM_ANDROID) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE) // On Android 32-bit ARM targets, Vulkan functions use the "hardfloat" // calling convention, i.e. float parameters are passed in registers. This // is true even if the rest of the application passes floats on the stack, diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c index 988fdfca3..58c08d852 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -49,7 +49,7 @@ #include #include -#ifdef __OpenBSD__ +#ifdef SDL_PLATFORM_OPENBSD static SDL_bool moderndri = SDL_FALSE; #else static SDL_bool moderndri = SDL_TRUE; @@ -191,13 +191,13 @@ static float CalculateRefreshRate(drmModeModeInfo *mode) static int KMSDRM_Available(void) { -#ifdef __OpenBSD__ +#ifdef SDL_PLATFORM_OPENBSD struct utsname nameofsystem; double releaseversion; #endif int ret = -ENOENT; -#ifdef __OpenBSD__ +#ifdef SDL_PLATFORM_OPENBSD if (!(uname(&nameofsystem) < 0)) { releaseversion = SDL_atof(nameofsystem.release); if (releaseversion >= 6.9) { diff --git a/src/video/kmsdrm/SDL_kmsdrmvulkan.c b/src/video/kmsdrm/SDL_kmsdrmvulkan.c index a3f463eaf..b0cb13475 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvulkan.c +++ b/src/video/kmsdrm/SDL_kmsdrmvulkan.c @@ -36,7 +36,7 @@ #include -#ifdef __OpenBSD__ +#ifdef SDL_PLATFORM_OPENBSD #define DEFAULT_VULKAN "libvulkan.so" #else #define DEFAULT_VULKAN "libvulkan.so.1" diff --git a/src/video/wayland/SDL_waylandvulkan.c b/src/video/wayland/SDL_waylandvulkan.c index 7debe29f4..a38865bdf 100644 --- a/src/video/wayland/SDL_waylandvulkan.c +++ b/src/video/wayland/SDL_waylandvulkan.c @@ -34,7 +34,7 @@ #include "../SDL_vulkan_internal.h" #include "SDL_waylandvulkan.h" -#ifdef __OpenBSD__ +#ifdef SDL_PLATFORM_OPENBSD #define DEFAULT_VULKAN "libvulkan.so" #else #define DEFAULT_VULKAN "libvulkan.so.1" diff --git a/src/video/windows/SDL_windowsclipboard.c b/src/video/windows/SDL_windowsclipboard.c index b9c788af1..2cd129cd7 100644 --- a/src/video/windows/SDL_windowsclipboard.c +++ b/src/video/windows/SDL_windowsclipboard.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #include "SDL_windowsvideo.h" #include "SDL_windowswindow.h" diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index 19588af03..d54b5ea41 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -45,7 +45,7 @@ #include "wmmsg.h" #endif -#ifdef __GDK__ +#ifdef SDL_PLATFORM_GDK #include "../../core/gdk/SDL_gdk.h" #endif @@ -169,11 +169,11 @@ static SDL_Scancode WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam) } else { Uint16 vkCode = LOWORD(wParam); -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) /* Windows may not report scan codes for some buttons (multimedia buttons etc). * Get scan code from the VK code.*/ scanCode = LOWORD(MapVirtualKey(vkCode, MAPVK_VK_TO_VSC_EX)); -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ /* Pause/Break key have a special scan code with 0xe1 prefix. * Use Pause scan code that is used in Win32. */ @@ -189,7 +189,7 @@ static SDL_Scancode WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam) return code; } -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) static SDL_bool WIN_ShouldIgnoreFocusClick(SDL_WindowData *data) { return !SDL_WINDOW_IS_POPUP(data->window) && @@ -398,14 +398,14 @@ static void WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus) data->in_window_deactivation = SDL_FALSE; } } -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ static SDL_bool ShouldGenerateWindowCloseOnAltF4(void) { return !SDL_GetHintBoolean(SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4, SDL_FALSE); } -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) /* We want to generate mouse events from mouse and pen, and touch events from touchscreens */ #define MI_WP_SIGNATURE 0xFF515700 #define MI_WP_SIGNATURE_MASK 0xFFFFFF00 @@ -440,7 +440,7 @@ static SDL_MOUSE_EVENT_SOURCE GetMouseMessageSource(ULONG extrainfo) } return SDL_MOUSE_EVENT_SOURCE_MOUSE; } -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ static SDL_WindowData *WIN_GetWindowDataFromHWND(HWND hwnd) { @@ -458,7 +458,7 @@ static SDL_WindowData *WIN_GetWindowDataFromHWND(HWND hwnd) return NULL; } -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) LRESULT CALLBACK WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam) { @@ -696,7 +696,7 @@ void WIN_PollRawMouseInput(void) data->last_rawinput_poll = now; } -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) @@ -706,7 +706,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) /* Get the window data for the window */ data = WIN_GetWindowDataFromHWND(hwnd); -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) if (!data) { /* Fallback */ data = (SDL_WindowData *)GetProp(hwnd, TEXT("SDL_WindowData")); @@ -728,7 +728,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } #endif /* WMMSG_DEBUG */ -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) if (IME_HandleMessage(hwnd, msg, wParam, &lParam, data->videodata)) { return 0; } @@ -745,7 +745,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } } break; -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) case WM_NCACTIVATE: { /* Don't immediately clip the cursor in case we're clicking minimize/maximize buttons */ @@ -906,7 +906,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) returnCode = 0; break; -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ case WM_KEYDOWN: case WM_SYSKEYDOWN: @@ -984,7 +984,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) returnCode = 0; break; -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #ifdef WM_INPUTLANGCHANGE case WM_INPUTLANGCHANGE: { @@ -1610,7 +1610,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } break; -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ } /* If there's a window proc, assume it's going to handle messages */ @@ -1623,7 +1623,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } } -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) static void WIN_UpdateClipCursorForWindows() { SDL_VideoDevice *_this = SDL_GetVideoDevice(); @@ -1672,7 +1672,7 @@ static void WIN_UpdateMouseCapture() } } } -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ /* A message hook called before TranslateMessage() */ static SDL_WindowsMessageHook g_WindowsMessageHook = NULL; @@ -1739,7 +1739,7 @@ void WIN_PumpEvents(SDL_VideoDevice *_this) #pragma warning(pop) #endif int new_messages = 0; -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) const Uint8 *keystate; SDL_Window *focusWindow; #endif @@ -1754,7 +1754,7 @@ void WIN_PumpEvents(SDL_VideoDevice *_this) } } -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) /* Don't dispatch any mouse motion queued prior to or including the last mouse warp */ if (msg.message == WM_MOUSEMOVE && SDL_last_warp_time) { if (!SDL_TICKS_PASSED(msg.time, (SDL_last_warp_time + 1))) { @@ -1764,7 +1764,7 @@ void WIN_PumpEvents(SDL_VideoDevice *_this) /* This mouse message happened after the warp */ SDL_last_warp_time = 0; } -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ WIN_SetMessageTick(msg.time); @@ -1789,7 +1789,7 @@ void WIN_PumpEvents(SDL_VideoDevice *_this) SDL_processing_messages = SDL_FALSE; } -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) /* Windows loses a shift KEYUP event when you have both pressed at once and let go of one. You won't get a KEYUP until both are released, and that keyup will only be for the second key you released. Take heroic measures and check the keystate as of the last handled event, @@ -1820,9 +1820,9 @@ void WIN_PumpEvents(SDL_VideoDevice *_this) /* Update mouse capture */ WIN_UpdateMouseCapture(); -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ -#ifdef __GDK__ +#ifdef SDL_PLATFORM_GDK GDK_DispatchTaskQueue(); #endif } @@ -1834,7 +1834,7 @@ HINSTANCE SDL_Instance = NULL; static void WIN_CleanRegisterApp(WNDCLASSEX wcex) { -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) if (wcex.hIcon) { DestroyIcon(wcex.hIcon); } @@ -1850,7 +1850,7 @@ static void WIN_CleanRegisterApp(WNDCLASSEX wcex) int SDL_RegisterApp(const char *name, Uint32 style, void *hInst) { WNDCLASSEX wcex; -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) const char *hint; TCHAR path[MAX_PATH]; #endif @@ -1885,7 +1885,7 @@ int SDL_RegisterApp(const char *name, Uint32 style, void *hInst) wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) hint = SDL_GetHint(SDL_HINT_WINDOWS_INTRESOURCE_ICON); if (hint && *hint) { wcex.hIcon = LoadIcon(SDL_Instance, MAKEINTRESOURCE(SDL_atoi(hint))); @@ -1899,7 +1899,7 @@ int SDL_RegisterApp(const char *name, Uint32 style, void *hInst) GetModuleFileName(SDL_Instance, path, MAX_PATH); ExtractIconEx(path, 0, &wcex.hIcon, &wcex.hIconSm, 1); } -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ if (!RegisterClassEx(&wcex)) { WIN_CleanRegisterApp(wcex); @@ -1925,7 +1925,7 @@ void SDL_UnregisterApp() wcex.hIcon = NULL; wcex.hIconSm = NULL; /* Check for any registered window classes. */ -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) if (GetClassInfoEx(SDL_Instance, SDL_Appname, &wcex)) { UnregisterClass(SDL_Appname, SDL_Instance); } diff --git a/src/video/windows/SDL_windowsframebuffer.c b/src/video/windows/SDL_windowsframebuffer.c index bdc7fe0fc..015634063 100644 --- a/src/video/windows/SDL_windowsframebuffer.c +++ b/src/video/windows/SDL_windowsframebuffer.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #include "SDL_windowsvideo.h" diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c index 633fe6766..6df84b3ab 100644 --- a/src/video/windows/SDL_windowskeyboard.c +++ b/src/video/windows/SDL_windowskeyboard.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #include "SDL_windowsvideo.h" diff --git a/src/video/windows/SDL_windowsmessagebox.c b/src/video/windows/SDL_windowsmessagebox.c index 82aca552b..fb076087f 100644 --- a/src/video/windows/SDL_windowsmessagebox.c +++ b/src/video/windows/SDL_windowsmessagebox.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #ifdef HAVE_LIMITS_H #include diff --git a/src/video/windows/SDL_windowsmodes.c b/src/video/windows/SDL_windowsmodes.c index 804835902..b9fed2f9f 100644 --- a/src/video/windows/SDL_windowsmodes.c +++ b/src/video/windows/SDL_windowsmodes.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #include "SDL_windowsvideo.h" #include "../../events/SDL_displayevents_c.h" diff --git a/src/video/windows/SDL_windowsmouse.c b/src/video/windows/SDL_windowsmouse.c index 07625887d..d6f847ad6 100644 --- a/src/video/windows/SDL_windowsmouse.c +++ b/src/video/windows/SDL_windowsmouse.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #include "SDL_windowsvideo.h" #include "SDL_windowsevents.h" diff --git a/src/video/windows/SDL_windowsopengl.c b/src/video/windows/SDL_windowsopengl.c index 6d4e90e9f..feb124666 100644 --- a/src/video/windows/SDL_windowsopengl.c +++ b/src/video/windows/SDL_windowsopengl.c @@ -95,7 +95,7 @@ typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC hDC, const int *attribList); -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) #define GetDC(hwnd) (HDC) hwnd #define ReleaseDC(hwnd, hdc) 1 #define SwapBuffers _this->gl_data->wglSwapBuffers @@ -143,7 +143,7 @@ int WIN_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) SDL_LoadFunction(handle, "wglShareLists"); /* *INDENT-ON* */ /* clang-format on */ -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) _this->gl_data->wglSwapBuffers = (BOOL(WINAPI *)(HDC)) SDL_LoadFunction(handle, "wglSwapBuffers"); _this->gl_data->wglDescribePixelFormat = (int(WINAPI *)(HDC, int, UINT, LPPIXELFORMATDESCRIPTOR)) @@ -160,7 +160,7 @@ int WIN_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) !_this->gl_data->wglCreateContext || !_this->gl_data->wglDeleteContext || !_this->gl_data->wglMakeCurrent -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) || !_this->gl_data->wglSwapBuffers || !_this->gl_data->wglDescribePixelFormat || !_this->gl_data->wglChoosePixelFormat || diff --git a/src/video/windows/SDL_windowsopengl.h b/src/video/windows/SDL_windowsopengl.h index 9780f664f..ee987d91d 100644 --- a/src/video/windows/SDL_windowsopengl.h +++ b/src/video/windows/SDL_windowsopengl.h @@ -25,7 +25,7 @@ #ifdef SDL_VIDEO_OPENGL_WGL -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) typedef struct tagPIXELFORMATDESCRIPTOR { WORD nSize; @@ -85,7 +85,7 @@ struct SDL_GLDriverData BOOL (WINAPI *wglGetPixelFormatAttribivARB)(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); BOOL (WINAPI *wglSwapIntervalEXT)(int interval); int (WINAPI *wglGetSwapIntervalEXT)(void); -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) BOOL (WINAPI *wglSwapBuffers)(HDC hdc); int (WINAPI *wglDescribePixelFormat)(HDC hdc, int iPixelFormat, diff --git a/src/video/windows/SDL_windowsopengles.c b/src/video/windows/SDL_windowsopengles.c index 7847b904b..5136bf8d8 100644 --- a/src/video/windows/SDL_windowsopengles.c +++ b/src/video/windows/SDL_windowsopengles.c @@ -20,7 +20,7 @@ */ #include "SDL_internal.h" -#if defined(SDL_VIDEO_DRIVER_WINDOWS) && defined(SDL_VIDEO_OPENGL_EGL) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && defined(SDL_VIDEO_OPENGL_EGL) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #include "SDL_windowsvideo.h" #include "SDL_windowsopengles.h" diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c index 4789fe1d1..7b4385a9c 100644 --- a/src/video/windows/SDL_windowsvideo.c +++ b/src/video/windows/SDL_windowsvideo.c @@ -64,7 +64,7 @@ static void SDLCALL UpdateWindowFrameUsableWhileCursorHidden(void *userdata, con g_WindowFrameUsableWhileCursorHidden = SDL_GetStringBoolean(newValue, SDL_TRUE); } -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) static int WIN_SuspendScreenSaver(SDL_VideoDevice *_this) { if (_this->suspend_screensaver) { @@ -76,7 +76,7 @@ static int WIN_SuspendScreenSaver(SDL_VideoDevice *_this) } #endif -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) extern void D3D12_XBOX_GetResolution(Uint32 *width, Uint32 *height); #endif @@ -87,7 +87,7 @@ static void WIN_DeleteDevice(SDL_VideoDevice *device) SDL_VideoData *data = device->driverdata; SDL_UnregisterApp(); -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) if (data->userDLL) { SDL_UnloadObject(data->userDLL); } @@ -124,7 +124,7 @@ static SDL_VideoDevice *WIN_CreateDevice(void) device->wakeup_lock = SDL_CreateMutex(); device->system_theme = WIN_GetSystemTheme(); -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) data->userDLL = SDL_LoadObject("USER32.DLL"); if (data->userDLL) { /* *INDENT-OFF* */ /* clang-format off */ @@ -155,12 +155,12 @@ static SDL_VideoDevice *WIN_CreateDevice(void) } else { SDL_ClearError(); } -#endif /* #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) */ +#endif /* #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) */ /* Set the function pointers */ device->VideoInit = WIN_VideoInit; device->VideoQuit = WIN_VideoQuit; -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) device->RefreshDisplays = WIN_RefreshDisplays; device->GetDisplayBounds = WIN_GetDisplayBounds; device->GetDisplayUsableBounds = WIN_GetDisplayUsableBounds; @@ -169,7 +169,7 @@ static SDL_VideoDevice *WIN_CreateDevice(void) #endif device->PumpEvents = WIN_PumpEvents; device->WaitEventTimeout = WIN_WaitEventTimeout; -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) device->SendWakeupEvent = WIN_SendWakeupEvent; device->SuspendScreenSaver = WIN_SuspendScreenSaver; #endif @@ -192,14 +192,14 @@ static SDL_VideoDevice *WIN_CreateDevice(void) device->SetWindowResizable = WIN_SetWindowResizable; device->SetWindowAlwaysOnTop = WIN_SetWindowAlwaysOnTop; device->SetWindowFullscreen = WIN_SetWindowFullscreen; -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) device->GetWindowICCProfile = WIN_GetWindowICCProfile; device->SetWindowMouseRect = WIN_SetWindowMouseRect; device->SetWindowMouseGrab = WIN_SetWindowMouseGrab; device->SetWindowKeyboardGrab = WIN_SetWindowKeyboardGrab; #endif device->DestroyWindow = WIN_DestroyWindow; -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) device->CreateWindowFramebuffer = WIN_CreateWindowFramebuffer; device->UpdateWindowFramebuffer = WIN_UpdateWindowFramebuffer; device->DestroyWindowFramebuffer = WIN_DestroyWindowFramebuffer; @@ -249,7 +249,7 @@ static SDL_VideoDevice *WIN_CreateDevice(void) device->Vulkan_CreateSurface = WIN_Vulkan_CreateSurface; #endif -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) device->StartTextInput = WIN_StartTextInput; device->StopTextInput = WIN_StopTextInput; device->SetTextInputRect = WIN_SetTextInputRect; @@ -286,7 +286,7 @@ static SDL_VideoDevice *WIN_CreateDevice(void) VideoBootStrap WINDOWS_bootstrap = { "windows", "SDL Windows video driver", WIN_CreateDevice, - #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) + #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) WIN_ShowMessageBox #else NULL @@ -295,7 +295,7 @@ VideoBootStrap WINDOWS_bootstrap = { static BOOL WIN_DeclareDPIAwareUnaware(SDL_VideoDevice *_this) { -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) SDL_VideoData *data = _this->driverdata; if (data->SetProcessDpiAwarenessContext) { @@ -310,7 +310,7 @@ static BOOL WIN_DeclareDPIAwareUnaware(SDL_VideoDevice *_this) static BOOL WIN_DeclareDPIAwareSystem(SDL_VideoDevice *_this) { -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) SDL_VideoData *data = _this->driverdata; if (data->SetProcessDpiAwarenessContext) { @@ -329,7 +329,7 @@ static BOOL WIN_DeclareDPIAwareSystem(SDL_VideoDevice *_this) static BOOL WIN_DeclareDPIAwarePerMonitor(SDL_VideoDevice *_this) { -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) SDL_VideoData *data = _this->driverdata; if (data->SetProcessDpiAwarenessContext) { @@ -349,7 +349,7 @@ static BOOL WIN_DeclareDPIAwarePerMonitor(SDL_VideoDevice *_this) static BOOL WIN_DeclareDPIAwarePerMonitorV2(SDL_VideoDevice *_this) { -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) return FALSE; #else SDL_VideoData *data = _this->driverdata; @@ -435,7 +435,7 @@ int WIN_VideoInit(SDL_VideoDevice *_this) SDL_Log("DPI awareness: %s", WIN_GetDPIAwareness(_this)); #endif -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) /* For Xbox, we just need to create the single display */ { SDL_DisplayMode mode; @@ -447,7 +447,7 @@ int WIN_VideoInit(SDL_VideoDevice *_this) SDL_AddBasicVideoDisplay(&mode); } -#else /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#else /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ if (WIN_InitModes(_this) < 0) { return -1; } @@ -460,7 +460,7 @@ int WIN_VideoInit(SDL_VideoDevice *_this) SDL_AddHintCallback(SDL_HINT_WINDOWS_ENABLE_MENU_MNEMONICS, UpdateWindowsEnableMenuMnemonics, NULL); SDL_AddHintCallback(SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN, UpdateWindowFrameUsableWhileCursorHidden, NULL); -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) data->_SDL_WAKEUP = RegisterWindowMessageA("_SDL_WAKEUP"); #endif @@ -469,14 +469,14 @@ int WIN_VideoInit(SDL_VideoDevice *_this) void WIN_VideoQuit(SDL_VideoDevice *_this) { -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) WIN_QuitModes(_this); WIN_QuitKeyboard(_this); WIN_QuitMouse(_this); #endif } -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #define D3D_DEBUG_INFO #include @@ -576,7 +576,7 @@ int SDL_Direct3D9GetAdapterIndex(SDL_DisplayID displayID) return adapterIndex; } } -#endif /* !defined(__XBOXONE__) && !defined(__XBOXSERIES__) */ +#endif /* !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) */ #ifdef HAVE_DXGI_H #define CINTERFACE @@ -712,7 +712,7 @@ SDL_SystemTheme WIN_GetSystemTheme(void) SDL_bool WIN_IsPerMonitorV2DPIAware(SDL_VideoDevice *_this) { -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) SDL_VideoData *data = _this->driverdata; if (data->AreDpiAwarenessContextsEqual && data->GetThreadDpiAwarenessContext) { diff --git a/src/video/windows/SDL_windowsvideo.h b/src/video/windows/SDL_windowsvideo.h index 925e4b2e3..2e9f18286 100644 --- a/src/video/windows/SDL_windowsvideo.h +++ b/src/video/windows/SDL_windowsvideo.h @@ -27,7 +27,7 @@ #include "../SDL_sysvideo.h" -#if defined(_MSC_VER) && (_MSC_VER >= 1500) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if defined(_MSC_VER) && (_MSC_VER >= 1500) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #include #else #include "SDL_msctf.h" @@ -43,7 +43,7 @@ #include "SDL_windowsevents.h" #include "SDL_windowsopengl.h" -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) #include "SDL_windowskeyboard.h" #include "SDL_windowsmodes.h" #include "SDL_windowsmouse.h" @@ -374,7 +374,7 @@ struct SDL_VideoData DWORD clipboard_count; -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* Xbox doesn't support user32/shcore*/ +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) /* Xbox doesn't support user32/shcore*/ /* Touch input functions */ void *userDLL; /* *INDENT-OFF* */ /* clang-format off */ @@ -401,7 +401,7 @@ struct SDL_VideoData UINT *dpiY ); HRESULT (WINAPI *SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS dpiAwareness); /* *INDENT-ON* */ /* clang-format on */ -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ SDL_bool cleared; diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index 2cab61dce..7b30ca7d7 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -192,7 +192,7 @@ static int WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, DWORD expanding the window client area to the previous window + chrome size, so shouldn't need to adjust the window size for the set styles. */ if (!(window->flags & SDL_WINDOW_BORDERLESS)) { -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) AdjustWindowRectEx(&rect, style, menu, 0); #else if (WIN_IsPerMonitorV2DPIAware(SDL_GetVideoDevice())) { @@ -240,7 +240,7 @@ int WIN_AdjustWindowRect(SDL_Window *window, int *x, int *y, int *width, int *he style = GetWindowLong(hwnd, GWL_STYLE); styleEx = GetWindowLong(hwnd, GWL_EXSTYLE); -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) menu = FALSE; #else menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL); @@ -257,13 +257,13 @@ int WIN_AdjustWindowRectForHWND(HWND hwnd, LPRECT lpRect, UINT frame_dpi) style = GetWindowLong(hwnd, GWL_STYLE); styleEx = GetWindowLong(hwnd, GWL_EXSTYLE); -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) menu = FALSE; #else menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL); #endif -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) AdjustWindowRectEx(lpRect, style, menu, styleEx); #else if (WIN_IsPerMonitorV2DPIAware(videodevice)) { @@ -336,7 +336,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd data->window = window; data->hwnd = hwnd; data->parent = parent; -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) data->hdc = (HDC)data->hwnd; #else data->hdc = GetDC(hwnd); @@ -361,7 +361,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd window->driverdata = data; -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) /* Associate the data with the window */ if (!SetProp(hwnd, TEXT("SDL_WindowData"), data)) { ReleaseDC(hwnd, data->hdc); @@ -411,7 +411,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd } } } -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) { POINT point; point.x = 0; @@ -461,7 +461,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd window->flags &= ~SDL_WINDOW_MINIMIZED; } } -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) window->flags |= SDL_WINDOW_INPUT_FOCUS; #else if (GetFocus() == hwnd) { @@ -477,7 +477,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd WIN_SetWindowAlwaysOnTop(_this, window, SDL_FALSE); } -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) /* Enable multi-touch */ if (videodata->RegisterTouchWindow) { videodata->RegisterTouchWindow(hwnd, (TWF_FINETOUCH | TWF_WANTPALM)); @@ -490,7 +490,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd data->initializing = SDL_FALSE; -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) if (window->flags & SDL_WINDOW_EXTERNAL) { /* Query the title from the existing window */ LPTSTR title; @@ -511,7 +511,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd SDL_small_free(title, isstack); } } -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ SDL_PropertiesID props = SDL_GetWindowProperties(window); SDL_SetProperty(props, SDL_PROPERTY_WINDOW_WIN32_HWND_POINTER, data->hwnd); @@ -529,7 +529,7 @@ static void CleanupWindowData(SDL_VideoDevice *_this, SDL_Window *window) if (data) { SDL_DelHintCallback(SDL_HINT_MOUSE_RELATIVE_MODE_CENTER, WIN_MouseRelativeModeCenterChanged, data); -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) if (data->ICMFileName) { SDL_free(data->ICMFileName); } @@ -556,9 +556,9 @@ static void CleanupWindowData(SDL_VideoDevice *_this, SDL_Window *window) #endif } } -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) SDL_free(data->rawinput); -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ SDL_free(data); } window->driverdata = NULL; @@ -676,7 +676,7 @@ int WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI } } -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) /* FIXME: does not work on all hardware configurations with different renders (i.e. hybrid GPUs) */ if (window->flags & SDL_WINDOW_TRANSPARENT) { void *handle = SDL_LoadObject("dwmapi.dll"); @@ -744,14 +744,14 @@ int WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI return SDL_SetError("Could not create GL window (WGL support not configured)"); #endif } -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ return 0; } void WIN_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window) { -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) HWND hwnd = window->driverdata->hwnd; LPTSTR title = WIN_UTF8ToString(window->title); SetWindowText(hwnd, title); @@ -761,7 +761,7 @@ void WIN_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window) int WIN_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *icon) { -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) HWND hwnd = window->driverdata->hwnd; HICON hicon = NULL; BYTE *icon_bmp; @@ -856,7 +856,7 @@ void WIN_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) int WIN_GetWindowBordersSize(SDL_VideoDevice *_this, SDL_Window *window, int *top, int *left, int *bottom, int *right) { -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) HWND hwnd = window->driverdata->hwnd; RECT rcClient; @@ -870,7 +870,7 @@ int WIN_GetWindowBordersSize(SDL_VideoDevice *_this, SDL_Window *window, int *to *right = rcClient.right; return 0; -#else /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#else /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ HWND hwnd = window->driverdata->hwnd; RECT rcClient, rcWindow; POINT ptDiff; @@ -918,7 +918,7 @@ int WIN_GetWindowBordersSize(SDL_VideoDevice *_this, SDL_Window *window, int *to *right = rcWindow.right - rcClient.right; return 0; -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ } void WIN_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int *w, int *h) @@ -989,7 +989,7 @@ void WIN_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) void WIN_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window) { -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) /* If desired, raise the window more forcefully. * Technique taken from http://stackoverflow.com/questions/916259/ . * Specifically, http://stackoverflow.com/a/34414846 . @@ -1033,7 +1033,7 @@ void WIN_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window) SetFocus(hwnd); SetActiveWindow(hwnd); } -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ } void WIN_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window) @@ -1114,7 +1114,7 @@ void WIN_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window) */ int WIN_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen) { -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) SDL_DisplayData *displaydata = display->driverdata; SDL_WindowData *data = window->driverdata; HWND hwnd = data->hwnd; @@ -1198,11 +1198,11 @@ int WIN_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_Vide SDL_Log("WIN_SetWindowFullscreen: %d finished. Set window to %d,%d, %dx%d", (int)fullscreen, x, y, w, h); #endif -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ return 0; } -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) void WIN_UpdateWindowICCProfile(SDL_Window *window, SDL_bool send_event) { SDL_WindowData *data = window->driverdata; @@ -1310,7 +1310,7 @@ void WIN_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_b WIN_UngrabKeyboard(window); } } -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ void WIN_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) { @@ -1383,7 +1383,7 @@ void SDL_HelperWindowDestroy(void) } } -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) void WIN_OnWindowEnter(SDL_VideoDevice *_this, SDL_Window *window) { SDL_WindowData *data = window->driverdata; @@ -1499,11 +1499,11 @@ int WIN_SetWindowHitTest(SDL_Window *window, SDL_bool enabled) { return 0; /* just succeed, the real work is done elsewhere. */ } -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ int WIN_SetWindowOpacity(SDL_VideoDevice *_this, SDL_Window *window, float opacity) { -#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) return -1; #else const SDL_WindowData *data = window->driverdata; @@ -1534,10 +1534,10 @@ int WIN_SetWindowOpacity(SDL_VideoDevice *_this, SDL_Window *window, float opaci } return 0; -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ } -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) void WIN_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept) { const SDL_WindowData *data = window->driverdata; @@ -1606,7 +1606,7 @@ int WIN_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool return 0; } -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ void WIN_UpdateDarkModeForHWND(HWND hwnd) { diff --git a/src/video/windows/SDL_windowswindow.h b/src/video/windows/SDL_windowswindow.h index 49659a106..3c887df47 100644 --- a/src/video/windows/SDL_windowswindow.h +++ b/src/video/windows/SDL_windowswindow.h @@ -67,13 +67,13 @@ struct SDL_WindowData SDL_bool windowed_mode_was_maximized; SDL_bool in_window_deactivation; RECT cursor_clipped_rect; -#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) RAWINPUT *rawinput; UINT rawinput_offset; UINT rawinput_size; UINT rawinput_count; Uint64 last_rawinput_poll; -#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ SDL_Point last_raw_mouse_position; SDL_bool mouse_tracked; SDL_bool destroy_parent_with_window; diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c index f4abb6959..0a7d696f2 100644 --- a/src/video/x11/SDL_x11opengl.c +++ b/src/video/x11/SDL_x11opengl.c @@ -30,14 +30,14 @@ #ifdef SDL_VIDEO_OPENGL_GLX #include "SDL_x11opengles.h" -#if defined(__IRIX__) || defined(__NetBSD__) || defined(__OpenBSD__) +#if defined(SDL_PLATFORM_IRIX) || defined(SDL_PLATFORM_NETBSD) || defined(SDL_PLATFORM_OPENBSD) /* * IRIX doesn't have a GL library versioning system. * NetBSD and OpenBSD have different GL library versions depending on how * the library was installed. */ #define DEFAULT_OPENGL "libGL.so" -#elif defined(__MACOS__) +#elif defined(SDL_PLATFORM_MACOS) #define DEFAULT_OPENGL "/opt/X11/lib/libGL.1.dylib" #else #define DEFAULT_OPENGL "libGL.so.1" diff --git a/src/video/x11/SDL_x11sym.h b/src/video/x11/SDL_x11sym.h index 78436c1f9..168c766c5 100644 --- a/src/video/x11/SDL_x11sym.h +++ b/src/video/x11/SDL_x11sym.h @@ -247,7 +247,7 @@ SDL_X11_SYM(void,_XRead32,(Display *dpy,register long *data,long len),(dpy,data, /* * These only show up on some variants of Unix. */ -#ifdef __osf__ +#ifdef SDL_PLATFORM_OSF SDL_X11_MODULE(OSF_ENTRY_POINTS) SDL_X11_SYM(void,_SmtBufferOverflow,(Display *dpy,register smtDisplayPtr p),(dpy,p),) SDL_X11_SYM(void,_SmtIpError,(Display *dpy,register smtDisplayPtr p,int i),(dpy,p,i),) diff --git a/src/video/x11/SDL_x11vulkan.c b/src/video/x11/SDL_x11vulkan.c index e92b5928f..88223ad65 100644 --- a/src/video/x11/SDL_x11vulkan.c +++ b/src/video/x11/SDL_x11vulkan.c @@ -31,7 +31,7 @@ #include /*#include */ -#ifdef __OpenBSD__ +#ifdef SDL_PLATFORM_OPENBSD #define DEFAULT_VULKAN "libvulkan.so" #else #define DEFAULT_VULKAN "libvulkan.so.1" diff --git a/test/checkkeys.c b/test/checkkeys.c index a5a27ff31..6c1cefba1 100644 --- a/test/checkkeys.c +++ b/test/checkkeys.c @@ -15,14 +15,14 @@ pump the event loop and catch keystrokes. */ -#ifdef __EMSCRIPTEN__ -#include -#endif - #include #include #include +#ifdef SDL_PLATFORM_EMSCRIPTEN +#include +#endif + static SDLTest_CommonState *state; static SDLTest_TextWindow *textwin; static int done; @@ -228,7 +228,7 @@ static void loop(void) /* Slow down framerate */ SDL_Delay(100); -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN if (done) { emscripten_cancel_main_loop(); } @@ -266,7 +266,7 @@ int main(int argc, char *argv[]) SDL_GetWindowSize(state->windows[0], &w, &h); textwin = SDLTest_TextWindowCreate(0.f, 0.f, (float)w, (float)h); -#ifdef __IOS__ +#ifdef SDL_PLATFORM_IOS { int i; /* Creating the context creates the view, which we need to show keyboard */ @@ -285,7 +285,7 @@ int main(int argc, char *argv[]) /* Watch keystrokes */ done = 0; -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop(loop, 0, 1); #else while (!done) { diff --git a/test/checkkeysthreads.c b/test/checkkeysthreads.c index 549244ce4..d04975117 100644 --- a/test/checkkeysthreads.c +++ b/test/checkkeysthreads.c @@ -15,17 +15,17 @@ pump the event loop and catch keystrokes. */ -#include -#include - -#ifdef __EMSCRIPTEN__ -#include -#endif - #include #include #include +#ifdef SDL_PLATFORM_EMSCRIPTEN +#include +#endif + +#include +#include + static int done; /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ @@ -214,7 +214,7 @@ static void loop(void) } (void)fprintf(stderr, "exiting event loop\n"); (void)fflush(stderr); -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN if (done) { emscripten_cancel_main_loop(); } @@ -279,7 +279,7 @@ int main(int argc, char *argv[]) renderer = SDL_CreateRenderer(window, NULL, 0); SDL_RenderPresent(renderer); -#ifdef __IOS__ +#ifdef SDL_PLATFORM_IOS /* Creating the context creates the view, which we need to show keyboard */ SDL_GL_CreateContext(window); #endif @@ -295,7 +295,7 @@ int main(int argc, char *argv[]) thread = SDL_CreateThread(ping_thread, "PingThread", NULL); -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop(loop, 0, 1); #else while (!done) { diff --git a/test/testaudio.c b/test/testaudio.c index 0738b1884..3f19333cf 100644 --- a/test/testaudio.c +++ b/test/testaudio.c @@ -644,7 +644,7 @@ static Thing *LoadWavThing(const char *fname, float x, float y) static const ThingType can_be_dropped_onto[] = { THING_TRASHCAN, THING_NULL }; char *titlebar = NULL; const char *nodirs = SDL_strrchr(fname, '/'); - #ifdef __WINDOWS__ + #ifdef SDL_PLATFORM_WINDOWS const char *nodirs2 = SDL_strrchr(nodirs ? nodirs : fname, '\\'); if (nodirs2) { nodirs = nodirs2; diff --git a/test/testaudiohotplug.c b/test/testaudiohotplug.c index daac0f7f5..79bb14d31 100644 --- a/test/testaudiohotplug.c +++ b/test/testaudiohotplug.c @@ -12,21 +12,21 @@ /* Program to test hotplugging of audio devices */ +#include +#include +#include +#include "testutils.h" + +#ifdef SDL_PLATFORM_EMSCRIPTEN +#include +#endif + #include #ifdef HAVE_SIGNAL_H #include #endif -#ifdef __EMSCRIPTEN__ -#include -#endif - -#include -#include -#include -#include "testutils.h" - static SDL_AudioSpec spec; static Uint8 *sound = NULL; /* Pointer to wave data */ static Uint32 soundlen = 0; /* Length of wave data */ @@ -101,7 +101,7 @@ static void iteration(void) } } -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN static void loop(void) { if (done) @@ -194,7 +194,7 @@ int main(int argc, char *argv[]) SDL_Log("Select a driver with the SDL_AUDIO_DRIVER environment variable.\n"); SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver()); -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop(loop, 0, 1); #else while (!done) { diff --git a/test/testaudiostreamdynamicresample.c b/test/testaudiostreamdynamicresample.c index b7b953abc..9ccdf1dfb 100644 --- a/test/testaudiostreamdynamicresample.c +++ b/test/testaudiostreamdynamicresample.c @@ -17,7 +17,7 @@ #include #include "testutils.h" -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN #include #endif @@ -219,7 +219,7 @@ static void loop(void) while (SDL_PollEvent(&e)) { SDLTest_CommonEvent(state, &e, &done); -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN if (done) { emscripten_cancel_main_loop(); } @@ -432,7 +432,7 @@ int main(int argc, char *argv[]) SDL_BindAudioStream(state->audio_id, stream); -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop(loop, 0, 1); #else while (!done) { diff --git a/test/testautomation_rwops.c b/test/testautomation_rwops.c index f7199f09a..4a1cc1358 100644 --- a/test/testautomation_rwops.c +++ b/test/testautomation_rwops.c @@ -340,11 +340,11 @@ static int rwops_testFileRead(void *arg) } /* Check type */ -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID SDLTest_AssertCheck( rw->type == SDL_RWOPS_STDFILE || rw->type == SDL_RWOPS_JNIFILE, "Verify RWops type is SDL_RWOPS_STDFILE or SDL_RWOPS_JNIFILE; expected: %d|%d, got: %d", SDL_RWOPS_STDFILE, SDL_RWOPS_JNIFILE, rw->type); -#elif defined(__WIN32__) +#elif defined(SDL_PLATFORM_WIN32) SDLTest_AssertCheck( rw->type == SDL_RWOPS_WINFILE, "Verify RWops type is SDL_RWOPS_WINFILE; expected: %d, got: %d", SDL_RWOPS_WINFILE, rw->type); @@ -387,11 +387,11 @@ static int rwops_testFileWrite(void *arg) } /* Check type */ -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID SDLTest_AssertCheck( rw->type == SDL_RWOPS_STDFILE || rw->type == SDL_RWOPS_JNIFILE, "Verify RWops type is SDL_RWOPS_STDFILE or SDL_RWOPS_JNIFILE; expected: %d|%d, got: %d", SDL_RWOPS_STDFILE, SDL_RWOPS_JNIFILE, rw->type); -#elif defined(__WIN32__) +#elif defined(SDL_PLATFORM_WIN32) SDLTest_AssertCheck( rw->type == SDL_RWOPS_WINFILE, "Verify RWops type is SDL_RWOPS_WINFILE; expected: %d, got: %d", SDL_RWOPS_WINFILE, rw->type); diff --git a/test/testautomation_stdlib.c b/test/testautomation_stdlib.c index adf4bb685..60b8800c6 100644 --- a/test/testautomation_stdlib.c +++ b/test/testautomation_stdlib.c @@ -839,7 +839,7 @@ static int stdlib_sscanf(void *arg) #ifdef _WIN64 #define SIZE_FORMAT "I64u" -#elif defined(__WIN32__) +#elif defined(SDL_PLATFORM_WIN32) #define SIZE_FORMAT "I32u" #else #define SIZE_FORMAT "zu" diff --git a/test/testcontroller.c b/test/testcontroller.c index 456b3f355..60cb83bd8 100644 --- a/test/testcontroller.c +++ b/test/testcontroller.c @@ -17,13 +17,13 @@ #include #include -#include "gamepadutils.h" -#include "testutils.h" - -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN #include #endif +#include "gamepadutils.h" +#include "testutils.h" + #if 0 #define DEBUG_AXIS_MAPPING #endif @@ -1883,7 +1883,7 @@ static void loop(void *arg) SDL_Delay(16); SDL_RenderPresent(screen); -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN if (done) { emscripten_cancel_main_loop(); } @@ -2090,7 +2090,7 @@ int main(int argc, char *argv[]) } /* Loop, getting gamepad events! */ -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop_arg(loop, NULL, 0, 1); #else while (!done) { diff --git a/test/testcustomcursor.c b/test/testcustomcursor.c index 91af2baef..ab7b75a74 100644 --- a/test/testcustomcursor.c +++ b/test/testcustomcursor.c @@ -9,15 +9,16 @@ including commercial applications, and to alter it and redistribute it freely. */ -#include - -#ifdef __EMSCRIPTEN__ -#include -#endif #include #include +#ifdef SDL_PLATFORM_EMSCRIPTEN +#include +#endif + +#include + /* Stolen from the mailing list */ /* Creates a new mouse cursor from an XPM */ @@ -329,7 +330,7 @@ static void loop(void) } SDL_RenderPresent(renderer); } -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN if (done) { emscripten_cancel_main_loop(); } @@ -411,7 +412,7 @@ int main(int argc, char *argv[]) /* Main render loop */ done = 0; -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop(loop, 0, 1); #else while (!done) { diff --git a/test/testdraw.c b/test/testdraw.c index d0d70c33b..25408cebc 100644 --- a/test/testdraw.c +++ b/test/testdraw.c @@ -12,17 +12,17 @@ /* Simple program: draw as many random objects on the screen as possible */ -#include -#include - -#ifdef __EMSCRIPTEN__ -#include -#endif - #include #include #include +#ifdef SDL_PLATFORM_EMSCRIPTEN +#include +#endif + +#include +#include + #define NUM_OBJECTS 100 static SDLTest_CommonState *state; @@ -200,7 +200,7 @@ static void loop(void) SDL_RenderPresent(renderer); } -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN if (done) { emscripten_cancel_main_loop(); } @@ -300,7 +300,7 @@ int main(int argc, char *argv[]) next_fps_check = SDL_GetTicks() + fps_check_delay; done = 0; -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop(loop, 0, 1); #else while (!done) { diff --git a/test/testdrawchessboard.c b/test/testdrawchessboard.c index 1388b044b..fb3b32d92 100644 --- a/test/testdrawchessboard.c +++ b/test/testdrawchessboard.c @@ -14,14 +14,14 @@ /* Sample program: Draw a Chess Board by using SDL_CreateSoftwareRenderer API */ -#ifdef __EMSCRIPTEN__ -#include -#endif - #include #include #include +#ifdef SDL_PLATFORM_EMSCRIPTEN +#include +#endif + static SDL_Window *window; static SDL_Renderer *renderer; static SDL_Surface *surface; @@ -79,7 +79,7 @@ static void loop(void) if (e.type == SDL_EVENT_QUIT) { done = 1; -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_cancel_main_loop(); #endif return; @@ -87,7 +87,7 @@ static void loop(void) if ((e.type == SDL_EVENT_KEY_DOWN) && (e.key.keysym.sym == SDLK_ESCAPE)) { done = 1; -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_cancel_main_loop(); #endif return; @@ -144,7 +144,7 @@ int main(int argc, char *argv[]) /* Draw the Image on rendering surface */ done = 0; -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop(loop, 0, 1); #else while (!done) { diff --git a/test/testffmpeg.c b/test/testffmpeg.c index d865a8d30..379913fef 100644 --- a/test/testffmpeg.c +++ b/test/testffmpeg.c @@ -45,14 +45,14 @@ #endif #endif -#ifdef __APPLE__ +#ifdef SDL_PLATFORM_APPLE #include "testffmpeg_videotoolbox.h" #endif -#ifdef __WIN32__ +#ifdef SDL_PLATFORM_WIN32 #define COBJMACROS #include -#endif /* __WIN32__ */ +#endif /* SDL_PLATFORM_WIN32 */ #include "icon.h" @@ -74,10 +74,10 @@ static SDL_bool has_EGL_EXT_image_dma_buf_import; static PFNGLACTIVETEXTUREARBPROC glActiveTextureARBFunc; static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOESFunc; #endif -#ifdef __APPLE__ +#ifdef SDL_PLATFORM_APPLE static SDL_bool has_videotoolbox_output; #endif -#ifdef __WIN32__ +#ifdef SDL_PLATFORM_WIN32 static ID3D11Device *d3d11_device; static ID3D11DeviceContext *d3d11_context; static const GUID SDL_IID_ID3D11Resource = { 0xdc8e63f3, 0xd12b, 0x4952, { 0xb4, 0x7b, 0x5e, 0x45, 0x02, 0x6a, 0x86, 0x2d } }; @@ -140,11 +140,11 @@ static SDL_bool CreateWindowAndRenderer(Uint32 window_flags, const char *driver) } #endif /* HAVE_EGL */ -#ifdef __APPLE__ +#ifdef SDL_PLATFORM_APPLE has_videotoolbox_output = SetupVideoToolboxOutput(renderer); #endif -#ifdef __WIN32__ +#ifdef SDL_PLATFORM_WIN32 d3d11_device = (ID3D11Device *)SDL_GetProperty(SDL_GetRendererProperties(renderer), SDL_PROPERTY_RENDERER_D3D11_DEVICE_POINTER, NULL); if (d3d11_device) { ID3D11Device_AddRef(d3d11_device); @@ -259,12 +259,12 @@ static SDL_bool SupportedPixelFormat(enum AVPixelFormat format) (format == AV_PIX_FMT_VAAPI || format == AV_PIX_FMT_DRM_PRIME)) { return SDL_TRUE; } -#ifdef __APPLE__ +#ifdef SDL_PLATFORM_APPLE if (has_videotoolbox_output && format == AV_PIX_FMT_VIDEOTOOLBOX) { return SDL_TRUE; } #endif -#ifdef __WIN32__ +#ifdef SDL_PLATFORM_WIN32 if (d3d11_device && format == AV_PIX_FMT_D3D11) { return SDL_TRUE; } @@ -351,7 +351,7 @@ static AVCodecContext *OpenVideoStream(AVFormatContext *ic, int stream, const AV continue; } -#ifdef __WIN32__ +#ifdef SDL_PLATFORM_WIN32 if (d3d11_device && type == AV_HWDEVICE_TYPE_D3D11VA) { AVD3D11VADeviceContext *device_context; @@ -598,7 +598,7 @@ static SDL_bool GetTextureForVAAPIFrame(AVFrame *frame, SDL_Texture **texture) static SDL_bool GetTextureForD3D11Frame(AVFrame *frame, SDL_Texture **texture) { -#ifdef __WIN32__ +#ifdef SDL_PLATFORM_WIN32 int texture_width = 0, texture_height = 0; ID3D11Texture2D *pTexture = (ID3D11Texture2D *)frame->data[0]; UINT iSliceIndex = (UINT)(uintptr_t)frame->data[1]; @@ -672,7 +672,7 @@ static void DisplayVideoTexture(AVFrame *frame) static void DisplayVideoToolbox(AVFrame *frame) { -#ifdef __APPLE__ +#ifdef SDL_PLATFORM_APPLE SDL_Rect viewport; SDL_GetRenderViewport(renderer, &viewport); DisplayVideoToolboxFrame(renderer, frame->data[3], 0, 0, frame->width, frame->height, viewport.x, viewport.y, viewport.w, viewport.h); @@ -908,9 +908,9 @@ int main(int argc, char *argv[]) } window_flags = SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY; -#ifdef __APPLE__ +#ifdef SDL_PLATFORM_APPLE window_flags |= SDL_WINDOW_METAL; -#elif !defined(__WIN32__) +#elif !defined(SDL_PLATFORM_WIN32) window_flags |= SDL_WINDOW_OPENGL; #endif #ifdef HAVE_EGL @@ -919,12 +919,12 @@ int main(int argc, char *argv[]) CreateWindowAndRenderer(window_flags, "opengles2"); } #endif -#ifdef __APPLE__ +#ifdef SDL_PLATFORM_APPLE if (!window) { CreateWindowAndRenderer(window_flags, "metal"); } #endif -#ifdef __WIN32__ +#ifdef SDL_PLATFORM_WIN32 if (!window) { CreateWindowAndRenderer(window_flags, "direct3d11"); } @@ -1111,10 +1111,10 @@ int main(int argc, char *argv[]) } return_code = 0; quit: -#ifdef __APPLE__ +#ifdef SDL_PLATFORM_APPLE CleanupVideoToolboxOutput(); #endif -#ifdef __WIN32__ +#ifdef SDL_PLATFORM_WIN32 if (d3d11_context) { ID3D11DeviceContext_Release(d3d11_device); d3d11_context = NULL; diff --git a/test/testfile.c b/test/testfile.c index be04064bf..2eeb572d5 100644 --- a/test/testfile.c +++ b/test/testfile.c @@ -29,7 +29,7 @@ /* WARNING ! those 2 files will be destroyed by this test program */ -#ifdef __IOS__ +#ifdef SDL_PLATFORM_IOS #define FBASENAME1 "../Documents/sdldata1" /* this file will be created during tests */ #define FBASENAME2 "../Documents/sdldata2" /* this file should not exist before starting test */ #else diff --git a/test/testgeometry.c b/test/testgeometry.c index 9abefab43..fc5ddd493 100644 --- a/test/testgeometry.c +++ b/test/testgeometry.c @@ -12,17 +12,17 @@ /* Simple program: draw a RGB triangle, with texture */ -#include -#include - -#ifdef __EMSCRIPTEN__ -#include -#endif - #include #include #include "testutils.h" +#ifdef SDL_PLATFORM_EMSCRIPTEN +#include +#endif + +#include +#include + static SDLTest_CommonState *state; static SDL_bool use_texture = SDL_FALSE; static SDL_Texture **sprites; @@ -174,7 +174,7 @@ static void loop(void) SDL_RenderPresent(renderer); } -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN if (done) { emscripten_cancel_main_loop(); } @@ -266,7 +266,7 @@ int main(int argc, char *argv[]) then = SDL_GetTicks(); done = 0; -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop(loop, 0, 1); #else while (!done) { diff --git a/test/testgles.c b/test/testgles.c index 36200e100..e6fc077ea 100644 --- a/test/testgles.c +++ b/test/testgles.c @@ -14,7 +14,7 @@ #include #include -#if defined(__IOS__) || defined(__ANDROID__) +#if defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_ANDROID) #define HAVE_OPENGLES #endif @@ -335,7 +335,7 @@ int main(int argc, char *argv[]) SDL_Log("%2.2f frames per second\n", ((double)frames * 1000) / (now - then)); } -#ifndef __ANDROID__ +#ifndef SDL_PLATFORM_ANDROID quit(0); #endif return 0; diff --git a/test/testgles2.c b/test/testgles2.c index 289aaf3dd..87dcf6b60 100644 --- a/test/testgles2.c +++ b/test/testgles2.c @@ -9,16 +9,17 @@ including commercial applications, and to alter it and redistribute it freely. */ -#include - -#ifdef __EMSCRIPTEN__ -#include -#endif #include #include -#if defined(__IOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__) || defined(__WINDOWS__) || defined(__LINUX__) +#ifdef SDL_PLATFORM_EMSCRIPTEN +#include +#endif + +#include + +#if defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_EMSCRIPTEN) || defined(SDL_PLATFORM_WINDOWS) || defined(SDL_PLATFORM_LINUX) #define HAVE_OPENGLES2 #endif @@ -535,7 +536,7 @@ Render(unsigned int width, unsigned int height, shader_data *data) static int done; static Uint32 frames; static shader_data *datas; -#ifndef __EMSCRIPTEN__ +#ifndef SDL_PLATFORM_EMSCRIPTEN static thread_data *threads; #endif @@ -560,7 +561,7 @@ render_window(int index) ++frames; } -#ifndef __EMSCRIPTEN__ +#ifndef SDL_PLATFORM_EMSCRIPTEN static int SDLCALL render_thread_fn(void *render_ctx) { @@ -652,7 +653,7 @@ loop(void) render_window(i); } } -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN else { emscripten_cancel_main_loop(); } @@ -912,7 +913,7 @@ int main(int argc, char *argv[]) then = SDL_GetTicks(); done = 0; -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop(loop, 0, 1); #else if (threaded) { @@ -950,7 +951,7 @@ int main(int argc, char *argv[]) SDL_Log("%2.2f frames per second\n", ((double)frames * 1000) / (now - then)); } -#ifndef __ANDROID__ +#ifndef SDL_PLATFORM_ANDROID quit(0); #endif return 0; diff --git a/test/testgles2_sdf.c b/test/testgles2_sdf.c index 7429aa06b..81e2c677b 100644 --- a/test/testgles2_sdf.c +++ b/test/testgles2_sdf.c @@ -9,17 +9,18 @@ including commercial applications, and to alter it and redistribute it freely. */ -#include - -#ifdef __EMSCRIPTEN__ -#include -#endif #include #include #include "testutils.h" -#if defined(__IOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__) || defined(__WINDOWS__) || defined(__LINUX__) +#ifdef SDL_PLATFORM_EMSCRIPTEN +#include +#endif + +#include + +#if defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_EMSCRIPTEN) || defined(SDL_PLATFORM_WINDOWS) || defined(SDL_PLATFORM_LINUX) #define HAVE_OPENGLES2 #endif @@ -425,7 +426,7 @@ static void loop(void) SDL_GL_SwapWindow(state->windows[i]); } } -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN else { emscripten_cancel_main_loop(); } @@ -769,7 +770,7 @@ int main(int argc, char *argv[]) then = SDL_GetTicks(); done = 0; -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop(loop, 0, 1); #else while (!done) { @@ -783,7 +784,7 @@ int main(int argc, char *argv[]) SDL_Log("%2.2f frames per second\n", ((double)frames * 1000) / (now - then)); } -#ifndef __ANDROID__ +#ifndef SDL_PLATFORM_ANDROID quit(0); #endif return 0; diff --git a/test/testime.c b/test/testime.c index 7553014ed..0e75e274a 100644 --- a/test/testime.c +++ b/test/testime.c @@ -27,9 +27,9 @@ #endif #ifdef HAVE_SDL_TTF -#ifdef __MACOS__ +#ifdef SDL_PLATFORM_MACOS #define DEFAULT_FONT "/System/Library/Fonts/华文细黑.ttf" -#elif defined(__WIN32__) +#elif defined(SDL_PLATFORM_WIN32) /* Some japanese font present on at least Windows 8.1. */ #define DEFAULT_FONT "C:\\Windows\\Fonts\\yugothic.ttf" #else diff --git a/test/testintersections.c b/test/testintersections.c index 126078fc7..5b733d60f 100644 --- a/test/testintersections.c +++ b/test/testintersections.c @@ -12,15 +12,15 @@ /* Simple program: draw as many random objects on the screen as possible */ -#include -#include +#include +#include -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN #include #endif -#include -#include +#include +#include #define SWAP(typ, a, b) \ do { \ @@ -273,7 +273,7 @@ static void loop(void *arg) SDL_RenderPresent(renderer); } -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN if (*done) { emscripten_cancel_main_loop(); } @@ -368,7 +368,7 @@ int main(int argc, char *argv[]) then = SDL_GetTicks(); done = 0; -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop_arg(loop, &done, 0, 1); #else while (!done) { diff --git a/test/testmouse.c b/test/testmouse.c index c92e162e7..99b1e8c61 100644 --- a/test/testmouse.c +++ b/test/testmouse.c @@ -14,13 +14,13 @@ #include #include -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN #include #endif #include /* exit() */ -#ifdef __IOS__ +#ifdef SDL_PLATFORM_IOS #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 480 #else @@ -245,7 +245,7 @@ static void loop(void *arg) SDL_RenderPresent(renderer); -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN if (loop_data->done) { emscripten_cancel_main_loop(); } @@ -294,7 +294,7 @@ int main(int argc, char *argv[]) } /* Main render loop */ -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop_arg(loop, &loop_data, 0, 1); #else while (loop_data.done == SDL_FALSE) { diff --git a/test/testmultiaudio.c b/test/testmultiaudio.c index 404dc3303..da8df08f6 100644 --- a/test/testmultiaudio.c +++ b/test/testmultiaudio.c @@ -15,13 +15,11 @@ #include "testutils.h" -#include /* for fflush() and stdout */ - -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN #include #endif -#include "testutils.h" +#include /* for fflush() and stdout */ static SDL_AudioSpec spec; static Uint8 *sound = NULL; /* Pointer to wave data */ @@ -31,7 +29,7 @@ static Uint32 soundlen = 0; /* Length of wave data */ static SDL_AudioStream *stream = NULL; -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN static void loop(void) { if (SDL_GetAudioStreamAvailable(stream) == 0) { @@ -51,7 +49,7 @@ test_multi_audio(SDL_AudioDeviceID *devices, int devcount) SDL_AudioStream **streams = NULL; int i; -#ifdef __ANDROID__ /* !!! FIXME: maybe always create a window, in the SDLTest layer, so these #ifdefs don't have to be here? */ +#ifdef SDL_PLATFORM_ANDROID /* !!! FIXME: maybe always create a window, in the SDLTest layer, so these #ifdefs don't have to be here? */ SDL_Event event; /* Create a Window to get fully initialized event processing for testing pause on Android. */ @@ -69,11 +67,11 @@ test_multi_audio(SDL_AudioDeviceID *devices, int devcount) SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(stream)); SDL_PutAudioStreamData(stream, sound, soundlen); SDL_FlushAudioStream(stream); -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop(loop, 0, 1); #else while (SDL_GetAudioStreamAvailable(stream) > 0) { -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID /* Empty queue, some application events would prevent pause. */ while (SDL_PollEvent(&event)) { } @@ -118,7 +116,7 @@ test_multi_audio(SDL_AudioDeviceID *devices, int devcount) keep_going = 1; } } -#ifdef __ANDROID__ +#ifdef SDL_PLATFORM_ANDROID /* Empty queue, some application events would prevent pause. */ while (SDL_PollEvent(&event)) {} #endif diff --git a/test/testoffscreen.c b/test/testoffscreen.c index 74df28390..0be2a9a2f 100644 --- a/test/testoffscreen.c +++ b/test/testoffscreen.c @@ -12,18 +12,18 @@ /* Simple program: picks the offscreen backend and renders each frame to a bmp */ -#include -#include - -#ifdef __EMSCRIPTEN__ -#include -#endif - #include #include #include #include +#ifdef SDL_PLATFORM_EMSCRIPTEN +#include +#endif + +#include +#include + static SDL_Renderer *renderer = NULL; static SDL_Window *window = NULL; static int done = SDL_FALSE; @@ -85,7 +85,7 @@ static void loop(void) draw(); save_surface_to_bmp(); -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN if (done) { emscripten_cancel_main_loop(); } @@ -94,7 +94,7 @@ static void loop(void) int main(int argc, char *argv[]) { -#ifndef __EMSCRIPTEN__ +#ifndef SDL_PLATFORM_EMSCRIPTEN Uint64 then, now; Uint32 frames; #endif @@ -142,7 +142,7 @@ int main(int argc, char *argv[]) srand((unsigned int)time(NULL)); -#ifndef __EMSCRIPTEN__ +#ifndef SDL_PLATFORM_EMSCRIPTEN /* Main render loop */ frames = 0; then = SDL_GetTicks(); @@ -151,7 +151,7 @@ int main(int argc, char *argv[]) SDL_Log("Rendering %u frames offscreen\n", max_frames); -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop(loop, 0, 1); #else while (!done && frames < max_frames) { diff --git a/test/testoverlay.c b/test/testoverlay.c index 54f148c62..96e4c27ad 100644 --- a/test/testoverlay.c +++ b/test/testoverlay.c @@ -16,17 +16,17 @@ * * ********************************************************************************/ -#include - -#ifdef __EMSCRIPTEN__ -#include -#endif - #include #include #include #include "testutils.h" +#ifdef SDL_PLATFORM_EMSCRIPTEN +#include +#endif + +#include + #define MOOSEPIC_W 64 #define MOOSEPIC_H 88 @@ -285,7 +285,7 @@ static void loop(void) } } -#ifndef __EMSCRIPTEN__ +#ifndef SDL_PLATFORM_EMSCRIPTEN SDL_Delay(fpsdelay); #endif @@ -295,7 +295,7 @@ static void loop(void) } MoveSprites(state->renderers[i]); } -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN if (done) { emscripten_cancel_main_loop(); } @@ -529,7 +529,7 @@ int main(int argc, char **argv) done = 0; /* Loop, waiting for QUIT or RESIZE */ -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop(loop, nodelay ? 0 : fps, 1); #else while (!done) { diff --git a/test/testpopup.c b/test/testpopup.c index 32595e3a1..1dabdd6f8 100644 --- a/test/testpopup.c +++ b/test/testpopup.c @@ -11,17 +11,17 @@ freely. */ /* Simple program: Move N sprites around on the screen as fast as possible */ -#include -#include - -#ifdef __EMSCRIPTEN__ -#include -#endif - #include #include #include +#ifdef SDL_PLATFORM_EMSCRIPTEN +#include +#endif + +#include +#include + #define MENU_WIDTH 120 #define MENU_HEIGHT 300 @@ -269,7 +269,7 @@ int main(int argc, char *argv[]) /* Main render loop */ done = 0; -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop(loop, 0, 1); #else while (!done) { diff --git a/test/testrelative.c b/test/testrelative.c index 0854aee95..40320d480 100644 --- a/test/testrelative.c +++ b/test/testrelative.c @@ -12,16 +12,16 @@ /* Simple program: Test relative mouse motion */ -#include -#include - #include #include -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN #include #endif +#include +#include + static SDLTest_CommonState *state; static int i, done; static float mouseX, mouseY; @@ -77,7 +77,7 @@ static void loop(void) SDL_RenderPresent(renderer); } -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN if (done) { emscripten_cancel_main_loop(); } @@ -124,7 +124,7 @@ int main(int argc, char *argv[]) rect.h = 10; /* Main render loop */ done = 0; -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop(loop, 0, 1); #else while (!done) { diff --git a/test/testrendercopyex.c b/test/testrendercopyex.c index 2ad1719cc..cea7a1aa5 100644 --- a/test/testrendercopyex.c +++ b/test/testrendercopyex.c @@ -11,16 +11,16 @@ */ /* Simple program: Move N sprites around on the screen as fast as possible */ -#include - -#ifdef __EMSCRIPTEN__ -#include -#endif - #include #include #include "testutils.h" +#ifdef SDL_PLATFORM_EMSCRIPTEN +#include +#endif + +#include + static SDLTest_CommonState *state; typedef struct @@ -105,7 +105,7 @@ static void loop(void) } Draw(&drawstates[i]); } -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN if (done) { emscripten_cancel_main_loop(); } @@ -155,7 +155,7 @@ int main(int argc, char *argv[]) then = SDL_GetTicks(); done = 0; -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop(loop, 0, 1); #else while (!done) { diff --git a/test/testrendertarget.c b/test/testrendertarget.c index e68127a7d..de9d7448f 100644 --- a/test/testrendertarget.c +++ b/test/testrendertarget.c @@ -11,16 +11,16 @@ */ /* Simple program: Move N sprites around on the screen as fast as possible */ -#include - -#ifdef __EMSCRIPTEN__ -#include -#endif - #include #include #include "testutils.h" +#ifdef SDL_PLATFORM_EMSCRIPTEN +#include +#endif + +#include + static SDLTest_CommonState *state; typedef struct @@ -199,7 +199,7 @@ static void loop(void) } } } -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN if (done) { emscripten_cancel_main_loop(); } @@ -269,7 +269,7 @@ int main(int argc, char *argv[]) then = SDL_GetTicks(); done = 0; -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop(loop, 0, 1); #else while (!done) { diff --git a/test/testscale.c b/test/testscale.c index a69c9c1d8..9abc0153a 100644 --- a/test/testscale.c +++ b/test/testscale.c @@ -11,16 +11,16 @@ */ /* Simple program: Move N sprites around on the screen as fast as possible */ -#include - -#ifdef __EMSCRIPTEN__ -#include -#endif - #include #include #include "testutils.h" +#ifdef SDL_PLATFORM_EMSCRIPTEN +#include +#endif + +#include + static SDLTest_CommonState *state; typedef struct @@ -92,7 +92,7 @@ static void loop(void) } Draw(&drawstates[i]); } -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN if (done) { emscripten_cancel_main_loop(); } @@ -146,7 +146,7 @@ int main(int argc, char *argv[]) then = SDL_GetTicks(); done = 0; -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop(loop, 0, 1); #else while (!done) { diff --git a/test/testspriteminimal.c b/test/testspriteminimal.c index 6ffcc46b9..e482bcac4 100644 --- a/test/testspriteminimal.c +++ b/test/testspriteminimal.c @@ -11,15 +11,15 @@ */ /* Simple program: Move N sprites around on the screen as fast as possible */ -#include -#include +#include +#include -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN #include #endif -#include -#include +#include +#include #include "icon.h" @@ -100,7 +100,7 @@ static void loop(void) } } MoveSprites(); -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN if (done) { emscripten_cancel_main_loop(); } @@ -157,7 +157,7 @@ int main(int argc, char *argv[]) /* Main render loop */ done = 0; -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop(loop, 0, 1); #else while (!done) { diff --git a/test/teststreaming.c b/test/teststreaming.c index bb0e02c91..2c9ee7f4f 100644 --- a/test/teststreaming.c +++ b/test/teststreaming.c @@ -15,17 +15,17 @@ * * ********************************************************************************/ -#include - -#ifdef __EMSCRIPTEN__ -#include -#endif - #include #include #include #include "testutils.h" +#ifdef SDL_PLATFORM_EMSCRIPTEN +#include +#endif + +#include + #define MOOSEPIC_W 64 #define MOOSEPIC_H 88 @@ -124,7 +124,7 @@ static void loop(void) SDL_RenderTexture(renderer, MooseTexture, NULL, NULL); SDL_RenderPresent(renderer); -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN if (done) { emscripten_cancel_main_loop(); } @@ -193,7 +193,7 @@ int main(int argc, char **argv) /* Loop, waiting for QUIT or the escape key */ frame = 0; -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop(loop, 0, 1); #else while (!done) { diff --git a/test/testvideocapture.c b/test/testvideocapture.c index d14fd485e..a6eb8d43d 100644 --- a/test/testvideocapture.c +++ b/test/testvideocapture.c @@ -13,12 +13,13 @@ #include "SDL3/SDL.h" #include "SDL3/SDL_test.h" #include "SDL3/SDL_video_capture.h" -#include -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN #include #endif +#include + static const char *usage = "\ \n\ =========================================================================\n\ @@ -62,7 +63,7 @@ update_fps(measure_fps_t *m) } } -#if defined(__linux__) && !defined(__ANDROID__) +#if defined(SDL_PLATFORM_LINUX) && !defined(SDL_PLATFORM_ANDROID) static void load_average(float *val) { FILE *fp = 0; @@ -663,7 +664,7 @@ int main(int argc, char **argv) /* display status and FPS */ if (!device) { -#ifdef __IOS__ +#ifdef SDL_PLATFORM_IOS const float x_offset = 500; #else const float x_offset = 0; @@ -672,7 +673,7 @@ int main(int argc, char **argv) SDL_snprintf(buf, 256, "Device %d (%s) is not opened", current_dev, SDL_GetVideoCaptureDeviceName(get_instance_id(current_dev))); SDLTest_DrawString(renderer, x_offset + 10, 10, buf); } else { -#ifdef __IOS__ +#ifdef SDL_PLATFORM_IOS const float x_offset = 500; #else const float x_offset = 0; @@ -714,7 +715,7 @@ int main(int argc, char **argv) } /* display load average */ -#if defined(__linux__) && !defined(__ANDROID__) +#if defined(SDL_PLATFORM_LINUX) && !defined(SDL_PLATFORM_ANDROID) { float val = 0.0f; char buf[128]; diff --git a/test/testvideocaptureminimal.c b/test/testvideocaptureminimal.c index 67840d78d..33396936d 100644 --- a/test/testvideocaptureminimal.c +++ b/test/testvideocaptureminimal.c @@ -13,12 +13,13 @@ #include "SDL3/SDL.h" #include "SDL3/SDL_test.h" #include "SDL3/SDL_video_capture.h" -#include -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN #include #endif +#include + int main(int argc, char **argv) { SDL_Window *window = NULL; diff --git a/test/testviewport.c b/test/testviewport.c index abca08979..6b953983b 100644 --- a/test/testviewport.c +++ b/test/testviewport.c @@ -11,23 +11,23 @@ */ /* Simple program: Check viewports */ -#include - -#ifdef __EMSCRIPTEN__ -#include -#endif - #include #include #include #include "testutils.h" +#ifdef SDL_PLATFORM_EMSCRIPTEN +#include +#endif + +#include + static SDLTest_CommonState *state; static SDL_Rect viewport; static int done, j; static SDL_bool use_target = SDL_FALSE; -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN static Uint32 wait_start; #endif static SDL_Texture *sprite; @@ -109,7 +109,7 @@ static void loop(void) { SDL_Event event; int i; -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN /* Avoid using delays */ if (SDL_GetTicks() - wait_start < 1000) { return; @@ -148,7 +148,7 @@ static void loop(void) } } -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN if (done) { emscripten_cancel_main_loop(); } @@ -217,7 +217,7 @@ int main(int argc, char *argv[]) done = 0; j = 0; -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN wait_start = SDL_GetTicks(); emscripten_set_main_loop(loop, 0, 1); #else diff --git a/test/testvulkan.c b/test/testvulkan.c index cad7acaa5..cfade5cd6 100644 --- a/test/testvulkan.c +++ b/test/testvulkan.c @@ -14,7 +14,7 @@ #include #include -#if defined(__ANDROID__) && defined(__ARM_EABI__) && !defined(__ARM_ARCH_7A__) +#if defined(SDL_PLATFORM_ANDROID) && defined(__ARM_EABI__) && !defined(__ARM_ARCH_7A__) int main(int argc, char *argv[]) { diff --git a/test/testwm.c b/test/testwm.c index b400e23de..24b5a0f05 100644 --- a/test/testwm.c +++ b/test/testwm.c @@ -10,14 +10,14 @@ freely. */ -#ifdef __EMSCRIPTEN__ -#include -#endif - #include #include #include +#ifdef SDL_PLATFORM_EMSCRIPTEN +#include +#endif + static SDLTest_CommonState *state; static int done; @@ -248,7 +248,7 @@ static void loop(void) SDL_RenderPresent(renderer); } } -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN if (done) { emscripten_cancel_main_loop(); } @@ -281,7 +281,7 @@ int main(int argc, char *argv[]) /* Main render loop */ done = 0; -#ifdef __EMSCRIPTEN__ +#ifdef SDL_PLATFORM_EMSCRIPTEN emscripten_set_main_loop(loop, 0, 1); #else while (!done) {