[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] use gnulib modules close (new) and open to hook into open/cl
From: |
Bruno Haible |
Subject: |
Re: [PATCH] use gnulib modules close (new) and open to hook into open/close |
Date: |
Fri, 10 Oct 2008 00:06:23 +0200 |
User-agent: |
KMail/1.5.4 |
Part 4 committed like this:
2008-10-09 Paolo Bonzini <address@hidden>
Bruno Haible <address@hidden>
New module 'close'.
* modules/close: New file.
* lib/unistd.in.h (close): Move declaration out of the
FCHDIR_REPLACEMENT scope.
(_gl_unregister_fd): New declaration.
* lib/close.c: New file.
* lib/fchdir.c (rpl_close): Remove function.
* m4/close.m4: New file.
* m4/fchdir.m4 (gl_FUNC_FCHDIR): When replacing fchdir, also replace
close.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize GNULIB_CLOSE and
REPLACE_CLOSE.
* modules/unistd (Makefile.am): Substitute GNULIB_CLOSE and
REPLACE_CLOSE.
* modules/fchdir (Depends-on): Add close.
========================== modules/close ==================================
Description:
close() function: close a file or socket.
Files:
lib/close.c
m4/close.m4
Depends-on:
unistd
configure.ac:
gl_FUNC_CLOSE
gl_UNISTD_MODULE_INDICATOR([close])
Makefile.am:
Include:
<unistd.h>
License:
LGPLv2+
Maintainer:
Paolo Bonzini, Simon Josefsson, Bruno Haible
========================== lib/close.c ====================================
/* close replacement.
Copyright (C) 2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <unistd.h>
/* Override close() to call into other gnulib modules. */
int
rpl_close (int fd)
#undef close
{
int retval = close (fd);
#ifdef FCHDIR_REPLACEMENT
if (retval >= 0)
_gl_unregister_fd (fd);
#endif
return retval;
}
========================== m4/close.m4 ====================================
# close.m4 serial 1
dnl Copyright (C) 2008 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_CLOSE],
[
:
])
AC_DEFUN([gl_REPLACE_CLOSE],
[
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
if test $REPLACE_CLOSE != 1; then
AC_LIBOBJ([close])
fi
REPLACE_CLOSE=1
])
===========================================================================
--- lib/unistd.in.h.orig 2008-10-09 23:57:57.000000000 +0200
+++ lib/unistd.in.h 2008-10-09 23:54:10.000000000 +0200
@@ -75,6 +75,16 @@
#endif
+#if @GNULIB_CLOSE@
+# if @REPLACE_CLOSE@
+/* Automatically included by modules that need a replacement for close. */
+# undef close
+# define close rpl_close
+extern int close (int);
+# endif
+#endif
+
+
#if @GNULIB_DUP2@
# if address@hidden@
/* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
@@ -123,8 +133,6 @@
<http://www.opengroup.org/susv3xsh/fchdir.html>. */
extern int fchdir (int /*fd*/);
-# define close rpl_close
-extern int close (int);
# define dup rpl_dup
extern int dup (int);
# define dup2 rpl_dup2
@@ -379,6 +387,12 @@
#endif
+#ifdef FCHDIR_REPLACEMENT
+/* gnulib internal function. */
+extern void _gl_unregister_fd (int fd);
+#endif
+
+
#ifdef __cplusplus
}
#endif
--- lib/fchdir.c.orig 2008-10-09 23:57:57.000000000 +0200
+++ lib/fchdir.c 2008-10-09 23:52:18.000000000 +0200
@@ -105,19 +105,6 @@
}
}
-/* Override close(), to keep track of the open file descriptors. */
-
-int
-rpl_close (int fd)
-#undef close
-{
- int retval = close (fd);
-
- if (retval >= 0)
- _gl_unregister_fd (fd);
- return retval;
-}
-
/* Override opendir() and closedir(), to keep track of the open file
descriptors. Needed because there is a function dirfd(). */
--- m4/fchdir.m4.orig 2008-10-09 23:57:57.000000000 +0200
+++ m4/fchdir.m4 2008-10-09 23:54:38.000000000 +0200
@@ -15,6 +15,7 @@
AC_DEFINE([FCHDIR_REPLACEMENT], 1,
[Define if gnulib's fchdir() replacement is used.])
gl_REPLACE_OPEN
+ gl_REPLACE_CLOSE
gl_CHECK_NEXT_HEADERS([dirent.h])
DIRENT_H='dirent.h'
else
--- m4/unistd_h.m4.orig 2008-10-09 23:57:57.000000000 +0200
+++ m4/unistd_h.m4 2008-10-09 23:55:31.000000000 +0200
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 13
+# unistd_h.m4 serial 14
dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -33,6 +33,7 @@
AC_DEFUN([gl_UNISTD_H_DEFAULTS],
[
GNULIB_CHOWN=0; AC_SUBST([GNULIB_CHOWN])
+ GNULIB_CLOSE=0; AC_SUBST([GNULIB_CLOSE])
GNULIB_DUP2=0; AC_SUBST([GNULIB_DUP2])
GNULIB_ENVIRON=0; AC_SUBST([GNULIB_ENVIRON])
GNULIB_FCHDIR=0; AC_SUBST([GNULIB_FCHDIR])
@@ -61,6 +62,7 @@
HAVE_OS_H=0; AC_SUBST([HAVE_OS_H])
HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H])
REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN])
+ REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE])
REPLACE_FCHDIR=0; AC_SUBST([REPLACE_FCHDIR])
REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD])
REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE])
--- modules/unistd.orig 2008-10-09 23:57:57.000000000 +0200
+++ modules/unistd 2008-10-09 23:56:37.000000000 +0200
@@ -25,6 +25,7 @@
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \
-e 's|@''GNULIB_CHOWN''@|$(GNULIB_CHOWN)|g' \
+ -e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \
-e 's|@''GNULIB_DUP2''@|$(GNULIB_DUP2)|g' \
-e 's|@''GNULIB_ENVIRON''@|$(GNULIB_ENVIRON)|g' \
-e 's|@''GNULIB_FCHDIR''@|$(GNULIB_FCHDIR)|g' \
@@ -52,6 +53,7 @@
-e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \
-e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \
-e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \
+ -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \
-e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
-e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
-e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
--- modules/fchdir.orig 2008-10-09 23:57:57.000000000 +0200
+++ modules/fchdir 2008-10-09 23:56:03.000000000 +0200
@@ -8,6 +8,7 @@
Depends-on:
canonicalize-lgpl
+close
dirfd
dup2
fcntl
- [PATCH] use gnulib modules close (new) and open to hook into open/close, Paolo Bonzini, 2008/10/07
- Re: [PATCH] use gnulib modules close (new) and open to hook into open/close, Simon Josefsson, 2008/10/08
- Re: [PATCH] use gnulib modules close (new) and open to hook into open/close, Bruno Haible, 2008/10/08
- Re: [PATCH] use gnulib modules close (new) and open to hook into open/close, Simon Josefsson, 2008/10/09
- Re: [PATCH] use gnulib modules close (new) and open to hook into open/close, Paolo Bonzini, 2008/10/09
- Re: [PATCH] use gnulib modules close (new) and open to hook into open/close, Bruno Haible, 2008/10/09
- Re: [PATCH] use gnulib modules close (new) and open to hook into open/close, Bruno Haible, 2008/10/09
- Re: [PATCH] use gnulib modules close (new) and open to hook into open/close, Bruno Haible, 2008/10/09
- Re: [PATCH] use gnulib modules close (new) and open to hook into open/close,
Bruno Haible <=
- Re: [PATCH] use gnulib modules close (new) and open to hook into open/close, Bruno Haible, 2008/10/09
- Re: [PATCH] use gnulib modules close (new) and open to hook into open/close, Bruno Haible, 2008/10/09
- Re: [PATCH] use gnulib modules close (new) and open to hook into open/close, Bruno Haible, 2008/10/11
- Re: [PATCH] use gnulib modules close (new) and open to hook into open/close, Paolo Bonzini, 2008/10/11
- Re: [PATCH] use gnulib modules close (new) and open to hook into open/close, Bruno Haible, 2008/10/09