Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/atomic/intern/atomic_ops_msvc.h')
-rw-r--r--intern/atomic/intern/atomic_ops_msvc.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/intern/atomic/intern/atomic_ops_msvc.h b/intern/atomic/intern/atomic_ops_msvc.h
index 034ac1e3e53..c24a9095735 100644
--- a/intern/atomic/intern/atomic_ops_msvc.h
+++ b/intern/atomic/intern/atomic_ops_msvc.h
@@ -43,6 +43,7 @@
/******************************************************************************/
/* 64-bit operations. */
#if (LG_SIZEOF_PTR == 8 || LG_SIZEOF_INT == 8)
+/* Unsigned */
ATOMIC_INLINE uint64_t atomic_add_and_fetch_uint64(uint64_t *p, uint64_t x)
{
return InterlockedExchangeAdd64((int64_t *)p, (int64_t)x) + x;
@@ -67,10 +68,37 @@ ATOMIC_INLINE uint64_t atomic_fetch_and_sub_uint64(uint64_t *p, uint64_t x)
{
return InterlockedExchangeAdd64((int64_t *)p, -((int64_t)x));
}
+
+/* Signed */
+ATOMIC_INLINE int64_t atomic_add_and_fetch_int64(int64_t *p, int64_t x)
+{
+ return InterlockedExchangeAdd64(p, x) + x;
+}
+
+ATOMIC_INLINE int64_t atomic_sub_and_fetch_int64(int64_t *p, int64_t x)
+{
+ return InterlockedExchangeAdd64(p, -x) - x;
+}
+
+ATOMIC_INLINE int64_t atomic_cas_int64(int64_t *v, int64_t old, int64_t _new)
+{
+ return InterlockedCompareExchange64(v, _new, old);
+}
+
+ATOMIC_INLINE int64_t atomic_fetch_and_add_int64(int64_t *p, int64_t x)
+{
+ return InterlockedExchangeAdd64(p, x);
+}
+
+ATOMIC_INLINE int64_t atomic_fetch_and_sub_int64(int64_t *p, int64_t x)
+{
+ return InterlockedExchangeAdd64(p, -x);
+}
#endif
/******************************************************************************/
/* 32-bit operations. */
+/* Unsigned */
ATOMIC_INLINE uint32_t atomic_add_and_fetch_uint32(uint32_t *p, uint32_t x)
{
return InterlockedExchangeAdd(p, x) + x;
@@ -101,9 +129,41 @@ ATOMIC_INLINE uint32_t atomic_fetch_and_and_uint32(uint32_t *p, uint32_t x)
return InterlockedAnd((long *)p, x);
}
+/* Signed */
+ATOMIC_INLINE int32_t atomic_add_and_fetch_int32(int32_t *p, int32_t x)
+{
+ return InterlockedExchangeAdd((long *)p, x) + x;
+}
+
+ATOMIC_INLINE int32_t atomic_sub_and_fetch_int32(int32_t *p, int32_t x)
+{
+ return InterlockedExchangeAdd((long *)p, -x) - x;
+}
+
+ATOMIC_INLINE int32_t atomic_cas_int32(int32_t *v, int32_t old, int32_t _new)
+{
+ return InterlockedCompareExchange((long *)v, _new, old);
+}
+
+ATOMIC_INLINE int32_t atomic_fetch_and_add_int32(int32_t *p, int32_t x)
+{
+ return InterlockedExchangeAdd((long *)p, x);
+}
+
+ATOMIC_INLINE int32_t atomic_fetch_and_or_int32(int32_t *p, int32_t x)
+{
+ return InterlockedOr((long *)p, x);
+}
+
+ATOMIC_INLINE int32_t atomic_fetch_and_and_int32(int32_t *p, int32_t x)
+{
+ return InterlockedAnd((long *)p, x);
+}
+
/******************************************************************************/
/* 8-bit operations. */
+/* Unsigned */
#pragma intrinsic(_InterlockedAnd8)
ATOMIC_INLINE uint8_t atomic_fetch_and_and_uint8(uint8_t *p, uint8_t b)
{
@@ -124,4 +184,25 @@ ATOMIC_INLINE uint8_t atomic_fetch_and_or_uint8(uint8_t *p, uint8_t b)
#endif
}
+/* Signed */
+#pragma intrinsic(_InterlockedAnd8)
+ATOMIC_INLINE int8_t atomic_fetch_and_and_int8(int8_t *p, int8_t b)
+{
+#if (LG_SIZEOF_PTR == 8 || LG_SIZEOF_INT == 8)
+ return InterlockedAnd8((char *)p, (char)b);
+#else
+ return _InterlockedAnd8((char *)p, (char)b);
+#endif
+}
+
+#pragma intrinsic(_InterlockedOr8)
+ATOMIC_INLINE int8_t atomic_fetch_and_or_int8(int8_t *p, int8_t b)
+{
+#if (LG_SIZEOF_PTR == 8 || LG_SIZEOF_INT == 8)
+ return InterlockedOr8((char *)p, (char)b);
+#else
+ return _InterlockedOr8((char *)p, (char)b);
+#endif
+}
+
#endif /* __ATOMIC_OPS_MSVC_H__ */