diff options
Diffstat (limited to 'libgo/go/sync/atomic/atomic.c')
-rw-r--r-- | libgo/go/sync/atomic/atomic.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libgo/go/sync/atomic/atomic.c b/libgo/go/sync/atomic/atomic.c index f0ba57b3cca..7e04027c3f1 100644 --- a/libgo/go/sync/atomic/atomic.c +++ b/libgo/go/sync/atomic/atomic.c @@ -25,6 +25,8 @@ int64_t SwapInt64 (int64_t *, int64_t) int64_t SwapInt64 (int64_t *addr, int64_t new) { + if (((uintptr_t) addr & 7) != 0) + addr = NULL; return __atomic_exchange_n (addr, new, __ATOMIC_SEQ_CST); } @@ -45,6 +47,8 @@ uint64_t SwapUint64 (uint64_t *, uint64_t) uint64_t SwapUint64 (uint64_t *addr, uint64_t new) { + if (((uintptr_t) addr & 7) != 0) + addr = NULL; return __atomic_exchange_n (addr, new, __ATOMIC_SEQ_CST); } @@ -85,6 +89,8 @@ _Bool CompareAndSwapInt64 (int64_t *, int64_t, int64_t) _Bool CompareAndSwapInt64 (int64_t *val, int64_t old, int64_t new) { + if (((uintptr_t) val & 7) != 0) + val = NULL; return __sync_bool_compare_and_swap (val, old, new); } @@ -105,6 +111,8 @@ _Bool CompareAndSwapUint64 (uint64_t *, uint64_t, uint64_t) _Bool CompareAndSwapUint64 (uint64_t *val, uint64_t old, uint64_t new) { + if (((uintptr_t) val & 7) != 0) + val = NULL; return __sync_bool_compare_and_swap (val, old, new); } @@ -155,6 +163,8 @@ int64_t AddInt64 (int64_t *, int64_t) int64_t AddInt64 (int64_t *val, int64_t delta) { + if (((uintptr_t) val & 7) != 0) + val = NULL; return __sync_add_and_fetch (val, delta); } @@ -165,6 +175,8 @@ uint64_t AddUint64 (uint64_t *, uint64_t) uint64_t AddUint64 (uint64_t *val, uint64_t delta) { + if (((uintptr_t) val & 7) != 0) + val = NULL; return __sync_add_and_fetch (val, delta); } @@ -202,6 +214,8 @@ LoadInt64 (int64_t *addr) { int64_t v; + if (((uintptr_t) addr & 7) != 0) + addr = NULL; v = *addr; while (! __sync_bool_compare_and_swap (addr, v, v)) v = *addr; @@ -232,6 +246,8 @@ LoadUint64 (uint64_t *addr) { uint64_t v; + if (((uintptr_t) addr & 7) != 0) + addr = NULL; v = *addr; while (! __sync_bool_compare_and_swap (addr, v, v)) v = *addr; @@ -291,6 +307,8 @@ StoreInt64 (int64_t *addr, int64_t val) { int64_t v; + if (((uintptr_t) addr & 7) != 0) + addr = NULL; v = *addr; while (! __sync_bool_compare_and_swap (addr, v, val)) v = *addr; @@ -319,6 +337,8 @@ StoreUint64 (uint64_t *addr, uint64_t val) { uint64_t v; + if (((uintptr_t) addr & 7) != 0) + addr = NULL; v = *addr; while (! __sync_bool_compare_and_swap (addr, v, val)) v = *addr; |