1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
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 2008-05-06 10:47:42.000000000 +0200
+++ commoncpp2-1.6.1/m4/ost_pthread.m4 2008-05-06 16:11:05.000000000 +0200
@@ -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
@@ -438,7 +458,11 @@
#if defined(__cplusplus)
#if defined(HAVE_GCC_BITS_ATOMIC) || defined(HAVE_GCC_CXX_BITS_ATOMIC)
-#include <bits/atomicity.h>
+#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2))
+ #include <ext/atomicity.h>
+#else
+ #include <bits/atomicity.h>
+#endif
#define HAVE_ATOMIC
#endif
#endif
|