try to make sure compiler/include/mmakefile is always refreshed correctly.
[AROS.git] / rom / exec / exec_locks.h
blob85ca18f5746526da4fcae4a336cb02ef7d808565
1 #ifndef _EXEC_LOCKS_H
2 #define _EXEC_LOCKS_H
4 /*
5 Copyright © 2017, The AROS Development Team. All rights reserved.
6 $Id$
7 */
9 #include <aros/config.h>
10 #include <exec/nodes.h>
11 #include <resources/execlock.h>
12 #include "exec_debug.h"
13 #include "exec_intern.h"
16 * NB : This file is only for internal Exec access to the ExecLock resource functions.
17 * All other code should use the public execlock.resource interface(s).
20 struct ExecLockBase
22 struct Node el_Node;
24 int (*ObtainSystemLock)(struct List *list, ULONG mode, ULONG flags);
25 void (*ReleaseSystemLock)(struct List *list, ULONG flags);
26 void * (*AllocLock)();
27 void (*FreeLock)(void *lock);
28 int (*ObtainLock)(void *lock, ULONG mode, ULONG flags);
29 void (*ReleaseLock)(void *lock, ULONG flags);
32 #if defined (__AROSEXEC_SMP__)
34 #define EXEC_LOCK_LIST_WRITE_AND_FORBID(list) do { \
35 struct ExecLockBase *b; \
36 if ((b = PrivExecBase(SysBase)->ExecLockBase)) { \
37 b->ObtainSystemLock(list, SPINLOCK_MODE_WRITE, LOCKF_FORBID); \
38 } else Forbid(); } while(0)
40 #define EXEC_LOCK_LIST_WRITE_AND_DISABLE(list) do { \
41 struct ExecLockBase *b; \
42 if ((b = PrivExecBase(SysBase)->ExecLockBase)) { \
43 b->ObtainSystemLock(list, SPINLOCK_MODE_WRITE, LOCKF_DISABLE); \
44 } else Disable(); } while(0)
46 #define EXEC_LOCK_LIST_READ_AND_FORBID(list) do { \
47 struct ExecLockBase *b; \
48 if ((b = PrivExecBase(SysBase)->ExecLockBase)) { \
49 b->ObtainSystemLock(list, SPINLOCK_MODE_READ, LOCKF_FORBID); \
50 } else Forbid(); } while(0)
52 #define EXEC_LOCK_LIST_READ_AND_DISABLE(list) do { \
53 struct ExecLockBase *b; \
54 if ((b = PrivExecBase(SysBase)->ExecLockBase)) { \
55 b->ObtainSystemLock(list, SPINLOCK_MODE_READ, LOCKF_DISABLE); \
56 } else Disable(); } while(0)
58 #define EXEC_UNLOCK_LIST_AND_PERMIT(list) do { \
59 struct ExecLockBase *b; \
60 if ((b = PrivExecBase(SysBase)->ExecLockBase)) { \
61 b->ReleaseSystemLock(list, LOCKF_FORBID); \
62 } else Permit(); } while(0)
64 #define EXEC_UNLOCK_LIST_AND_ENABLE(list) do { \
65 struct ExecLockBase *b; \
66 if ((b = PrivExecBase(SysBase)->ExecLockBase)) { \
67 b->ReleaseSystemLock(list, LOCKF_DISABLE); \
68 } else Enable(); } while(0)
70 #define EXEC_LOCK_LIST_WRITE(list) do { \
71 struct ExecLockBase *b; \
72 if ((b = PrivExecBase(SysBase)->ExecLockBase)) { \
73 b->ObtainSystemLock(list, SPINLOCK_MODE_WRITE, 0); \
74 } } while(0)
76 #define EXEC_LOCK_LIST_READ(list) do { \
77 struct ExecLockBase *b; \
78 if ((b = PrivExecBase(SysBase)->ExecLockBase)) { \
79 b->ObtainSystemLock(list, SPINLOCK_MODE_READ, 0); \
80 } } while(0)
82 #define EXEC_UNLOCK_LIST(list) do { \
83 struct ExecLockBase *b; \
84 if ((b = PrivExecBase(SysBase)->ExecLockBase)) { \
85 b->ReleaseSystemLock(list, 0); \
86 } } while(0)
88 #define EXEC_LOCK_READ(lock) do { \
89 struct ExecLockBase *b; \
90 if ((b = PrivExecBase(SysBase)->ExecLockBase)) { \
91 b->ObtainLock(lock, SPINLOCK_MODE_READ, 0); \
92 } } while(0)
94 #define EXEC_LOCK_WRITE(lock) do { \
95 struct ExecLockBase *b; \
96 if ((b = PrivExecBase(SysBase)->ExecLockBase)) { \
97 b->ObtainLock(lock, SPINLOCK_MODE_WRITE, 0); \
98 } } while(0)
100 #define EXEC_LOCK_READ_AND_FORBID(lock) do { \
101 struct ExecLockBase *b; \
102 if ((b = PrivExecBase(SysBase)->ExecLockBase)) { \
103 b->ObtainLock(lock, SPINLOCK_MODE_READ, LOCKF_FORBID); \
104 } else Forbid(); } while(0)
106 #define EXEC_LOCK_WRITE_AND_FORBID(lock) do { \
107 struct ExecLockBase *b; \
108 if ((b = PrivExecBase(SysBase)->ExecLockBase)) { \
109 b->ObtainLock(lock, SPINLOCK_MODE_WRITE, LOCKF_FORBID); \
110 } else Forbid(); } while(0)
112 #define EXEC_LOCK_READ_AND_DISABLE(lock) do { \
113 struct ExecLockBase *b; \
114 if ((b = PrivExecBase(SysBase)->ExecLockBase)) { \
115 b->ObtainLock(lock, SPINLOCK_MODE_READ, LOCKF_DISABLE); \
116 } else Disable(); } while(0)
118 #define EXEC_LOCK_WRITE_AND_DISABLE(lock) do { \
119 struct ExecLockBase *b; \
120 if ((b = PrivExecBase(SysBase)->ExecLockBase)) { \
121 b->ObtainLock(lock, SPINLOCK_MODE_WRITE, LOCKF_DISABLE); \
122 } else Disable(); } while(0)
124 #define EXEC_UNLOCK(lock) do { \
125 struct ExecLockBase *b; \
126 if ((b = PrivExecBase(SysBase)->ExecLockBase)) { \
127 b->ReleaseLock(lock, 0); \
128 } } while(0)
130 #define EXEC_UNLOCK_AND_PERMIT(lock) do { \
131 struct ExecLockBase *b; \
132 if ((b = PrivExecBase(SysBase)->ExecLockBase)) { \
133 b->ReleaseLock(lock, LOCKF_FORBID); \
134 } else Permit(); } while(0)
136 #define EXEC_UNLOCK_AND_ENABLE(lock) do { \
137 struct ExecLockBase *b; \
138 if ((b = PrivExecBase(SysBase)->ExecLockBase)) { \
139 b->ReleaseLock(lock, LOCKF_DISABLE); \
140 } else Enable(); } while(0)
142 #else
144 #define EXEC_LOCK_LIST_READ_AND_FORBID(list) do { Forbid(); } while(0)
145 #define EXEC_LOCK_LIST_READ_AND_DISABLE(list) do { Disable(); } while(0)
146 #define EXEC_LOCK_LIST_WRITE_AND_FORBID(list) do { Forbid(); } while(0)
147 #define EXEC_LOCK_LIST_WRITE_AND_DISABLE(list) do { Disable(); } while(0)
148 #define EXEC_UNLOCK_LIST_AND_PERMIT(list) do { Permit(); } while(0)
149 #define EXEC_UNLOCK_LIST_AND_ENABLE(list) do { Enable(); } while(0)
150 #define EXEC_LOCK_LIST_READ(list) /* eps */
151 #define EXEC_LOCK_LIST_WRITE(list) /* eps */
152 #define EXEC_UNLOCK_LIST(list) /* eps */
153 #define EXEC_LOCK_READ(lock) /* eps */
154 #define EXEC_LOCK_WRITE(lock) /* eps */
155 #define EXEC_LOCK_READ_AND_FORBID(lock) do { Forbid(); } while(0)
156 #define EXEC_LOCK_WRITE_AND_FORBID(lock) do { Forbid(); } while(0)
157 #define EXEC_LOCK_READ_AND_DISABLE(lock) do { Disable(); } while(0)
158 #define EXEC_LOCK_WRITE_AND_DISABLE(lock) do { Disable(); } while(0)
159 #define EXEC_UNLOCK(lock) /* eps */
160 #define EXEC_UNLOCK_AND_PERMIT(lock) do { Permit(); } while(0)
161 #define EXEC_UNLOCK_AND_ENABLE(lock) do { Enable(); } while(0)
163 #endif
165 #endif /* _EXEC_LOCKS_H */