Differences From Artifact [8449195015]:
- File src/threading.h — part of check-in [8e7c6ddf8c] at 2016-07-30 21:22:31 on branch trunk — of_spinlock_(un)lock: Add memory barrier (user: js, size: 6278) [annotate] [blame] [check-ins using]
To Artifact [91e8883d41]:
- File
src/threading.h
— part of check-in
[24796a2dc1]
at
2016-07-31 21:54:30
on branch trunk
— Add of_memory_barrier_{producer,consumer}()
Also changes the naming slightly (leave -> exit). This is more similar
to the membar_*() API NetBSD and OpenBSD provides. (user: js, size: 6277) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
180 181 182 183 184 185 186 | } static OF_INLINE bool of_spinlock_trylock(of_spinlock_t *spinlock) { #if defined(OF_HAVE_ATOMIC_OPS) if (of_atomic_int_cmpswap(spinlock, 0, 1)) { | | | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | } static OF_INLINE bool of_spinlock_trylock(of_spinlock_t *spinlock) { #if defined(OF_HAVE_ATOMIC_OPS) if (of_atomic_int_cmpswap(spinlock, 0, 1)) { of_memory_barrier_enter(); return true; } return false; #elif defined(OF_HAVE_PTHREAD_SPINLOCKS) return !pthread_spin_trylock(spinlock); #else |
︙ | ︙ | |||
219 220 221 222 223 224 225 | static OF_INLINE bool of_spinlock_unlock(of_spinlock_t *spinlock) { #if defined(OF_HAVE_ATOMIC_OPS) bool ret = of_atomic_int_cmpswap(spinlock, 1, 0); | | | 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | static OF_INLINE bool of_spinlock_unlock(of_spinlock_t *spinlock) { #if defined(OF_HAVE_ATOMIC_OPS) bool ret = of_atomic_int_cmpswap(spinlock, 1, 0); of_memory_barrier_exit(); return ret; #elif defined(OF_HAVE_PTHREAD_SPINLOCKS) return !pthread_spin_unlock(spinlock); #else return of_mutex_unlock(spinlock); #endif |
︙ | ︙ |