My Project
Loading...
Searching...
No Matches
SDL_mutex.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2023 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
22#ifndef SDL_mutex_h_
23#define SDL_mutex_h_
24
31#include "SDL_stdinc.h"
32#include "SDL_error.h"
33
34#include "begin_code.h"
35/* Set up for C function definitions, even when using C++ */
36#ifdef __cplusplus
37extern "C" {
38#endif
39
44#define SDL_MUTEX_TIMEDOUT 1
45
49#define SDL_MUTEX_MAXWAIT (~(Uint32)0)
50
51
55/* @{ */
56
57/* The SDL mutex structure, defined in SDL_sysmutex.c */
58struct SDL_mutex;
59typedef struct SDL_mutex SDL_mutex;
60
81extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void);
82
99extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex);
100#define SDL_mutexP(m) SDL_LockMutex(m)
101
122extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex);
123
141extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex);
142#define SDL_mutexV(m) SDL_UnlockMutex(m)
143
162extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex * mutex);
163
164/* @} *//* Mutex functions */
165
166
170/* @{ */
171
172/* The SDL semaphore structure, defined in SDL_syssem.c */
173struct SDL_semaphore;
174typedef struct SDL_semaphore SDL_sem;
175
198extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value);
199
217extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem * sem);
218
244extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem * sem);
245
268extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem);
269
293extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms);
294
311extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem * sem);
312
323extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem * sem);
324
325/* @} *//* Semaphore functions */
326
327
331/* @{ */
332
333/* The SDL condition variable structure, defined in SDL_syscond.c */
334struct SDL_cond;
335typedef struct SDL_cond SDL_cond;
336
351extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void);
352
366extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond * cond);
367
383extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond * cond);
384
400extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond * cond);
401
428extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex);
429
457extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond * cond,
458 SDL_mutex * mutex, Uint32 ms);
459
460/* @} *//* Condition variable functions */
461
462
463/* Ends C function definitions when using C++ */
464#ifdef __cplusplus
465}
466#endif
467#include "close_code.h"
468
469#endif /* SDL_mutex_h_ */
470
471/* vi: set ts=4 sw=4 expandtab: */
DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void)
DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex *mutex)
DECLSPEC int SDLCALL SDL_SemPost(SDL_sem *sem)
DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond *cond)
DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem)
DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond *cond)
DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem *sem, Uint32 ms)
DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex *mutex)
DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem *sem)
DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond *cond)
DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void)
DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms)
DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex *mutex)
DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value)
DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem *sem)
DECLSPEC int SDLCALL SDL_SemWait(SDL_sem *sem)
DECLSPEC int SDLCALL SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex)
DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex *mutex)