diff options
author | Darius Rad <darius@bluespec.com> | 2015-09-21 07:36:27 -0400 |
---|---|---|
committer | Darius Rad <darius@bluespec.com> | 2015-11-18 08:28:07 -0500 |
commit | b9961802ce2f774c884d6708beec5e8ac6f264ed (patch) | |
tree | 60c9687bbee963dc277a20762ee6c670cca136b0 | |
parent | 197a8b81e4bbf61c497c93c0ac4630a33ab11b1c (diff) | |
download | riscv-pk-b9961802ce2f774c884d6708beec5e8ac6f264ed.zip riscv-pk-b9961802ce2f774c884d6708beec5e8ac6f264ed.tar.gz riscv-pk-b9961802ce2f774c884d6708beec5e8ac6f264ed.tar.bz2 |
Fix macros for emulating atomic operations (--disable-atomics).
-rw-r--r-- | pk/atomic.h | 6 | ||||
-rw-r--r-- | pk/file.c | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/pk/atomic.h b/pk/atomic.h index c2adf00..2ec4a04 100644 --- a/pk/atomic.h +++ b/pk/atomic.h @@ -23,19 +23,19 @@ typedef struct { int lock; } spinlock_t; #else # define atomic_add(ptr, inc) ({ \ long flags = disable_irqsave(); \ - typeof(ptr) res = *(volatile typeof(ptr))(ptr); \ + typeof(*(ptr)) res = *(volatile typeof(*(ptr)) *)(ptr); \ *(volatile typeof(ptr))(ptr) = res + (inc); \ enable_irqrestore(flags); \ res; }) # define atomic_swap(ptr, swp) ({ \ long flags = disable_irqsave(); \ - typeof(ptr) res = *(volatile typeof(ptr))(ptr); \ + typeof(*(ptr)) res = *(volatile typeof(*(ptr)) *)(ptr); \ *(volatile typeof(ptr))(ptr) = (swp); \ enable_irqrestore(flags); \ res; }) # define atomic_cas(ptr, cmp, swp) ({ \ long flags = disable_irqsave(); \ - typeof(ptr) res = *(volatile typeof(ptr))(ptr); \ + typeof(*(ptr)) res = *(volatile typeof(*(ptr)) *)(ptr); \ if (res == (cmp)) *(volatile typeof(ptr))(ptr) = (swp); \ enable_irqrestore(flags); \ res; }) @@ -107,7 +107,7 @@ int fd_close(int fd) file_t* f = file_get(fd); if (!f) return -1; - file_t* old = atomic_cas(&fds[fd], (long)f, 0); + file_t* old = atomic_cas(&fds[fd], f, 0); file_decref(f); if (old != f) return -1; |