Revision 164d1586 xseg/xtypes/xlock.h
b/xseg/xtypes/xlock.h | ||
---|---|---|
1 |
#ifndef _XQ_LOCK_H
|
|
2 |
#define _XQ_LOCK_H
|
|
1 |
#ifndef _XLOCK_H |
|
2 |
#define _XLOCK_H |
|
3 | 3 |
|
4 | 4 |
#define MFENCE() __sync_synchronize() |
5 | 5 |
#define BARRIER() __asm__ __volatile__ ("" ::: "memory") |
... | ... | |
9 | 9 |
|
10 | 10 |
#define Noone ((unsigned long)-1) |
11 | 11 |
|
12 |
struct xq_lock {
|
|
12 |
struct xlock { |
|
13 | 13 |
long owner; |
14 | 14 |
} __attribute__ ((aligned (16))); /* support up to 128bit longs */ |
15 | 15 |
|
16 |
static inline unsigned long xq_acquire(struct xq_lock *lock, unsigned long who)
|
|
16 |
static inline unsigned long xlock_acquire(struct xlock *lock, unsigned long who)
|
|
17 | 17 |
{ |
18 | 18 |
for (;;) { |
19 | 19 |
for (; *(volatile unsigned long *)(&lock->owner) != Noone; ) |
... | ... | |
26 | 26 |
return who; |
27 | 27 |
} |
28 | 28 |
|
29 |
static inline void xq_release(struct xq_lock *lock)
|
|
29 |
static inline void xlock_release(struct xlock *lock)
|
|
30 | 30 |
{ |
31 | 31 |
lock->owner = Noone; |
32 | 32 |
} |
33 | 33 |
|
34 |
static inline unsigned long xq_get_owner(struct xq_lock *lock)
|
|
34 |
static inline unsigned long xlock_get_owner(struct xlock *lock)
|
|
35 | 35 |
{ |
36 | 36 |
return *(volatile unsigned long *)(&lock->owner); |
37 | 37 |
} |
Also available in: Unified diff