]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
atomics: Define HAVE_GCC_ATOMIC_OPERATIONS when building with clang
authorTobias Brunner <tobias@strongswan.org>
Tue, 5 Jun 2018 13:58:08 +0000 (15:58 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 3 Jul 2018 09:31:31 +0000 (11:31 +0200)
We should probably check for stdatomic.h and use the c11 functions if
available.

src/libstrongswan/utils/utils/atomics.h

index a973b1adc092915df9b6a4c19cf7045655c1a6c1..4b530ebbf984e60d0a3c0183297e9dce00ca57a9 100644 (file)
  */
 typedef u_int refcount_t;
 
+/* use __atomic* built-ins with clang, if available (note that clang also
+ * defines __GNUC__, however only claims to be GCC 4.2) */
+#if defined(__clang__)
+# if __has_builtin(__atomic_add_fetch)
+#  define HAVE_GCC_ATOMIC_OPERATIONS
+# endif
 /* use __atomic* built-ins with GCC 4.7 and newer */
-#ifdef __GNUC__
+#elif defined(__GNUC__)
 # if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6))
 #  define HAVE_GCC_ATOMIC_OPERATIONS
 # endif