changes
[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
17 typedef struct {
18   unsigned int counter;
19 } atomic_t;
20
21 void initdsmlocks(volatile unsigned int *addr);
22 void readLock(volatile unsigned int *addr);
23 void writeLock(volatile unsigned int *addr);
24 int read_trylock(volatile unsigned int *lock);
25 int write_trylock(volatile unsigned int *lock);
26 void atomic_dec(volatile unsigned int *v);
27 void atomic_inc(volatile unsigned int *v);
28 static void atomic_add(int i, atomic_t *v);
29 static int atomic_sub_and_test(int i, atomic_t *v);
30 void read_unlock(volatile unsigned int *rw);
31 void write_unlock(volatile unsigned int *rw);
32 #endif