winrt: Removed WinRT/Windows Phone/UWP support.

Fixes #10724.
This commit is contained in:
Ryan C. Gordon
2024-09-05 23:36:16 -04:00
parent 6d7c211faf
commit 154452a726
126 changed files with 150 additions and 9582 deletions

View File

@@ -56,12 +56,6 @@ typedef struct CONDITION_VARIABLE
} CONDITION_VARIABLE, *PCONDITION_VARIABLE;
#endif
#ifdef SDL_PLATFORM_WINRT
#define pWakeConditionVariable WakeConditionVariable
#define pWakeAllConditionVariable WakeAllConditionVariable
#define pSleepConditionVariableSRW SleepConditionVariableSRW
#define pSleepConditionVariableCS SleepConditionVariableCS
#else
typedef VOID(WINAPI *pfnWakeConditionVariable)(PCONDITION_VARIABLE);
typedef VOID(WINAPI *pfnWakeAllConditionVariable)(PCONDITION_VARIABLE);
typedef BOOL(WINAPI *pfnSleepConditionVariableSRW)(PCONDITION_VARIABLE, PSRWLOCK, DWORD, ULONG);
@@ -71,7 +65,6 @@ static pfnWakeConditionVariable pWakeConditionVariable = NULL;
static pfnWakeAllConditionVariable pWakeAllConditionVariable = NULL;
static pfnSleepConditionVariableSRW pSleepConditionVariableSRW = NULL;
static pfnSleepConditionVariableCS pSleepConditionVariableCS = NULL;
#endif
typedef struct SDL_cond_cv
{
@@ -152,7 +145,6 @@ static const SDL_cond_impl_t SDL_cond_impl_cv = {
};
#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,
@@ -161,7 +153,6 @@ static const SDL_cond_impl_t SDL_cond_impl_generic = {
&SDL_BroadcastCondition_generic,
&SDL_WaitConditionTimeoutNS_generic,
};
#endif
SDL_Condition *SDL_CreateCondition(void)
{
@@ -179,10 +170,6 @@ SDL_Condition *SDL_CreateCondition(void)
SDL_assert(SDL_mutex_impl_active.Type != SDL_MUTEX_INVALID);
}
#ifdef SDL_PLATFORM_WINRT
// Link statically on this platform
impl = &SDL_cond_impl_cv;
#else
// Default to generic implementation, works with all mutex implementations
impl = &SDL_cond_impl_generic;
{
@@ -198,7 +185,6 @@ SDL_Condition *SDL_CreateCondition(void)
}
}
}
#endif
SDL_copyp(&SDL_cond_impl_active, impl);
}

View File

