0.2.0-dev Download ZIP
73 lines ·2.0 KB Raw
| 1 | /* |
| 2 | Simple DirectMedia Layer |
| 3 | Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org> |
| 4 | |
| 5 | This software is provided 'as-is', without any express or implied |
| 6 | warranty. In no event will the authors be held liable for any damages |
| 7 | arising from the use of this software. |
| 8 | |
| 9 | Permission is granted to anyone to use this software for any purpose, |
| 10 | including commercial applications, and to alter it and redistribute it |
| 11 | freely, subject to the following restrictions: |
| 12 | |
| 13 | 1. The origin of this software must not be misrepresented; you must not |
| 14 | claim that you wrote the original software. If you use this software |
| 15 | in a product, an acknowledgment in the product documentation would be |
| 16 | appreciated but is not required. |
| 17 | 2. Altered source versions must be plainly marked as such, and must not be |
| 18 | misrepresented as being the original software. |
| 19 | 3. This notice may not be removed or altered from any source distribution. |
| 20 | */ |
| 21 | #include "SDL_internal.h" |
| 22 | |
| 23 | #include "../../core/windows/SDL_windows.h" |
| 24 | |
| 25 | typedef SDL_Mutex *(*pfnSDL_CreateMutex)(void); |
| 26 | typedef void (*pfnSDL_LockMutex)(SDL_Mutex *); |
| 27 | typedef bool (*pfnSDL_TryLockMutex)(SDL_Mutex *); |
| 28 | typedef void (*pfnSDL_UnlockMutex)(SDL_Mutex *); |
| 29 | typedef void (*pfnSDL_DestroyMutex)(SDL_Mutex *); |
| 30 | |
| 31 | typedef enum |
| 32 | { |
| 33 | SDL_MUTEX_INVALID = 0, |
| 34 | SDL_MUTEX_SRW, |
| 35 | SDL_MUTEX_CS, |
| 36 | } SDL_MutexType; |
| 37 | |
| 38 | typedef struct SDL_mutex_impl_t |
| 39 | { |
| 40 | pfnSDL_CreateMutex Create; |
| 41 | pfnSDL_DestroyMutex Destroy; |
| 42 | pfnSDL_LockMutex Lock; |
| 43 | pfnSDL_TryLockMutex TryLock; |
| 44 | pfnSDL_UnlockMutex Unlock; |
| 45 | // Needed by SDL_Condition: |
| 46 | SDL_MutexType Type; |
| 47 | } SDL_mutex_impl_t; |
| 48 | |
| 49 | extern SDL_mutex_impl_t SDL_mutex_impl_active; |
| 50 | |
| 51 | #ifndef SRWLOCK_INIT |
| 52 | #define SRWLOCK_INIT \ |
| 53 | { \ |
| 54 | 0 \ |
| 55 | } |
| 56 | typedef struct _SRWLOCK |
| 57 | { |
| 58 | PVOID Ptr; |
| 59 | } SRWLOCK, *PSRWLOCK; |
| 60 | #endif |
| 61 | |
| 62 | typedef struct SDL_mutex_srw |
| 63 | { |
| 64 | SRWLOCK srw; |
| 65 | // SRW Locks are not recursive, that has to be handled by SDL: |
| 66 | DWORD count; |
| 67 | DWORD owner; |
| 68 | } SDL_mutex_srw; |
| 69 | |
| 70 | typedef struct SDL_mutex_cs |
| 71 | { |
| 72 | CRITICAL_SECTION cs; |
| 73 | } SDL_mutex_cs; |