Detect and propagate atomic libraries like bind9
BIND9 headers expect atomic definitions are configured before they are included. It needs adding atomic libraries detection in configure AND including config.h before any ISC headers are included. Move dyndb-config.h before isc headers anywhere where needed.
This commit is contained in:
parent
1be57227a9
commit
131ddb918a
72
configure.ac
72
configure.ac
@ -145,6 +145,78 @@ AC_RUN_IFELSE([AC_LANG_PROGRAM([
|
||||
], [AC_MSG_ERROR([Cross compiling is not supported.])]
|
||||
)
|
||||
|
||||
# Following atomic checks taken from bind9 configure
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
ISC_ATOMIC_LIBS=""
|
||||
AC_CHECK_HEADERS(
|
||||
[stdatomic.h],
|
||||
[AC_MSG_CHECKING([for memory model aware atomic operations])
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#include <stdatomic.h>]],
|
||||
[[atomic_int_fast32_t val = 0; atomic_fetch_add_explicit(&val, 1, memory_order_relaxed);]]
|
||||
)],
|
||||
[AC_MSG_RESULT([stdatomic.h])
|
||||
AC_MSG_CHECKING([whether -latomic is needed for 64-bit stdatomic.h functions])
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#include <stdatomic.h>]],
|
||||
[[atomic_int_fast64_t val = 0; atomic_fetch_add_explicit(&val, 1, memory_order_relaxed);]]
|
||||
)],
|
||||
[AC_MSG_RESULT([no])],
|
||||
[ISC_ATOMIC_LIBS="-latomic"
|
||||
AX_SAVE_FLAGS([atomic])
|
||||
LIBS="$LIBS $ISC_ATOMIC_LIBS"
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#include <stdatomic.h>]],
|
||||
[[atomic_int_fast64_t val = 0; atomic_fetch_add_explicit(&val, 1, memory_order_relaxed);]]
|
||||
)],
|
||||
[AC_MSG_RESULT([yes])],
|
||||
[AC_MSG_FAILURE([libatomic needed, but linking with -latomic failed, please fix your toolchain.])])
|
||||
AX_RESTORE_FLAGS([atomic])
|
||||
])
|
||||
],
|
||||
[AC_MSG_FAILURE([stdatomic.h header found, but compilation failed, please fix your toolchain.])]
|
||||
)],
|
||||
[AC_MSG_CHECKING([for memory model aware atomic operations])
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#include <inttypes.h>]],
|
||||
[[int32_t val = 0; __atomic_fetch_add(&val, 1, __ATOMIC_RELAXED);]]
|
||||
)],
|
||||
[AC_MSG_RESULT([__atomic builtins])
|
||||
AC_DEFINE([HAVE___ATOMIC], [1], [define if __atomic builtins are not available])
|
||||
AC_MSG_CHECKING([whether -latomic is needed for 64-bit __atomic builtins])
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#include <inttypes.h>]],
|
||||
[[int64_t val = 0; __atomic_fetch_add(&val, 1, __ATOMIC_RELAXED);]]
|
||||
)],
|
||||
[AC_MSG_RESULT([no])],
|
||||
[ISC_ATOMIC_LIBS="-latomic"
|
||||
AX_SAVE_FLAGS([atomic])
|
||||
LIBS="$LIBS $ISC_ATOMIC_LIBS"
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#include <inttypes.h>]],
|
||||
[[int64_t val = 0; __atomic_fetch_add(&val, 1, __ATOMIC_RELAXED);]]
|
||||
)],
|
||||
[AC_MSG_RESULT([yes])],
|
||||
[AC_MSG_FAILURE([libatomic needed, but linking with -latomic failed, please fix your toolchain.])])
|
||||
AX_RESTORE_FLAGS([atomic])
|
||||
])
|
||||
],
|
||||
[AC_MSG_FAILURE([not found])
|
||||
])
|
||||
])
|
||||
LIBS="$LIBS $ISC_ATOMIC_LIBS"
|
||||
|
||||
dnl isc_errno_toresult() was not available in older header files
|
||||
AC_MSG_CHECKING([isc_errno_toresult availability])
|
||||
AC_TRY_RUN([
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "dyndb-config.h"
|
||||
|
||||
#include <isc/result.h>
|
||||
#include <isc/types.h>
|
||||
#include <isc/util.h>
|
||||
@ -8,7 +10,6 @@
|
||||
#include <dns/zone.h>
|
||||
#include <dns/zt.h>
|
||||
|
||||
#include "dyndb-config.h"
|
||||
#include "empty_zones.h"
|
||||
#include "util.h"
|
||||
#include "zone_register.h"
|
||||
|
2
src/fs.c
2
src/fs.c
@ -8,6 +8,8 @@
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "dyndb-config.h"
|
||||
|
||||
#include <isc/dir.h>
|
||||
#include <isc/file.h>
|
||||
#include <isc/errno.h>
|
||||
|
@ -2,11 +2,12 @@
|
||||
* Copyright (C) 2013-2014 bind-dyndb-ldap authors; see COPYING for license
|
||||
*/
|
||||
|
||||
#include "dyndb-config.h"
|
||||
|
||||
#include <isc/rwlock.h>
|
||||
#include <isc/util.h>
|
||||
#include <dns/name.h>
|
||||
|
||||
#include "dyndb-config.h"
|
||||
#include "rbt_helper.h"
|
||||
#include "fwd_register.h"
|
||||
#include "util.h"
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#define _POSIX_C_SOURCE 200112L /* setenv */
|
||||
|
||||
#include "dyndb-config.h"
|
||||
#include <isc/util.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -2,6 +2,8 @@
|
||||
* Copyright (C) 2009-2015 bind-dyndb-ldap authors; see COPYING for license
|
||||
*/
|
||||
|
||||
#include "dyndb-config.h"
|
||||
|
||||
#include <isc/buffer.h>
|
||||
#include <isc/hex.h>
|
||||
#include <isc/mem.h>
|
||||
@ -20,7 +22,6 @@
|
||||
#include <strings.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "dyndb-config.h"
|
||||
#include "str.h"
|
||||
#include "ldap_convert.h"
|
||||
#include "log.h"
|
||||
|
@ -2,12 +2,14 @@
|
||||
* Copyright (C) 2011-2014 bind-dyndb-ldap authors; see COPYING for license
|
||||
*/
|
||||
#include <uuid/uuid.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "dyndb-config.h"
|
||||
|
||||
#include <dns/rdata.h>
|
||||
#include <dns/ttl.h>
|
||||
#include <dns/types.h>
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <isc/region.h>
|
||||
#include <isc/types.h>
|
||||
#include <isc/util.h>
|
||||
|
@ -2,6 +2,8 @@
|
||||
* Copyright (C) 2014 bind-dyndb-ldap authors; see COPYING for license
|
||||
*/
|
||||
|
||||
#include "dyndb-config.h"
|
||||
|
||||
#include <isc/task.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "dyndb-config.h"
|
||||
|
||||
#include <isc/formatcheck.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
* Meta-database for information which are not represented in DNS data.
|
||||
*/
|
||||
|
||||
#include "dyndb-config.h"
|
||||
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
|
@ -8,8 +8,10 @@
|
||||
#include <ldap.h>
|
||||
#include <stddef.h>
|
||||
#include <uuid/uuid.h>
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "dyndb-config.h"
|
||||
|
||||
#include <isc/net.h>
|
||||
#include <isc/refcount.h>
|
||||
#include <isc/result.h>
|
||||
@ -27,7 +29,6 @@
|
||||
#include "metadb.h"
|
||||
#include "mldap.h"
|
||||
#include "util.h"
|
||||
#include "dyndb-config.h"
|
||||
|
||||
#if LIBDNS_VERSION_MAJOR < 1600
|
||||
#define REFCOUNT_CAST(n) ((typeof(((isc_refcount_t *)0)->refs)) (n))
|
||||
|
@ -2,12 +2,13 @@
|
||||
* Copyright (C) 2013-2014 bind-dyndb-ldap authors; see COPYING for license
|
||||
*/
|
||||
|
||||
#include "dyndb-config.h"
|
||||
|
||||
#include <isc/util.h>
|
||||
#include <dns/rbt.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "rbt_helper.h"
|
||||
#include "dyndb-config.h"
|
||||
|
||||
#define LDAPDB_RBTITER_MAGIC ISC_MAGIC('L', 'D', 'P', 'I')
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
* own signal. However, for our purposes, this shouldn't be needed.
|
||||
*/
|
||||
|
||||
#include "dyndb-config.h"
|
||||
|
||||
#include <isc/condition.h>
|
||||
#include <isc/result.h>
|
||||
#include <isc/util.h>
|
||||
|
@ -2,6 +2,8 @@
|
||||
* Copyright (C) 2009-2014 bind-dyndb-ldap authors; see COPYING for license
|
||||
*/
|
||||
|
||||
#include "dyndb-config.h"
|
||||
|
||||
#include <isc/util.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/task.h>
|
||||
@ -24,7 +26,6 @@
|
||||
#include "types.h"
|
||||
#include "ldap_helper.h"
|
||||
#include "zone_register.h"
|
||||
#include "dyndb-config.h"
|
||||
|
||||
#if LIBDNS_VERSION_MAJOR < 1600
|
||||
#define cfg_parse_buffer cfg_parse_buffer4
|
||||
|
@ -9,6 +9,8 @@
|
||||
* Review all the REQUIRE() macros.
|
||||
*/
|
||||
|
||||
#include "dyndb-config.h"
|
||||
|
||||
#include <isc/buffer.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/mutex.h>
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "dyndb-config.h"
|
||||
|
||||
#include <isc/event.h>
|
||||
#include <isc/netaddr.h>
|
||||
#include <isc/task.h>
|
||||
@ -18,7 +20,6 @@
|
||||
#include <dns/zone.h>
|
||||
#include <dns/zt.h>
|
||||
|
||||
#include "dyndb-config.h"
|
||||
#include "util.h"
|
||||
#include "ldap_convert.h"
|
||||
#include "ldap_entry.h"
|
||||
|
@ -3,6 +3,8 @@
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "dyndb-config.h"
|
||||
|
||||
#include <isc/types.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
* Copyright (C) 2009-2014 bind-dyndb-ldap authors; see COPYING for license
|
||||
*/
|
||||
|
||||
#include "dyndb-config.h"
|
||||
|
||||
#include <isc/mem.h>
|
||||
#include <isc/rwlock.h>
|
||||
#include <isc/util.h>
|
||||
@ -12,7 +14,6 @@
|
||||
#include <dns/result.h>
|
||||
#include <dns/zone.h>
|
||||
|
||||
#include "dyndb-config.h"
|
||||
#include "fs.h"
|
||||
#include "ldap_driver.h"
|
||||
#include "log.h"
|
||||
|
Loading…
Reference in New Issue
Block a user