[ros-diffs] [tkreuzer] 50456: [INTRIN] - Implement _mm_sfence, _mm_lfence, __faststorefence (for amd64) - Don't use __sync_synchronize() for _ReadWriteBarrier, as it issues an mfence instruction and this is no...

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Fri Jan 21 20:56:36 UTC 2011


Author: tkreuzer
Date: Fri Jan 21 20:56:36 2011
New Revision: 50456

URL: http://svn.reactos.org/svn/reactos?rev=50456&view=rev
Log:
[INTRIN]
- Implement _mm_sfence, _mm_lfence, __faststorefence (for amd64)
- Don't use __sync_synchronize() for _ReadWriteBarrier, as it issues an mfence instruction and this is not what we want
- Remove "BUGBUG" comment, because the fact that _ReadBarrier and _WriteBarrier are full (compiler) barriers isn't critical.

Modified:
    trunk/reactos/include/crt/mingw32/intrin_x86.h

Modified: trunk/reactos/include/crt/mingw32/intrin_x86.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/crt/mingw32/intrin_x86.h?rev=50456&r1=50455&r2=50456&view=diff
==============================================================================
--- trunk/reactos/include/crt/mingw32/intrin_x86.h [iso-8859-1] (original)
+++ trunk/reactos/include/crt/mingw32/intrin_x86.h [iso-8859-1] Fri Jan 21 20:56:36 2011
@@ -79,21 +79,36 @@
 #define _alloca(s) __builtin_alloca(s)
 #endif
 
-/*** Atomic operations ***/
-
-#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
-#define _ReadWriteBarrier() __sync_synchronize()
-#else
-__INTRIN_INLINE void _MemoryBarrier(void)
+/*** Memory barriers ***/
+
+#ifdef _x86_64
+__INTRIN_INLINE void __faststorefence(void)
+{
+    long local;
+	__asm__ __volatile__("lock; orl $0, %0;" : : "m"(local));
+}
+#endif
+
+__INTRIN_INLINE void _mm_lfence(void)
+{
+	__asm__ __volatile__("lfence");
+}
+
+__INTRIN_INLINE void _mm_sfence(void)
+{
+	__asm__ __volatile__("sfence");
+}
+
+__INTRIN_INLINE void _ReadWriteBarrier(void)
 {
 	__asm__ __volatile__("" : : : "memory");
 }
-#define _ReadWriteBarrier() _MemoryBarrier()
-#endif
-
-/* BUGBUG: GCC only supports full barriers */
+
+/* GCC only supports full barriers */
 #define _ReadBarrier _ReadWriteBarrier
 #define _WriteBarrier _ReadWriteBarrier
+
+/*** Atomic operations ***/
 
 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
 




More information about the Ros-diffs mailing list