summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2021-10-24 00:00:19 +0300
committerIvan Maidanski <ivmai@mail.ru>2021-10-24 14:17:19 +0300
commit103191a7c0265cc0e74d26b2eb110ae40967ded6 (patch)
treeee157b4969bf9ca342bb2eb23a2cf4502c84b0bc /src
parent19cc51bdda7e5cbbc7cc7f314bc929e8ddb8f1bc (diff)
downloadlibatomic_ops-103191a7c0265cc0e74d26b2eb110ae40967ded6.tar.gz
Implement and/or/xor for AO_t, short and int types (MS VC)
* src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER >= 1800 && !AO_PREFER_GENERALIZED] (_InterlockedAnd16, _InterlockedOr16, _InterlockedXor16, _InterlockedAnd, _InterlockedOr, _InterlockedXor): Specify as intrinsic. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER >= 1800 && !AO_PREFER_GENERALIZED && !AO_T_IS_INT] (_InterlockedAnd64, _InterlockedOr64, _InterlockedXor64): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER >= 1800 && !AO_PREFER_GENERALIZED && (_M_ARM || _M_ARM64)] (_InterlockedAnd16_acq, _InterlockedAnd16_nf, _InterlockedAnd16_rel, _InterlockedOr16_acq, _InterlockedOr16_nf, _InterlockedOr16_rel, _InterlockedXor16_acq, _InterlockedXor16_nf, _InterlockedXor16_rel, _InterlockedAnd_acq, _InterlockedAnd_nf, _InterlockedAnd_rel, _InterlockedOr_acq, _InterlockedOr_nf, _InterlockedOr_rel, _InterlockedXor_acq, _InterlockedXor_nf, _InterlockedXor_rel): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER >= 1800 && !AO_PREFER_GENERALIZED && (_M_ARM || _M_ARM64) && !AO_T_IS_INT] (_InterlockedAnd64_acq, _InterlockedAnd64_nf, _InterlockedAnd64_rel, _InterlockedOr64_acq, _InterlockedOr64_nf, _InterlockedOr64_rel, _InterlockedXor64_acq, _InterlockedXor64_nf, _InterlockedXor64_rel): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER >= 1800 && !AO_PREFER_GENERALIZED] (AO_short_and_full, AO_short_or_full, AO_short_xor_full, AO_and_full, AO_or_full, AO_xor_full): Implement. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER >= 1800 && !AO_PREFER_GENERALIZED && !AO_T_IS_INT] (AO_int_and_full, AO_int_or_full, AO_int_xor_full): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER >= 1800 && !AO_PREFER_GENERALIZED && (_M_ARM || _M_ARM64)] (AO_short_and, AO_short_or, AO_short_xor, AO_short_and_acquire, AO_short_or_acquire, AO_short_xor_acquire, AO_short_and_release, AO_short_or_release, AO_short_xor_release, AO_and, AO_or, AO_xor, AO_and_acquire, AO_or_acquire, AO_xor_acquire, AO_and_release, AO_or_release, AO_xor_release): Likewise. * src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER >= 1800 && !AO_PREFER_GENERALIZED && (_M_ARM || _M_ARM64) && !AO_T_IS_INT] (AO_int_and, AO_int_or, AO_int_xor, AO_int_and_acquire, AO_int_or_acquire, AO_int_xor_acquire, AO_int_and_release, AO_int_or_release, AO_int_xor_release): Likewise.
Diffstat (limited to 'src')
-rw-r--r--src/atomic_ops/sysdeps/msftc/common32_defs.h348
1 files changed, 348 insertions, 0 deletions
diff --git a/src/atomic_ops/sysdeps/msftc/common32_defs.h b/src/atomic_ops/sysdeps/msftc/common32_defs.h
index 30a5082..646eaf3 100644
--- a/src/atomic_ops/sysdeps/msftc/common32_defs.h
+++ b/src/atomic_ops/sysdeps/msftc/common32_defs.h
@@ -244,6 +244,97 @@
#if _MSC_VER >= 1800 /* Visual Studio 2013+ */
+# ifndef AO_PREFER_GENERALIZED
+# pragma intrinsic (_InterlockedAnd16)
+# pragma intrinsic (_InterlockedOr16)
+# pragma intrinsic (_InterlockedXor16)
+
+ AO_INLINE void
+ AO_short_and_full(volatile unsigned short *p, unsigned short value)
+ {
+ (void)_InterlockedAnd16((short volatile *)p, value);
+ }
+# define AO_HAVE_short_and_full
+
+ AO_INLINE void
+ AO_short_or_full(volatile unsigned short *p, unsigned short value)
+ {
+ (void)_InterlockedOr16((short volatile *)p, value);
+ }
+# define AO_HAVE_short_or_full
+
+ AO_INLINE void
+ AO_short_xor_full(volatile unsigned short *p, unsigned short value)
+ {
+ (void)_InterlockedXor16((short volatile *)p, value);
+ }
+# define AO_HAVE_short_xor_full
+
+# pragma intrinsic (_InterlockedAnd)
+# pragma intrinsic (_InterlockedOr)
+# pragma intrinsic (_InterlockedXor)
+
+# ifndef AO_T_IS_INT
+ AO_INLINE void
+ AO_int_and_full(volatile unsigned int *p, unsigned int value)
+ {
+ (void)_InterlockedAnd((long volatile *)p, value);
+ }
+# define AO_HAVE_int_and_full
+
+ AO_INLINE void
+ AO_int_or_full(volatile unsigned int *p, unsigned int value)
+ {
+ (void)_InterlockedOr((long volatile *)p, value);
+ }
+# define AO_HAVE_int_or_full
+
+ AO_INLINE void
+ AO_int_xor_full(volatile unsigned int *p, unsigned int value)
+ {
+ (void)_InterlockedXor((long volatile *)p, value);
+ }
+# define AO_HAVE_int_xor_full
+
+# pragma intrinsic (_InterlockedAnd64)
+# pragma intrinsic (_InterlockedOr64)
+# pragma intrinsic (_InterlockedXor64)
+# endif /* !AO_T_IS_INT */
+
+ AO_INLINE void
+ AO_and_full(volatile AO_t *p, AO_t value)
+ {
+# ifdef AO_T_IS_INT
+ (void)_InterlockedAnd((long volatile *)p, value);
+# else
+ (void)_InterlockedAnd64((__int64 volatile *)p, value);
+# endif
+ }
+# define AO_HAVE_and_full
+
+ AO_INLINE void
+ AO_or_full(volatile AO_t *p, AO_t value)
+ {
+# ifdef AO_T_IS_INT
+ (void)_InterlockedOr((long volatile *)p, value);
+# else
+ (void)_InterlockedOr64((__int64 volatile *)p, value);
+# endif
+ }
+# define AO_HAVE_or_full
+
+ AO_INLINE void
+ AO_xor_full(volatile AO_t *p, AO_t value)
+ {
+# ifdef AO_T_IS_INT
+ (void)_InterlockedXor((long volatile *)p, value);
+# else
+ (void)_InterlockedXor64((__int64 volatile *)p, value);
+# endif
+ }
+# define AO_HAVE_xor_full
+# endif /* !AO_PREFER_GENERALIZED */
+
# if !defined(AO_PREFER_GENERALIZED) && (defined(_M_ARM) || defined(_M_ARM64))
# pragma intrinsic (_InterlockedAnd8_acq)
# pragma intrinsic (_InterlockedAnd8_nf)
@@ -318,6 +409,263 @@
}
# define AO_HAVE_char_xor_release
+# pragma intrinsic (_InterlockedAnd16_acq)
+# pragma intrinsic (_InterlockedAnd16_nf)
+# pragma intrinsic (_InterlockedAnd16_rel)
+# pragma intrinsic (_InterlockedOr16_acq)
+# pragma intrinsic (_InterlockedOr16_nf)
+# pragma intrinsic (_InterlockedOr16_rel)
+# pragma intrinsic (_InterlockedXor16_acq)
+# pragma intrinsic (_InterlockedXor16_nf)
+# pragma intrinsic (_InterlockedXor16_rel)
+
+ AO_INLINE void
+ AO_short_and(volatile unsigned short *p, unsigned short value)
+ {
+ (void)_InterlockedAnd16_nf((short volatile *)p, value);
+ }
+# define AO_HAVE_short_and
+
+ AO_INLINE void
+ AO_short_or(volatile unsigned short *p, unsigned short value)
+ {
+ (void)_InterlockedOr16_nf((short volatile *)p, value);
+ }
+# define AO_HAVE_short_or
+
+ AO_INLINE void
+ AO_short_xor(volatile unsigned short *p, unsigned short value)
+ {
+ (void)_InterlockedXor16_nf((short volatile *)p, value);
+ }
+# define AO_HAVE_short_xor
+
+ AO_INLINE void
+ AO_short_and_acquire(volatile unsigned short *p, unsigned short value)
+ {
+ (void)_InterlockedAnd16_acq((short volatile *)p, value);
+ }
+# define AO_HAVE_short_and_acquire
+
+ AO_INLINE void
+ AO_short_or_acquire(volatile unsigned short *p, unsigned short value)
+ {
+ (void)_InterlockedOr16_acq((short volatile *)p, value);
+ }
+# define AO_HAVE_short_or_acquire
+
+ AO_INLINE void
+ AO_short_xor_acquire(volatile unsigned short *p, unsigned short value)
+ {
+ (void)_InterlockedXor16_acq((short volatile *)p, value);
+ }
+# define AO_HAVE_short_xor_acquire
+
+ AO_INLINE void
+ AO_short_and_release(volatile unsigned short *p, unsigned short value)
+ {
+ (void)_InterlockedAnd16_rel((short volatile *)p, value);
+ }
+# define AO_HAVE_short_and_release
+
+ AO_INLINE void
+ AO_short_or_release(volatile unsigned short *p, unsigned short value)
+ {
+ (void)_InterlockedOr16_rel((short volatile *)p, value);
+ }
+# define AO_HAVE_short_or_release
+
+ AO_INLINE void
+ AO_short_xor_release(volatile unsigned short *p, unsigned short value)
+ {
+ (void)_InterlockedXor16_rel((short volatile *)p, value);
+ }
+# define AO_HAVE_short_xor_release
+
+# pragma intrinsic (_InterlockedAnd_acq)
+# pragma intrinsic (_InterlockedAnd_nf)
+# pragma intrinsic (_InterlockedAnd_rel)
+# pragma intrinsic (_InterlockedOr_acq)
+# pragma intrinsic (_InterlockedOr_nf)
+# pragma intrinsic (_InterlockedOr_rel)
+# pragma intrinsic (_InterlockedXor_acq)
+# pragma intrinsic (_InterlockedXor_nf)
+# pragma intrinsic (_InterlockedXor_rel)
+
+# ifndef AO_T_IS_INT
+ AO_INLINE void
+ AO_int_and(volatile unsigned int *p, unsigned int value)
+ {
+ (void)_InterlockedAnd_nf((long volatile *)p, value);
+ }
+# define AO_HAVE_int_and
+
+ AO_INLINE void
+ AO_int_or(volatile unsigned int *p, unsigned int value)
+ {
+ (void)_InterlockedOr_nf((long volatile *)p, value);
+ }
+# define AO_HAVE_int_or
+
+ AO_INLINE void
+ AO_int_xor(volatile unsigned int *p, unsigned int value)
+ {
+ (void)_InterlockedXor_nf((long volatile *)p, value);
+ }
+# define AO_HAVE_int_xor
+
+ AO_INLINE void
+ AO_int_and_acquire(volatile unsigned int *p, unsigned int value)
+ {
+ (void)_InterlockedAnd_acq((long volatile *)p, value);
+ }
+# define AO_HAVE_int_and_acquire
+
+ AO_INLINE void
+ AO_int_or_acquire(volatile unsigned int *p, unsigned int value)
+ {
+ (void)_InterlockedOr_acq((long volatile *)p, value);
+ }
+# define AO_HAVE_int_or_acquire
+
+ AO_INLINE void
+ AO_int_xor_acquire(volatile unsigned int *p, unsigned int value)
+ {
+ (void)_InterlockedXor_acq((long volatile *)p, value);
+ }
+# define AO_HAVE_int_xor_acquire
+
+ AO_INLINE void
+ AO_int_and_release(volatile unsigned int *p, unsigned int value)
+ {
+ (void)_InterlockedAnd_rel((long volatile *)p, value);
+ }
+# define AO_HAVE_int_and_release
+
+ AO_INLINE void
+ AO_int_or_release(volatile unsigned int *p, unsigned int value)
+ {
+ (void)_InterlockedOr_rel((long volatile *)p, value);
+ }
+# define AO_HAVE_int_or_release
+
+ AO_INLINE void
+ AO_int_xor_release(volatile unsigned int *p, unsigned int value)
+ {
+ (void)_InterlockedXor_rel((long volatile *)p, value);
+ }
+# define AO_HAVE_int_xor_release
+
+# pragma intrinsic (_InterlockedAnd64_acq)
+# pragma intrinsic (_InterlockedAnd64_nf)
+# pragma intrinsic (_InterlockedAnd64_rel)
+# pragma intrinsic (_InterlockedOr64_acq)
+# pragma intrinsic (_InterlockedOr64_nf)
+# pragma intrinsic (_InterlockedOr64_rel)
+# pragma intrinsic (_InterlockedXor64_acq)
+# pragma intrinsic (_InterlockedXor64_nf)
+# pragma intrinsic (_InterlockedXor64_rel)
+# endif /* !AO_T_IS_INT */
+
+ AO_INLINE void
+ AO_and(volatile AO_t *p, AO_t value)
+ {
+# ifdef AO_T_IS_INT
+ (void)_InterlockedAnd_nf((long volatile *)p, value);
+# else
+ (void)_InterlockedAnd64_nf((__int64 volatile *)p, value);
+# endif
+ }
+# define AO_HAVE_and
+
+ AO_INLINE void
+ AO_or(volatile AO_t *p, AO_t value)
+ {
+# ifdef AO_T_IS_INT
+ (void)_InterlockedOr_nf((long volatile *)p, value);
+# else
+ (void)_InterlockedOr64_nf((__int64 volatile *)p, value);
+# endif
+ }
+# define AO_HAVE_or
+
+ AO_INLINE void
+ AO_xor(volatile AO_t *p, AO_t value)
+ {
+# ifdef AO_T_IS_INT
+ (void)_InterlockedXor_nf((long volatile *)p, value);
+# else
+ (void)_InterlockedXor64_nf((__int64 volatile *)p, value);
+# endif
+ }
+# define AO_HAVE_xor
+
+ AO_INLINE void
+ AO_and_acquire(volatile AO_t *p, AO_t value)
+ {
+# ifdef AO_T_IS_INT
+ (void)_InterlockedAnd_acq((long volatile *)p, value);
+# else
+ (void)_InterlockedAnd64_acq((__int64 volatile *)p, value);
+# endif
+ }
+# define AO_HAVE_and_acquire
+
+ AO_INLINE void
+ AO_or_acquire(volatile AO_t *p, AO_t value)
+ {
+# ifdef AO_T_IS_INT
+ (void)_InterlockedOr_acq((long volatile *)p, value);
+# else
+ (void)_InterlockedOr64_acq((__int64 volatile *)p, value);
+# endif
+ }
+# define AO_HAVE_or_acquire
+
+ AO_INLINE void
+ AO_xor_acquire(volatile AO_t *p, AO_t value)
+ {
+# ifdef AO_T_IS_INT
+ (void)_InterlockedXor_acq((long volatile *)p, value);
+# else
+ (void)_InterlockedXor64_acq((__int64 volatile *)p, value);
+# endif
+ }
+# define AO_HAVE_xor_acquire
+
+ AO_INLINE void
+ AO_and_release(volatile AO_t *p, AO_t value)
+ {
+# ifdef AO_T_IS_INT
+ (void)_InterlockedAnd_rel((long volatile *)p, value);
+# else
+ (void)_InterlockedAnd64_rel((__int64 volatile *)p, value);
+# endif
+ }
+# define AO_HAVE_and_release
+
+ AO_INLINE void
+ AO_or_release(volatile AO_t *p, AO_t value)
+ {
+# ifdef AO_T_IS_INT
+ (void)_InterlockedOr_rel((long volatile *)p, value);
+# else
+ (void)_InterlockedOr64_rel((__int64 volatile *)p, value);
+# endif
+ }
+# define AO_HAVE_or_release
+
+ AO_INLINE void
+ AO_xor_release(volatile AO_t *p, AO_t value)
+ {
+# ifdef AO_T_IS_INT
+ (void)_InterlockedXor_rel((long volatile *)p, value);
+# else
+ (void)_InterlockedXor64_rel((__int64 volatile *)p, value);
+# endif
+ }
+# define AO_HAVE_xor_release
+
# pragma intrinsic (_InterlockedDecrement16_acq)
# pragma intrinsic (_InterlockedDecrement16_nf)
# pragma intrinsic (_InterlockedDecrement16_rel)