aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/utils/utils.h
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2014-05-02 17:58:26 +0200
committerAndreas Steffen <andreas.steffen@strongswan.org>2014-05-04 19:16:46 +0200
commita0c2370ea59eea2d298a3eb63611753d60096773 (patch)
treefb5bb156aef964120d4b7a6993179cb02f694399 /src/libstrongswan/utils/utils.h
parent9be1c8d1759dbedc2b9986f9f43a56b754cf56a6 (diff)
downloadstrongswan-a0c2370ea59eea2d298a3eb63611753d60096773.tar.bz2
strongswan-a0c2370ea59eea2d298a3eb63611753d60096773.tar.xz
utils: Enable __atomic* built-ins based on the GCC version
This solves a problem with GNAT when compiling charon-tkm as __atomic* built-ins are only provided in GCC 4.7 and newer. Currently GNAT 4.6 and GCC 4.7.2 is shipped with Debian wheezy (stable), as used in the testing environment. So while the configure script correctly detected the __atomic* built-ins, and defined HAVE_GCC_ATOMIC_OPERATIONS, this define turned out to be incorrect when charon-tkm was later built with GNAT.
Diffstat (limited to 'src/libstrongswan/utils/utils.h')
-rw-r--r--src/libstrongswan/utils/utils.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libstrongswan/utils/utils.h b/src/libstrongswan/utils/utils.h
index 8f91e8431..75b31ec1b 100644
--- a/src/libstrongswan/utils/utils.h
+++ b/src/libstrongswan/utils/utils.h
@@ -748,6 +748,13 @@ static inline size_t round_down(size_t size, size_t alignment)
*/
typedef u_int refcount_t;
+/* use __atomic* built-ins with GCC 4.7 and newer */
+#ifdef __GNUC__
+# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6))
+# define HAVE_GCC_ATOMIC_OPERATIONS
+# endif
+#endif
+
#ifdef HAVE_GCC_ATOMIC_OPERATIONS
#define ref_get(ref) __atomic_add_fetch(ref, 1, __ATOMIC_RELAXED)