diff --git a/src/os/include/os/os_atomics_gcc.h b/src/os/include/os/os_atomics_gcc.h index 7a1d974..89bda3c 100644 --- a/src/os/include/os/os_atomics_gcc.h +++ b/src/os/include/os/os_atomics_gcc.h @@ -331,6 +331,11 @@ VDDS_INLINE int os_atomic_casvoidp (volatile os_atomic_voidp_t *x, void *exp, vo VDDS_INLINE void os_atomic_fence (void) { __sync_synchronize (); } +VDDS_INLINE void os_atomic_fence_ldld (void) { +#if !(defined __i386__ || defined __x86_64__ || defined _M_IX86 || defined _M_X64) + __sync_synchronize (); +#endif +} VDDS_INLINE void os_atomic_fence_acq (void) { os_atomic_fence (); } diff --git a/src/os/include/os/os_atomics_solaris.h b/src/os/include/os/os_atomics_solaris.h index 23a36c9..04a5c2c 100644 --- a/src/os/include/os/os_atomics_solaris.h +++ b/src/os/include/os/os_atomics_solaris.h @@ -231,6 +231,9 @@ VDDS_INLINE void os_atomic_fence (void) { membar_exit (); membar_enter (); } +VDDS_INLINE void os_atomic_fence_ldld (void) { + membar_enter (); +} VDDS_INLINE void os_atomic_fence_acq (void) { membar_enter (); } diff --git a/src/os/include/os/os_atomics_win32.h b/src/os/include/os/os_atomics_win32.h index 21b718e..fc0497a 100644 --- a/src/os/include/os/os_atomics_win32.h +++ b/src/os/include/os/os_atomics_win32.h @@ -416,6 +416,11 @@ OS_ATOMIC_API_INLINE void os_atomic_fence (void) { InterlockedExchange (&tmp, 0); #pragma warning (pop) } +OS_ATOMIC_API_INLINE void os_atomic_fence_ldld (void) { +#if !(defined _M_IX86 || defined _M_X64) + os_atomic_fence (); +#endif +} OS_ATOMIC_API_INLINE void os_atomic_fence_acq (void) { os_atomic_fence (); } diff --git a/src/util/src/ut_hopscotch.c b/src/util/src/ut_hopscotch.c index 7134f36..4528e23 100644 --- a/src/util/src/ut_hopscotch.c +++ b/src/util/src/ut_hopscotch.c @@ -34,11 +34,7 @@ struct ut_chhBucket { struct _Struct_size_bytes_(size) ut_chhBucketArray { uint32_t size; /* power of 2 */ -#if __STDC_VERSION__ >= 199901L struct ut_chhBucket bs[]; -#else - struct ut_chhBucket bs[1]; -#endif }; struct ut_chhBackingLock { @@ -91,9 +87,6 @@ static int ut_chhInit (struct ut_chh *rt, uint32_t init_size, ut_hhHash_fn hash, for (i = 0; i < N_BACKING_LOCKS; i++) { struct ut_chhBackingLock *s = &rt->backingLocks[i]; os_mutexInit (&s->lock); - } - for (i = 0; i < N_BACKING_LOCKS; i++) { - struct ut_chhBackingLock *s = &rt->backingLocks[i]; os_condInit (&s->cv, &s->lock); } for (i = 0; i < N_RESIZE_LOCKS; i++) { @@ -205,7 +198,7 @@ static void *ut_chhLookupInternal (struct ut_chhBucketArray const * const bsary, do { uint32_t hopinfo; timestamp = os_atomic_ld32 (&bs[bucket].timestamp); - os_atomic_fence (); + os_atomic_fence_ldld (); hopinfo = os_atomic_ld32 (&bs[bucket].hopinfo); for (idx = 0; hopinfo != 0; hopinfo >>= 1, idx++) { const uint32_t bidx = (bucket + idx) & idxmask; @@ -214,7 +207,7 @@ static void *ut_chhLookupInternal (struct ut_chhBucketArray const * const bsary, return data; } } - os_atomic_fence (); + os_atomic_fence_ldld (); } while (timestamp != os_atomic_ld32 (&bs[bucket].timestamp) && ++try_counter < CHH_MAX_TRIES); if (try_counter == CHH_MAX_TRIES) { /* Note: try_counter would not have been incremented to