diff options
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | catman.c | 6 | ||||
-rwxr-xr-x | configure | 39 | ||||
-rw-r--r-- | configure.local.example | 8 | ||||
-rw-r--r-- | mandocd.c | 6 | ||||
-rw-r--r-- | test-cmsg.c | 13 | ||||
-rw-r--r-- | test-recvmsg.c | 8 |
7 files changed, 78 insertions, 6 deletions
@@ -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 \ @@ -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> @@ -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. @@ -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; +} |