lock is 32bits long. Using type "long" would promote 64bits on x86_64...
[AROS.git] / compiler / include / aros / types / spinlock_s.h
blobcc621d701c17653b43907d90116b5cd04673e4e4
1 #ifndef _AROS_TYPES_SPINLOCK_S_H_
2 #define _AROS_TYPES_SPINLOCK_S_H_
4 #include <aros/cpu.h>
6 typedef struct {
7 union
9 volatile struct {
10 unsigned int readcount : 24;
11 unsigned int _pad2 : 3;
12 unsigned int write : 1;
13 unsigned int _pad1 : 3;
14 unsigned int updating : 1;
15 } slock;
16 volatile unsigned char block[4];
17 volatile unsigned int lock;
19 } __attribute__((__aligned__(128))) spinlock_t;
21 #define SPINLOCK_UNLOCKED 0
22 #define SPINLOCKB_WRITE 27
23 #define SPINLOCKB_UPDATING 31
24 #define SPINLOCKF_WRITE (1 << SPINLOCKB_WRITE)
25 #define SPINLOCKF_UPDATING (1 << SPINLOCKB_UPDATING)
27 #define SPINLOCK_INIT_UNLOCKED { SPINLOCK_UNLOCKED }
28 #define SPINLOCK_INIT_WRITE_LOCKED { SPINLOCKF_WRITE }
29 #define SPINLOCK_INIT_READ_LOCKED(n) { n }
31 #define SPINLOCK_MODE_READ 0
32 #define SPINLOCK_MODE_WRITE 1
34 #endif /* ! _AROS_TYPES_SPINLOCK_S_H_ */