Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/sdl/thread/windows/SDL_sysmutex_c.h
9905 views
1
/*
2
Simple DirectMedia Layer
3
Copyright (C) 1997-2025 Sam Lantinga <[email protected]>
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;
74
75