bug from a long time :
[IRC.git] / Robust / src / Runtime / DSTM / interface / dsmlock.h
1 #ifndef _DSMLOCK_H_
2 #define _DSMLOCK_H_
3
4 #define RW_LOCK_BIAS             0x01000000
5 #define atomic_read(v)          (*v)
6 #define RW_LOCK_UNLOCKED          { RW_LOCK_BIAS }
7 //#define LOCK_PREFIX ""
8 #define LOCK_PREFIX \
9   ".section .smp_locks,\"a\"\n"   \
10   "  .align 4\n"                  \
11   "  .long 661f\n"             /* address */\
12   ".previous\n"                   \
13   "661:\n\tlock; "
14
15
16 void initdsmlocks(volatile int *addr);
17 int read_trylock(volatile int *lock);
18 int write_trylock(volatile int *lock);
19 void atomic_dec(volatile int *v);
20 void atomic_inc(volatile int *v);
21 static void atomic_add(int i, volatile int *v);
22 static int atomic_sub_and_test(int i, volatile int *v);
23 void read_unlock(volatile int *rw);
24 void write_unlock(volatile int *rw);
25 #endif