SDL_thread.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef _SDL_thread_h
  2. #define _SDL_thread_h
  3. #include "SDL_stdinc.h"
  4. #include "SDL_error.h"
  5. #include "SDL_atomic.h"
  6. #include "SDL_mutex.h"
  7. #include "begin_code.h"
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. struct SDL_Thread;
  12. typedef struct SDL_Thread SDL_Thread;
  13. typedef unsigned long SDL_threadID;
  14. typedef unsigned int SDL_TLSID;
  15. typedef enum {
  16. SDL_THREAD_PRIORITY_LOW,
  17. SDL_THREAD_PRIORITY_NORMAL,
  18. SDL_THREAD_PRIORITY_HIGH
  19. } SDL_ThreadPriority;
  20. typedef int (SDLCALL * SDL_ThreadFunction) (void *data);
  21. #if defined(__WIN32__) && !defined(HAVE_LIBC)
  22. #define SDL_PASSED_BEGINTHREAD_ENDTHREAD
  23. #include <process.h>
  24. typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned,
  25. unsigned (__stdcall *
  26. func) (void
  27. *),
  28. void *arg, unsigned,
  29. unsigned *threadID);
  30. typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code);
  31. extern DECLSPEC SDL_Thread *SDLCALL
  32. SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data,
  33. pfnSDL_CurrentBeginThread pfnBeginThread,
  34. pfnSDL_CurrentEndThread pfnEndThread);
  35. #define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex)
  36. #else
  37. extern DECLSPEC SDL_Thread *SDLCALL
  38. SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data);
  39. #endif
  40. typedef const char * SDLCALL tSDL_GetThreadName(SDL_Thread *thread);
  41. typedef SDL_threadID SDLCALL tSDL_ThreadID(void);
  42. typedef SDL_threadID SDLCALL tSDL_GetThreadID(SDL_Thread * thread);
  43. typedef int SDLCALL tSDL_SetThreadPriority(SDL_ThreadPriority priority);
  44. typedef void SDLCALL tSDL_WaitThread(SDL_Thread * thread, int *status);
  45. typedef SDL_TLSID SDLCALL tSDL_TLSCreate(void);
  46. typedef void * SDLCALL tSDL_TLSGet(SDL_TLSID id);
  47. typedef int SDLCALL tSDL_TLSSet(SDL_TLSID id, const void *value, void (*destructor)(void*));
  48. extern tSDL_GetThreadName *SDL_GetThreadName;
  49. extern tSDL_ThreadID *SDL_ThreadID;
  50. extern tSDL_GetThreadID *SDL_GetThreadID;
  51. extern tSDL_SetThreadPriority *SDL_SetThreadPriority;
  52. extern tSDL_WaitThread *SDL_WaitThread;
  53. extern tSDL_TLSCreate *SDL_TLSCreate;
  54. extern tSDL_TLSGet *SDL_TLSGet;
  55. extern tSDL_TLSSet *SDL_TLSSet;
  56. #ifdef __cplusplus
  57. }
  58. #endif
  59. #include "close_code.h"
  60. #endif