Improve support for private platforms (#11220)

This commit is contained in:
Caleb Cornett 2024-10-15 18:02:07 -04:00 committed by GitHub
parent 66d09a1cda
commit 9af5ffcfbe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 70 additions and 18 deletions

View file

@ -966,8 +966,8 @@ if(SDL_LIBC)
bcopy bcopy
calloc ceil ceilf copysign copysignf cos cosf calloc ceil ceilf copysign copysignf cos cosf
_Exit exp expf _Exit exp expf
fabs fabsf floor floorf fmod fmodf fopen64 free fseeko fseeko64 fabs fabsf fdatasync floor floorf fmod fmodf fopen64 free fseeko fseeko64
getenv getenv gethostname
_i64toa index itoa _i64toa index itoa
log log10 log10f logf lround lroundf _ltoa log log10 log10f logf lround lroundf _ltoa
malloc memcmp memcpy memmove memset modf modff malloc memcmp memcpy memmove memset modf modff

View file

@ -229,6 +229,12 @@ typedef enum SDL_EventType
SDL_EVENT_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */ SDL_EVENT_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */
SDL_EVENT_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */ SDL_EVENT_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */
/* Reserved events for private platforms */
SDL_EVENT_PRIVATE0 = 0x4000,
SDL_EVENT_PRIVATE1,
SDL_EVENT_PRIVATE2,
SDL_EVENT_PRIVATE3,
/* Internal events */ /* Internal events */
SDL_EVENT_POLL_SENTINEL = 0x7F00, /**< Signals the end of an event poll cycle */ SDL_EVENT_POLL_SENTINEL = 0x7F00, /**< Signals the end of an event poll cycle */

View file

@ -49,7 +49,11 @@
#include <SDL3/SDL_events.h> #include <SDL3/SDL_events.h>
#ifndef SDL_MAIN_HANDLED #ifndef SDL_MAIN_HANDLED
#ifdef SDL_PLATFORM_WIN32 #if defined(SDL_PLATFORM_PRIVATE_MAIN)
/* Private platforms may have their own ideas about entry points. */
#include "SDL_main_private.h"
#elif defined(SDL_PLATFORM_WIN32)
/* On Windows SDL provides WinMain(), which parses the command line and passes /* On Windows SDL provides WinMain(), which parses the command line and passes
the arguments to your main function. the arguments to your main function.

View file

@ -68,7 +68,11 @@
unless the real entry point needs to be somewhere else entirely, like Android where it's in Java code */ unless the real entry point needs to be somewhere else entirely, like Android where it's in Java code */
#if (!defined(SDL_MAIN_USE_CALLBACKS) || defined(SDL_MAIN_CALLBACK_STANDARD)) && !defined(SDL_MAIN_EXPORTED) #if (!defined(SDL_MAIN_USE_CALLBACKS) || defined(SDL_MAIN_CALLBACK_STANDARD)) && !defined(SDL_MAIN_EXPORTED)
#if defined(SDL_PLATFORM_WINDOWS) #if defined(SDL_PLATFORM_PRIVATE_MAIN)
/* Private platforms may have their own ideas about entry points. */
#include "SDL_main_impl_private.h"
#elif defined(SDL_PLATFORM_WINDOWS)
/* these defines/typedefs are needed for the WinMain() definition */ /* these defines/typedefs are needed for the WinMain() definition */
#ifndef WINAPI #ifndef WINAPI

View file

@ -31,7 +31,9 @@
*/ */
/* Add any platform that doesn't build using the configure system. */ /* Add any platform that doesn't build using the configure system. */
#if defined(SDL_PLATFORM_WIN32) #if defined(SDL_PLATFORM_PRIVATE)
#include "SDL_build_config_private.h"
#elif defined(SDL_PLATFORM_WIN32)
#include "SDL_build_config_windows.h" #include "SDL_build_config_windows.h"
#elif defined(SDL_PLATFORM_WINGDK) #elif defined(SDL_PLATFORM_WINGDK)
#include "SDL_build_config_wingdk.h" #include "SDL_build_config_wingdk.h"

View file

@ -75,8 +75,10 @@
#cmakedefine HAVE_MALLOC 1 #cmakedefine HAVE_MALLOC 1
#cmakedefine HAVE_CALLOC 1 #cmakedefine HAVE_CALLOC 1
#cmakedefine HAVE_REALLOC 1 #cmakedefine HAVE_REALLOC 1
#cmakedefine HAVE_FDATASYNC 1
#cmakedefine HAVE_FREE 1 #cmakedefine HAVE_FREE 1
#cmakedefine HAVE_GETENV 1 #cmakedefine HAVE_GETENV 1
#cmakedefine HAVE_GETHOSTNAME 1
#cmakedefine HAVE_SETENV 1 #cmakedefine HAVE_SETENV 1
#cmakedefine HAVE_PUTENV 1 #cmakedefine HAVE_PUTENV 1
#cmakedefine HAVE_UNSETENV 1 #cmakedefine HAVE_UNSETENV 1

View file

@ -57,8 +57,10 @@
#define HAVE_MALLOC 1 #define HAVE_MALLOC 1
#define HAVE_CALLOC 1 #define HAVE_CALLOC 1
#define HAVE_REALLOC 1 #define HAVE_REALLOC 1
#define HAVE_FDATASYNC 1
#define HAVE_FREE 1 #define HAVE_FREE 1
#define HAVE_GETENV 1 #define HAVE_GETENV 1
#define HAVE_GETHOSTNAME 1
#define HAVE_PUTENV 1 #define HAVE_PUTENV 1
#define HAVE_SETENV 1 #define HAVE_SETENV 1
#define HAVE_UNSETENV 1 #define HAVE_UNSETENV 1

View file

@ -60,8 +60,10 @@
#define HAVE_MALLOC 1 #define HAVE_MALLOC 1
#define HAVE_CALLOC 1 #define HAVE_CALLOC 1
#define HAVE_REALLOC 1 #define HAVE_REALLOC 1
#define HAVE_FDATASYNC 1
#define HAVE_FREE 1 #define HAVE_FREE 1
#define HAVE_GETENV 1 #define HAVE_GETENV 1
#define HAVE_GETHOSTNAME 1
#define HAVE_SETENV 1 #define HAVE_SETENV 1
#define HAVE_PUTENV 1 #define HAVE_PUTENV 1
#define HAVE_UNSETENV 1 #define HAVE_UNSETENV 1

View file

@ -49,8 +49,10 @@
#define HAVE_MALLOC 1 #define HAVE_MALLOC 1
#define HAVE_CALLOC 1 #define HAVE_CALLOC 1
#define HAVE_REALLOC 1 #define HAVE_REALLOC 1
#define HAVE_FDATASYNC 1
#define HAVE_FREE 1 #define HAVE_FREE 1
#define HAVE_GETENV 1 #define HAVE_GETENV 1
#define HAVE_GETHOSTNAME 1
#define HAVE_PUTENV 1 #define HAVE_PUTENV 1
#define HAVE_SETENV 1 #define HAVE_SETENV 1
#define HAVE_UNSETENV 1 #define HAVE_UNSETENV 1

View file

@ -54,8 +54,10 @@
#define HAVE_MALLOC 1 #define HAVE_MALLOC 1
#define HAVE_CALLOC 1 #define HAVE_CALLOC 1
#define HAVE_REALLOC 1 #define HAVE_REALLOC 1
#define HAVE_FDATASYNC 1
#define HAVE_FREE 1 #define HAVE_FREE 1
#define HAVE_GETENV 1 #define HAVE_GETENV 1
#define HAVE_GETHOSTNAME 1
#define HAVE_SETENV 1 #define HAVE_SETENV 1
#define HAVE_PUTENV 1 #define HAVE_PUTENV 1
#define HAVE_UNSETENV 1 #define HAVE_UNSETENV 1

View file

@ -135,6 +135,7 @@ typedef unsigned int uintptr_t;
#define HAVE_MALLOC 1 #define HAVE_MALLOC 1
#define HAVE_CALLOC 1 #define HAVE_CALLOC 1
#define HAVE_REALLOC 1 #define HAVE_REALLOC 1
#define HAVE_FDATASYNC 1
#define HAVE_FREE 1 #define HAVE_FREE 1
#define HAVE_ABS 1 #define HAVE_ABS 1
#define HAVE_MEMSET 1 #define HAVE_MEMSET 1

View file

@ -75,6 +75,7 @@
#define HAVE_LIBC 1 #define HAVE_LIBC 1
#define HAVE_MALLOC 1 #define HAVE_MALLOC 1
#define HAVE_CALLOC 1 #define HAVE_CALLOC 1
#define HAVE_FDATASYNC 1
#define HAVE_REALLOC 1 #define HAVE_REALLOC 1
#define HAVE_FREE 1 #define HAVE_FREE 1
#define HAVE_ABS 1 #define HAVE_ABS 1

View file

@ -662,7 +662,9 @@ const char *SDL_GetRevision(void)
// Get the name of the platform // Get the name of the platform
const char *SDL_GetPlatform(void) const char *SDL_GetPlatform(void)
{ {
#if defined(SDL_PLATFORM_AIX) #if defined(SDL_PLATFORM_PRIVATE)
return SDL_PLATFORM_PRIVATE_NAME;
#elif defined(SDL_PLATFORM_AIX)
return "AIX"; return "AIX";
#elif defined(SDL_PLATFORM_ANDROID) #elif defined(SDL_PLATFORM_ANDROID)
return "Android"; return "Android";

View file

@ -245,7 +245,9 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v
state = (SDL_AssertState)selected; state = (SDL_AssertState)selected;
} }
} else { } else {
#ifdef SDL_PLATFORM_EMSCRIPTEN #ifdef SDL_PLATFORM_PRIVATE_ASSERT
SDL_PRIVATE_PROMPTASSERTION();
#elif defined(SDL_PLATFORM_EMSCRIPTEN)
// This is nasty, but we can't block on a custom UI. // This is nasty, but we can't block on a custom UI.
for (;;) { for (;;) {
bool okay = true; bool okay = true;

View file

@ -20,7 +20,7 @@
*/ */
#include "SDL_internal.h" #include "SDL_internal.h"
#if defined(SDL_PLATFORM_UNIX) || defined(SDL_PLATFORM_APPLE) #ifdef HAVE_GETHOSTNAME
#include <unistd.h> #include <unistd.h>
#endif #endif
@ -299,7 +299,7 @@ int SDL_URIToLocal(const char *src, char *dst)
const size_t src_len = hostname_end - (src + 1); const size_t src_len = hostname_end - (src + 1);
size_t hostname_len; size_t hostname_len;
#if defined(SDL_PLATFORM_UNIX) || defined(SDL_PLATFORM_APPLE) #ifdef HAVE_GETHOSTNAME
char hostname[257]; char hostname[257];
if (gethostname(hostname, 255) == 0) { if (gethostname(hostname, 255) == 0) {
hostname[256] = '\0'; hostname[256] = '\0';

View file

@ -26,6 +26,9 @@
// Available audio drivers // Available audio drivers
static const AudioBootStrap *const bootstrap[] = { static const AudioBootStrap *const bootstrap[] = {
#ifdef SDL_AUDIO_DRIVER_PRIVATE
&PRIVATEAUDIO_bootstrap,
#endif
#ifdef SDL_AUDIO_DRIVER_PULSEAUDIO #ifdef SDL_AUDIO_DRIVER_PULSEAUDIO
#ifdef SDL_AUDIO_DRIVER_PIPEWIRE #ifdef SDL_AUDIO_DRIVER_PIPEWIRE
&PIPEWIRE_PREFERRED_bootstrap, &PIPEWIRE_PREFERRED_bootstrap,

View file

@ -353,6 +353,7 @@ typedef struct AudioBootStrap
} AudioBootStrap; } AudioBootStrap;
// Not all of these are available in a given build. Use #ifdefs, etc. // Not all of these are available in a given build. Use #ifdefs, etc.
extern AudioBootStrap PRIVATEAUDIO_bootstrap;
extern AudioBootStrap PIPEWIRE_PREFERRED_bootstrap; extern AudioBootStrap PIPEWIRE_PREFERRED_bootstrap;
extern AudioBootStrap PIPEWIRE_bootstrap; extern AudioBootStrap PIPEWIRE_bootstrap;
extern AudioBootStrap PULSEAUDIO_bootstrap; extern AudioBootStrap PULSEAUDIO_bootstrap;

View file

@ -27,8 +27,6 @@
#define DEBUG_CAMERA 0 #define DEBUG_CAMERA 0
typedef struct SDL_Camera SDL_Camera;
/* Backends should call this as devices are added to the system (such as /* Backends should call this as devices are added to the system (such as
a USB camera being plugged in), and should also be called for a USB camera being plugged in), and should also be called for
for every device found during DetectDevices(). */ for every device found during DetectDevices(). */

View file

@ -43,7 +43,9 @@
#include "TargetConditionals.h" #include "TargetConditionals.h"
#endif #endif
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE // probably not useful on iOS. #if defined(SDL_PLATFORM_PRIVATE) // probably not useful on private platforms.
#define SDL_DYNAMIC_API 0
#elif defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE // probably not useful on iOS.
#define SDL_DYNAMIC_API 0 #define SDL_DYNAMIC_API 0
#elif defined(SDL_PLATFORM_ANDROID) // probably not useful on Android. #elif defined(SDL_PLATFORM_ANDROID) // probably not useful on Android.
#define SDL_DYNAMIC_API 0 #define SDL_DYNAMIC_API 0

View file

@ -370,10 +370,8 @@ static int SDL_fdatasync(int fd)
result = fcntl(fd, F_FULLFSYNC); result = fcntl(fd, F_FULLFSYNC);
#elif defined(SDL_PLATFORM_HAIKU) #elif defined(SDL_PLATFORM_HAIKU)
result = fsync(fd); result = fsync(fd);
#elif defined(_POSIX_SYNCHRONIZED_IO) // POSIX defines this if fdatasync() exists, so we don't need a CMake test. #elif defined(HAVE_FDATASYNC)
#ifndef SDL_PLATFORM_RISCOS // !!! FIXME: however, RISCOS doesn't have the symbol...maybe we need to link to an extra library or something?
result = fdatasync(fd); result = fdatasync(fd);
#endif
#endif #endif
return result; return result;
} }

View file

@ -29,6 +29,9 @@
Alternatively, you can use the app located in test/controllermap Alternatively, you can use the app located in test/controllermap
*/ */
static const char *s_GamepadMappings[] = { static const char *s_GamepadMappings[] = {
#ifdef SDL_JOYSTICK_PRIVATE
SDL_PRIVATE_GAMEPAD_DEFINITIONS
#endif
#ifdef SDL_JOYSTICK_XINPUT #ifdef SDL_JOYSTICK_XINPUT
"xinput,*,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,", "xinput,*,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 #endif

View file

@ -52,6 +52,9 @@ static SDL_JoystickDriver *SDL_joystick_drivers[] = {
#ifdef SDL_JOYSTICK_HIDAPI // Highest priority driver for supported devices #ifdef SDL_JOYSTICK_HIDAPI // Highest priority driver for supported devices
&SDL_HIDAPI_JoystickDriver, &SDL_HIDAPI_JoystickDriver,
#endif #endif
#ifdef SDL_JOYSTICK_PRIVATE
&SDL_PRIVATE_JoystickDriver,
#endif
#ifdef SDL_JOYSTICK_GAMEINPUT // Higher priority than other Windows drivers #ifdef SDL_JOYSTICK_GAMEINPUT // Higher priority than other Windows drivers
&SDL_GAMEINPUT_JoystickDriver, &SDL_GAMEINPUT_JoystickDriver,
#endif #endif

View file

@ -240,6 +240,7 @@ typedef struct SDL_JoystickDriver
#define SDL_LED_MIN_REPEAT_MS 5000 #define SDL_LED_MIN_REPEAT_MS 5000
// The available joystick drivers // The available joystick drivers
extern SDL_JoystickDriver SDL_PRIVATE_JoystickDriver;
extern SDL_JoystickDriver SDL_ANDROID_JoystickDriver; extern SDL_JoystickDriver SDL_ANDROID_JoystickDriver;
extern SDL_JoystickDriver SDL_BSD_JoystickDriver; extern SDL_JoystickDriver SDL_BSD_JoystickDriver;
extern SDL_JoystickDriver SDL_DARWIN_JoystickDriver; extern SDL_JoystickDriver SDL_DARWIN_JoystickDriver;

View file

@ -26,7 +26,9 @@
#include <pthread_np.h> #include <pthread_np.h>
#endif #endif
#ifdef HAVE_SIGNAL_H
#include <signal.h> #include <signal.h>
#endif
#include <errno.h> #include <errno.h>
#ifdef SDL_PLATFORM_LINUX #ifdef SDL_PLATFORM_LINUX
@ -55,11 +57,13 @@
#include <kernel/OS.h> #include <kernel/OS.h>
#endif #endif
#ifdef HAVE_SIGNAL_H
// List of signals to mask in the subthreads // List of signals to mask in the subthreads
static const int sig_list[] = { static const int sig_list[] = {
SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGWINCH, SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGWINCH,
SIGVTALRM, SIGPROF, 0 SIGVTALRM, SIGPROF, 0
}; };
#endif
static void *RunThread(void *data) static void *RunThread(void *data)
{ {
@ -117,8 +121,10 @@ bool SDL_SYS_CreateThread(SDL_Thread *thread,
void SDL_SYS_SetupThread(const char *name) void SDL_SYS_SetupThread(const char *name)
{ {
#ifdef HAVE_SIGNAL_H
int i; int i;
sigset_t mask; sigset_t mask;
#endif
if (name) { if (name) {
#if (defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_LINUX)) && defined(HAVE_DLOPEN) #if (defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_LINUX)) && defined(HAVE_DLOPEN)
@ -154,12 +160,14 @@ void SDL_SYS_SetupThread(const char *name)
#endif #endif
} }
#ifdef HAVE_SIGNAL_H
// Mask asynchronous signals for this thread // Mask asynchronous signals for this thread
sigemptyset(&mask); sigemptyset(&mask);
for (i = 0; sig_list[i]; ++i) { for (i = 0; sig_list[i]; ++i) {
sigaddset(&mask, sig_list[i]); sigaddset(&mask, sig_list[i]);
} }
pthread_sigmask(SIG_BLOCK, &mask, 0); pthread_sigmask(SIG_BLOCK, &mask, 0);
#endif
#ifdef PTHREAD_CANCEL_ASYNCHRONOUS #ifdef PTHREAD_CANCEL_ASYNCHRONOUS
// Allow ourselves to be asynchronously cancelled // Allow ourselves to be asynchronously cancelled

View file

@ -300,7 +300,9 @@ void SDL_EGL_UnloadLibrary(SDL_VideoDevice *_this)
static bool SDL_EGL_LoadLibraryInternal(SDL_VideoDevice *_this, const char *egl_path) static bool SDL_EGL_LoadLibraryInternal(SDL_VideoDevice *_this, const char *egl_path)
{ {
SDL_SharedObject *egl_dll_handle = NULL; SDL_SharedObject *egl_dll_handle = NULL;
#if !defined(SDL_VIDEO_STATIC_ANGLE) && !defined(SDL_VIDEO_DRIVER_VITA)
SDL_SharedObject *opengl_dll_handle = NULL; SDL_SharedObject *opengl_dll_handle = NULL;
#endif
const char *path = NULL; const char *path = NULL;
#if defined(SDL_VIDEO_DRIVER_WINDOWS) #if defined(SDL_VIDEO_DRIVER_WINDOWS)
const char *d3dcompiler; const char *d3dcompiler;
@ -426,9 +428,6 @@ static bool SDL_EGL_LoadLibraryInternal(SDL_VideoDevice *_this, const char *egl_
#endif #endif
_this->egl_data->egl_dll_handle = egl_dll_handle; _this->egl_data->egl_dll_handle = egl_dll_handle;
#ifdef SDL_VIDEO_DRIVER_VITA
_this->egl_data->opengl_dll_handle = opengl_dll_handle;
#endif
// Load new function pointers // Load new function pointers
LOAD_FUNC(PFNEGLGETDISPLAYPROC, eglGetDisplay); LOAD_FUNC(PFNEGLGETDISPLAYPROC, eglGetDisplay);

View file

@ -498,6 +498,7 @@ typedef struct VideoBootStrap
} VideoBootStrap; } VideoBootStrap;
// Not all of these are available in a given build. Use #ifdefs, etc. // Not all of these are available in a given build. Use #ifdefs, etc.
extern VideoBootStrap PRIVATE_bootstrap;
extern VideoBootStrap COCOA_bootstrap; extern VideoBootStrap COCOA_bootstrap;
extern VideoBootStrap X11_bootstrap; extern VideoBootStrap X11_bootstrap;
extern VideoBootStrap WINDOWS_bootstrap; extern VideoBootStrap WINDOWS_bootstrap;

View file

@ -71,6 +71,9 @@
// Available video drivers // Available video drivers
static VideoBootStrap *bootstrap[] = { static VideoBootStrap *bootstrap[] = {
#ifdef SDL_VIDEO_DRIVER_PRIVATE
&PRIVATE_bootstrap,
#endif
#ifdef SDL_VIDEO_DRIVER_COCOA #ifdef SDL_VIDEO_DRIVER_COCOA
&COCOA_bootstrap, &COCOA_bootstrap,
#endif #endif