diff options
Diffstat (limited to 'intern')
-rw-r--r-- | intern/atomic/atomic_ops.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/intern/atomic/atomic_ops.h b/intern/atomic/atomic_ops.h index d8161d10401..c7bb0509fdf 100644 --- a/intern/atomic/atomic_ops.h +++ b/intern/atomic/atomic_ops.h @@ -90,6 +90,8 @@ ATOMIC_INLINE uint32_t atomic_add_uint32(uint32_t *p, uint32_t x); ATOMIC_INLINE uint32_t atomic_sub_uint32(uint32_t *p, uint32_t x); ATOMIC_INLINE uint32_t atomic_cas_uint32(uint32_t *v, uint32_t old, uint32_t _new); +ATOMIC_INLINE uint8_t atomic_fetch_and_and_uint8(uint8_t *p, uint8_t b); + ATOMIC_INLINE size_t atomic_add_z(size_t *p, size_t x); ATOMIC_INLINE size_t atomic_sub_z(size_t *p, size_t x); ATOMIC_INLINE size_t atomic_cas_z(size_t *v, size_t old, size_t _new); @@ -378,6 +380,26 @@ atomic_cas_uint32(uint32_t *v, uint32_t old, uint32_t _new) #endif /******************************************************************************/ +/* 8-bit operations. */ +#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 +ATOMIC_INLINE uint8_t +atomic_fetch_and_and_uint8(uint8_t *p, uint8_t b) +{ + return __sync_fetch_and_and(p, b); +} +#elif (defined(_MSC_VER)) +#include <intrin.h> +#pragma intrinsic(_InterlockedAnd8) +ATOMIC_INLINE uint8_t +atomic_fetch_and_and_uint8(uint8_t *p, uint8_t b) +{ + return InterlockedAnd8((char *)p, (char)b); +} +#else +# error "Missing implementation for 8-bit atomic operations" +#endif + +/******************************************************************************/ /* size_t operations. */ ATOMIC_INLINE size_t atomic_add_z(size_t *p, size_t x) |