summaryrefslogtreecommitdiffstats
path: root/src/gallium/include
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2010-02-01 16:12:44 +0000
committerJosé Fonseca <[email protected]>2010-02-01 16:12:44 +0000
commit57839d11ff806d172506e4a5104c1ae3d286df1c (patch)
tree54942244536c984fb74bb38b9c0c614a903e397c /src/gallium/include
parent1776e738fb6f41954542bce064e4e5e59a4aa530 (diff)
gallium: Use MSVC atomic intrinsics directly instead of the Windows header wrappers.
Diffstat (limited to 'src/gallium/include')
-rw-r--r--src/gallium/include/pipe/p_atomic.h26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/gallium/include/pipe/p_atomic.h b/src/gallium/include/pipe/p_atomic.h
index d50526662fe..a4b769d0bf5 100644
--- a/src/gallium/include/pipe/p_atomic.h
+++ b/src/gallium/include/pipe/p_atomic.h
@@ -26,8 +26,8 @@ extern "C" {
#if (defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || \
defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT))
#define PIPE_ATOMIC_OS_UNLOCKED
-#elif (defined(PIPE_CC_MSVC) && defined(PIPE_SUBSYSTEM_WINDOWS_USER))
-#define PIPE_ATOMIC_OS_MS_INTERLOCK
+#elif defined(PIPE_CC_MSVC)
+#define PIPE_ATOMIC_MSVC_INTRINSIC
#elif (defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86))
#define PIPE_ATOMIC_ASM_MSVC_X86
#elif (defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86))
@@ -217,42 +217,46 @@ p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
#endif
-#if defined(PIPE_ATOMIC_OS_MS_INTERLOCK)
+#if defined(PIPE_ATOMIC_MSVC_INTRINSIC)
-#define PIPE_ATOMIC "MS userspace interlocks"
-
-#include <windows.h>
+#define PIPE_ATOMIC "MSVC Intrinsics"
struct pipe_atomic
{
- volatile long count;
+ int32_t count;
};
+#include <intrin.h>
+
+#pragma intrinsic(_InterlockedIncrement)
+#pragma intrinsic(_InterlockedDecrement)
+#pragma intrinsic(_InterlockedCompareExchange)
+
#define p_atomic_set(_v, _i) ((_v)->count = (_i))
#define p_atomic_read(_v) ((_v)->count)
static INLINE boolean
p_atomic_dec_zero(struct pipe_atomic *v)
{
- return InterlockedDecrement(&v->count) == 0;
+ return _InterlockedDecrement(&v->count) == 0;
}
static INLINE void
p_atomic_inc(struct pipe_atomic *v)
{
- InterlockedIncrement(&v->count);
+ _InterlockedIncrement(&v->count);
}
static INLINE void
p_atomic_dec(struct pipe_atomic *v)
{
- InterlockedDecrement(&v->count);
+ _InterlockedDecrement(&v->count);
}
static INLINE int32_t
p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
{
- return InterlockedCompareExchange(&v->count, _new, old);
+ return _InterlockedCompareExchange(&v->count, _new, old);
}
#endif