Use libbsd when available

Use the libbsd (https://libbsd.freedesktop.org/) overlay to transparently
use the bsd compatibility layer without needing any actual code changes.

Remove now unnecessary direct access to libbsd includes. And remove
checks for unused functions.
This commit is contained in:
Guillem Jover 2016-06-09 01:55:07 +02:00
parent 15a2c1b591
commit 1fb763761b
1 changed files with 10 additions and 6 deletions

View File

@ -238,7 +238,7 @@ if grep VERSION_TEXT $ssldir/include/openssl/opensslv.h | grep "LibreSSL" >/dev/
AC_DEFINE([HAVE_LIBRESSL], [1], [Define if we have LibreSSL]) AC_DEFINE([HAVE_LIBRESSL], [1], [Define if we have LibreSSL])
# libressl provides these compat functions, but they may also be # libressl provides these compat functions, but they may also be
# declared by the OS in libc. See if they have been declared. # declared by the OS in libc. See if they have been declared.
AC_CHECK_DECLS([strlcpy,strlcat,arc4random,arc4random_uniform,reallocarray]) AC_CHECK_DECLS([strlcpy,arc4random,arc4random_uniform])
else else
AC_MSG_RESULT([no]) AC_MSG_RESULT([no])
fi fi
@ -928,7 +928,7 @@ dnl ----- Start of "Things needed for gldns" section
dnl ----- dnl -----
dnl --------------------------------------------------------------------------- dnl ---------------------------------------------------------------------------
AC_CHECK_HEADERS([stdarg.h stdint.h netinet/in.h arpa/inet.h netdb.h sys/socket.h time.h sys/time.h bsd/string.h sys/select.h],,, [AC_INCLUDES_DEFAULT]) AC_CHECK_HEADERS([stdarg.h stdint.h netinet/in.h arpa/inet.h netdb.h sys/socket.h time.h sys/time.h sys/select.h],,, [AC_INCLUDES_DEFAULT])
dnl Check the printf-format attribute (if any) dnl Check the printf-format attribute (if any)
dnl result in HAVE_ATTR_FORMAT. dnl result in HAVE_ATTR_FORMAT.
@ -967,6 +967,14 @@ AC_MSG_RESULT($ac_cv_c_unused_attribute)
if test $ac_cv_c_unused_attribute = yes; then if test $ac_cv_c_unused_attribute = yes; then
AC_DEFINE(HAVE_ATTR_UNUSED, 1, [Whether the C compiler accepts the "unused" attribute]) AC_DEFINE(HAVE_ATTR_UNUSED, 1, [Whether the C compiler accepts the "unused" attribute])
fi fi
# Check for libbsd, so that the next function checks pick it as their
# system implementation.
PKG_CHECK_MODULES([LIBBSD],[libbsd-overlay],[
LIBS="$LIBS $LIBBSD_LIBS"
CFLAGS="$CFLAGS $LIBBSD_CFLAGS"
],[
AC_MSG_WARN([libbsd not found or usable; using embedded code instead])
])
AC_CHECK_DECLS([strlcpy,arc4random,arc4random_uniform]) AC_CHECK_DECLS([strlcpy,arc4random,arc4random_uniform])
AC_REPLACE_FUNCS(inet_pton) AC_REPLACE_FUNCS(inet_pton)
AC_REPLACE_FUNCS(inet_ntop) AC_REPLACE_FUNCS(inet_ntop)
@ -1050,10 +1058,6 @@ AH_BOTTOM([
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#ifdef HAVE_BSD_STRING_H
#include <bsd/string.h>
#endif
/* the version of the windows API enabled */ /* the version of the windows API enabled */
#ifndef WINVER #ifndef WINVER
#define WINVER 0x0600 // 0x0502 #define WINVER 0x0600 // 0x0502