SDL_systhread.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. #include "SDL_internal.h"
  19. // These are functions that need to be implemented by a port of SDL
  20. #ifndef SDL_systhread_h_
  21. #define SDL_systhread_h_
  22. #include "SDL_thread_c.h"
  23. // Set up for C function definitions, even when using C++
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /* This function creates a thread, passing args to SDL_RunThread(),
  28. saves a system-dependent thread id in thread->id, and returns 0
  29. on success.
  30. */
  31. extern bool SDL_SYS_CreateThread(SDL_Thread *thread,
  32. SDL_FunctionPointer pfnBeginThread,
  33. SDL_FunctionPointer pfnEndThread);
  34. // This function does any necessary setup in the child thread
  35. extern void SDL_SYS_SetupThread(const char *name);
  36. // This function sets the current thread priority
  37. extern bool SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority);
  38. /* This function waits for the thread to finish and frees any data
  39. allocated by SDL_SYS_CreateThread()
  40. */
  41. extern void SDL_SYS_WaitThread(SDL_Thread *thread);
  42. // Mark thread as cleaned up as soon as it exits, without joining.
  43. extern void SDL_SYS_DetachThread(SDL_Thread *thread);
  44. // Initialize the global TLS data
  45. extern void SDL_SYS_InitTLSData(void);
  46. // Get the thread local storage for this thread
  47. extern SDL_TLSData *SDL_SYS_GetTLSData(void);
  48. // Set the thread local storage for this thread
  49. extern bool SDL_SYS_SetTLSData(SDL_TLSData *data);
  50. // Quit the global TLS data
  51. extern void SDL_SYS_QuitTLSData(void);
  52. // A helper function for setting up a thread with a stack size.
  53. extern SDL_Thread *SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, size_t stacksize, void *data);
  54. // Ends C function definitions when using C++
  55. #ifdef __cplusplus
  56. }
  57. #endif
  58. #endif // SDL_systhread_h_