diff options
author | Andrew Waterman <waterman@s141.Millennium.Berkeley.EDU> | 2010-08-18 18:24:55 -0700 |
---|---|---|
committer | Andrew Waterman <waterman@s141.Millennium.Berkeley.EDU> | 2010-08-18 18:24:55 -0700 |
commit | 29cc0dc9854c66f12bd65e12516f68ccd9a741da (patch) | |
tree | 23bd8147007d3d0fbb005f578f395e71f7d7d18d /pk/atomic.h | |
parent | e97220c9bf519b8e0f0b131a4f868331c4d526fb (diff) | |
download | pk-29cc0dc9854c66f12bd65e12516f68ccd9a741da.zip pk-29cc0dc9854c66f12bd65e12516f68ccd9a741da.tar.gz pk-29cc0dc9854c66f12bd65e12516f68ccd9a741da.tar.bz2 |
[pk,fesvr] improved proxykernel build system
Now uses a modified MCPPBS. Add --host=riscv to configure path.
Front-end server now just searches PATH for riscv-pk, so just install the pk
to somewhere in your path.
Diffstat (limited to 'pk/atomic.h')
-rw-r--r-- | pk/atomic.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/pk/atomic.h b/pk/atomic.h new file mode 100644 index 0000000..3294b6c --- /dev/null +++ b/pk/atomic.h @@ -0,0 +1,43 @@ +#ifndef _RISCV_ATOMIC_H +#define _RISCV_ATOMIC_H + +typedef struct { long val; } atomic_t; +typedef struct { atomic_t lock; } spinlock_t; +#define SPINLOCK_INIT {{0}} + +static inline long atomic_add(atomic_t* a, long inc) +{ + long old = a->val; + a->val += inc; + return old; +} + +static inline long atomic_swap(atomic_t* a, long val) +{ + long old = a->val; + a->val = val; + return old; +} + +static inline void atomic_set(atomic_t* a, long val) +{ + a->val = val; +} + +static inline long atomic_read(atomic_t* a) +{ + return a->val; +} + +static inline void spinlock_lock(spinlock_t* lock) +{ + while(atomic_read(&lock->lock)) + while(atomic_swap(&lock->lock,-1)); +} + +static inline void spinlock_unlock(spinlock_t* lock) +{ + atomic_set(&lock->lock,0); +} + +#endif |