Define SDL_PLATFORM_* macros instead of underscored ones (#8875)

This commit is contained in:
Anonymous Maarten
2024-01-24 02:40:51 +01:00
committed by GitHub
parent ceccf24519
commit 31d133db40
208 changed files with 1293 additions and 1138 deletions

View File

@@ -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;

View File

@@ -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)

View File

@@ -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 */

View File

@@ -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");

View File

@@ -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 */

View File

@@ -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");
}

View File

@@ -20,7 +20,7 @@
*/
#include "SDL_internal.h"
#ifdef __LINUX__
#ifdef SDL_PLATFORM_LINUX
#ifndef SDL_THREADS_DISABLED
#include <sys/time.h>
@@ -342,4 +342,4 @@ int SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int sc
#endif
}
#endif /* __LINUX__ */
#endif /* SDL_PLATFORM_LINUX */

View File

@@ -21,7 +21,7 @@
#include "SDL_internal.h"
#ifdef __3DS__
#ifdef SDL_PLATFORM_3DS
#include <3ds.h>

View File

@@ -4,7 +4,7 @@
#include "SDL_internal.h"
#ifdef __NGAGE__
#ifdef SDL_PLATFORM_NGAGE
#include <e32std.h>
#include <e32def.h>
@@ -75,4 +75,4 @@ cleanup:
return ret;
}
#endif // __NGAGE__
#endif // SDL_PLATFORM_NGAGE

View File

@@ -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]) {

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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);

View File

@@ -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 */

View File

@@ -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_ */

View File

@@ -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 *)&notification_client);
}
#endif /* (defined(__WIN32__) || defined(__GDK__)) && defined(HAVE_MMDEVICEAPI_H) */
#endif /* (defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)) && defined(HAVE_MMDEVICEAPI_H) */

View File

@@ -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 <shellapi.h> /* 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) */

View File

@@ -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

View File

@@ -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

View File

@@ -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 <math.h> /* Required to compile with recent MSVC... */
#include <XInputOnGameInput.h>