bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/4] Add AF_UNIX test of socket familly


From: Bruno Haible
Subject: Re: [PATCH 1/4] Add AF_UNIX test of socket familly
Date: Tue, 8 Mar 2011 11:04:55 +0100
User-agent: KMail/1.9.9

Hello Bastien,

> Test availability of AF_UNIX socket familly. It will be used by 
> sendfd/receivefd.
> ---
>  m4/afunix.m4   |   96 
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  m4/sockpfaf.m4 |   23 +++++++++++++-

This looks nearly right already, so I've committed this for you, with the
following ChangeLog entry and a few additional tweaks of mine.

2011-03-07  Bastien Roucari├Ęs  <address@hidden>

        passfd module, part 1.
        * m4/afunix.m4: New file.
        * m4/sockpfaf.m4 (gl_SOCKET_FAMILIES): Also test for UNIX domain
        sockets.

Now that you are contributing code to gnulib, can you please start the
copyright assignment process? Since gnulib is used by central packages of
GNU, we want most of its copyright to be held by the FSF. I'll give you
more details by private email.

The tweaks are the following:

- gl_SOCKET_FAMILIES is used by the 'sys_socket' module, which does not need
  UNIX sockets. Why should users of that module have an extra configure time
  check? It's better to move this code to a separate macro.
- In afunix.m4: Indentation ought to make the structure of the code clear at
  a glimpse. It doesn't matter if this indentation introduces a few more lines.
- GNU style parenthesizing of C code: put a space before the argument list of
  function calls and macro calls.
- Fix the wording in the AC_MSG_CHECKING (English grammar).

Hope you agree to this.


2011-03-08  Bruno Haible  <address@hidden>

        passfd module, part 1, tweaks.
        * m4/afunix.m4 (gl_SOCKET_AFUNIX): Update AC_REQUIRE invocation.
        Improve indentation. Improve AC_MSG_CHECKING messages.
        * m4/sockpfaf.m4 (gl_SOCKET_FAMILY_UNIX): New macro, extracted from
        gl_SOCKET_FAMILIES.

--- m4/afunix.m4.orig   Tue Mar  8 10:49:28 2011
+++ m4/afunix.m4        Tue Mar  8 10:49:27 2011
@@ -1,4 +1,4 @@
-# afunix.m4 serial 1
+# afunix.m4 serial 2
 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,
@@ -7,90 +7,107 @@
 AC_DEFUN([gl_SOCKET_AFUNIX],
 [
   AC_REQUIRE([gl_HEADER_SYS_SOCKET])
-  AC_REQUIRE([gl_SOCKET_FAMILIES])
+  AC_REQUIRE([gl_SOCKET_FAMILY_UNIX])
 
-  AC_MSG_CHECKING([for UNIX domain sockets SCM_RIGHT])
+  AC_MSG_CHECKING([for UNIX domain sockets SCM_RIGHTS])
   AC_CACHE_VAL([gl_cv_socket_unix_scm_rights],
-  [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#ifdef HAVE_SYS_UN_H
-#include <sys/un.h>
-#endif
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
-#endif
-]],
-[[struct cmsghdr cmh;
-  cmh.cmsg_level = SOL_SOCKET;
-  cmh.cmsg_type = SCM_RIGHTS;
-  if (&cmh) return 0;]])],
-  gl_cv_socket_unix_scm_rights=yes, gl_cv_socket_unix_scm_rights=no)])
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <sys/types.h>
+            #ifdef HAVE_SYS_SOCKET_H
+            #include <sys/socket.h>
+            #endif
+            #ifdef HAVE_SYS_UN_H
+            #include <sys/un.h>
+            #endif
+            #ifdef HAVE_WINSOCK2_H
+            #include <winsock2.h>
+            #endif
+          ]],
+          [[struct cmsghdr cmh;
+            cmh.cmsg_level = SOL_SOCKET;
+            cmh.cmsg_type = SCM_RIGHTS;
+            if (&cmh) return 0;
+          ]])],
+       [gl_cv_socket_unix_scm_rights=yes],
+       [gl_cv_socket_unix_scm_rights=no])
+    ])
   AC_MSG_RESULT([$gl_cv_socket_unix_scm_rights])
   if test $gl_cv_socket_unix_scm_rights = yes; then
-    AC_DEFINE([HAVE_UNIXSOCKET_SCM_RIGHTS], [1], [Define to 1 if 
<sys/socket.h> defines SCM_RIGHTS.])
-  fi 
+    AC_DEFINE([HAVE_UNIXSOCKET_SCM_RIGHTS], [1],
+      [Define to 1 if <sys/socket.h> defines SCM_RIGHTS.])
+  fi
 
