Mutex
Description
Mutex struct. Layout is platform-conditional but the API is uniform. Stack-declare with MutexInit(); do not poke fields.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Mutex.h:47:
_Atomic int _state;
#else
# error "Mutex: unsupported platform/architecture (no direct-syscall path)"
#endif
} Mutex;- In
Mutex.h:49:
# error "Mutex: unsupported platform/architecture (no direct-syscall path)"
#endif
} Mutex;
///
- In
Mutex.h:68:
#if PLATFORM_WINDOWS
// _lock is a void* layout-compatible with SRWLOCK. NULL = SRWLOCK_INIT.
# define MutexInit() ((Mutex) {._lock = NULL})
#elif FEATURE_DIRECT_SYSCALL
// _Atomic int = 0 is "unlocked" in the futex / __ulock state machine.
- In
Mutex.h:71:
#elif FEATURE_DIRECT_SYSCALL
// _Atomic int = 0 is "unlocked" in the futex / __ulock state machine.
# define MutexInit() ((Mutex) {._state = 0})
#endif- In
Mutex.h:84:
/// TAGS: Sys, Mutex, Deinit
///
void MutexDeinit(Mutex *m);
///
- In
Mutex.h:94:
/// TAGS: Sys, Mutex, Lock
///
Mutex *MutexLock(Mutex *m);
///
- In
Mutex.h:104:
/// TAGS: Sys, Mutex, Unlock
///
Mutex *MutexUnlock(Mutex *m);
#ifdef __cplusplus- In
Mutex.c:21:
/// lock, kernel32, no init call needed (just zero-init).
#include <Misra/Sys/Mutex.h>
#include <Misra/Std.h>- In
Mutex.c:46:
# endif
#else
# error "Mutex: unsupported platform/architecture (no direct-syscall path)"
#endif- In
Mutex.c:82:
#endif
void MutexDeinit(Mutex *m) {
if (!m) {
return;- In
Mutex.c:93:
# error "MutexDeinit: unsupported platform/architecture (no direct-syscall path)"
#endif
MemSet(m, 0, sizeof(Mutex));
}- In
Mutex.c:96:
}
Mutex *MutexLock(Mutex *m) {
if (!m) {
LOG_FATAL("MutexLock: NULL mutex");- In
Mutex.c:136:
}
Mutex *MutexUnlock(Mutex *m) {
if (!m) {
LOG_FATAL("MutexUnlock: NULL mutex");
Last updated on