Fix issue in Freebsd when building with GCC 14.1.0

Since GCC 14 now implements `__has_extension()` the build started to use
Clang atomics, i.e. the `__c11_*` APIs only provided by Clang.

Fix build to use GNUC atomics and include the upstream patch:
  https://reviews.freebsd.org/D16585
which enables C11 atomics when building with GCC >= 4.7.
This commit is contained in:
Björn Svensson 2024-05-13 00:23:51 +02:00 committed by fengbojiang
parent 30c7c4a391
commit 486200e57f
2 changed files with 5 additions and 2 deletions

View File

@ -795,7 +795,7 @@
* Type Safety Checking
*
* Clang provides additional attributes to enable checking type safety
* properties that cannot be enforced by the C type system.
* properties that cannot be enforced by the C type system.
*/
#if __has_attribute(__argument_with_type_tag__) && \

View File

@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#include <sys/_types.h>
#if __has_extension(c_atomic) || __has_extension(cxx_atomic)
#if defined(__clang__) && (__has_extension(c_atomic) || __has_extension(cxx_atomic))
#define __CLANG_ATOMICS
#elif __GNUC_PREREQ__(4, 7)
#define __GNUC_ATOMICS
@ -87,6 +87,9 @@
#if defined(__CLANG_ATOMICS)
#define ATOMIC_VAR_INIT(value) (value)
#define atomic_init(obj, value) __c11_atomic_init(obj, value)
#elif defined(__GNUC_ATOMICS)
#define ATOMIC_VAR_INIT(value) (value)
#define atomic_init(obj, value) __atomic_init(obj, value)
#else
#define ATOMIC_VAR_INIT(value) { .__val = (value) }
#define atomic_init(obj, value) ((void)((obj)->__val = (value)))