bug-gnulib
[Top][All Lists]
Advanced

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

Re: proposal: module 'accept4'


From: Bruno Haible
Subject: Re: proposal: module 'accept4'
Date: Mon, 24 Aug 2009 00:58:24 +0200
User-agent: KMail/1.9.9

Paolo Bonzini wrote:
> For binary GNU/Linux distributions, the package will usually 
> be built on the latest kernel, but the user may have chosen not to 
> install a new-enough kernel.

I would see this as a bug in the Linux distro. They should use the oldest
supported kernel, not the newest one, for running the configure scripts of
all packages.

But anyway, it's not so hard to implement this. Here for pipe2 and dup3.
Will do as well for accept4 once Simon gives his opinion.


2009-08-23  Bruno Haible  <address@hidden>

        Tolerate declared but missing pipe2 syscall.
        * lib/pipe2.c (pipe2): Invoke original pipe2 function first, if
        available.
        * lib/unistd.in.h (pipe2): If the function is already present,
        override it.
        * m4/pipe2.m4 (gl_FUNC_PIPE2): Remove AC_LIBOBJ invocation.
        * modules/pipe2 (Makefile.am): Compile pipe2.c always.
        Reported by Paolo Bonzini.

--- lib/pipe2.c.orig    2009-08-24 00:41:59.000000000 +0200
+++ lib/pipe2.c 2009-08-24 00:36:48.000000000 +0200
@@ -40,6 +40,17 @@
 int
 pipe2 (int fd[2], int flags)
 {
+# if HAVE_PIPE2
+#  undef pipe2
+  /* Try the system call first, if it exists.  (We may be running with a glibc
+     that has the function but with an older kernel that lacks it.)  */
+  {
+    int result = pipe2 (fd, flags);
+    if (!(result < 0 && errno == ENOSYS))
+      return result;
+  }
+# endif
+
 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
 /* Native Woe32 API.  */
 
--- lib/unistd.in.h.orig        2009-08-24 00:41:59.000000000 +0200
+++ lib/unistd.in.h     2009-08-24 00:36:13.000000000 +0200
@@ -562,9 +562,10 @@
    Return 0 upon success, or -1 with errno set upon failure.
    See also the Linux man page at
    <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>.  */
-# if address@hidden@
-extern int pipe2 (int fd[2], int flags);
+# if @HAVE_PIPE2@
+#  define pipe2 rpl_pipe2
 # endif
+extern int pipe2 (int fd[2], int flags);
 #elif defined GNULIB_POSIXCHECK
 # undef pipe2
 # define pipe2(f,o) \
--- m4/pipe2.m4.orig    2009-08-24 00:41:59.000000000 +0200
+++ m4/pipe2.m4 2009-08-24 00:36:13.000000000 +0200
@@ -1,4 +1,4 @@
-# pipe2.m4 serial 1
+# pipe2.m4 serial 2
 dnl Copyright (C) 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -14,6 +14,5 @@
   AC_CHECK_FUNCS_ONCE([pipe2])
   if test $ac_cv_func_pipe2 != yes; then
     HAVE_PIPE2=0
-    AC_LIBOBJ([pipe2])
   fi
 ])
--- modules/pipe2.orig  2009-08-24 00:41:59.000000000 +0200
+++ modules/pipe2       2009-08-24 00:36:13.000000000 +0200
@@ -15,6 +15,7 @@
 gl_UNISTD_MODULE_INDICATOR([pipe2])
 
 Makefile.am:
+lib_SOURCES += pipe2.c
 
 Include:
 <unistd.h>


2009-08-23  Bruno Haible  <address@hidden>

        Tolerate declared but missing dup3 syscall.
        * lib/dup3.c (dup3): Invoke original dup3 function first, if available.
        * lib/unistd.in.h (dup3): If the function is already present,
        override it.
        * m4/dup3.m4 (gl_FUNC_DUP3): Remove AC_LIBOBJ invocation.
        * modules/dup3 (Makefile.am): Compile dup3.c always.
        Reported by Paolo Bonzini.

--- lib/dup3.c.orig     2009-08-24 00:55:47.000000000 +0200
+++ lib/dup3.c  2009-08-24 00:49:30.000000000 +0200
@@ -48,6 +48,17 @@
 int
 dup3 (int oldfd, int newfd, int flags)
 {
+#if HAVE_DUP3
+# undef dup3
+  /* Try the system call first, if it exists.  (We may be running with a glibc
+     that has the function but with an older kernel that lacks it.)  */
+  {
+    int result = dup3 (oldfd, newfd, flags);
+    if (!(result < 0 && errno == ENOSYS))
+      return result;
+  }
+#endif
+
   if (oldfd < 0 || newfd < 0 || newfd >= getdtablesize ())
     {
       errno = EBADF;
--- lib/unistd.in.h.orig        2009-08-24 00:55:47.000000000 +0200
+++ lib/unistd.in.h     2009-08-24 00:53:53.000000000 +0200
@@ -179,7 +179,6 @@
 
 
 #if @GNULIB_DUP3@
-# if address@hidden@
 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
    specified flags.
    The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
@@ -188,8 +187,10 @@
    Return newfd if successful, otherwise -1 and errno set.
    See the Linux man page at
    <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>.  */
-extern int dup3 (int oldfd, int newfd, int flags);
+# if @HAVE_DUP3@
+#  define dup3 rpl_dup3
 # endif
+extern int dup3 (int oldfd, int newfd, int flags);
 #elif defined GNULIB_POSIXCHECK
 # undef dup3
 # define dup3(o,n,f) \
--- m4/dup3.m4.orig     2009-08-24 00:55:47.000000000 +0200
+++ m4/dup3.m4  2009-08-24 00:50:03.000000000 +0200
@@ -1,4 +1,4 @@
-# dup3.m4 serial 1
+# dup3.m4 serial 2
 dnl Copyright (C) 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -14,6 +14,5 @@
   AC_CHECK_FUNCS_ONCE([dup3])
   if test $ac_cv_func_dup3 != yes; then
     HAVE_DUP3=0
-    AC_LIBOBJ([dup3])
   fi
 ])
--- modules/dup3.orig   2009-08-24 00:55:47.000000000 +0200
+++ modules/dup3        2009-08-24 00:49:51.000000000 +0200
@@ -16,6 +16,7 @@
 gl_UNISTD_MODULE_INDICATOR([dup3])
 
 Makefile.am:
+lib_SOURCES += dup3.c
 
 Include:
 <unistd.h>




reply via email to

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