diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2013-05-01 15:12:14 +0300 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2013-05-01 15:12:55 +0300 |
commit | 09cf6a9ff71b19f20cd710abc65ba8552d593f7a (patch) | |
tree | 9499a06abdab4e569757acd3da13ffa4149bdbb9 /gl | |
parent | e4c503763c743d70bf18fa911120da1d3ab86538 (diff) | |
download | gnutls-09cf6a9ff71b19f20cd710abc65ba8552d593f7a.tar.gz |
updated gnulib
Diffstat (limited to 'gl')
-rw-r--r-- | gl/Makefile.am | 17 | ||||
-rw-r--r-- | gl/m4/extern-inline.m4 | 14 | ||||
-rw-r--r-- | gl/m4/getdtablesize.m4 | 17 | ||||
-rw-r--r-- | gl/m4/gnulib-comp.m4 | 11 | ||||
-rw-r--r-- | gl/tests/Makefile.am | 17 | ||||
-rw-r--r-- | gl/tests/getdtablesize.c | 86 | ||||
-rw-r--r-- | gl/tests/glthread/threadlib.c | 73 | ||||
-rw-r--r-- | gl/tests/test-dup2.c | 7 | ||||
-rwxr-xr-x | gl/tests/test-getdtablesize | bin | 0 -> 10661 bytes | |||
-rw-r--r-- | gl/tests/test-getdtablesize.c | 34 |
10 files changed, 264 insertions, 12 deletions
diff --git a/gl/Makefile.am b/gl/Makefile.am index 8c46c18f3d..79b79b3ac2 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am @@ -565,15 +565,16 @@ EXTRA_libgnu_la_SOURCES += getsubopt.c ## begin gnulib module gettext -# This is for those projects which use "gettextize --intl" to put a source-code -# copy of libintl into their package. In such projects, every Makefile.am needs +# If your project uses "gettextize --intl" to put a source-code +# copy of libintl into the package, every Makefile.am needs # -I$(top_builddir)/intl, so that <libintl.h> can be found in this directory. -# For the Makefile.ams in other directories it is the maintainer's -# responsibility; for the one from gnulib we do it here. -# This option has no effect when the user disables NLS (because then the intl -# directory contains no libintl.h file) or when the project does not use -# "gettextize --intl". -AM_CPPFLAGS += -I$(top_builddir)/intl +# Here's one way to do this: +#AM_CPPFLAGS += -I$(top_builddir)/intl +# This option has no effect when the user disables NLS (because then +# the intl directory contains no libintl.h file). This option is not +# enabled by default because the intl directory might not exist if +# your project does not use "gettext --intl", and some compilers +# complain about -I options applied to nonexistent directories. EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath diff --git a/gl/m4/extern-inline.m4 b/gl/m4/extern-inline.m4 index 0152f29326..94b46dde07 100644 --- a/gl/m4/extern-inline.m4 +++ b/gl/m4/extern-inline.m4 @@ -21,13 +21,21 @@ AC_DEFUN([gl_EXTERN_INLINE], Suppress extern inline with HP-UX cc, as it appears to be broken; see <http://lists.gnu.org/archive/html/bug-texinfo/2013-02/msg00030.html>. - Suppress the use of extern inline on Apple's platforms, - as Libc-825.25 (2012-09-19) is incompatible with it; see + Suppress extern inline with Sun C in standards-conformance mode, as it + mishandles inline functions that call each other. E.g., for 'inline void f + (void) { } inline void g (void) { f (); }', c99 incorrectly complains + 'reference to static identifier "f" in extern inline function'. + This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16. + + Suppress the use of extern inline on Apple's platforms, as Libc at least + through Libc-825.26 (2013-04-09) is incompatible with it; see, e.g., <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>. Perhaps Apple will fix this some day. */ #if ((__GNUC__ \ ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \ - : 199901L <= __STDC_VERSION__ && !defined __HP_cc) \ + : (199901L <= __STDC_VERSION__ \ + && !defined __HP_cc \ + && !(defined __SUNPRO_C && __STDC__))) \ && !defined __APPLE__) # define _GL_INLINE inline # define _GL_EXTERN_INLINE extern inline diff --git a/gl/m4/getdtablesize.m4 b/gl/m4/getdtablesize.m4 new file mode 100644 index 0000000000..8f04b3b8c2 --- /dev/null +++ b/gl/m4/getdtablesize.m4 @@ -0,0 +1,17 @@ +# getdtablesize.m4 serial 4 +dnl Copyright (C) 2008-2013 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 + fi +]) + +# Prerequisites of lib/getdtablesize.c. +AC_DEFUN([gl_PREREQ_GETDTABLESIZE], [:]) diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index 4d6a3a42d4..24ed4b30d1 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 @@ -125,6 +125,8 @@ AC_DEFUN([gl_EARLY], # Code from module getcwd-lgpl-tests: # Code from module getdelim: # Code from module getdelim-tests: + # Code from module getdtablesize: + # Code from module getdtablesize-tests: # Code from module getline: # Code from module getline-tests: # Code from module getopt-gnu: @@ -958,6 +960,12 @@ changequote([, ])dnl AC_LIBOBJ([getcwd-lgpl]) fi gl_UNISTD_MODULE_INDICATOR([getcwd]) + gl_FUNC_GETDTABLESIZE + if test $HAVE_GETDTABLESIZE = 0; then + AC_LIBOBJ([getdtablesize]) + gl_PREREQ_GETDTABLESIZE + fi + gl_UNISTD_MODULE_INDICATOR([getdtablesize]) gl_FUNC_GETPAGESIZE if test $REPLACE_GETPAGESIZE = 1; then AC_LIBOBJ([getpagesize]) @@ -1422,6 +1430,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/getaddrinfo.m4 m4/getcwd.m4 m4/getdelim.m4 + m4/getdtablesize.m4 m4/getline.m4 m4/getopt.m4 m4/getpagesize.m4 @@ -1638,6 +1647,7 @@ AC_DEFUN([gl_FILE_LIST], [ tests/test-getaddrinfo.c tests/test-getcwd-lgpl.c tests/test-getdelim.c + tests/test-getdtablesize.c tests/test-getline.c tests/test-getopt.c tests/test-getopt.h @@ -1759,6 +1769,7 @@ AC_DEFUN([gl_FILE_LIST], [ tests=lib/fdopen.c tests=lib/ftruncate.c tests=lib/getcwd-lgpl.c + tests=lib/getdtablesize.c tests=lib/getpagesize.c tests=lib/glthread/lock.c tests=lib/glthread/lock.h diff --git a/gl/tests/Makefile.am b/gl/tests/Makefile.am index 12e4a27a3a..0b3462cbb8 100644 --- a/gl/tests/Makefile.am +++ b/gl/tests/Makefile.am @@ -432,6 +432,23 @@ EXTRA_DIST += test-getdelim.c signature.h macros.h ## end gnulib module getdelim-tests +## begin gnulib module getdtablesize + + +EXTRA_DIST += getdtablesize.c + +EXTRA_libtests_a_SOURCES += getdtablesize.c + +## end gnulib module getdtablesize + +## begin gnulib module getdtablesize-tests + +TESTS += test-getdtablesize +check_PROGRAMS += test-getdtablesize +EXTRA_DIST += test-getdtablesize.c signature.h macros.h + +## end gnulib module getdtablesize-tests + ## begin gnulib module getline-tests TESTS += test-getline diff --git a/gl/tests/getdtablesize.c b/gl/tests/getdtablesize.c new file mode 100644 index 0000000000..9947405af6 --- /dev/null +++ b/gl/tests/getdtablesize.c @@ -0,0 +1,86 @@ +/* getdtablesize() function for platforms that don't have it. + Copyright (C) 2008-2013 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> + +#include "msvc-inval.h" + +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +static int +_setmaxstdio_nothrow (int newmax) +{ + int result; + + TRY_MSVC_INVAL + { + result = _setmaxstdio (newmax); + } + CATCH_MSVC_INVAL + { + result = -1; + } + DONE_MSVC_INVAL; + + return result; +} +# define _setmaxstdio _setmaxstdio_nothrow +#endif + +/* Cache for the previous getdtablesize () result. */ +static int dtablesize; + +int +getdtablesize (void) +{ + if (dtablesize == 0) + { + /* We are looking for the number N such that the valid file descriptors + are 0..N-1. It can be obtained through a loop as follows: + { + int fd; + for (fd = 3; fd < 65536; fd++) + if (dup2 (0, fd) == -1) + break; + return fd; + } + On Windows XP, the result is 2048. + The drawback of this loop is that it allocates memory for a libc + internal array that is never freed. + + The number N can also be obtained as the upper bound for + _getmaxstdio (). _getmaxstdio () returns the maximum number of open + FILE objects. The sanity check in _setmaxstdio reveals the maximum + number of file descriptors. This too allocates memory, but it is + freed when we call _setmaxstdio with the original value. */ + int orig_max_stdio = _getmaxstdio (); + unsigned int bound; + for (bound = 0x10000; _setmaxstdio (bound) < 0; bound = bound / 2) + ; + _setmaxstdio (orig_max_stdio); + dtablesize = bound; + } + return dtablesize; +} + +#endif diff --git a/gl/tests/glthread/threadlib.c b/gl/tests/glthread/threadlib.c new file mode 100644 index 0000000000..b447657302 --- /dev/null +++ b/gl/tests/glthread/threadlib.c @@ -0,0 +1,73 @@ +/* Multithreading primitives. + Copyright (C) 2005-2013 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, 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/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2005. */ + +#include <config.h> + +/* ========================================================================= */ + +#if USE_POSIX_THREADS + +/* Use the POSIX threads library. */ + +# include <pthread.h> +# include <stdlib.h> + +# if PTHREAD_IN_USE_DETECTION_HARD + +/* The function to be executed by a dummy thread. */ +static void * +dummy_thread_func (void *arg) +{ + return arg; +} + +int +glthread_in_use (void) +{ + static int tested; + static int result; /* 1: linked with -lpthread, 0: only with libc */ + + if (!tested) + { + pthread_t thread; + + if (pthread_create (&thread, NULL, dummy_thread_func, NULL) != 0) + /* Thread creation failed. */ + result = 0; + else + { + /* Thread creation works. */ + void *retval; + if (pthread_join (thread, &retval) != 0) + abort (); + result = 1; + } + tested = 1; + } + return result; +} + +# endif + +#endif + +/* ========================================================================= */ + +/* This declaration is solely to ensure that after preprocessing + this file is never empty. */ +typedef int dummy; diff --git a/gl/tests/test-dup2.c b/gl/tests/test-dup2.c index 9600c850b1..ecb2692d2a 100644 --- a/gl/tests/test-dup2.c +++ b/gl/tests/test-dup2.c @@ -26,6 +26,10 @@ SIGNATURE_CHECK (dup2, int, (int, int)); #include <errno.h> #include <fcntl.h> +#if HAVE_SYS_RESOURCE_H +# include <sys/resource.h> +#endif + #include "binary-io.h" #if GNULIB_TEST_CLOEXEC @@ -103,6 +107,7 @@ main (void) { const char *file = "test-dup2.tmp"; char buffer[1]; + int bad_fd = getdtablesize (); int fd = open (file, O_CREAT | O_TRUNC | O_RDWR, 0600); /* Assume std descriptors were provided by invoker. */ @@ -146,7 +151,7 @@ main (void) ASSERT (dup2 (fd, -2) == -1); ASSERT (errno == EBADF); errno = 0; - ASSERT (dup2 (fd, 10000000) == -1); + ASSERT (dup2 (fd, bad_fd) == -1); ASSERT (errno == EBADF); /* Using dup2 can skip fds. */ diff --git a/gl/tests/test-getdtablesize b/gl/tests/test-getdtablesize Binary files differnew file mode 100755 index 0000000000..3dcb228646 --- /dev/null +++ b/gl/tests/test-getdtablesize diff --git a/gl/tests/test-getdtablesize.c b/gl/tests/test-getdtablesize.c new file mode 100644 index 0000000000..7046481ba3 --- /dev/null +++ b/gl/tests/test-getdtablesize.c @@ -0,0 +1,34 @@ +/* Test of getdtablesize() function. + Copyright (C) 2008-2013 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/>. */ + +/* Written by Bruno Haible <bruno@clisp.org>, 2008. */ + +#include <config.h> + +#include <unistd.h> + +#include "signature.h" +SIGNATURE_CHECK (getdtablesize, int, (void)); + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + ASSERT (getdtablesize () >= 3); + + return 0; +} |