-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathlock.h
32 lines (26 loc) · 958 Bytes
/
lock.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// ***************************************************************
// lock.h - Creation date: 26/08/2022
// -------------------------------------------------------------
// NanoShell Copyright (C) 2022 - Licensed under GPL V3
//
// ***************************************************************
// Programmer(s): iProgramInCpp ([email protected])
// ***************************************************************
#ifndef _LOCK_H
#define _LOCK_H
typedef struct
{
volatile bool m_held;
volatile void* m_task_owning_it;
volatile void* m_return_addr;
}
SafeLock;
void LockAcquire (SafeLock *pLock);
void LockFree (SafeLock *pLock);
// note: you may NOT return from this. If you do, you've ruined the entire point of this.
#define USING_LOCK(lock, statement) do { \
LockAcquire(lock); \
statement; \
LockFree(lock); \
} while (0)
#endif