]> git.mxchange.org Git - simgear.git/commitdiff
Use a compile test to see if we need to provide the GCC atomic built-ins ourselves...
authorJames Turner <zakalawe@mac.com>
Sun, 23 Oct 2011 14:59:27 +0000 (15:59 +0100)
committerJames Turner <zakalawe@mac.com>
Sun, 23 Oct 2011 14:59:27 +0000 (15:59 +0100)
CMakeLists.txt
simgear/simgear_config_cmake.h.in
simgear/structure/SGAtomic.cxx

index f672915562231befcd1e2d847aef7663fda95e7b..fc2d2630a99d1fb8d00346eda3df52a3f5df66b0 100644 (file)
@@ -99,7 +99,7 @@ find_package(ZLIB REQUIRED)
 find_package(Threads REQUIRED)
 
 if(SIMGEAR_HEADLESS)
-    message(STATUS "headlesss mode")
+    message(STATUS "headless mode")
     set(NO_OPENSCENEGRAPH_INTERFACE 1)
 else()
     find_package(OpenGL REQUIRED)
@@ -179,6 +179,13 @@ check_cxx_source_compiles(
 
 if(CMAKE_COMPILER_IS_GNUCXX)
     set(WARNING_FLAGS -Wall)
+    
+    # certain GCC versions don't provide the atomic builds, and hence
+    # require is to provide them in SGAtomic.cxx
+    set(CMAKE_REQUIRED_INCLUDES ${CMAKE_INCLUDE_PATH})
+    check_cxx_source_compiles(
+       "int main() { unsigned mValue; return __sync_add_and_fetch(&mValue, 1); }"
+        GCC_ATOMIC_BUILTINS_FOUND)
 endif(CMAKE_COMPILER_IS_GNUCXX)
 
 if(WIN32)
index 3d132306340aa413509da72223d816deb3f93f41..a1192283281103dd0525e9338a46b9f73aa8181f 100644 (file)
@@ -16,5 +16,7 @@
 #cmakedefine HAVE_SVN_CLIENT_H
 #cmakedefine HAVE_LIBSVN_CLIENT_1
 
+#cmakedefine GCC_ATOMIC_BUILTINS_FOUND
+
 // set if building headless (no OSG or OpenGL libs)
 #cmakedefine NO_OPENSCENEGRAPH_INTERFACE
index 728994df81be057fd3ec03a909b61f6b2e1ecbae..3f0b9f441ccdd526c0af61813050f37cbb5720f0 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  */
+#ifdef HAVE_CONFIG_H
+#  include <simgear_config.h>
+#endif
 
 #include "SGAtomic.hxx"
 
-#if defined(SGATOMIC_USE_GCC4_BUILTINS) && defined (__i386__)
+#if defined(SGATOMIC_USE_GCC4_BUILTINS) && !defined (GCC_ATOMIC_BUILTINS_FOUND)
 
 // Usually the appropriate functions are inlined by gcc.
 // But if gcc is called with something equivalent to -march=i386,