Merge commit '852f2a6343518919e5ca8d3c1bbcab9f493e3cd8'
This commit is contained in:
12
external/sdl/SDL/src/thread/n3ds/SDL_syscond.c
vendored
12
external/sdl/SDL/src/thread/n3ds/SDL_syscond.c
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -37,8 +37,6 @@ SDL_Condition *SDL_CreateCondition(void)
|
||||
SDL_Condition *cond = (SDL_Condition *)SDL_malloc(sizeof(SDL_Condition));
|
||||
if (cond) {
|
||||
CondVar_Init(&cond->cond_variable);
|
||||
} else {
|
||||
SDL_OutOfMemory();
|
||||
}
|
||||
return cond;
|
||||
}
|
||||
@ -54,7 +52,7 @@ void SDL_DestroyCondition(SDL_Condition *cond)
|
||||
/* Restart one of the threads that are waiting on the condition variable */
|
||||
int SDL_SignalCondition(SDL_Condition *cond)
|
||||
{
|
||||
if (cond == NULL) {
|
||||
if (!cond) {
|
||||
return SDL_InvalidParamError("cond");
|
||||
}
|
||||
|
||||
@ -65,7 +63,7 @@ int SDL_SignalCondition(SDL_Condition *cond)
|
||||
/* Restart all threads that are waiting on the condition variable */
|
||||
int SDL_BroadcastCondition(SDL_Condition *cond)
|
||||
{
|
||||
if (cond == NULL) {
|
||||
if (!cond) {
|
||||
return SDL_InvalidParamError("cond");
|
||||
}
|
||||
|
||||
@ -98,10 +96,10 @@ int SDL_WaitConditionTimeoutNS(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 tim
|
||||
{
|
||||
Result res;
|
||||
|
||||
if (cond == NULL) {
|
||||
if (!cond) {
|
||||
return SDL_InvalidParamError("cond");
|
||||
}
|
||||
if (mutex == NULL) {
|
||||
if (!mutex) {
|
||||
return SDL_InvalidParamError("mutex");
|
||||
}
|
||||
|
||||
|
44
external/sdl/SDL/src/thread/n3ds/SDL_sysmutex.c
vendored
44
external/sdl/SDL/src/thread/n3ds/SDL_sysmutex.c
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -22,26 +22,19 @@
|
||||
|
||||
#ifdef SDL_THREAD_N3DS
|
||||
|
||||
/* An implementation of mutexes using libctru's RecursiveLock */
|
||||
// An implementation of mutexes using libctru's RecursiveLock
|
||||
|
||||
#include "SDL_sysmutex_c.h"
|
||||
|
||||
/* Create a mutex */
|
||||
SDL_Mutex *SDL_CreateMutex(void)
|
||||
{
|
||||
SDL_Mutex *mutex;
|
||||
|
||||
/* Allocate mutex memory */
|
||||
mutex = (SDL_Mutex *)SDL_malloc(sizeof(*mutex));
|
||||
SDL_Mutex *mutex = (SDL_Mutex *)SDL_malloc(sizeof(*mutex));
|
||||
if (mutex) {
|
||||
RecursiveLock_Init(&mutex->lock);
|
||||
} else {
|
||||
SDL_OutOfMemory();
|
||||
}
|
||||
return mutex;
|
||||
}
|
||||
|
||||
/* Free the mutex */
|
||||
void SDL_DestroyMutex(SDL_Mutex *mutex)
|
||||
{
|
||||
if (mutex) {
|
||||
@ -49,38 +42,23 @@ void SDL_DestroyMutex(SDL_Mutex *mutex)
|
||||
}
|
||||
}
|
||||
|
||||
/* Lock the mutex */
|
||||
int SDL_LockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
|
||||
void SDL_LockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS // clang doesn't know about NULL mutexes
|
||||
{
|
||||
if (mutex == NULL) {
|
||||
return 0;
|
||||
if (mutex != NULL) {
|
||||
RecursiveLock_Lock(&mutex->lock);
|
||||
}
|
||||
|
||||
RecursiveLock_Lock(&mutex->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* try Lock the mutex */
|
||||
int SDL_TryLockMutex(SDL_Mutex *mutex)
|
||||
{
|
||||
if (mutex == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return RecursiveLock_TryLock(&mutex->lock);
|
||||
return (!mutex) ? 0 : RecursiveLock_TryLock(&mutex->lock);
|
||||
}
|
||||
|
||||
/* Unlock the mutex */
|
||||
int SDL_UnlockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */
|
||||
void SDL_UnlockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS // clang doesn't know about NULL mutexes
|
||||
{
|
||||
if (mutex == NULL) {
|
||||
return 0;
|
||||
if (mutex != NULL) {
|
||||
RecursiveLock_Unlock(&mutex->lock);
|
||||
}
|
||||
|
||||
RecursiveLock_Unlock(&mutex->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* SDL_THREAD_N3DS */
|
||||
#endif // SDL_THREAD_N3DS
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
13
external/sdl/SDL/src/thread/n3ds/SDL_syssem.c
vendored
13
external/sdl/SDL/src/thread/n3ds/SDL_syssem.c
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -43,8 +43,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value)
|
||||
}
|
||||
|
||||
sem = (SDL_Semaphore *)SDL_malloc(sizeof(*sem));
|
||||
if (sem == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
if (!sem) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -63,11 +62,11 @@ void SDL_DestroySemaphore(SDL_Semaphore *sem)
|
||||
|
||||
int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
|
||||
{
|
||||
if (sem == NULL) {
|
||||
if (!sem) {
|
||||
return SDL_InvalidParamError("sem");
|
||||
}
|
||||
|
||||
if (timeoutNS == SDL_MUTEX_MAXWAIT) {
|
||||
if (timeoutNS == -1) { // -1 == wait indefinitely.
|
||||
LightSemaphore_Acquire(&sem->semaphore, 1);
|
||||
return 0;
|
||||
}
|
||||
@ -99,7 +98,7 @@ int WaitOnSemaphoreFor(SDL_Semaphore *sem, Sint64 timeout)
|
||||
|
||||
Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem)
|
||||
{
|
||||
if (sem == NULL) {
|
||||
if (!sem) {
|
||||
SDL_InvalidParamError("sem");
|
||||
return 0;
|
||||
}
|
||||
@ -108,7 +107,7 @@ Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem)
|
||||
|
||||
int SDL_PostSemaphore(SDL_Semaphore *sem)
|
||||
{
|
||||
if (sem == NULL) {
|
||||
if (!sem) {
|
||||
return SDL_InvalidParamError("sem");
|
||||
}
|
||||
LightSemaphore_Release(&sem->semaphore, 1);
|
||||
|
28
external/sdl/SDL/src/thread/n3ds/SDL_systhread.c
vendored
28
external/sdl/SDL/src/thread/n3ds/SDL_systhread.c
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -26,9 +26,8 @@
|
||||
|
||||
#include "../SDL_systhread.h"
|
||||
|
||||
/* N3DS has very limited RAM (128MB), so we put a limit on thread stack size. */
|
||||
#define N3DS_THREAD_STACK_SIZE_MAX (16 * 1024)
|
||||
#define N3DS_THREAD_STACK_SIZE_DEFAULT (4 * 1024)
|
||||
/* N3DS has very limited RAM (128MB), so we set a low default thread stack size. */
|
||||
#define N3DS_THREAD_STACK_SIZE_DEFAULT (80 * 1024)
|
||||
|
||||
#define N3DS_THREAD_PRIORITY_LOW 0x3F /**< Minimum priority */
|
||||
#define N3DS_THREAD_PRIORITY_MEDIUM 0x2F /**< Slightly higher than main thread (0x30) */
|
||||
@ -49,18 +48,25 @@ static void ThreadEntry(void *arg)
|
||||
|
||||
int SDL_SYS_CreateThread(SDL_Thread *thread)
|
||||
{
|
||||
s32 priority;
|
||||
s32 priority = 0x30;
|
||||
int cpu = -1;
|
||||
size_t stack_size = GetStackSize(thread->stacksize);
|
||||
|
||||
svcGetThreadPriority(&priority, CUR_THREAD_HANDLE);
|
||||
|
||||
/* prefer putting audio thread on system core */
|
||||
if (thread->name && (SDL_strncmp(thread->name, "SDLAudioP", 9) == 0) && R_SUCCEEDED(APT_SetAppCpuTimeLimit(30))) {
|
||||
cpu = 1;
|
||||
}
|
||||
|
||||
thread->handle = threadCreate(ThreadEntry,
|
||||
thread,
|
||||
stack_size,
|
||||
priority,
|
||||
-1,
|
||||
cpu,
|
||||
false);
|
||||
|
||||
if (thread->handle == NULL) {
|
||||
if (!thread->handle) {
|
||||
return SDL_SetError("Couldn't create thread");
|
||||
}
|
||||
|
||||
@ -73,14 +79,6 @@ static size_t GetStackSize(size_t requested_size)
|
||||
return N3DS_THREAD_STACK_SIZE_DEFAULT;
|
||||
}
|
||||
|
||||
if (requested_size > N3DS_THREAD_STACK_SIZE_MAX) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_SYSTEM,
|
||||
"Requested a thread size of %zu,"
|
||||
" falling back to the maximum supported of %zu\n",
|
||||
requested_size,
|
||||
N3DS_THREAD_STACK_SIZE_MAX);
|
||||
requested_size = N3DS_THREAD_STACK_SIZE_MAX;
|
||||
}
|
||||
return requested_size;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
Reference in New Issue
Block a user