File blocxx-2.1.0-memorybarrier.diff of Package blocxx

BloCxx Bug #2799341:
	https://sourceforge.net/tracker/?func=detail&aid=2799341&group_id=176030&atid=875611

BloCxx SVN Repository:
	https://blocxx.svn.sourceforge.net/svnroot/blocxx/

Index: trunk/src/blocxx/MemoryBarrier.hpp
===================================================================
--- trunk/src/blocxx/MemoryBarrier.hpp	(Revision 226)
+++ trunk/src/blocxx/MemoryBarrier.hpp	(Revision 411)
@@ -51,30 +51,35 @@
  */
 inline void readWriteMemoryBarrier()
 {
-	#if defined(__alpha)
+#if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
+	// The GCC compiler-provided synchronization routine is better for
+	// optimization than any inline assembly we can provide.
+	__sync_synchronize();
+
+#elif defined(__alpha)
 	// DEC/COMPAQ/HP Alpha
 	__asm__ __volatile__("mb");
 
-	#elif defined(__HP_aCC) && defined(BLOCXX_ARCH_IA64)
+#elif defined(__HP_aCC) && defined(BLOCXX_ARCH_IA64)
 	// Itanium (useable with aCC as the compiler).
 	_Asm_mf();
-	#elif defined(BLOCXX_ARCH_IA64)
+#elif defined(BLOCXX_ARCH_IA64)
 	// Intel Itanium
 	__asm__ __volatile__("mf");
 
-	#elif defined(BLOCXX_ARCH_PPC) || defined(BLOCXX_ARCH_PPC64)
+#elif defined(BLOCXX_ARCH_PPC) || defined(BLOCXX_ARCH_PPC64)
 	// PPC/PPC64
 	__asm__ __volatile__ ("sync" : : : "memory");
 
-	#elif defined(BLOCXX_ARCH_S390) || defined(BLOCXX_ARCH_S390X)
+#elif defined(BLOCXX_ARCH_S390) || defined(BLOCXX_ARCH_S390X)
 	// s390/s390x
 	__asm__ __volatile__ ( "bcr 15,0" : : : "memory" ); 
 
-	#elif defined(BLOCXX_ARCH_X86_64) || defined(BLOCXX_ARCH_X86) || defined(BLOCXX_ARCH_HPPA20) || defined(BLOCXX_ARCH_SPARC)
+#elif defined(BLOCXX_ARCH_X86_64) || defined(BLOCXX_ARCH_X86) || defined(BLOCXX_ARCH_HPPA20) || defined(BLOCXX_ARCH_SPARC)
 	// Nothing required for these architectures.
-	#else // if defined(BLOCXX_ARCH_UNKNOWN)
-	#error "Unknown architecture. readWriteMemoryBarrier() must be updated"
-	#endif
+#else // if defined(BLOCXX_ARCH_UNKNOWN)
+#error "Unknown architecture. readWriteMemoryBarrier() must be updated"
+#endif
 }
 
 } // end namespace BLOCXX_NAMESPACE