SDL_sysmutex_c.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2020 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. #include "../../core/windows/SDL_windows.h"
  20. #include "SDL_mutex.h"
  21. typedef SDL_mutex * (*pfnSDL_CreateMutex)(void);
  22. typedef int (*pfnSDL_LockMutex)(SDL_mutex *);
  23. typedef int (*pfnSDL_TryLockMutex)(SDL_mutex *);
  24. typedef int (*pfnSDL_UnlockMutex)(SDL_mutex *);
  25. typedef void (*pfnSDL_DestroyMutex)(SDL_mutex *);
  26. typedef enum
  27. {
  28. SDL_MUTEX_INVALID = 0,
  29. SDL_MUTEX_SRW,
  30. SDL_MUTEX_CS,
  31. } SDL_MutexType;
  32. typedef struct SDL_mutex_impl_t
  33. {
  34. pfnSDL_CreateMutex Create;
  35. pfnSDL_DestroyMutex Destroy;
  36. pfnSDL_LockMutex Lock;
  37. pfnSDL_TryLockMutex TryLock;
  38. pfnSDL_UnlockMutex Unlock;
  39. /* Needed by SDL_cond: */
  40. SDL_MutexType Type;
  41. } SDL_mutex_impl_t;
  42. extern SDL_mutex_impl_t SDL_mutex_impl_active;
  43. #ifndef SRWLOCK_INIT
  44. #define SRWLOCK_INIT {0}
  45. typedef struct _SRWLOCK {
  46. PVOID Ptr;
  47. } SRWLOCK, *PSRWLOCK;
  48. #endif
  49. typedef struct SDL_mutex_srw
  50. {
  51. SRWLOCK srw;
  52. /* SRW Locks are not recursive, that has to be handled by SDL: */
  53. DWORD count;
  54. DWORD owner;
  55. } SDL_mutex_srw;
  56. /* vi: set ts=4 sw=4 expandtab: */