aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-02-08 16:11:40 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-02-08 16:11:40 +0000
commitb3d021af18b2745d4a2594b05bc4e605d918a9e3 (patch)
treeeebee3b5d5f59cd9135567e1efe2560a0b7e505a
parent05ede23b72a253dad7a9e6f68dc14d4f2a1ea3c2 (diff)
downloadmandoc-b3d021af18b2745d4a2594b05bc4e605d918a9e3.tar.gz
mandoc-b3d021af18b2745d4a2594b05bc4e605d918a9e3.tar.zst
mandoc-b3d021af18b2745d4a2594b05bc4e605d918a9e3.zip
config glue for recvmsg(2) and CMSG_FIRSTHDR(3);
needed for Solaris 11
-rw-r--r--Makefile4
-rw-r--r--catman.c6
-rwxr-xr-xconfigure39
-rw-r--r--configure.local.example8
-rw-r--r--mandocd.c6
-rw-r--r--test-cmsg.c13
-rw-r--r--test-recvmsg.c8
7 files changed, 78 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 76eb6e52..27d682ac 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.498 2017/02/08 13:36:32 schwarze Exp $
+# $Id: Makefile,v 1.499 2017/02/08 16:11:40 schwarze Exp $
#
# Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
# Copyright (c) 2011, 2013-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -20,6 +20,7 @@ VERSION = 1.14.1
# === LIST OF FILES ====================================================
TESTSRCS = test-be32toh.c \
+ test-cmsg.c \
test-dirent-namlen.c \
test-EFTYPE.c \
test-err.c \
@@ -34,6 +35,7 @@ TESTSRCS = test-be32toh.c \
test-PATH_MAX.c \
test-pledge.c \
test-progname.c \
+ test-recvmsg.c \
test-reallocarray.c \
test-rewb-bsd.c \
test-rewb-sysv.c \
diff --git a/catman.c b/catman.c
index 6c9276d4..438474a5 100644
--- a/catman.c
+++ b/catman.c
@@ -1,4 +1,4 @@
-/* $Id: catman.c,v 1.15 2017/02/08 14:50:53 schwarze Exp $ */
+/* $Id: catman.c,v 1.16 2017/02/08 16:11:40 schwarze Exp $ */
/*
* Copyright (c) 2017 Michael Stapelberg <stapelberg@debian.org>
* Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -17,6 +17,10 @@
*/
#include "config.h"
+#if HAVE_CMSG_XPG42
+#define _XPG4_2
+#endif
+
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
diff --git a/configure b/configure
index 38a2a37f..bb3a7357 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $Id: configure,v 1.56 2017/02/04 12:03:07 schwarze Exp $
+# $Id: configure,v 1.57 2017/02/08 16:11:41 schwarze Exp $
#
# Copyright (c) 2014, 2015, 2016 Ingo Schwarze <schwarze@openbsd.org>
#
@@ -44,12 +44,15 @@ LDADD=
LDFLAGS=
LD_NANOSLEEP=
LD_OHASH=
+LD_RECVMSG=
STATIC="-static"
BUILD_CGI=0
BUILD_CATMAN=0
INSTALL_LIBMANDOC=0
+HAVE_CMSG=
+HAVE_CMSG_XPG42=0
HAVE_DIRENT_NAMLEN=
HAVE_EFTYPE=
HAVE_ENDIAN=
@@ -67,6 +70,7 @@ HAVE_PATH_MAX=
HAVE_PLEDGE=
HAVE_PROGNAME=
HAVE_REALLOCARRAY=
+HAVE_RECVMSG=
HAVE_REWB_BSD=
HAVE_REWB_SYSV=
HAVE_SANDBOX_INIT=
@@ -267,6 +271,36 @@ if [ "${HAVE_NANOSLEEP}" -eq 0 ]; then
exit 1
fi
+if [ ${BUILD_CATMAN} -gt 0 ]; then
+ # --- recvmsg ---
+ if [ -n "${LD_RECVMSG}" ]; then
+ runtest recvmsg RECVMSG "${LD_RECVMSG}" || true
+ elif singletest recvmsg RECVMSG; then
+ :
+ elif runtest recvmsg RECVMSG "-lsocket"; then
+ LD_RECVMSG="-lsocket"
+ fi
+ if [ "${HAVE_RECVMSG}" -eq 0 ]; then
+ echo "FATAL: recvmsg: no" 1>&2
+ echo "FATAL: recvmsg: no" 1>&3
+ echo "Without recvmsg(2), you cannot BUILD_CATMAN." 1>&2
+ exit 1
+ fi
+
+ # --- cmsg ---
+ if singletest cmsg CMSG; then
+ :
+ elif runtest cmsg CMSG "-D_XPG4_2"; then
+ HAVE_CMSG_XPG42=1
+ fi
+ if [ "${HAVE_CMSG}" -eq 0 ]; then
+ echo "FATAL: cmsg: no" 1>&2
+ echo "FATAL: cmsg: no" 1>&3
+ echo "Without CMSG_FIRSTHDR(3), you cannot BUILD_CATMAN." 1>&2
+ exit 1
+ fi
+fi
+
# --- ohash ---
if ismanual ohash OHASH "${HAVE_OHASH}"; then
:
@@ -282,7 +316,7 @@ if [ "${HAVE_OHASH}" -eq 0 ]; then
fi
# --- LDADD ---
-LDADD="${LDADD} ${LD_NANOSLEEP} ${LD_OHASH} -lz"
+LDADD="${LDADD} ${LD_NANOSLEEP} ${LD_RECVMSG} ${LD_OHASH} -lz"
echo "LDADD=\"${LDADD}\"" 1>&2
echo "LDADD=\"${LDADD}\"" 1>&3
echo 1>&3
@@ -326,6 +360,7 @@ if [ ${HAVE_ENDIAN} -eq 0 -a ${HAVE_SYS_ENDIAN} -eq 0 ]; then
fi
cat << __HEREDOC__
+#define HAVE_CMSG_XPG42 ${HAVE_CMSG_XPG42}
#define HAVE_DIRENT_NAMLEN ${HAVE_DIRENT_NAMLEN}
#define HAVE_ENDIAN ${HAVE_ENDIAN}
#define HAVE_ERR ${HAVE_ERR}
diff --git a/configure.local.example b/configure.local.example
index 6ac2310a..a7fa8484 100644
--- a/configure.local.example
+++ b/configure.local.example
@@ -1,4 +1,4 @@
-# $Id: configure.local.example,v 1.23 2017/02/04 12:03:07 schwarze Exp $
+# $Id: configure.local.example,v 1.24 2017/02/08 16:11:41 schwarze Exp $
#
# Copyright (c) 2014, 2015, 2016 Ingo Schwarze <schwarze@openbsd.org>
#
@@ -140,6 +140,12 @@ CFLAGS="${CFLAGS} -I/usr/local/include"
LD_NANOSLEEP="-lrt"
+# Some platforms may need an additional linker flag for recvmsg(2).
+# If none is needed or it is -lsocket, it is autodetected.
+# Otherwise, set the following variable.
+
+LD_RECVMSG="-lsocket"
+
# Some platforms might need additional linker flags to link against
# libmandoc that are not autodetected, though no such cases are
# currently known.
diff --git a/mandocd.c b/mandocd.c
index 47022606..b8a2b6dc 100644
--- a/mandocd.c
+++ b/mandocd.c
@@ -1,4 +1,4 @@
-/* $Id: mandocd.c,v 1.3 2017/02/06 19:02:37 schwarze Exp $ */
+/* $Id: mandocd.c,v 1.4 2017/02/08 16:11:41 schwarze Exp $ */
/*
* Copyright (c) 2017 Michael Stapelberg <stapelberg@debian.org>
* Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -17,6 +17,10 @@
*/
#include "config.h"
+#if HAVE_CMSG_XPG42
+#define _XPG4_2
+#endif
+
#include <sys/types.h>
#include <sys/socket.h>
diff --git a/test-cmsg.c b/test-cmsg.c
new file mode 100644
index 00000000..b5441f9c
--- /dev/null
+++ b/test-cmsg.c
@@ -0,0 +1,13 @@
+#include <stddef.h>
+#include <sys/socket.h>
+
+int
+main(void)
+{
+ struct msghdr msg;
+
+ msg.msg_control = NULL;
+ msg.msg_controllen = 0;
+
+ return CMSG_FIRSTHDR(&msg) != NULL;
+}
diff --git a/test-recvmsg.c b/test-recvmsg.c
new file mode 100644
index 00000000..d026c70f
--- /dev/null
+++ b/test-recvmsg.c
@@ -0,0 +1,8 @@
+#include <sys/socket.h>
+#include <stddef.h>
+
+int
+main(void)
+{
+ return recvmsg(-1, NULL, 0) != -1;
+}