On FreeBSD 6.4, the compilation succeeds but the test fails: recvfd: Function not implemented sendfd: Function not implemented FAIL: test-passfd
config.log shows this: configure:7701: checking for UNIX domain sockets SCM_RIGHTS that behave in BSD4. 4 way configure:7744: gcc -c -g -O2 -Wall conftest.c >&5 conftest.c: In function `main': conftest.c:98: error: `NULL' undeclared (first use in this function) conftest.c:98: error: (Each undeclared identifier is reported only once conftest.c:98: error: for each function it appears in.) conftest.c:94: warning: unused variable `fdptr' The reason is that the expansion of CMSG_FIRSTHDR (...) contains a reference to NULL. In <sys/socket.h>: #define CMSG_NXTHDR(mhdr, cmsg) \ ((char *)(cmsg) == NULL ? CMSG_FIRSTHDR(mhdr) : \ ... 2011-03-13 Bruno Haible <br...@clisp.org> passfd: Work around bug with CMSG_FIRSTHDR on FreeBSD 6.4. * lib/sys_socket.in.h: Include <stddef.h>. * m4/afunix.m4 (gl_SOCKET_AFUNIX): Include <stddef.h> before using CMSG_FIRSTHDR. Remove unused variable. --- lib/sys_socket.in.h.orig Sun Mar 13 23:51:21 2011 +++ lib/sys_socket.in.h Sun Mar 13 23:50:39 2011 @@ -50,6 +50,10 @@ <sys/types.h>. */ # include <sys/types.h> +/* On FreeBSD 6.4, <sys/socket.h> defines some macros that assume that NULL + is defined. */ +# include <stddef.h> + /* The include_next requires a split double-inclusion guard. */ # @INCLUDE_NEXT@ @NEXT_SYS_SOCKET_H@ --- m4/afunix.m4.orig Sun Mar 13 23:51:21 2011 +++ m4/afunix.m4 Sun Mar 13 23:51:11 2011 @@ -1,4 +1,4 @@ -# afunix.m4 serial 3 +# afunix.m4 serial 4 dnl Copyright (C) 2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -43,6 +43,7 @@ [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[#include <sys/types.h> + #include <stddef.h> #ifdef HAVE_SYS_SOCKET_H #include <sys/socket.h> #endif @@ -57,7 +58,6 @@ struct cmsghdr *cmsg; int myfds[1] = {0}; char buf[CMSG_SPACE (sizeof (myfds))]; - int *fdptr; msg.msg_control = buf; msg.msg_controllen = sizeof buf; -- In memoriam Odette Sansom <http://en.wikipedia.org/wiki/Odette_Hallowes>