diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-05-09 12:45:43 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-05-09 12:45:43 +0300 |
commit | dc5e02c42ce85f88c6ac089ecbe139404562f4a3 (patch) | |
tree | 00b98d6502ef22adc2b06313f056466e4f2e63d7 /intern/atomic/atomic_ops.h | |
parent | a27772cd661839b0194acb782fdf8beab19b000d (diff) |
Atomics: Add atomic_fetch_and_or_uint8() function
Hopefully it compiles on all platforms still..
Diffstat (limited to 'intern/atomic/atomic_ops.h')
-rw-r--r-- | intern/atomic/atomic_ops.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/intern/atomic/atomic_ops.h b/intern/atomic/atomic_ops.h index 06eb8f21da6..dd1bdd2328d 100644 --- a/intern/atomic/atomic_ops.h +++ b/intern/atomic/atomic_ops.h @@ -91,6 +91,7 @@ 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_or_uint8(uint8_t *p, uint8_t b); 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); @@ -384,6 +385,11 @@ atomic_cas_uint32(uint32_t *v, uint32_t old, uint32_t _new) /* 8-bit operations. */ #ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 ATOMIC_INLINE uint8_t +atomic_fetch_and_or_uint8(uint8_t *p, uint8_t b) +{ + return __sync_fetch_and_or(p, b); +} +ATOMIC_INLINE uint8_t atomic_fetch_and_and_uint8(uint8_t *p, uint8_t b) { return __sync_fetch_and_and(p, b); @@ -392,6 +398,15 @@ atomic_fetch_and_and_uint8(uint8_t *p, uint8_t b) #include <intrin.h> #pragma intrinsic(_InterlockedAnd8) ATOMIC_INLINE uint8_t +atomic_fetch_and_or_uint8(uint8_t *p, uint8_t b) +{ +#if (LG_SIZEOF_PTR == 3 || LG_SIZEOF_INT == 3) + return InterlockedOr8((char *)p, (char)b); +#else + return _InterlockedOr8((char *)p, (char)b); +#endif +} +ATOMIC_INLINE uint8_t atomic_fetch_and_and_uint8(uint8_t *p, uint8_t b) { #if (LG_SIZEOF_PTR == 3 || LG_SIZEOF_INT == 3) @@ -402,6 +417,11 @@ atomic_fetch_and_and_uint8(uint8_t *p, uint8_t b) } #elif defined(JE_FORCE_SYNC_COMPARE_AND_SWAP_1) ATOMIC_INLINE uint8_t +atomic_fetch_and_or_uint8(uint8_t *p, uint8_t b) +{ + return __sync_fetch_and_or(p, b); +} +ATOMIC_INLINE uint8_t atomic_fetch_and_and_uint8(uint8_t *p, uint8_t b) { return __sync_fetch_and_and(p, b); |