changeset 30273:c9ca8a5f6680

New module 'getdtablesize'.
author Bruno Haible <bruno@clisp.org>
date Sun, 05 Oct 2008 16:51:07 +0200
parents 31f89a34eeef
children c154fabf8cad
files ChangeLog doc/glibc-functions/getdtablesize.texi lib/getdtablesize.c lib/unistd.in.h m4/getdtablesize.m4 m4/unistd_h.m4 modules/getdtablesize modules/unistd
diffstat 8 files changed, 110 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Oct 05 16:37:45 2008 +0200
+++ b/ChangeLog	Sun Oct 05 16:51:07 2008 +0200
@@ -1,3 +1,16 @@
+2008-10-05  Bruno Haible  <bruno@clisp.org>
+
+	New module 'getdtablesize'.
+	* lib/unistd.in.h (getdtablesize): New declaration.
+	* lib/getdtablesize.c: New file.
+	* m4/getdtablesize.m4: New file.
+	* modules/getdtablesize: New file.
+	* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize
+	GNULIB_GETDTABLESIZE, HAVE_GETDTABLESIZE.
+	* modules/unistd (Makefile.am): Substitute GNULIB_GETDTABLESIZE,
+	HAVE_GETDTABLESIZE.
+	* doc/glibc-functions/getdtablesize.texi: Mention the new module.
+
 2008-10-05  Bruno Haible  <bruno@clisp.org>
 
 	* modules/sched (Makefile.am): Fix typo.
--- a/doc/glibc-functions/getdtablesize.texi	Sun Oct 05 16:37:45 2008 +0200
+++ b/doc/glibc-functions/getdtablesize.texi	Sun Oct 05 16:51:07 2008 +0200
@@ -2,15 +2,15 @@
 @subsection @code{getdtablesize}
 @findex getdtablesize
 
-Gnulib module: ---
+Gnulib module: getdtablesize
 
 Portability problems fixed by Gnulib:
 @itemize
-@end itemize
-
-Portability problems not fixed by Gnulib:
-@itemize
 @item
 This function is missing on some platforms:
 mingw.
 @end itemize
+
+Portability problems not fixed by Gnulib:
+@itemize
+@end itemize
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/getdtablesize.c	Sun Oct 05 16:51:07 2008 +0200
@@ -0,0 +1,33 @@
+/* getdtablesize() function for platforms that don't have it.
+   Copyright (C) 2008 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2008.
+
+   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>
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+
+#include <stdio.h>
+
+int
+getdtablesize (void)
+{
+  return _getmaxstdio ();
+}
+
+#endif
--- a/lib/unistd.in.h	Sun Oct 05 16:37:45 2008 +0200
+++ b/lib/unistd.in.h	Sun Oct 05 16:51:07 2008 +0200
@@ -201,6 +201,20 @@
 #endif
 
 
+#if @GNULIB_GETDTABLESIZE@
+# if !@HAVE_GETDTABLESIZE@
+/* Return the maximum number of file descriptors in the current process.  */
+extern int getdtablesize (void);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef getdtablesize
+# define getdtablesize() \
+    (GL_LINK_WARNING ("getdtablesize is unportable - " \
+                      "use gnulib module getdtablesize for portability"), \
+     getdtablesize ())
+#endif
+
+
 #if @GNULIB_GETLOGIN_R@
 /* Copies the user's login name to NAME.
    The array pointed to by NAME has room for SIZE bytes.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m4/getdtablesize.m4	Sun Oct 05 16:51:07 2008 +0200
@@ -0,0 +1,15 @@
+# getdtablesize.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_GETDTABLESIZE],
+[
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([getdtablesize])
+  if test $ac_cv_func_getdtablesize != yes; then
+    HAVE_GETDTABLESIZE=0
+    AC_LIBOBJ([getdtablesize])
+  fi
+])
--- a/m4/unistd_h.m4	Sun Oct 05 16:37:45 2008 +0200
+++ b/m4/unistd_h.m4	Sun Oct 05 16:51:07 2008 +0200
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 12
+# unistd_h.m4 serial 13
 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,
@@ -39,6 +39,7 @@
   GNULIB_FSYNC=0;            AC_SUBST([GNULIB_FSYNC])
   GNULIB_FTRUNCATE=0;        AC_SUBST([GNULIB_FTRUNCATE])
   GNULIB_GETCWD=0;           AC_SUBST([GNULIB_GETCWD])
+  GNULIB_GETDTABLESIZE=0;    AC_SUBST([GNULIB_GETDTABLESIZE])
   GNULIB_GETLOGIN_R=0;       AC_SUBST([GNULIB_GETLOGIN_R])
   GNULIB_GETPAGESIZE=0;      AC_SUBST([GNULIB_GETPAGESIZE])
   GNULIB_LCHOWN=0;           AC_SUBST([GNULIB_LCHOWN])
@@ -51,6 +52,7 @@
   HAVE_DUP2=1;            AC_SUBST([HAVE_DUP2])
   HAVE_FSYNC=1;           AC_SUBST([HAVE_FSYNC])
   HAVE_FTRUNCATE=1;       AC_SUBST([HAVE_FTRUNCATE])
+  HAVE_GETDTABLESIZE=1;   AC_SUBST([HAVE_GETDTABLESIZE])
   HAVE_GETPAGESIZE=1;     AC_SUBST([HAVE_GETPAGESIZE])
   HAVE_READLINK=1;        AC_SUBST([HAVE_READLINK])
   HAVE_SLEEP=1;           AC_SUBST([HAVE_SLEEP])
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/getdtablesize	Sun Oct 05 16:51:07 2008 +0200
@@ -0,0 +1,25 @@
+Description:
+getdtablesize() function: return maximum number of file descriptors.
+
+Files:
+lib/getdtablesize.c
+m4/getdtablesize.m4
+
+Depends-on:
+unistd
+
+configure.ac:
+gl_FUNC_GETDTABLESIZE
+gl_UNISTD_MODULE_INDICATOR([getdtablesize])
+
+Makefile.am:
+
+Include:
+<unistd.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+
--- a/modules/unistd	Sun Oct 05 16:37:45 2008 +0200
+++ b/modules/unistd	Sun Oct 05 16:51:07 2008 +0200
@@ -31,6 +31,7 @@
 	      -e 's|@''GNULIB_FSYNC''@|$(GNULIB_FSYNC)|g' \
 	      -e 's|@''GNULIB_FTRUNCATE''@|$(GNULIB_FTRUNCATE)|g' \
 	      -e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \
+	      -e 's|@''GNULIB_GETDTABLESIZE''@|$(GNULIB_GETDTABLESIZE)|g' \
 	      -e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \
 	      -e 's|@''GNULIB_GETPAGESIZE''@|$(GNULIB_GETPAGESIZE)|g' \
 	      -e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \
@@ -42,6 +43,7 @@
 	      -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \
 	      -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \
 	      -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \
+	      -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \
 	      -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
 	      -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
 	      -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \