2022-05-03 17:51:49 +02:00
|
|
|
/*
|
|
|
|
|
Simple DirectMedia Layer
|
2024-01-01 13:15:26 -08:00
|
|
|
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
2022-05-03 17:51:49 +02:00
|
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
|
arising from the use of this software.
|
|
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
|
freely, subject to the following restrictions:
|
|
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
|
|
|
claim that you wrote the original software. If you use this software
|
|
|
|
|
in a product, an acknowledgment in the product documentation would be
|
|
|
|
|
appreciated but is not required.
|
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
|
|
|
misrepresented as being the original software.
|
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
|
|
|
*/
|
2022-11-29 18:34:15 -08:00
|
|
|
#include "SDL_internal.h"
|
2022-05-03 17:51:49 +02:00
|
|
|
|
2023-03-29 21:49:01 +00:00
|
|
|
#ifdef SDL_THREAD_NGAGE
|
2022-05-03 17:51:49 +02:00
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// N-Gage thread management routines for SDL
|
2022-05-03 17:51:49 +02:00
|
|
|
|
|
|
|
|
#include <e32std.h>
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
#undef NULL
|
|
|
|
|
#include "../SDL_systhread.h"
|
|
|
|
|
#include "../SDL_thread_c.h"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int object_count;
|
|
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
static int RunThread(TAny *data)
|
2022-05-03 17:51:49 +02:00
|
|
|
{
|
2022-11-30 12:51:59 -08:00
|
|
|
SDL_RunThread((SDL_Thread *)data);
|
2022-11-27 17:38:43 +01:00
|
|
|
return 0;
|
2022-05-03 17:51:49 +02:00
|
|
|
}
|
|
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
static TInt NewThread(const TDesC &aName, TAny *aPtr1, TAny *aPtr2)
|
2022-05-03 17:51:49 +02:00
|
|
|
{
|
2022-11-27 17:38:43 +01:00
|
|
|
return ((RThread *)(aPtr1))->Create(aName, RunThread, KDefaultStackSize, NULL, aPtr2);
|
2022-05-03 17:51:49 +02:00
|
|
|
}
|
|
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
int CreateUnique(TInt (*aFunc)(const TDesC &aName, TAny *, TAny *), TAny *aPtr1, TAny *aPtr2)
|
2022-05-03 17:51:49 +02:00
|
|
|
{
|
|
|
|
|
TBuf<16> name;
|
2022-11-30 12:51:59 -08:00
|
|
|
TInt status = KErrNone;
|
2022-11-29 17:30:03 +01:00
|
|
|
do {
|
2022-05-03 17:51:49 +02:00
|
|
|
object_count++;
|
|
|
|
|
name.Format(_L("SDL_%x"), object_count);
|
|
|
|
|
status = aFunc(name, aPtr1, aPtr2);
|
2022-11-29 17:30:03 +01:00
|
|
|
} while (status == KErrAlreadyExists);
|
2022-05-03 17:51:49 +02:00
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-22 17:33:49 -07:00
|
|
|
bool SDL_SYS_CreateThread(SDL_Thread *thread,
|
|
|
|
|
SDL_FunctionPointer pfnBeginThread,
|
|
|
|
|
SDL_FunctionPointer pfnEndThread)
|
2022-05-03 17:51:49 +02:00
|
|
|
{
|
|
|
|
|
RThread rthread;
|
|
|
|
|
|
|
|
|
|
TInt status = CreateUnique(NewThread, &rthread, thread);
|
2022-11-27 17:38:43 +01:00
|
|
|
if (status != KErrNone) {
|
2023-02-03 22:08:42 +01:00
|
|
|
delete (RThread *)thread->handle;
|
2022-05-03 17:51:49 +02:00
|
|
|
thread->handle = NULL;
|
2022-11-29 17:30:03 +01:00
|
|
|
return SDL_SetError("Not enough resources to create thread");
|
2022-05-03 17:51:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rthread.Resume();
|
|
|
|
|
thread->handle = rthread.Handle();
|
2024-08-22 17:33:49 -07:00
|
|
|
return true;
|
2022-05-03 17:51:49 +02:00
|
|
|
}
|
|
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
void SDL_SYS_SetupThread(const char *name)
|
2022-05-03 17:51:49 +02:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-18 04:57:12 -08:00
|
|
|
SDL_ThreadID SDL_GetCurrentThreadID(void)
|
2022-05-03 17:51:49 +02:00
|
|
|
{
|
2022-11-30 12:51:59 -08:00
|
|
|
RThread current;
|
2022-05-03 17:51:49 +02:00
|
|
|
TThreadId id = current.Id();
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-22 17:33:49 -07:00
|
|
|
bool SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
|
2022-05-03 17:51:49 +02:00
|
|
|
{
|
2024-08-22 17:33:49 -07:00
|
|
|
return true;
|
2022-05-03 17:51:49 +02:00
|
|
|
}
|
|
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
void SDL_SYS_WaitThread(SDL_Thread *thread)
|
2022-05-03 17:51:49 +02:00
|
|
|
{
|
|
|
|
|
RThread t;
|
|
|
|
|
t.Open(thread->threadid);
|
2022-11-27 17:38:43 +01:00
|
|
|
if (t.ExitReason() == EExitPending) {
|
2022-05-03 17:51:49 +02:00
|
|
|
TRequestStatus status;
|
|
|
|
|
t.Logon(status);
|
|
|
|
|
User::WaitForRequest(status);
|
|
|
|
|
}
|
|
|
|
|
t.Close();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
void SDL_SYS_DetachThread(SDL_Thread *thread)
|
2022-05-03 17:51:49 +02:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
#endif // SDL_THREAD_NGAGE
|