-  AC_MSG_CHECKING([for UNIX domain sockets SCM_RIGHT behave in BSD4.4 way])
+  AC_MSG_CHECKING([for UNIX domain sockets SCM_RIGHTS that behave in BSD4.4 
way])
   AC_CACHE_VAL([gl_cv_socket_unix_scm_rights_bsd44_way],
-  [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#ifdef HAVE_SYS_UN_H
-#include <sys/un.h>
-#endif
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
-#endif
-]],
-[[struct msghdr msg = {0};
-  struct cmsghdr *cmsg;
-  int myfds[1] = {0};
-  char buf[CMSG_SPACE(sizeof(myfds))];
-  int *fdptr;
-
-  msg.msg_control = buf;
-  msg.msg_controllen = sizeof buf;
-  cmsg = CMSG_FIRSTHDR(&msg);
-  cmsg->cmsg_level = SOL_SOCKET;
-  cmsg->cmsg_type = SCM_RIGHTS;
-  cmsg->cmsg_len = CMSG_LEN(sizeof(int));
-  /* fake Initialize the payload: */
-  (void) CMSG_DATA(cmsg);
-  /* Sum of the length of all control messages in the buffer: */
-  msg.msg_controllen = cmsg->cmsg_len;
-  return 0;
-]])],
-  gl_cv_socket_unix_scm_rights_bsd44_way=yes, 
gl_cv_socket_unix_scm_rights_bsd44_way=no)])
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <sys/types.h>
+            #ifdef HAVE_SYS_SOCKET_H
+            #include <sys/socket.h>
+            #endif
+            #ifdef HAVE_SYS_UN_H
+            #include <sys/un.h>
+            #endif
+            #ifdef HAVE_WINSOCK2_H
+            #include <winsock2.h>
+            #endif
+            ]],
+            [[struct msghdr msg = {0};
+              struct cmsghdr *cmsg;
+              int myfds[1] = {0};
+              char buf[CMSG_SPACE (sizeof (myfds))];
+              int *fdptr;
+
+              msg.msg_control = buf;
+              msg.msg_controllen = sizeof buf;
+              cmsg = CMSG_FIRSTHDR (&msg);
+              cmsg->cmsg_level = SOL_SOCKET;
+              cmsg->cmsg_type = SCM_RIGHTS;
+              cmsg->cmsg_len = CMSG_LEN (sizeof (int));
+              /* fake Initialize the payload: */
+              (void) CMSG_DATA (cmsg);
+              /* Sum of the length of all control messages in the buffer: */
+              msg.msg_controllen = cmsg->cmsg_len;
+              return 0;
+            ]])],
+       [gl_cv_socket_unix_scm_rights_bsd44_way=yes],
+       [gl_cv_socket_unix_scm_rights_bsd44_way=no])
+    ])
   AC_MSG_RESULT([$gl_cv_socket_unix_scm_rights_bsd44_way])
   if test $gl_cv_socket_unix_scm_rights_bsd44_way = yes; then
-    AC_DEFINE([HAVE_UNIXSOCKET_SCM_RIGHTS_BSD44_WAY], [1], [Define to 1 if fd 
could be send/received in the BSD4.4 way.])
+    AC_DEFINE([HAVE_UNIXSOCKET_SCM_RIGHTS_BSD44_WAY], [1],
+      [Define to 1 if fd can be sent/received in the BSD4.4 way.])
   fi
 
-  AC_MSG_CHECKING([for UNIX domain sockets SCM_RIGHT behave in BSD4.3 way])
+  AC_MSG_CHECKING([for UNIX domain sockets SCM_RIGHTS that behave in BSD4.3 
way])
   AC_CACHE_VAL([gl_cv_socket_unix_scm_rights_bsd43_way],
-  [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#ifdef HAVE_SYS_UN_H
-#include <sys/un.h>
-#endif
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
-#endif
-]],
-[[struct msghdr msg;
-  int fd = 0;
-  msg.msg_accrights = &fd;
-  msg.msg_accrightslen = sizeof(fd);
-  if (&msg) return 0;]])],
-  gl_cv_socket_unix_scm_rights_bsd43_way=yes, 
gl_cv_socket_unix_scm_rights_bsd43_way=no)])
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <sys/types.h>
+            #ifdef HAVE_SYS_SOCKET_H
+            #include <sys/socket.h>
+            #endif
+            #ifdef HAVE_SYS_UN_H
+            #include <sys/un.h>
+            #endif
+            #ifdef HAVE_WINSOCK2_H
+            #include <winsock2.h>
+            #endif
+            ]],
+            [[struct msghdr msg;
+              int fd = 0;
+              msg.msg_accrights = &fd;
+              msg.msg_accrightslen = sizeof (fd);
+              if (&msg) return 0;
+            ]])],
+       [gl_cv_socket_unix_scm_rights_bsd43_way=yes],
+       [gl_cv_socket_unix_scm_rights_bsd43_way=no])
+    ])
   AC_MSG_RESULT([$gl_cv_socket_unix_scm_rights_bsd43_way])
   if test $gl_cv_socket_unix_scm_rights_bsd43_way = yes; then
-    AC_DEFINE([HAVE_UNIXSOCKET_SCM_RIGHTS_BSD43_WAY], [1], [Define to 1 if fd 
could be send/received in the BSD4.3 way.])
+    AC_DEFINE([HAVE_UNIXSOCKET_SCM_RIGHTS_BSD43_WAY], [1],
+      [Define to 1 if fd can be sent/received in the BSD4.3 way.])
   fi
 ])
 
--- m4/sockpfaf.m4.orig Tue Mar  8 10:49:28 2011
+++ m4/sockpfaf.m4      Tue Mar  8 10:39:15 2011
@@ -58,8 +58,13 @@
   if test $gl_cv_socket_ipv6 = yes; then
     AC_DEFINE([HAVE_IPV6], [1], [Define to 1 if <sys/socket.h> defines 
AF_INET6.])
   fi
+])
 
+AC_DEFUN([gl_SOCKET_FAMILY_UNIX],
+[
+  AC_REQUIRE([gl_HEADER_SYS_SOCKET])
   AC_CHECK_HEADERS_ONCE([sys/un.h])
+
   AC_MSG_CHECKING([for UNIX domain sockets])
   AC_CACHE_VAL([gl_cv_socket_unix],
     [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>


-- 
In memoriam Amar Singh Chamkila 
<http://en.wikipedia.org/wiki/Amar_Singh_Chamkila>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]