summaryrefslogtreecommitdiff
path: root/src/atomic_ops
diff options
context:
space:
mode:
Diffstat (limited to 'src/atomic_ops')
-rw-r--r--src/atomic_ops/sysdeps/msftc/common32_defs.h18
-rw-r--r--src/atomic_ops/sysdeps/msftc/x86_64.h18
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