Allow use of gcc-style __atomic* builtins in older clang versions. Avoid use of const pointers with atomic_load because strictly C11 compliant compilers error on this. Using const became allowed in C17: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2244.htm#dr_459 --- lib/isc/include/isc/stdatomic.h.orig 2022-10-10 18:01:57.000000000 +1100 +++ lib/isc/include/isc/stdatomic.h 2022-11-03 20:54:26.000000000 +1100 @@ -21,7 +21,9 @@ #endif /* HAVE_UCHAR_H */ /* GCC 4.7.0 introduced __atomic builtins, but not the __GNUC_ATOMICS define */ -#if !defined(__GNUC_ATOMICS) && __GNUC__ == 4 && __GNUC_MINOR__ >= 7 +/* Clang 3.1 and later have the builtins but none define __GNUC_ATOMICS */ +#if !defined(__GNUC_ATOMICS) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 7) \ + || defined(__clang__)) #define __GNUC_ATOMICS #endif --- lib/isc/netmgr/netmgr-int.h.orig 2022-10-10 18:44:05.000000000 +1100 +++ lib/isc/netmgr/netmgr-int.h 2022-11-03 20:57:03.000000000 +1100 @@ -244,7 +244,7 @@ typedef struct isc__networker { #define NMHANDLE_MAGIC ISC_MAGIC('N', 'M', 'H', 'D') #define VALID_NMHANDLE(t) \ (ISC_MAGIC_VALID(t, NMHANDLE_MAGIC) && \ - atomic_load(&(t)->references) > 0) + atomic_load((isc_refcount_t *)&(t)->references) > 0) typedef void (*isc__nm_closecb)(isc_nmhandle_t *); typedef struct isc_nm_http_session isc_nm_http_session_t; --- lib/isc/netmgr/http.c.orig 2022-10-10 18:44:05.000000000 +1100 +++ lib/isc/netmgr/http.c 2022-11-03 21:02:50.000000000 +1100 @@ -1672,7 +1672,7 @@ find_server_request_handler(const char * REQUIRE(VALID_NMSOCK(serversocket)); - if (atomic_load(&serversocket->listening)) { + if (atomic_load((atomic_bool *)&serversocket->listening)) { handler = http_endpoints_find( request_path, http_get_listener_endpoints(serversocket, tid));