diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2017-01-21 09:55:44 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2017-01-23 11:04:21 +0300 |
commit | 9182c620e181947df4a402322141b86ffdd0d4be (patch) | |
tree | ed4ae0c74f663c543fbcae1ae9f25f5b9da5789a | |
parent | 4a871e01583aab0d8a040ec84113f7b0b60200d9 (diff) | |
download | libatomic_ops-9182c620e181947df4a402322141b86ffdd0d4be.tar.gz |
Implement char and/or/xor and short CAS for msftc ARM and X86[_64]
* src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER>1400
&& !_M_ARM] (_InterlockedAnd8, _InterlockedCompareExchange16,
_InterlockedOr8, _InterlockedXor8): Declare intrinsic.
* src/atomic_ops/sysdeps/msftc/x86_64.h [_MSC_VER>1400]
(_InterlockedAnd8, _InterlockedCompareExchange16, _InterlockedOr8,
_InterlockedXor8): Likewise.
* src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER>1400
&& !_M_ARM] (AO_char_and_full, AO_char_or_full, AO_char_xor_full,
AO_short_fetch_compare_and_swap_full): Implement (using intrinsic).
* src/atomic_ops/sysdeps/msftc/x86_64.h [_MSC_VER>1400]
(AO_char_and_full, AO_char_or_full, AO_char_xor_full,
AO_short_fetch_compare_and_swap_full): Likewise.
-rw-r--r-- | src/atomic_ops/sysdeps/msftc/common32_defs.h | 40 | ||||
-rw-r--r-- | src/atomic_ops/sysdeps/msftc/x86_64.h | 39 |
2 files changed, 79 insertions, 0 deletions
diff --git a/src/atomic_ops/sysdeps/msftc/common32_defs.h b/src/atomic_ops/sysdeps/msftc/common32_defs.h index ab57e45..de55fef 100644 --- a/src/atomic_ops/sysdeps/msftc/common32_defs.h +++ b/src/atomic_ops/sysdeps/msftc/common32_defs.h @@ -116,3 +116,43 @@ AO_fetch_and_sub1_full(volatile AO_t *p) } # define AO_HAVE_fetch_compare_and_swap_full #endif /* AO_ASSUME_WINDOWS98 */ + +#if (_MSC_VER > 1400) && !defined(_M_ARM) + +# pragma intrinsic (_InterlockedAnd8) +# pragma intrinsic (_InterlockedCompareExchange16) +# pragma intrinsic (_InterlockedOr8) +# pragma intrinsic (_InterlockedXor8) + + AO_INLINE void + AO_char_and_full(volatile unsigned char *p, unsigned char value) + { + _InterlockedAnd8((char volatile *)p, value); + } +# define AO_HAVE_char_and_full + + AO_INLINE void + AO_char_or_full(volatile unsigned char *p, unsigned char value) + { + _InterlockedOr8((char volatile *)p, value); + } +# define AO_HAVE_char_or_full + + AO_INLINE void + AO_char_xor_full(volatile unsigned char *p, unsigned char value) + { + _InterlockedXor8((char volatile *)p, value); + } +# define AO_HAVE_char_xor_full + + AO_INLINE unsigned short + AO_short_fetch_compare_and_swap_full(volatile unsigned short *addr, + unsigned short old_val, + unsigned short new_val) + { + return _InterlockedCompareExchange16((short volatile *)addr, + new_val, old_val); + } +# define AO_HAVE_short_fetch_compare_and_swap_full + +#endif /* _MSC_VER > 1400 */ diff --git a/src/atomic_ops/sysdeps/msftc/x86_64.h b/src/atomic_ops/sysdeps/msftc/x86_64.h index ed6eb0c..86fa2b7 100644 --- a/src/atomic_ops/sysdeps/msftc/x86_64.h +++ b/src/atomic_ops/sysdeps/msftc/x86_64.h @@ -114,6 +114,45 @@ AO_int_fetch_and_add_full(volatile unsigned int *p, unsigned int incr) # define AO_HAVE_int_fetch_and_sub1_full #endif /* !AO_PREFER_GENERALIZED */ +#if _MSC_VER > 1400 +# pragma intrinsic (_InterlockedAnd8) +# pragma intrinsic (_InterlockedCompareExchange16) +# pragma intrinsic (_InterlockedOr8) +# pragma intrinsic (_InterlockedXor8) + + AO_INLINE void + AO_char_and_full(volatile unsigned char *p, unsigned char value) + { + _InterlockedAnd8((char volatile *)p, value); + } +# define AO_HAVE_char_and_full + + AO_INLINE void + AO_char_or_full(volatile unsigned char *p, unsigned char value) + { + _InterlockedOr8((char volatile *)p, value); + } +# define AO_HAVE_char_or_full + + AO_INLINE void + AO_char_xor_full(volatile unsigned char *p, unsigned char value) + { + _InterlockedXor8((char volatile *)p, value); + } +# define AO_HAVE_char_xor_full + + AO_INLINE unsigned short + AO_short_fetch_compare_and_swap_full(volatile unsigned short *addr, + unsigned short old_val, + unsigned short new_val) + { + return _InterlockedCompareExchange16((short volatile *)addr, + new_val, old_val); + } +# define AO_HAVE_short_fetch_compare_and_swap_full + +#endif /* _MSC_VER > 1400 */ + #ifdef AO_ASM_X64_AVAILABLE AO_INLINE unsigned char |