diff options
| author | Ivan Maidanski <ivmai@mail.ru> | 2017-01-24 01:32:41 +0300 |
|---|---|---|
| committer | Ivan Maidanski <ivmai@mail.ru> | 2017-01-24 01:32:41 +0300 |
| commit | a013152ae8fb09223b91f3183b40869960a7a79e (patch) | |
| tree | 59a3034d46aa1d3308530448d9a912f302ca289a /src/atomic_ops | |
| parent | cf9732e5e7e49e5409a8d80336a028046913e448 (diff) | |
| download | libatomic_ops-a013152ae8fb09223b91f3183b40869960a7a79e.tar.gz | |
Implement short inc/dec directly for msftc ARM and X86[_64]
* src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER>1400
&& !AO_PREFER_GENERALIZED] (_InterlockedIncrement16,
_InterlockedDecrement16): Declare intrinsic.
* src/atomic_ops/sysdeps/msftc/x86_64.h [_MSC_VER>1400
&& !AO_PREFER_GENERALIZED] (_InterlockedIncrement16,
_InterlockedDecrement16): Likewise.
* src/atomic_ops/sysdeps/msftc/common32_defs.h [_MSC_VER>1400
&& !AO_PREFER_GENERALIZED] (AO_short_fetch_and_add1_full,
AO_short_fetch_and_sub1_full): Implement using intrinsic.
* src/atomic_ops/sysdeps/msftc/x86_64.h [_MSC_VER>=1800
&& !AO_PREFER_GENERALIZED] (AO_char_fetch_and_add_full,
AO_short_fetch_and_add_full): Likewise.
Diffstat (limited to 'src/atomic_ops')
| -rw-r--r-- | src/atomic_ops/sysdeps/msftc/common32_defs.h | 18 | ||||
| -rw-r--r-- | src/atomic_ops/sysdeps/msftc/x86_64.h | 18 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/atomic_ops/sysdeps/msftc/common32_defs.h b/src/atomic_ops/sysdeps/msftc/common32_defs.h index dfb8cf6..c3f5ee9 100644 --- a/src/atomic_ops/sysdeps/msftc/common32_defs.h +++ b/src/atomic_ops/sysdeps/msftc/common32_defs.h @@ -155,4 +155,22 @@ AO_fetch_and_sub1_full(volatile AO_t *p) } # define AO_HAVE_short_fetch_compare_and_swap_full +# ifndef AO_PREFER_GENERALIZED +# pragma intrinsic (_InterlockedIncrement16) +# pragma intrinsic (_InterlockedDecrement16) + + AO_INLINE unsigned short + AO_short_fetch_and_add1_full(volatile unsigned short *p) + { + return _InterlockedIncrement16((short volatile *)p) - 1; + } +# define AO_HAVE_short_fetch_and_add1_full + + AO_INLINE unsigned short + AO_short_fetch_and_sub1_full(volatile unsigned short *p) + { + return _InterlockedDecrement16((short volatile *)p) + 1; + } +# define AO_HAVE_short_fetch_and_sub1_full +# endif /* !AO_PREFER_GENERALIZED */ #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 86fa2b7..b5eb298 100644 --- a/src/atomic_ops/sysdeps/msftc/x86_64.h +++ b/src/atomic_ops/sysdeps/msftc/x86_64.h @@ -151,6 +151,24 @@ AO_int_fetch_and_add_full(volatile unsigned int *p, unsigned int incr) } # define AO_HAVE_short_fetch_compare_and_swap_full +# ifndef AO_PREFER_GENERALIZED +# pragma intrinsic (_InterlockedIncrement16) +# pragma intrinsic (_InterlockedDecrement16) + + AO_INLINE unsigned short + AO_short_fetch_and_add1_full(volatile unsigned short *p) + { + return _InterlockedIncrement16((short volatile *)p) - 1; + } +# define AO_HAVE_short_fetch_and_add1_full + + AO_INLINE unsigned short + AO_short_fetch_and_sub1_full(volatile unsigned short *p) + { + return _InterlockedDecrement16((short volatile *)p) + 1; + } +# define AO_HAVE_short_fetch_and_sub1_full +# endif /* !AO_PREFER_GENERALIZED */ #endif /* _MSC_VER > 1400 */ #ifdef AO_ASM_X64_AVAILABLE |
