From: Tobias Brunner Date: Tue, 5 Jun 2018 13:58:08 +0000 (+0200) Subject: atomics: Define HAVE_GCC_ATOMIC_OPERATIONS when building with clang X-Git-Tag: 5.7.0dr5~20^2~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=942599b6238a54cd82631e4e19dea86867dd900d;p=thirdparty%2Fstrongswan.git atomics: Define HAVE_GCC_ATOMIC_OPERATIONS when building with clang We should probably check for stdatomic.h and use the c11 functions if available. --- diff --git a/src/libstrongswan/utils/utils/atomics.h b/src/libstrongswan/utils/utils/atomics.h index a973b1adc0..4b530ebbf9 100644 --- a/src/libstrongswan/utils/utils/atomics.h +++ b/src/libstrongswan/utils/utils/atomics.h @@ -27,8 +27,14 @@ */ 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