Hi there,

Since the bits/atomicity.h has been moved to ext/atomicity.h for gcc
>=4.2.0, a couple applications depending on commoncpp2 show build errors
>when building.
One part of the patch updates m4/ost_pthread.m4 to check for
ext/atomicity.h as well, the other part adds HAVE_EXT_ATOMICITY.H to
config.h.in and adds a define switch to include the right header-file.

I'd not hardcode either bits/atomicity.h or ext/atomicity.h depending on
the configure-results in the config.h since someone might build/have
built commoncpp with gcc-4.1.0 and then build the app with gcc-4.2.2
(or vice versa).

Cheers,
Tiziano

-- 
Tiziano Müller
Gentoo Linux Developer
Areas of responsibility: Samba, PostgreSQL, cpp, Python
E-Mail     : [EMAIL PROTECTED]
GnuPG FP   : F327 283A E769 2E36 18D5  4DE2 1B05 6A63 AE9C 1E30
diff -Naur commoncpp2-1.6.1.orig/config.h.in commoncpp2-1.6.1/config.h.in
--- commoncpp2-1.6.1.orig/config.h.in   2007-12-24 09:45:11.000000000 +0100
+++ commoncpp2-1.6.1/config.h.in        2007-12-24 10:25:43.000000000 +0100
@@ -239,6 +239,9 @@
 /* Define to 1 if you have the <bits/atomicity.h> header file. */
 #undef HAVE_BITS_ATOMICITY_H
 
+/* Define to 1 if you have the <ext/atomicity.h> header file. */
+#undef HAVE_EXT_ATOMICITY_H
+
 /* Define to 1 if you have the <bits/wordsize.h> header file. */
 #undef HAVE_BITS_WORDSIZE_H
 
@@ -1088,7 +1091,11 @@
 
 #if defined(__cplusplus)
 #if defined(HAVE_GCC_BITS_ATOMIC) || defined(HAVE_GCC_CXX_BITS_ATOMIC)
+#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2))
+#include <ext/atomicity.h>
+#else
 #include <bits/atomicity.h>
+#endif
 #define HAVE_ATOMIC
 #endif
 #endif
diff -Naur commoncpp2-1.6.1.orig/m4/ost_pthread.m4 
commoncpp2-1.6.1/m4/ost_pthread.m4
--- commoncpp2-1.6.1.orig/m4/ost_pthread.m4     2007-12-24 09:45:11.000000000 
+0100
+++ commoncpp2-1.6.1/m4/ost_pthread.m4  2007-12-24 10:12:24.000000000 +0100
@@ -92,7 +92,9 @@
   dnl check for gcc's bits/atomicity and the atomic functions therein
   AC_CHECK_HEADERS([bits/atomicity.h],
        ost_cv_bits_atomicity=yes,
-       ost_cv_bits_atomicity=no)
+       [AC_CHECK_HEADERS([ext/atomicity.h],
+               ost_cv_bits_atomicity=yes,
+               ost_cv_bits_atomicity=no)])
   if test $ost_cv_bits_atomicity = yes ; then
       AC_MSG_CHECKING([for _Atomic_word])
       AC_TRY_COMPILE([#include <bits/atomicity.h>],
@@ -103,7 +105,15 @@
            ],
            [ost_cv_gcc_atomic=yes
             AC_DEFINE(HAVE_GCC_BITS_ATOMIC, [1], [has gcc atomic functions])],
-           [ost_cv_gcc_atomic=no])
+           [AC_TRY_COMPILE([#include <ext/atomicity.h>],
+                   [
+                   _Atomic_word i = 0;
+                   __atomic_add(&i, 1);
+                   __exchange_and_add(&i, 1);
+                   ],
+                   [ost_cv_gcc_atomic=yes
+                   AC_DEFINE(HAVE_GCC_BITS_ATOMIC, [1], [has gcc atomic 
functions])],
+                   [ost_cv_gcc_atomic=no])])
       AC_MSG_RESULT($ost_cv_gcc_atomic)
 
       AC_MSG_CHECKING([for __gnu_cxx::_Atomic_word])
@@ -117,7 +127,17 @@
            [ost_cv_gcc_cxx_atomic=yes
             AC_DEFINE(HAVE_GCC_CXX_BITS_ATOMIC, [1], 
                [has __gnu_cxx atomic functions])],
-           [ost_cv_gcc_cxx_atomic=no])
+           [AC_TRY_COMPILE([#include <ext/atomicity.h>],
+                   [
+                   using namespace __gnu_cxx;
+                   _Atomic_word i = 0;
+                   __atomic_add(&i, 1);
+                   __exchange_and_add(&i, 1);
+                   ],
+                   [ost_cv_gcc_cxx_atomic=yes
+                    AC_DEFINE(HAVE_GCC_CXX_BITS_ATOMIC, [1], 
+                       [has __gnu_cxx atomic functions])],
+                   [ost_cv_gcc_cxx_atomic=no])])
       AC_MSG_RESULT($ost_cv_gcc_cxx_atomic)
   fi
 

Attachment: pgpkPemBJISep.pgp
Description: PGP signature

_______________________________________________
Bug-commoncpp mailing list
Bug-commoncpp@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-commoncpp

Reply via email to