[Gc] [libatomic_ops] Intel Compiler with gcc compatible mode

Patrick MARLIER patrick.marlier at unine.ch
Thu Feb 18 23:47:14 PST 2010


Since Intel Compiler (icc) is gcc compatible mode by default under 
linux, libatomic_ops can use the gcc definition to support more 
architecture.

Here a proposed patch.

Patrick Marlier.




-------------- next part --------------
Index: src/atomic_ops.h
===================================================================
RCS file: /cvsroot/bdwgc/bdwgc/libatomic_ops/src/atomic_ops.h,v
retrieving revision 1.3
diff -u -r1.3 atomic_ops.h
--- src/atomic_ops.h	17 Dec 2009 07:16:46 -0000	1.3
+++ src/atomic_ops.h	19 Feb 2010 07:45:44 -0000
@@ -199,6 +199,9 @@
 
 #if defined(__GNUC__) && !defined(AO_USE_PTHREAD_DEFS) \
     && !defined(__INTEL_COMPILER)
+# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
+#  define HAVE_GCC_ATOMIC_BUILTINS 1
+# endif
 # if defined(__i386__)
 #   include "atomic_ops/sysdeps/gcc/x86.h"
 # endif /* __i386__ */
@@ -252,6 +255,15 @@
 #   include "atomic_ops/sysdeps/icc/ia64.h"
 #   define AO_GENERALIZE_TWICE
 # endif
+# if defined(__GNUC__)
+  /* Intel Compiler in gcc compatible mode (but not support __sync_ primitive) */
+#  if defined(__i386__)
+#   include "atomic_ops/sysdeps/gcc/x86.h"
+#  endif /* __i386__ */
+#  if defined (__x86_64__)
+#   include "atomic_ops/sysdeps/gcc/x86_64.h"
+#  endif
+# endif
 #endif
 
 #if defined(_HPUX_SOURCE) && !defined(__GNUC__) && !defined(AO_USE_PTHREAD_DEFS)
Index: src/atomic_ops/sysdeps/gcc/x86_64.h
===================================================================
RCS file: /cvsroot/bdwgc/bdwgc/libatomic_ops/src/atomic_ops/sysdeps/gcc/x86_64.h,v
retrieving revision 1.3
diff -u -r1.3 x86_64.h
--- src/atomic_ops/sysdeps/gcc/x86_64.h	18 Feb 2010 10:12:08 -0000	1.3
+++ src/atomic_ops/sysdeps/gcc/x86_64.h	19 Feb 2010 07:45:44 -0000
@@ -121,7 +121,7 @@
 AO_INLINE int
 AO_compare_and_swap_full(volatile AO_t *addr, AO_t old, AO_t new_val)
 {
-# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
+# ifdef HAVE_GCC_ATOMIC_BUILTINS
     return (int)__sync_bool_compare_and_swap(addr, old, new_val);
 # else
     char result;


More information about the Gc mailing list