diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2017-11-09 21:56:59 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2017-11-09 21:56:59 +0000 |
commit | 5ac29058f01502c407a7b77ec57a08c96941f796 (patch) | |
tree | 86e5c9abbcc0655073df1ceafdd557cfeca4d68a /libgo/go/sync | |
parent | d60edaba4fc4e75824f27291ff448bf48118b3f4 (diff) | |
download | gcc-5ac29058f01502c407a7b77ec57a08c96941f796.zip gcc-5ac29058f01502c407a7b77ec57a08c96941f796.tar.gz gcc-5ac29058f01502c407a7b77ec57a08c96941f796.tar.bz2 |
sync/atomic, runtime/internal/atomic: don't assume reads from 0 fail
For a misaligned address force a panic rather than assuming that reading
from the address 0 will cause one.
Reviewed-on: https://go-review.googlesource.com/69850
From-SVN: r254610
Diffstat (limited to 'libgo/go/sync')
-rw-r--r-- | libgo/go/sync/atomic/atomic.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/libgo/go/sync/atomic/atomic.c b/libgo/go/sync/atomic/atomic.c index 7e04027..32cbf03 100644 --- a/libgo/go/sync/atomic/atomic.c +++ b/libgo/go/sync/atomic/atomic.c @@ -26,7 +26,7 @@ int64_t SwapInt64 (int64_t *addr, int64_t new) { if (((uintptr_t) addr & 7) != 0) - addr = NULL; + panicmem (); return __atomic_exchange_n (addr, new, __ATOMIC_SEQ_CST); } @@ -48,7 +48,7 @@ uint64_t SwapUint64 (uint64_t *addr, uint64_t new) { if (((uintptr_t) addr & 7) != 0) - addr = NULL; + panicmem (); return __atomic_exchange_n (addr, new, __ATOMIC_SEQ_CST); } @@ -215,7 +215,7 @@ LoadInt64 (int64_t *addr) int64_t v; if (((uintptr_t) addr & 7) != 0) - addr = NULL; + panicmem (); v = *addr; while (! __sync_bool_compare_and_swap (addr, v, v)) v = *addr; @@ -247,7 +247,7 @@ LoadUint64 (uint64_t *addr) uint64_t v; if (((uintptr_t) addr & 7) != 0) - addr = NULL; + panicmem (); v = *addr; while (! __sync_bool_compare_and_swap (addr, v, v)) v = *addr; @@ -308,7 +308,7 @@ StoreInt64 (int64_t *addr, int64_t val) int64_t v; if (((uintptr_t) addr & 7) != 0) - addr = NULL; + panicmem (); v = *addr; while (! __sync_bool_compare_and_swap (addr, v, val)) v = *addr; @@ -338,7 +338,7 @@ StoreUint64 (uint64_t *addr, uint64_t val) uint64_t v; if (((uintptr_t) addr & 7) != 0) - addr = NULL; + panicmem (); v = *addr; while (! __sync_bool_compare_and_swap (addr, v, val)) v = *addr; |