[llvm-commits] [llvm] r71856 - /llvm/trunk/include/llvm/System/Atomic.h
Anton Korobeynikov
asl at math.spbu.ru
Fri May 15 04:05:10 PDT 2009
Author: asl
Date: Fri May 15 06:04:52 2009
New Revision: 71856
URL: http://llvm.org/viewvc/llvm-project?rev=71856&view=rev
Log:
Unbreak mingw build
Modified:
llvm/trunk/include/llvm/System/Atomic.h
Modified: llvm/trunk/include/llvm/System/Atomic.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Atomic.h?rev=71856&r1=71855&r2=71856&view=diff
==============================================================================
--- llvm/trunk/include/llvm/System/Atomic.h (original)
+++ llvm/trunk/include/llvm/System/Atomic.h Fri May 15 06:04:52 2009
@@ -27,12 +27,12 @@
namespace llvm {
namespace sys {
-
+
#if !defined(ENABLE_THREADS) || ENABLE_THREADS == 0
inline void MemoryFence() {
return;
}
-
+
typedef uint32_t cas_flag;
inline cas_flag CompareAndSwap(cas_flag* dest, cas_flag exc, cas_flag c) {
cas_flag result = *dest;
@@ -40,22 +40,22 @@
*dest = exc;
return result;
}
-
+
#elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
inline void MemoryFence() {
__sync_synchronize();
}
-
+
typedef volatile uint32_t cas_flag;
inline cas_flag CompareAndSwap(cas_flag* dest, cas_flag exc, cas_flag c) {
return __sync_val_compare_and_swap(dest, exc, c);
}
-
+
#elif defined(__APPLE__)
inline void MemoryFence() {
OSMemoryBarrier();
}
-
+
typedef volatile int32_t cas_flag;
inline cas_flag CompareAndSwap(cas_flag* dest, cas_flag exc, cas_flag c) {
cas_flag old = *dest;
@@ -63,11 +63,18 @@
return old;
}
#elif defined(LLVM_ON_WIN32)
-#warning Memory fence implementation requires Windows 2003 or later.
inline void MemoryFence() {
+#ifdef _MSC_VER
MemoryBarrier();
+#elif 0
+ // FIXME: Requires SSE2 support
+ __asm__ __volatile__("mfence":::"memory");
+#else
+ // FIXME: just temporary workaround. We need to emit some fence...
+ __asm__ __volatile__("":::"memory");
+#endif
}
-
+
typedef volatile long cas_flag;
inline cas_flag CompareAndSwap(cas_flag* dest, cas_flag exc, cas_flag c) {
return InterlockedCompareExchange(dest, exc, c);
@@ -75,8 +82,8 @@
#else
#error No memory atomics implementation for your platform!
#endif
-
+
}
}
-#endif
\ No newline at end of file
+#endif
More information about the llvm-commits
mailing list