@@ -39,13 +39,6 @@ SDL_mutex_impl_t SDL_mutex_impl_active = { 0 };
* Implementation based on Slim Reader/Writer (SRW) Locks for Win 7 and newer.
*/
#ifdef SDL_PLATFORM_WINRT
// Functions are guaranteed to be available
#define pInitializeSRWLock InitializeSRWLock
#define pReleaseSRWLockExclusive ReleaseSRWLockExclusive
#define pAcquireSRWLockExclusive AcquireSRWLockExclusive
#define pTryAcquireSRWLockExclusive TryAcquireSRWLockExclusive
#else
typedef VOID(WINAPI *pfnInitializeSRWLock)(PSRWLOCK);
typedef VOID(WINAPI *pfnReleaseSRWLockExclusive)(PSRWLOCK);
typedef VOID(WINAPI *pfnAcquireSRWLockExclusive)(PSRWLOCK);
@@ -54,7 +47,6 @@ static pfnInitializeSRWLock pInitializeSRWLock = NULL;
static pfnReleaseSRWLockExclusive pReleaseSRWLockExclusive = NULL;
static pfnAcquireSRWLockExclusive pAcquireSRWLockExclusive = NULL;
static pfnTryAcquireSRWLockExclusive pTryAcquireSRWLockExclusive = NULL;
#endif
static SDL_Mutex *SDL_CreateMutex_srw(void)
{
@@ -143,12 +135,8 @@ static SDL_Mutex *SDL_CreateMutex_cs(void)
if (mutex) {
// Initialize
// On SMP systems, a non-zero spin count generally helps performance
#ifdef SDL_PLATFORM_WINRT
InitializeCriticalSectionEx(&mutex->cs, 2000, 0);
#else
// This function always succeeds
(void)InitializeCriticalSectionAndSpinCount(&mutex->cs, 2000);
#endif
}
return (SDL_Mutex *)mutex;
}
@@ -194,9 +182,6 @@ static const SDL_mutex_impl_t SDL_mutex_impl_cs = {
SDL_Mutex *SDL_CreateMutex(void)
{
if (!SDL_mutex_impl_active.Create) {
#ifdef SDL_PLATFORM_WINRT
const SDL_mutex_impl_t *impl = &SDL_mutex_impl_srw;
#else
const SDL_mutex_impl_t *impl = &SDL_mutex_impl_cs;
// Try faster implementation for Windows 7 and newer
@@ -212,7 +197,6 @@ SDL_Mutex *SDL_CreateMutex(void)
impl = &SDL_mutex_impl_srw;
}
}
#endif // SDL_PLATFORM_WINRT
// Copy instead of using pointer to save one level of indirection
SDL_copyp(&SDL_mutex_impl_active, impl);

View File

@@ -35,17 +35,6 @@ typedef VOID(WINAPI *pfnReleaseSRWLockExclusive)(PSRWLOCK);
typedef VOID(WINAPI *pfnAcquireSRWLockExclusive)(PSRWLOCK);
typedef BOOLEAN(WINAPI *pfnTryAcquireSRWLockExclusive)(PSRWLOCK);
#ifdef SDL_PLATFORM_WINRT
// Functions are guaranteed to be available
#define pTryAcquireSRWLockExclusive TryAcquireSRWLockExclusive
#define pInitializeSRWLock InitializeSRWLock
#define pReleaseSRWLockShared ReleaseSRWLockShared
#define pAcquireSRWLockShared AcquireSRWLockShared
#define pTryAcquireSRWLockShared TryAcquireSRWLockShared
#define pReleaseSRWLockExclusive ReleaseSRWLockExclusive
#define pAcquireSRWLockExclusive AcquireSRWLockExclusive
#define pTryAcquireSRWLockExclusive TryAcquireSRWLockExclusive
#else
static pfnInitializeSRWLock pInitializeSRWLock = NULL;
static pfnReleaseSRWLockShared pReleaseSRWLockShared = NULL;
static pfnAcquireSRWLockShared pAcquireSRWLockShared = NULL;
@@ -53,7 +42,6 @@ static pfnTryAcquireSRWLockShared pTryAcquireSRWLockShared = NULL;
static pfnReleaseSRWLockExclusive pReleaseSRWLockExclusive = NULL;
static pfnAcquireSRWLockExclusive pAcquireSRWLockExclusive = NULL;
static pfnTryAcquireSRWLockExclusive pTryAcquireSRWLockExclusive = NULL;
#endif
typedef SDL_RWLock *(*pfnSDL_CreateRWLock)(void);
typedef void (*pfnSDL_DestroyRWLock)(SDL_RWLock *);
@@ -152,7 +140,6 @@ static const SDL_rwlock_impl_t SDL_rwlock_impl_srw = {
&SDL_UnlockRWLock_srw
};
#ifndef SDL_PLATFORM_WINRT
#include "../generic/SDL_sysrwlock_c.h"
@@ -166,19 +153,12 @@ static const SDL_rwlock_impl_t SDL_rwlock_impl_generic = {
&SDL_TryLockRWLockForWriting_generic,
&SDL_UnlockRWLock_generic
};
#endif
SDL_RWLock *SDL_CreateRWLock(void)
{
if (!SDL_rwlock_impl_active.Create) {
const SDL_rwlock_impl_t *impl;
#ifdef SDL_PLATFORM_WINRT
// Link statically on this platform
impl = &SDL_rwlock_impl_srw;
#else
// Default to generic implementation, works with all mutex implementations
impl = &SDL_rwlock_impl_generic;
const SDL_rwlock_impl_t *impl = &SDL_rwlock_impl_generic;
{
HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll"));
if (kernel32) {
@@ -197,7 +177,6 @@ SDL_RWLock *SDL_CreateRWLock(void)
}
}
}
#endif
SDL_copyp(&SDL_rwlock_impl_active, impl);
}

View File

@@ -60,18 +60,11 @@ static SDL_sem_impl_t SDL_sem_impl_active = { 0 };
// APIs not available on WinPhone 8.1
// https://www.microsoft.com/en-us/download/details.aspx?id=47328
#if !SDL_WINAPI_FAMILY_PHONE
#ifdef SDL_PLATFORM_WINRT
// Functions are guaranteed to be available
#define pWaitOnAddress WaitOnAddress
#define pWakeByAddressSingle WakeByAddressSingle
#else
typedef BOOL(WINAPI *pfnWaitOnAddress)(volatile VOID *, PVOID, SIZE_T, DWORD);
typedef VOID(WINAPI *pfnWakeByAddressSingle)(PVOID);
static pfnWaitOnAddress pWaitOnAddress = NULL;
static pfnWakeByAddressSingle pWakeByAddressSingle = NULL;
#endif
typedef struct SDL_semaphore_atom
{
@@ -196,7 +189,6 @@ static const SDL_sem_impl_t SDL_sem_impl_atom = {
&SDL_GetSemaphoreValue_atom,
&SDL_SignalSemaphore_atom,
};
#endif // !SDL_WINAPI_FAMILY_PHONE
/**
* Fallback Semaphore implementation using Kernel Semaphores
@@ -217,12 +209,7 @@ static SDL_Semaphore *SDL_CreateSemaphore_kern(Uint32 initial_value)
sem = (SDL_sem_kern *)SDL_malloc(sizeof(*sem));
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 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);
#endif
sem->count = initial_value;
if (!sem->id) {
SDL_SetError("Couldn't create semaphore");
@@ -316,12 +303,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value)
// Default to fallback implementation
const SDL_sem_impl_t *impl = &SDL_sem_impl_kern;
#if !SDL_WINAPI_FAMILY_PHONE
if (!SDL_GetHintBoolean(SDL_HINT_WINDOWS_FORCE_SEMAPHORE_KERNEL, false)) {
#ifdef SDL_PLATFORM_WINRT
// Link statically on this platform
impl = &SDL_sem_impl_atom;
#else
/* We already statically link to features from this Api
* Set (e.g. WaitForSingleObject). Dynamically loading
* API Sets is not explicitly documented but according to
@@ -338,9 +320,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value)
impl = &SDL_sem_impl_atom;
}
}
#endif
}
#endif
// Copy instead of using pointer to save one level of indirection
SDL_copyp(&SDL_sem_impl_active, impl);

View File

@@ -109,7 +109,6 @@ void SDL_SYS_SetupThread(const char *name)
{
if (name) {
PVOID exceptionHandlerHandle;
#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;
@@ -133,7 +132,6 @@ void SDL_SYS_SetupThread(const char *name)
SDL_free(strw);
}
}
#endif
/* Presumably some version of Visual Studio will understand SetThreadDescription(),
but we still need to deal with older OSes and debuggers. Set it with the arcane

View File

@@ -27,18 +27,6 @@
#include "../SDL_thread_c.h"
#if WINAPI_FAMILY_WINRT
#include <fibersapi.h>
#ifndef TLS_OUT_OF_INDEXES
#define TLS_OUT_OF_INDEXES FLS_OUT_OF_INDEXES
#endif
#define TlsAlloc() FlsAlloc(NULL)
#define TlsSetValue FlsSetValue
#define TlsGetValue FlsGetValue
#endif
static DWORD thread_local_storage = TLS_OUT_OF_INDEXES;
static bool generic_local_storage = false;