diff options
author | Rickard Green <[email protected]> | 2011-04-18 16:49:55 +0200 |
---|---|---|
committer | Rickard Green <[email protected]> | 2011-06-14 11:40:20 +0200 |
commit | 0204e80cba378dfc1140a7f98d96705d470bddde (patch) | |
tree | 8cc07fe1797cd75a79b9ae07905baf145f21c1a6 /erts/emulator/beam/safe_hash.c | |
parent | 7f19af0423934f85c74ccb75546e5e3a6b6d10e8 (diff) | |
download | otp-0204e80cba378dfc1140a7f98d96705d470bddde.tar.gz otp-0204e80cba378dfc1140a7f98d96705d470bddde.tar.bz2 otp-0204e80cba378dfc1140a7f98d96705d470bddde.zip |
Use new atomic API in runtime system
All uses of the old deprecated atomic API in the runtime system
have been replaced with the use of the new atomic API. In a lot of
places this change imply a relaxation of memory barriers used.
Diffstat (limited to 'erts/emulator/beam/safe_hash.c')
-rw-r--r-- | erts/emulator/beam/safe_hash.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/erts/emulator/beam/safe_hash.c b/erts/emulator/beam/safe_hash.c index 4c54e19cdb..3326e5cc2a 100644 --- a/erts/emulator/beam/safe_hash.c +++ b/erts/emulator/beam/safe_hash.c @@ -61,7 +61,7 @@ static ERTS_INLINE int align_up_pow2(int val) */ static void rehash(SafeHash* h, int grow_limit) { - if (erts_smp_atomic_xchg(&h->is_rehashing, 1) != 0) { + if (erts_smp_atomic_xchg_acqb(&h->is_rehashing, 1) != 0) { return; /* already in progress */ } if (h->grow_limit == grow_limit) { @@ -166,8 +166,8 @@ SafeHash* safe_hash_init(ErtsAlcType_t type, SafeHash* h, char* name, int size, h->name = name; h->fun = fun; set_size(h,size); - erts_smp_atomic_init(&h->is_rehashing, 0); - erts_smp_atomic_init(&h->nitems, 0); + erts_smp_atomic_init_nob(&h->is_rehashing, 0); + erts_smp_atomic_init_nob(&h->nitems, 0); for (i=0; i<SAFE_HASH_LOCK_CNT; i++) { erts_smp_mtx_init(&h->lock_vec[i].mtx,"safe_hash"); } @@ -222,7 +222,7 @@ void* safe_hash_put(SafeHash* h, void* tmpl) *head = b; grow_limit = h->grow_limit; erts_smp_mtx_unlock(lock); - if (erts_smp_atomic_inctest(&h->nitems) > grow_limit) { + if (erts_smp_atomic_inc_read_nob(&h->nitems) > grow_limit) { rehash(h, grow_limit); } return (void*) b; @@ -245,7 +245,7 @@ void* safe_hash_erase(SafeHash* h, void* tmpl) if ((b->hvalue == hval) && (h->fun.cmp(tmpl, (void*)b) == 0)) { *prevp = b->next; erts_smp_mtx_unlock(lock); - erts_smp_atomic_dec(&h->nitems); + erts_smp_atomic_dec_nob(&h->nitems); h->fun.free((void*)b); return tmpl; } |