From b23a8463848dff32b7247e648dd89d8283c82c02 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 24 Aug 2009 00:42:22 +0200 Subject: [PATCH] Tolerate declared but missing pipe2 syscall. --- ChangeLog | 11 +++++++++++ lib/pipe2.c | 11 +++++++++++ lib/unistd.in.h | 5 +++-- m4/pipe2.m4 | 3 +-- modules/pipe2 | 1 + 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 438cc9c553..3f8349d429 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2009-08-23 Bruno Haible + + 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. + 2009-08-23 Bruno Haible * lib/pipe2.c (pipe2): Move #ifs inside function. diff --git a/lib/pipe2.c b/lib/pipe2.c index d5833ddfcc..c18860de30 100644 --- a/lib/pipe2.c +++ b/lib/pipe2.c @@ -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. */ diff --git a/lib/unistd.in.h b/lib/unistd.in.h index 7dd98346c0..2f3be17400 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -562,9 +562,10 @@ extern int link (const char *path1, const char *path2); Return 0 upon success, or -1 with errno set upon failure. See also the Linux man page at . */ -# if !@HAVE_PIPE2@ -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) \ diff --git a/m4/pipe2.m4 b/m4/pipe2.m4 index d0aae439e0..54f6ec7565 100644 --- a/m4/pipe2.m4 +++ b/m4/pipe2.m4 @@ -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_DEFUN([gl_FUNC_PIPE2], AC_CHECK_FUNCS_ONCE([pipe2]) if test $ac_cv_func_pipe2 != yes; then HAVE_PIPE2=0 - AC_LIBOBJ([pipe2]) fi ]) diff --git a/modules/pipe2 b/modules/pipe2 index 9117e73adf..036d8730b6 100644 --- a/modules/pipe2 +++ b/modules/pipe2 @@ -15,6 +15,7 @@ gl_FUNC_PIPE2 gl_UNISTD_MODULE_INDICATOR([pipe2]) Makefile.am: +lib_SOURCES += pipe2.c Include: -- 2.30.2