diff options
Diffstat (limited to 'pk')
-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; |