aboutsummaryrefslogtreecommitdiff
path: root/include/jemalloc/internal/atomic.h
diff options
context:
space:
mode:
authorMike Hommey <mh@glandium.org>2012-04-30 12:38:31 +0200
committerJason Evans <je@fb.com>2012-05-01 11:32:11 -0700
commitfd97b1dfc76647c3f90f28dc63cc987041fe20df (patch)
tree97ed1b2b8de5dfd5bddc4f32da1cecd0af4c5da8 /include/jemalloc/internal/atomic.h
parentb45c57ecaf2bf7ff8abe013b856be90fb4e365f3 (diff)
downloadjemalloc-fd97b1dfc76647c3f90f28dc63cc987041fe20df.tar.gz
Add support for MSVC
Tested with MSVC 8 32 and 64 bits.
Diffstat (limited to 'include/jemalloc/internal/atomic.h')
-rw-r--r--include/jemalloc/internal/atomic.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/include/jemalloc/internal/atomic.h b/include/jemalloc/internal/atomic.h
index 016c472..11a7b47 100644
--- a/include/jemalloc/internal/atomic.h
+++ b/include/jemalloc/internal/atomic.h
@@ -47,6 +47,20 @@ atomic_sub_uint64(uint64_t *p, uint64_t x)
return (__sync_sub_and_fetch(p, x));
}
+#elif (defined(_MSC_VER))
+JEMALLOC_INLINE uint64_t
+atomic_add_uint64(uint64_t *p, uint64_t x)
+{
+
+ return (InterlockedExchangeAdd64(p, x));
+}
+
+JEMALLOC_INLINE uint64_t
+atomic_sub_uint64(uint64_t *p, uint64_t x)
+{
+
+ return (InterlockedExchangeAdd64(p, -((int64_t)x)));
+}
#elif (defined(JEMALLOC_OSATOMIC))
JEMALLOC_INLINE uint64_t
atomic_add_uint64(uint64_t *p, uint64_t x)
@@ -145,6 +159,20 @@ atomic_sub_uint32(uint32_t *p, uint32_t x)
return (__sync_sub_and_fetch(p, x));
}
+#elif (defined(_MSC_VER))
+JEMALLOC_INLINE uint32_t
+atomic_add_uint32(uint32_t *p, uint32_t x)
+{
+
+ return (InterlockedExchangeAdd(p, x));
+}
+
+JEMALLOC_INLINE uint32_t
+atomic_sub_uint32(uint32_t *p, uint32_t x)
+{
+
+ return (InterlockedExchangeAdd(p, -((int32_t)x)));
+}
#elif (defined(JEMALLOC_OSATOMIC))
JEMALLOC_INLINE uint32_t
atomic_add_uint32(uint32_t *p, uint32_t x)