diff options
author | Simon Josefsson <simon@josefsson.org> | 2011-09-21 15:49:06 +0200 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2011-09-21 15:49:06 +0200 |
commit | 5fdaefe2cfd2e38a83fee58c6a2b852d5e124d69 (patch) | |
tree | aba3494f385bea407fd4b4f840b8b9cdfef711c2 /gl/tests | |
parent | 0f206a54a53abe0ca38216081d587cf98096fb26 (diff) | |
download | gnutls-5fdaefe2cfd2e38a83fee58c6a2b852d5e124d69.tar.gz |
Update gnulib files.
Diffstat (limited to 'gl/tests')
32 files changed, 1012 insertions, 56 deletions
diff --git a/gl/tests/Makefile.am b/gl/tests/Makefile.am index d385feb580..ba41456a89 100644 --- a/gl/tests/Makefile.am +++ b/gl/tests/Makefile.am @@ -198,6 +198,22 @@ EXTRA_DIST += test-fcntl-h.c ## end gnulib module fcntl-h-tests +## begin gnulib module fdopen-tests + +TESTS += test-fdopen +check_PROGRAMS += test-fdopen +EXTRA_DIST += test-fdopen.c signature.h macros.h + +## end gnulib module fdopen-tests + +## begin gnulib module fgetc-tests + +TESTS += test-fgetc +check_PROGRAMS += test-fgetc +EXTRA_DIST += test-fgetc.c signature.h macros.h + +## end gnulib module fgetc-tests + ## begin gnulib module float-tests TESTS += test-float @@ -211,7 +227,7 @@ EXTRA_DIST += test-float.c macros.h TESTS += test-frexp-nolibm check_PROGRAMS += test-frexp-nolibm test_frexp_nolibm_SOURCES = test-frexp.c -EXTRA_DIST += test-frexp.c minus-zero.h nan.h signature.h macros.h +EXTRA_DIST += test-frexp.c minus-zero.h infinity.h nan.h signature.h macros.h ## end gnulib module frexp-nolibm-tests @@ -220,7 +236,7 @@ EXTRA_DIST += test-frexp.c minus-zero.h nan.h signature.h macros.h TESTS += test-frexpl-nolibm check_PROGRAMS += test-frexpl-nolibm test_frexpl_nolibm_SOURCES = test-frexpl.c -EXTRA_DIST += test-frexpl.c minus-zero.h nan.h signature.h macros.h +EXTRA_DIST += test-frexpl.c minus-zero.h infinity.h nan.h signature.h macros.h ## end gnulib module frexpl-nolibm-tests @@ -234,9 +250,9 @@ EXTRA_DIST += test-fseek.c test-fseek.sh test-fseek2.sh signature.h macros.h ## begin gnulib module fseeko-tests -TESTS += test-fseeko.sh test-fseeko2.sh test-fseeko3.sh -check_PROGRAMS += test-fseeko test-fseeko3 -EXTRA_DIST += test-fseeko.c test-fseeko.sh test-fseeko2.sh test-fseeko3.c test-fseeko3.sh signature.h macros.h +TESTS += test-fseeko.sh test-fseeko2.sh test-fseeko3.sh test-fseeko4.sh +check_PROGRAMS += test-fseeko test-fseeko3 test-fseeko4 +EXTRA_DIST += test-fseeko.c test-fseeko.sh test-fseeko2.sh test-fseeko3.c test-fseeko3.sh test-fseeko4.c test-fseeko4.sh signature.h macros.h ## end gnulib module fseeko-tests @@ -249,6 +265,14 @@ EXTRA_DIST += test-fseterr.c ## end gnulib module fseterr-tests +## begin gnulib module fstat-tests + +TESTS += test-fstat +check_PROGRAMS += test-fstat +EXTRA_DIST += test-fstat.c signature.h macros.h + +## end gnulib module fstat-tests + ## begin gnulib module ftell-tests TESTS += test-ftell.sh test-ftell2.sh test-ftell3 @@ -260,10 +284,10 @@ EXTRA_DIST += test-ftell.c test-ftell.sh test-ftell2.sh test-ftell3.c signature. ## begin gnulib module ftello-tests -TESTS += test-ftello.sh test-ftello2.sh test-ftello3 -check_PROGRAMS += test-ftello test-ftello3 +TESTS += test-ftello.sh test-ftello2.sh test-ftello3 test-ftello4.sh +check_PROGRAMS += test-ftello test-ftello3 test-ftello4 MOSTLYCLEANFILES += t-ftello3.tmp -EXTRA_DIST += test-ftello.c test-ftello.sh test-ftello2.sh test-ftello3.c signature.h macros.h +EXTRA_DIST += test-ftello.c test-ftello.sh test-ftello2.sh test-ftello3.c test-ftello4.c test-ftello4.sh signature.h macros.h ## end gnulib module ftello-tests @@ -415,7 +439,7 @@ EXTRA_DIST += test-inttypes.c TESTS += test-isnand-nolibm check_PROGRAMS += test-isnand-nolibm -EXTRA_DIST += test-isnand-nolibm.c test-isnand.h minus-zero.h nan.h macros.h +EXTRA_DIST += test-isnand-nolibm.c test-isnand.h minus-zero.h infinity.h nan.h macros.h ## end gnulib module isnand-nolibm-tests @@ -424,7 +448,7 @@ EXTRA_DIST += test-isnand-nolibm.c test-isnand.h minus-zero.h nan.h macros.h TESTS += test-isnanf-nolibm check_PROGRAMS += test-isnanf-nolibm -EXTRA_DIST += test-isnanf-nolibm.c test-isnanf.h minus-zero.h nan.h macros.h +EXTRA_DIST += test-isnanf-nolibm.c test-isnanf.h minus-zero.h infinity.h nan.h macros.h ## end gnulib module isnanf-nolibm-tests @@ -433,7 +457,7 @@ EXTRA_DIST += test-isnanf-nolibm.c test-isnanf.h minus-zero.h nan.h macros.h TESTS += test-isnanl-nolibm check_PROGRAMS += test-isnanl-nolibm -EXTRA_DIST += test-isnanl-nolibm.c test-isnanl.h minus-zero.h nan.h macros.h +EXTRA_DIST += test-isnanl-nolibm.c test-isnanl.h minus-zero.h infinity.h nan.h macros.h ## end gnulib module isnanl-nolibm-tests @@ -495,6 +519,15 @@ EXTRA_DIST += test-memchr.c zerosize-ptr.h signature.h macros.h ## end gnulib module memchr-tests +## begin gnulib module msvc-inval + + +EXTRA_DIST += msvc-inval.c msvc-inval.h + +EXTRA_libtests_a_SOURCES += msvc-inval.c + +## end gnulib module msvc-inval + ## begin gnulib module netdb-tests TESTS += test-netdb @@ -528,6 +561,21 @@ EXTRA_DIST += test-open.h test-open.c signature.h macros.h ## end gnulib module open-tests +## begin gnulib module pathmax + + +EXTRA_DIST += pathmax.h + +## end gnulib module pathmax + +## begin gnulib module pathmax-tests + +TESTS += test-pathmax +check_PROGRAMS += test-pathmax +EXTRA_DIST += test-pathmax.c + +## end gnulib module pathmax-tests + ## begin gnulib module printf-frexp-tests TESTS += test-printf-frexp @@ -598,7 +646,7 @@ EXTRA_DIST += test-setenv.c signature.h macros.h TESTS += test-signbit check_PROGRAMS += test-signbit -EXTRA_DIST += test-signbit.c minus-zero.h macros.h +EXTRA_DIST += test-signbit.c minus-zero.h infinity.h macros.h ## end gnulib module signbit-tests @@ -855,6 +903,14 @@ EXTRA_DIST += test-sys_time.c ## end gnulib module sys_time-tests +## begin gnulib module sys_types-tests + +TESTS += test-sys_types +check_PROGRAMS += test-sys_types +EXTRA_DIST += test-sys_types.c + +## end gnulib module sys_types-tests + ## begin gnulib module sys_uio-tests TESTS += test-sys_uio @@ -961,7 +1017,7 @@ EXTRA_DIST += test-version-etc.c test-version-etc.sh TESTS += test-vfprintf-posix.sh check_PROGRAMS += test-vfprintf-posix -EXTRA_DIST += test-vfprintf-posix.sh test-vfprintf-posix.c test-fprintf-posix.h test-printf-posix.output signature.h macros.h +EXTRA_DIST += test-vfprintf-posix.sh test-vfprintf-posix.c test-fprintf-posix.h test-printf-posix.output infinity.h signature.h macros.h ## end gnulib module vfprintf-posix-tests @@ -969,7 +1025,7 @@ EXTRA_DIST += test-vfprintf-posix.sh test-vfprintf-posix.c test-fprintf-posix.h TESTS += test-vprintf-posix.sh check_PROGRAMS += test-vprintf-posix -EXTRA_DIST += test-vprintf-posix.sh test-vprintf-posix.c test-printf-posix.h test-printf-posix.output signature.h macros.h +EXTRA_DIST += test-vprintf-posix.sh test-vprintf-posix.c test-printf-posix.h test-printf-posix.output infinity.h signature.h macros.h ## end gnulib module vprintf-posix-tests diff --git a/gl/tests/dup2.c b/gl/tests/dup2.c index e00dc7b2e3..234bdfe50b 100644 --- a/gl/tests/dup2.c +++ b/gl/tests/dup2.c @@ -31,6 +31,8 @@ # include <windows.h> #endif +#include "msvc-inval.h" + #if HAVE_DUP2 # undef dup2 @@ -45,7 +47,19 @@ rpl_dup2 (int fd, int desired_fd) future dup2 calls will hang. */ if (fd == desired_fd) { - if ((HANDLE) _get_osfhandle (fd) == INVALID_HANDLE_VALUE) + HANDLE handle; + + TRY_MSVC_INVAL + { + handle = (HANDLE) _get_osfhandle (fd); + } + CATCH_MSVC_INVAL + { + handle = INVALID_HANDLE_VALUE; + } + DONE_MSVC_INVAL; + + if (handle == INVALID_HANDLE_VALUE) { errno = EBADF; return -1; @@ -64,7 +78,18 @@ rpl_dup2 (int fd, int desired_fd) if (fd == desired_fd) return fcntl (fd, F_GETFL) == -1 ? -1 : fd; # endif - result = dup2 (fd, desired_fd); + + TRY_MSVC_INVAL + { + result = dup2 (fd, desired_fd); + } + CATCH_MSVC_INVAL + { + result = -1; + errno = EBADF; + } + DONE_MSVC_INVAL; + # ifdef __linux__ /* Correct a Linux return value. <http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.30.y.git;a=commitdiff;h=2b79bc4f7ebbd5af3c8b867968f9f15602d5f802> diff --git a/gl/tests/infinity.h b/gl/tests/infinity.h new file mode 100644 index 0000000000..19a687301b --- /dev/null +++ b/gl/tests/infinity.h @@ -0,0 +1,60 @@ +/* Macros for infinity. + Copyright (C) 2011 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/>. */ + + +/* Infinityf () returns a 'float' +Infinity. */ + +/* The Microsoft MSVC 9 compiler chokes on the expression 1.0f / 0.0f. */ +#if defined _MSC_VER +static float +Infinityf () +{ + static float zero = 0.0f; + return 1.0f / zero; +} +#else +# define Infinityf() (1.0f / 0.0f) +#endif + + +/* Infinityd () returns a 'double' +Infinity. */ + +/* The Microsoft MSVC 9 compiler chokes on the expression 1.0 / 0.0. */ +#if defined _MSC_VER +static double +Infinityd () +{ + static double zero = 0.0; + return 1.0 / zero; +} +#else +# define Infinityd() (1.0 / 0.0) +#endif + + +/* Infinityl () returns a 'long double' +Infinity. */ + +/* The Microsoft MSVC 9 compiler chokes on the expression 1.0L / 0.0L. */ +#if defined _MSC_VER +static double +Infinityl () +{ + static long double zero = 0.0L; + return 1.0L / zero; +} +#else +# define Infinityl() (1.0L / 0.0L) +#endif diff --git a/gl/tests/init.sh b/gl/tests/init.sh index e6f5f1c42c..373d9d4fe7 100644 --- a/gl/tests/init.sh +++ b/gl/tests/init.sh @@ -74,7 +74,20 @@ Exit () { set +e; (exit $1); exit $1; } # the reason for skip/failure to console, rather than to the .log files. : ${stderr_fileno_=2} -warn_ () { echo "$@" 1>&$stderr_fileno_; } +# Note that correct expansion of "$*" depends on IFS starting with ' '. +# Always write the full diagnostic to stderr. +# When stderr_fileno_ is not 2, also emit the first line of the +# diagnostic to that file descriptor. +warn_ () +{ + # If IFS does not start with ' ', set it and emit the warning in a subshell. + case $IFS in + ' '*) printf '%s\n' "$*" >&2 + test $stderr_fileno_ = 2 \ + || { printf '%s\n' "$*" | sed 1q >&$stderr_fileno_ ; } ;; + *) (IFS=' '; warn_ "$@");; + esac +} fail_ () { warn_ "$ME_: failed test: $@"; Exit 1; } skip_ () { warn_ "$ME_: skipped test: $@"; Exit 77; } fatal_ () { warn_ "$ME_: hard error: $@"; Exit 99; } diff --git a/gl/tests/msvc-inval.c b/gl/tests/msvc-inval.c new file mode 100644 index 0000000000..cff07960de --- /dev/null +++ b/gl/tests/msvc-inval.c @@ -0,0 +1,69 @@ +/* Invalid parameter handler for MSVC runtime libraries. + Copyright (C) 2011 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, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#include <config.h> + +/* Specification. */ +#include "msvc-inval.h" + +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER + +# ifdef STATUS_GNULIB_INVALID_PARAMETER + +/* Get declarations of the Win32 API functions. */ +# define WIN32_LEAN_AND_MEAN +# include <windows.h> + +static void cdecl +gl_msvc_invalid_parameter_handler (const wchar_t *expression, + const wchar_t *function, + const wchar_t *file, + unsigned int line, + uintptr_t dummy) +{ + RaiseException (STATUS_GNULIB_INVALID_PARAMETER, 0, 0, NULL); +} + +static int gl_msvc_inval_initialized /* = 0 */; + +void +gl_msvc_inval_ensure_handler (void) +{ + if (gl_msvc_inval_initialized == 0) + { + _set_invalid_parameter_handler (gl_msvc_invalid_parameter_handler); + gl_msvc_inval_initialized = 1; + } +} + +# else + +jmp_buf gl_msvc_inval_restart; + +void cdecl +gl_msvc_invalid_parameter_handler (const wchar_t *expression, + const wchar_t *function, + const wchar_t *file, + unsigned int line, + uintptr_t dummy) +{ + longjmp (gl_msvc_inval_restart, 1); +} + +# endif + +#endif diff --git a/gl/tests/msvc-inval.h b/gl/tests/msvc-inval.h new file mode 100644 index 0000000000..00d3a1e96c --- /dev/null +++ b/gl/tests/msvc-inval.h @@ -0,0 +1,167 @@ +/* Invalid parameter handler for MSVC runtime libraries. + Copyright (C) 2011 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, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef _MSVC_INVAL_H +#define _MSVC_INVAL_H + +/* With MSVC runtime libraries with the "invalid parameter handler" concept, + functions like fprintf(), dup2(), or close() crash when the caller passes + an invalid argument. But POSIX wants error codes (such as EINVAL or EBADF) + instead. + This file defines macros that turn such an invalid parameter notification + into a non-local exit. An error code can then be produced at the target + of this exit. You can thus write code like + + TRY_MSVC_INVAL + { + <Code that can trigger an invalid parameter notification + but does not do 'return', 'break', 'continue', nor 'goto'.> + } + CATCH_MSVC_INVAL + { + <Code that handles an invalid parameter notification + but does not do 'return', 'break', 'continue', nor 'goto'.> + } + DONE_MSVC_INVAL; + + This entire block expands to a single statement. + */ + +#if HAVE_MSVC_INVALID_PARAMETER_HANDLER +/* A native Windows platform with the "invalid parameter handler" concept. */ + +/* Get _invalid_parameter_handler type and _set_invalid_parameter_handler + declaration. */ +#include <stdlib.h> + +# if defined _MSC_VER +/* A compiler that supports __try/__except, as described in the page + "try-except statement" on microsoft.com + <http://msdn.microsoft.com/en-us/library/s58ftw19.aspx>. + With __try/__except, we can use the multithread-safe exception handling. */ + +/* Gnulib can define its own status codes, as described in the page + "Raising Software Exceptions" on microsoft.com + <http://msdn.microsoft.com/en-us/library/het71c37.aspx>. + Our status codes are composed of + - 0xE0000000, mandatory for all user-defined status codes, + - 0x474E550, a API identifier ("GNU"), + - 0, 1, 2, ..., used to distinguish different status codes from the + same API. */ +# define STATUS_GNULIB_INVALID_PARAMETER (0xE0000000 + 0x474E550 + 0) + +# ifdef __cplusplus +extern "C" { +# endif + +/* Ensure that the invalid parameter handler in installed that raises a + software exception with code STATUS_GNULIB_INVALID_PARAMETER. + Because we assume no other part of the program installs a different + invalid parameter handler, this solution is multithread-safe. */ +extern void gl_msvc_inval_ensure_handler (void); + +# ifdef __cplusplus +} +# endif + +# define TRY_MSVC_INVAL \ + do \ + { \ + gl_msvc_inval_ensure_handler (); \ + __try +# define CATCH_MSVC_INVAL \ + __except (GetExceptionCode () == STATUS_GNULIB_INVALID_PARAMETER \ + ? EXCEPTION_EXECUTE_HANDLER \ + : EXCEPTION_CONTINUE_SEARCH) +# define DONE_MSVC_INVAL \ + } \ + while (0) + +# else +/* Any compiler. + We can only use setjmp/longjmp. + Unfortunately, this is *not* multithread-safe. */ + +# include <setjmp.h> + +# ifdef __cplusplus +extern "C" { +# endif + +/* The restart that will resume execution at the code between + CATCH_MSVC_INVAL and DONE_MSVC_INVAL. It is enabled only between + TRY_MSVC_INVAL and CATCH_MSVC_INVAL. */ +extern jmp_buf gl_msvc_inval_restart; + +/* The invalid parameter handler that unwinds the stack up to the + gl_msvc_inval_restart. It is enabled only between TRY_MSVC_INVAL + and CATCH_MSVC_INVAL. */ +extern void cdecl gl_msvc_invalid_parameter_handler (const wchar_t *expression, + const wchar_t *function, + const wchar_t *file, + unsigned int line, + uintptr_t dummy); + +# ifdef __cplusplus +} +# endif + +# define TRY_MSVC_INVAL \ + do \ + { \ + _invalid_parameter_handler orig_handler; \ + /* First, initialize gl_msvc_inval_restart. */ \ + if (setjmp (gl_msvc_inval_restart) == 0) \ + { \ + /* Then, enable gl_msvc_invalid_parameter_handler. */ \ + orig_handler = \ + _set_invalid_parameter_handler (gl_msvc_invalid_parameter_handler); +# define CATCH_MSVC_INVAL \ + /* Execution completed. \ + Disable gl_msvc_invalid_parameter_handler. */ \ + _set_invalid_parameter_handler (orig_handler); \ + } \ + else \ + { \ + /* Execution triggered an invalid parameter notification. \ + Disable gl_msvc_invalid_parameter_handler. */ \ + _set_invalid_parameter_handler (orig_handler); +# define DONE_MSVC_INVAL \ + } \ + } \ + while (0) + +# endif + +#else +/* A platform that does not need to the invalid parameter handler. */ + +/* The braces here avoid GCC warnings like + "warning: suggest explicit braces to avoid ambiguous `else'". */ +# define TRY_MSVC_INVAL \ + do \ + { \ + if (1) +# define CATCH_MSVC_INVAL \ + else +# define DONE_MSVC_INVAL \ + } \ + while (0) + +#endif + +#endif /* _MSVC_INVAL_H */ diff --git a/gl/tests/nan.h b/gl/tests/nan.h index 5e1c0c3798..eb5fd95931 100644 --- a/gl/tests/nan.h +++ b/gl/tests/nan.h @@ -17,8 +17,9 @@ /* NaNf () returns a 'float' not-a-number. */ -/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */ -#ifdef __DECC +/* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke + on the expression 0.0 / 0.0. */ +#if defined __DECC || defined _MSC_VER static float NaNf () { @@ -32,8 +33,9 @@ NaNf () /* NaNd () returns a 'double' not-a-number. */ -/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */ -#ifdef __DECC +/* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke + on the expression 0.0 / 0.0. */ +#if defined __DECC || defined _MSC_VER static double NaNd () { @@ -48,13 +50,21 @@ NaNd () /* NaNl () returns a 'long double' not-a-number. */ /* On Irix 6.5, gcc 3.4.3 can't compute compile-time NaN, and needs the - runtime type conversion. */ + runtime type conversion. + The Microsoft MSVC 9 compiler chokes on the expression 0.0L / 0.0L. */ #ifdef __sgi static long double NaNl () { double zero = 0.0; return zero / zero; } +#elif defined _MSC_VER +static long double +NaNl () +{ + static long double zero = 0.0L; + return zero / zero; +} #else # define NaNl() (0.0L / 0.0L) #endif diff --git a/gl/tests/pathmax.h b/gl/tests/pathmax.h new file mode 100644 index 0000000000..c47618a1b6 --- /dev/null +++ b/gl/tests/pathmax.h @@ -0,0 +1,84 @@ +/* Define PATH_MAX somehow. Requires sys/types.h. + Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2011 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, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef _PATHMAX_H +# define _PATHMAX_H + +/* POSIX:2008 defines PATH_MAX to be the maximum number of bytes in a filename, + including the terminating NUL byte. + <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html> + PATH_MAX is not defined on systems which have no limit on filename length, + such as GNU/Hurd. + + This file does *not* define PATH_MAX always. Programs that use this file + can handle the GNU/Hurd case in several ways: + - Either with a package-wide handling, or with a per-file handling, + - Either through a + #ifdef PATH_MAX + or through a fallback like + #ifndef PATH_MAX + # define PATH_MAX 8192 + #endif + or through a fallback like + #ifndef PATH_MAX + # define PATH_MAX pathconf ("/", _PC_PATH_MAX) + #endif + */ + +# include <unistd.h> + +# include <limits.h> + +# ifndef _POSIX_PATH_MAX +# define _POSIX_PATH_MAX 256 +# endif + +/* Don't include sys/param.h if it already has been. */ +# if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN +# include <sys/param.h> +# endif + +# if !defined PATH_MAX && defined MAXPATHLEN +# define PATH_MAX MAXPATHLEN +# endif + +# ifdef __hpux +/* On HP-UX, PATH_MAX designates the maximum number of bytes in a filename, + *not* including the terminating NUL byte, and is set to 1023. + Additionally, when _XOPEN_SOURCE is defined to 500 or more, PATH_MAX is + not defined at all any more. */ +# undef PATH_MAX +# define PATH_MAX 1024 +# endif + +# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +/* The page "Naming Files, Paths, and Namespaces" on msdn.microsoft.com, + section "Maximum Path Length Limitation", + <http://msdn.microsoft.com/en-us/library/aa365247(v=vs.85).aspx#maxpath> + explains that the maximum size of a filename, including the terminating + NUL byte, is 260 = 3 + 256 + 1. + This is the same value as + - FILENAME_MAX in <stdio.h>, + - _MAX_PATH in <stdlib.h>, + - MAX_PATH in <windef.h>. + Undefine the original value, because mingw's <limits.h> gets it wrong. */ +# undef PATH_MAX +# define PATH_MAX 260 +# endif + +#endif /* _PATHMAX_H */ diff --git a/gl/tests/putenv.c b/gl/tests/putenv.c index 68e5fec31b..3c332791bb 100644 --- a/gl/tests/putenv.c +++ b/gl/tests/putenv.c @@ -34,10 +34,12 @@ #include <string.h> #include <unistd.h> -#if HAVE_GNU_LD +#if _LIBC +# if HAVE_GNU_LD # define environ __environ -#else +# else extern char **environ; +# endif #endif #if _LIBC diff --git a/gl/tests/stat.c b/gl/tests/stat.c index 1002f161bf..1397aa9329 100644 --- a/gl/tests/stat.c +++ b/gl/tests/stat.c @@ -46,6 +46,15 @@ orig_stat (const char *filename, struct stat *buf) #include "dosname.h" #include "verify.h" +#if REPLACE_FUNC_STAT_DIR +# include "pathmax.h" + /* The only known systems where REPLACE_FUNC_STAT_DIR is needed also + have a constant PATH_MAX. */ +# ifndef PATH_MAX +# error "Please port this replacement to your platform" +# endif +#endif + /* Store information about NAME into ST. Work around bugs with trailing slashes. Mingw has other bugs (such as st_ino always being 0 on success) which this wrapper does not work around. But @@ -70,11 +79,6 @@ rpl_stat (char const *name, struct stat *st) } #endif /* REPLACE_FUNC_STAT_FILE */ #if REPLACE_FUNC_STAT_DIR - /* The only known systems where REPLACE_FUNC_STAT_DIR is needed also - have a constant PATH_MAX. */ -# ifndef PATH_MAX -# error "Please port this replacement to your platform" -# endif if (result == -1 && errno == ENOENT) { diff --git a/gl/tests/test-dup2.c b/gl/tests/test-dup2.c index e2ad88bcca..37454e965c 100644 --- a/gl/tests/test-dup2.c +++ b/gl/tests/test-dup2.c @@ -121,6 +121,9 @@ main (void) ASSERT (dup2 (-1, fd) == -1); ASSERT (errno == EBADF); errno = 0; + ASSERT (dup2 (99, fd) == -1); + ASSERT (errno == EBADF); + errno = 0; ASSERT (dup2 (AT_FDCWD, fd) == -1); ASSERT (errno == EBADF); ASSERT (is_open (fd)); diff --git a/gl/tests/test-fcntl-h.c b/gl/tests/test-fcntl-h.c index 648701ef4b..7f350b46f1 100644 --- a/gl/tests/test-fcntl-h.c +++ b/gl/tests/test-fcntl-h.c @@ -31,6 +31,11 @@ int sk[] = { SEEK_CUR, SEEK_END, SEEK_SET }; /* Check that the FD_* macros are defined. */ int i = FD_CLOEXEC; +/* Check that the types are all defined. */ +pid_t t1; +off_t t2; +mode_t t3; + int main (void) { diff --git a/gl/tests/test-fdopen.c b/gl/tests/test-fdopen.c new file mode 100644 index 0000000000..304e520a4c --- /dev/null +++ b/gl/tests/test-fdopen.c @@ -0,0 +1,54 @@ +/* Test opening a stream with a file descriptor. + Copyright (C) 2011 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> + +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (fdopen, FILE *, (int, const char *)); + +#include <errno.h> + +#include "macros.h" + +int +main (void) +{ + /* Test behaviour for invalid file descriptors. */ + { + FILE *fp; + + errno = 0; + fp = fdopen (-1, "r"); + if (fp == NULL) + ASSERT (errno == EBADF); + else + fclose (fp); + } + { + FILE *fp; + + errno = 0; + fp = fdopen (99, "r"); + if (fp == NULL) + ASSERT (errno == EBADF); + else + fclose (fp); + } + + return 0; +} diff --git a/gl/tests/test-fgetc.c b/gl/tests/test-fgetc.c new file mode 100644 index 0000000000..a4e1953eec --- /dev/null +++ b/gl/tests/test-fgetc.c @@ -0,0 +1,84 @@ +/* Test of fgetc() function. + Copyright (C) 2011 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, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#include <config.h> + +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (fgetc, int, (FILE *)); + +#include <errno.h> +#include <fcntl.h> +#include <unistd.h> + +#include "macros.h" + +int +main (int argc, char **argv) +{ + const char *filename = "test-fgetc.txt"; + + /* Prepare a file. */ + { + const char text[] = "hello world"; + int fd = open (filename, O_RDWR | O_CREAT | O_TRUNC, 0600); + ASSERT (fd >= 0); + ASSERT (write (fd, text, sizeof (text)) == sizeof (text)); + ASSERT (close (fd) == 0); + } + + /* Test that fgetc() sets errno if someone else closes the stream + fd behind the back of stdio. */ + { + FILE *fp = fopen (filename, "r"); + ASSERT (fp != NULL); + ASSERT (close (fileno (fp)) == 0); + errno = 0; + ASSERT (fgetc (fp) == EOF); + ASSERT (errno == EBADF); + fclose (fp); + } + + /* Test that fgetc() sets errno if the stream was constructed with + an invalid file descriptor. */ + { + FILE *fp = fdopen (-1, "r"); + if (fp != NULL) + { + errno = 0; + ASSERT (fgetc (fp) == EOF); + ASSERT (errno == EBADF); + fclose (fp); + } + } + { + FILE *fp = fdopen (99, "r"); + if (fp != NULL) + { + errno = 0; + ASSERT (fgetc (fp) == EOF); + ASSERT (errno == EBADF); + fclose (fp); + } + } + + /* Clean up. */ + unlink (filename); + + return 0; +} diff --git a/gl/tests/test-fprintf-posix.h b/gl/tests/test-fprintf-posix.h index 9481aaa16f..e0fa537071 100644 --- a/gl/tests/test-fprintf-posix.h +++ b/gl/tests/test-fprintf-posix.h @@ -16,6 +16,8 @@ /* Written by Bruno Haible <bruno@clisp.org>, 2007. */ +#include "infinity.h" + static void test_function (int (*my_fprintf) (FILE *, const char *, ...)) { @@ -37,13 +39,13 @@ test_function (int (*my_fprintf) (FILE *, const char *, ...)) my_fprintf (stdout, "%a %d\n", 0.0, 33, 44, 55); /* Positive infinity. */ - my_fprintf (stdout, "%a %d\n", 1.0 / 0.0, 33, 44, 55); + my_fprintf (stdout, "%a %d\n", Infinityd (), 33, 44, 55); /* Negative infinity. */ - my_fprintf (stdout, "%a %d\n", -1.0 / 0.0, 33, 44, 55); + my_fprintf (stdout, "%a %d\n", - Infinityd (), 33, 44, 55); /* FLAG_ZERO with infinite number. */ - my_fprintf (stdout, "%010a %d\n", 1.0 / 0.0, 33, 44, 55); + my_fprintf (stdout, "%010a %d\n", Infinityd (), 33, 44, 55); /* Test the support of the %f format directive. */ diff --git a/gl/tests/test-frexp.c b/gl/tests/test-frexp.c index 4ed24d2902..a7ec639df6 100644 --- a/gl/tests/test-frexp.c +++ b/gl/tests/test-frexp.c @@ -27,6 +27,7 @@ SIGNATURE_CHECK (frexp, double, (double, int *)); #include "isnand-nolibm.h" #include "minus-zero.h" +#include "infinity.h" #include "nan.h" #include "macros.h" @@ -67,7 +68,7 @@ main () { /* Positive infinity. */ int exp = -9999; double mantissa; - x = 1.0 / 0.0; + x = Infinityd (); mantissa = frexp (x, &exp); ASSERT (mantissa == x); } @@ -75,7 +76,7 @@ main () { /* Negative infinity. */ int exp = -9999; double mantissa; - x = -1.0 / 0.0; + x = - Infinityd (); mantissa = frexp (x, &exp); ASSERT (mantissa == x); } diff --git a/gl/tests/test-frexpl.c b/gl/tests/test-frexpl.c index ccb547b037..905b293a1d 100644 --- a/gl/tests/test-frexpl.c +++ b/gl/tests/test-frexpl.c @@ -28,6 +28,7 @@ SIGNATURE_CHECK (frexpl, long double, (long double, int *)); #include "fpucw.h" #include "isnanl-nolibm.h" #include "minus-zero.h" +#include "infinity.h" #include "nan.h" #include "macros.h" @@ -79,7 +80,7 @@ main () { /* Positive infinity. */ int exp = -9999; long double mantissa; - x = 1.0L / 0.0L; + x = Infinityl (); mantissa = frexpl (x, &exp); ASSERT (mantissa == x); } @@ -87,7 +88,7 @@ main () { /* Negative infinity. */ int exp = -9999; long double mantissa; - x = -1.0L / 0.0L; + x = - Infinityl (); mantissa = frexpl (x, &exp); ASSERT (mantissa == x); } diff --git a/gl/tests/test-fseeko4.c b/gl/tests/test-fseeko4.c new file mode 100644 index 0000000000..61559e1429 --- /dev/null +++ b/gl/tests/test-fseeko4.c @@ -0,0 +1,71 @@ +/* Test of fseeko() function. + Copyright (C) 2011 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> + +#include <stdio.h> + +#include <errno.h> +#include <unistd.h> + +#include "macros.h" + +int +main (int argc, char **argv) +{ + const char *filename = argv[1]; + + /* Test that fseeko() sets errno if someone else closes the stream + fd behind the back of stdio. */ + { + FILE *fp = fopen (filename, "r"); + ASSERT (fp != NULL); + setvbuf (fp, NULL, _IONBF, 0); + ASSERT (ftell (fp) == 0); + ASSERT (fseeko (fp, 0, SEEK_END) == 0); + ASSERT (ftell (fp) > 0); + ASSERT (close (fileno (fp)) == 0); + errno = 0; + ASSERT (fseeko (fp, 0, SEEK_SET) == -1); + ASSERT (errno == EBADF); + fclose (fp); + } + + /* Test that fseeko() sets errno if the stream was constructed with + an invalid file descriptor. */ + { + FILE *fp = fdopen (-1, "w"); + if (fp != NULL) + { + errno = 0; + ASSERT (fseeko (fp, 0, SEEK_END) == -1); + ASSERT (errno == EBADF); + fclose (fp); + } + } + { + FILE *fp = fdopen (99, "w"); + if (fp != NULL) + { + errno = 0; + ASSERT (fseeko (fp, 0, SEEK_END) == -1); + ASSERT (errno == EBADF); + fclose (fp); + } + } + + return 0; +} diff --git a/gl/tests/test-fseeko4.sh b/gl/tests/test-fseeko4.sh new file mode 100755 index 0000000000..e6464ae44a --- /dev/null +++ b/gl/tests/test-fseeko4.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +./test-fseeko4${EXEEXT} "$srcdir/test-fseeko4.sh" || exit 1 + +exit 0 diff --git a/gl/tests/test-fstat.c b/gl/tests/test-fstat.c new file mode 100644 index 0000000000..6c120d9dd5 --- /dev/null +++ b/gl/tests/test-fstat.c @@ -0,0 +1,48 @@ +/* Tests of fstat() function. + Copyright (C) 2011 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> + +#include <sys/stat.h> + +#include "signature.h" +SIGNATURE_CHECK (fstat, int, (int, struct stat *)); + +#include <errno.h> + +#include "macros.h" + +int +main (int argc, char *argv[]) +{ + /* Test behaviour for invalid file descriptors. */ + { + struct stat statbuf; + + errno = 0; + ASSERT (fstat (-1, &statbuf) == -1); + ASSERT (errno == EBADF); + } + { + struct stat statbuf; + + errno = 0; + ASSERT (fstat (99, &statbuf) == -1); + ASSERT (errno == EBADF); + } + + return 0; +} diff --git a/gl/tests/test-ftello4.c b/gl/tests/test-ftello4.c new file mode 100644 index 0000000000..d503f71389 --- /dev/null +++ b/gl/tests/test-ftello4.c @@ -0,0 +1,68 @@ +/* Test of ftello() function. + Copyright (C) 2011 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> + +#include <stdio.h> + +#include <errno.h> +#include <unistd.h> + +#include "macros.h" + +int +main (int argc, char **argv) +{ + const char *filename = argv[1]; + + /* Test that ftello() sets errno if someone else closes the stream + fd behind the back of stdio. */ + { + FILE *fp = fopen (filename, "r"); + ASSERT (fp != NULL); + setvbuf (fp, NULL, _IONBF, 0); + ASSERT (close (fileno (fp)) == 0); + errno = 0; + ASSERT (ftello (fp) == (off_t)-1); + ASSERT (errno == EBADF); + fclose (fp); + } + + /* Test that ftello() sets errno if the stream was constructed with + an invalid file descriptor. */ + { + FILE *fp = fdopen (-1, "w"); + if (fp != NULL) + { + errno = 0; + ASSERT (ftello (fp) == (off_t)-1); + ASSERT (errno == EBADF); + fclose (fp); + } + } + { + FILE *fp = fdopen (99, "w"); + if (fp != NULL) + { + errno = 0; + ASSERT (ftello (fp) == (off_t)-1); + ASSERT (errno == EBADF); + fclose (fp); + } + } + + return 0; +} diff --git a/gl/tests/test-ftello4.sh b/gl/tests/test-ftello4.sh new file mode 100755 index 0000000000..e3702bb605 --- /dev/null +++ b/gl/tests/test-ftello4.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +./test-ftello4${EXEEXT} "$srcdir/test-ftello4.sh" || exit 1 + +exit 0 diff --git a/gl/tests/test-isnand.h b/gl/tests/test-isnand.h index de69331efd..181e36ff05 100644 --- a/gl/tests/test-isnand.h +++ b/gl/tests/test-isnand.h @@ -19,6 +19,7 @@ #include <limits.h> #include "minus-zero.h" +#include "infinity.h" #include "nan.h" #include "macros.h" @@ -35,8 +36,8 @@ main () ASSERT (!isnand (0.0)); ASSERT (!isnand (minus_zerod)); /* Infinite values. */ - ASSERT (!isnand (1.0 / 0.0)); - ASSERT (!isnand (-1.0 / 0.0)); + ASSERT (!isnand (Infinityd ())); + ASSERT (!isnand (- Infinityd ())); /* Quiet NaN. */ ASSERT (isnand (NaNd ())); #if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT diff --git a/gl/tests/test-isnanf.h b/gl/tests/test-isnanf.h index f4b0e861fc..4a33508e4a 100644 --- a/gl/tests/test-isnanf.h +++ b/gl/tests/test-isnanf.h @@ -19,6 +19,7 @@ #include <limits.h> #include "minus-zero.h" +#include "infinity.h" #include "nan.h" #include "macros.h" @@ -35,8 +36,8 @@ main () ASSERT (!isnanf (0.0f)); ASSERT (!isnanf (minus_zerof)); /* Infinite values. */ - ASSERT (!isnanf (1.0f / 0.0f)); - ASSERT (!isnanf (-1.0f / 0.0f)); + ASSERT (!isnanf (Infinityf ())); + ASSERT (!isnanf (- Infinityf ())); /* Quiet NaN. */ ASSERT (isnanf (NaNf ())); #if defined FLT_EXPBIT0_WORD && defined FLT_EXPBIT0_BIT diff --git a/gl/tests/test-isnanl.h b/gl/tests/test-isnanl.h index c07f3a9646..055d05f479 100644 --- a/gl/tests/test-isnanl.h +++ b/gl/tests/test-isnanl.h @@ -20,6 +20,7 @@ #include <limits.h> #include "minus-zero.h" +#include "infinity.h" #include "nan.h" #include "macros.h" @@ -41,8 +42,8 @@ main () ASSERT (!isnanl (0.0L)); ASSERT (!isnanl (minus_zerol)); /* Infinite values. */ - ASSERT (!isnanl (1.0L / 0.0L)); - ASSERT (!isnanl (-1.0L / 0.0L)); + ASSERT (!isnanl (Infinityl ())); + ASSERT (!isnanl (- Infinityl ())); /* Quiet NaN. */ ASSERT (isnanl (NaNl ())); diff --git a/gl/tests/test-pathmax.c b/gl/tests/test-pathmax.c new file mode 100644 index 0000000000..96a1364cc0 --- /dev/null +++ b/gl/tests/test-pathmax.c @@ -0,0 +1,32 @@ +/* Test of "pathmax.h". + Copyright (C) 2011 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>, 2011. */ + +#include <config.h> + +#include "pathmax.h" + +/* Check that PATH_MAX is a constant if it is defined. */ +#ifdef PATH_MAX +int a = PATH_MAX; +#endif + +int +main (void) +{ + return 0; +} diff --git a/gl/tests/test-printf-posix.h b/gl/tests/test-printf-posix.h index 73365a5b9d..3d29212116 100644 --- a/gl/tests/test-printf-posix.h +++ b/gl/tests/test-printf-posix.h @@ -16,6 +16,8 @@ /* Written by Bruno Haible <bruno@clisp.org>, 2007. */ +#include "infinity.h" + static void test_function (int (*my_printf) (const char *, ...)) { @@ -37,15 +39,15 @@ test_function (int (*my_printf) (const char *, ...)) my_printf ("%a %d\n", 0.0, 33, 44, 55); /* Positive infinity. */ - my_printf ("%a %d\n", 1.0 / 0.0, 33, 44, 55); + my_printf ("%a %d\n", Infinityd (), 33, 44, 55); /* Negative infinity. */ - my_printf ("%a %d\n", -1.0 / 0.0, 33, 44, 55); + my_printf ("%a %d\n", - Infinityd (), 33, 44, 55); /* FLAG_ZERO with infinite number. */ /* "0000000inf 33" is not a valid result; see <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */ - my_printf ("%010a %d\n", 1.0 / 0.0, 33, 44, 55); + my_printf ("%010a %d\n", Infinityd (), 33, 44, 55); /* Test the support of the %f format directive. */ diff --git a/gl/tests/test-signbit.c b/gl/tests/test-signbit.c index c8981498a1..940156e6d9 100644 --- a/gl/tests/test-signbit.c +++ b/gl/tests/test-signbit.c @@ -29,6 +29,7 @@ #include <limits.h> #include "minus-zero.h" +#include "infinity.h" #include "macros.h" float zerof = 0.0f; @@ -52,8 +53,8 @@ test_signbitf () else ASSERT (!signbit (minus_zerof)); /* Infinite values. */ - ASSERT (!signbit (1.0f / 0.0f)); - ASSERT (signbit (-1.0f / 0.0f)); + ASSERT (!signbit (Infinityf ())); + ASSERT (signbit (- Infinityf ())); /* Quiet NaN. */ (void) signbit (zerof / zerof); #if defined FLT_EXPBIT0_WORD && defined FLT_EXPBIT0_BIT @@ -97,8 +98,8 @@ test_signbitd () else ASSERT (!signbit (minus_zerod)); /* Infinite values. */ - ASSERT (!signbit (1.0 / 0.0)); - ASSERT (signbit (-1.0 / 0.0)); + ASSERT (!signbit (Infinityd ())); + ASSERT (signbit (- Infinityd ())); /* Quiet NaN. */ (void) signbit (zerod / zerod); #if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT @@ -140,8 +141,8 @@ test_signbitl () else ASSERT (!signbit (minus_zerol)); /* Infinite values. */ - ASSERT (!signbit (1.0L / 0.0L)); - ASSERT (signbit (-1.0L / 0.0L)); + ASSERT (!signbit (Infinityl ())); + ASSERT (signbit (- Infinityl ())); /* Quiet NaN. */ (void) signbit (zerol / zerol); #if defined LDBL_EXPBIT0_WORD && defined LDBL_EXPBIT0_BIT diff --git a/gl/tests/test-sys_socket.c b/gl/tests/test-sys_socket.c index a6e99d6008..58c1899e9c 100644 --- a/gl/tests/test-sys_socket.c +++ b/gl/tests/test-sys_socket.c @@ -30,6 +30,10 @@ int a[] = { SHUT_RD, SHUT_WR, SHUT_RDWR }; /* Check that the 'socklen_t' type is defined. */ socklen_t t1; +/* Check that the 'size_t' and 'ssize_t' types are defined. */ +size_t t2; +ssize_t t3; + /* Check that 'struct iovec' is defined. */ struct iovec io; diff --git a/gl/tests/test-sys_stat.c b/gl/tests/test-sys_stat.c index cd07d86e87..3303badcce 100644 --- a/gl/tests/test-sys_stat.c +++ b/gl/tests/test-sys_stat.c @@ -26,11 +26,14 @@ int a[] = { S_IFMT, - S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFREG, -#ifdef S_IFLNK /* missing on mingw and djgpp */ +#ifdef S_IFBLK /* missing on MSVC */ + S_IFBLK, +#endif + S_IFCHR, S_IFDIR, S_IFIFO, S_IFREG, +#ifdef S_IFLNK /* missing on native Windows and DJGPP */ S_IFLNK, #endif -#ifdef S_IFSOCK /* missing on mingw and djgpp */ +#ifdef S_IFSOCK /* missing on native Windows and DJGPP */ S_IFSOCK, #endif S_IRWXU, S_IRUSR, S_IWUSR, S_IXUSR, @@ -61,7 +64,9 @@ verify (S_IRWXU == (S_IRUSR | S_IWUSR | S_IXUSR)); verify (S_IRWXG == (S_IRGRP | S_IWGRP | S_IXGRP)); verify (S_IRWXO == (S_IROTH | S_IWOTH | S_IXOTH)); +#ifdef S_IFBLK verify (S_ISBLK (S_IFBLK)); +#endif verify (!S_ISBLK (S_IFCHR)); verify (!S_ISBLK (S_IFDIR)); verify (!S_ISBLK (S_IFIFO)); @@ -73,7 +78,9 @@ verify (!S_ISBLK (S_IFLNK)); verify (!S_ISBLK (S_IFSOCK)); #endif +#ifdef S_IFBLK verify (!S_ISCHR (S_IFBLK)); +#endif verify (S_ISCHR (S_IFCHR)); verify (!S_ISCHR (S_IFDIR)); verify (!S_ISCHR (S_IFIFO)); @@ -85,7 +92,9 @@ verify (!S_ISCHR (S_IFLNK)); verify (!S_ISCHR (S_IFSOCK)); #endif +#ifdef S_IFBLK verify (!S_ISDIR (S_IFBLK)); +#endif verify (!S_ISDIR (S_IFCHR)); verify (S_ISDIR (S_IFDIR)); verify (!S_ISDIR (S_IFIFO)); @@ -97,7 +106,9 @@ verify (!S_ISDIR (S_IFLNK)); verify (!S_ISDIR (S_IFSOCK)); #endif +#ifdef S_IFBLK verify (!S_ISFIFO (S_IFBLK)); +#endif verify (!S_ISFIFO (S_IFCHR)); verify (!S_ISFIFO (S_IFDIR)); verify (S_ISFIFO (S_IFIFO)); @@ -109,7 +120,9 @@ verify (!S_ISFIFO (S_IFLNK)); verify (!S_ISFIFO (S_IFSOCK)); #endif +#ifdef S_IFBLK verify (!S_ISREG (S_IFBLK)); +#endif verify (!S_ISREG (S_IFCHR)); verify (!S_ISREG (S_IFDIR)); verify (!S_ISREG (S_IFIFO)); @@ -121,7 +134,9 @@ verify (!S_ISREG (S_IFLNK)); verify (!S_ISREG (S_IFSOCK)); #endif +#ifdef S_IFBLK verify (!S_ISLNK (S_IFBLK)); +#endif verify (!S_ISLNK (S_IFCHR)); verify (!S_ISLNK (S_IFDIR)); verify (!S_ISLNK (S_IFIFO)); @@ -133,7 +148,9 @@ verify (S_ISLNK (S_IFLNK)); verify (!S_ISLNK (S_IFSOCK)); #endif +#ifdef S_IFBLK verify (!S_ISSOCK (S_IFBLK)); +#endif verify (!S_ISSOCK (S_IFCHR)); verify (!S_ISSOCK (S_IFDIR)); verify (!S_ISSOCK (S_IFIFO)); @@ -145,7 +162,9 @@ verify (!S_ISSOCK (S_IFLNK)); verify (S_ISSOCK (S_IFSOCK)); #endif +#ifdef S_IFBLK verify (!S_ISDOOR (S_IFBLK)); +#endif verify (!S_ISDOOR (S_IFCHR)); verify (!S_ISDOOR (S_IFDIR)); verify (!S_ISDOOR (S_IFIFO)); @@ -157,7 +176,9 @@ verify (!S_ISDOOR (S_IFLNK)); verify (!S_ISDOOR (S_IFSOCK)); #endif +#ifdef S_IFBLK verify (!S_ISMPB (S_IFBLK)); +#endif verify (!S_ISMPB (S_IFCHR)); verify (!S_ISMPB (S_IFDIR)); verify (!S_ISMPB (S_IFIFO)); @@ -169,7 +190,9 @@ verify (!S_ISMPB (S_IFLNK)); verify (!S_ISMPB (S_IFSOCK)); #endif +#ifdef S_IFBLK verify (!S_ISNAM (S_IFBLK)); +#endif verify (!S_ISNAM (S_IFCHR)); verify (!S_ISNAM (S_IFDIR)); verify (!S_ISNAM (S_IFIFO)); @@ -181,7 +204,9 @@ verify (!S_ISNAM (S_IFLNK)); verify (!S_ISNAM (S_IFSOCK)); #endif +#ifdef S_IFBLK verify (!S_ISNWK (S_IFBLK)); +#endif verify (!S_ISNWK (S_IFCHR)); verify (!S_ISNWK (S_IFDIR)); verify (!S_ISNWK (S_IFIFO)); @@ -193,7 +218,9 @@ verify (!S_ISNWK (S_IFLNK)); verify (!S_ISNWK (S_IFSOCK)); #endif +#ifdef S_IFBLK verify (!S_ISPORT (S_IFBLK)); +#endif verify (!S_ISPORT (S_IFCHR)); verify (!S_ISPORT (S_IFDIR)); verify (!S_ISPORT (S_IFIFO)); @@ -205,7 +232,9 @@ verify (!S_ISPORT (S_IFLNK)); verify (!S_ISPORT (S_IFSOCK)); #endif +#ifdef S_IFBLK verify (!S_ISCTG (S_IFBLK)); +#endif verify (!S_ISCTG (S_IFCHR)); verify (!S_ISCTG (S_IFDIR)); verify (!S_ISCTG (S_IFIFO)); @@ -217,7 +246,9 @@ verify (!S_ISCTG (S_IFLNK)); verify (!S_ISCTG (S_IFSOCK)); #endif +#ifdef S_IFBLK verify (!S_ISOFD (S_IFBLK)); +#endif verify (!S_ISOFD (S_IFCHR)); verify (!S_ISOFD (S_IFDIR)); verify (!S_ISOFD (S_IFIFO)); @@ -229,7 +260,9 @@ verify (!S_ISOFD (S_IFLNK)); verify (!S_ISOFD (S_IFSOCK)); #endif +#ifdef S_IFBLK verify (!S_ISOFL (S_IFBLK)); +#endif verify (!S_ISOFL (S_IFCHR)); verify (!S_ISOFL (S_IFDIR)); verify (!S_ISOFL (S_IFIFO)); @@ -241,7 +274,9 @@ verify (!S_ISOFL (S_IFLNK)); verify (!S_ISOFL (S_IFSOCK)); #endif +#ifdef S_IFBLK verify (!S_ISWHT (S_IFBLK)); +#endif verify (!S_ISWHT (S_IFCHR)); verify (!S_ISWHT (S_IFDIR)); verify (!S_ISWHT (S_IFIFO)); @@ -278,8 +313,10 @@ invalid UTIME macros /* Check the existence of some types. */ nlink_t t1; +off_t t2; +mode_t t3; -struct timespec t2; +struct timespec st; int main (void) diff --git a/gl/tests/test-sys_types.c b/gl/tests/test-sys_types.c new file mode 100644 index 0000000000..816c9d6162 --- /dev/null +++ b/gl/tests/test-sys_types.c @@ -0,0 +1,34 @@ +/* Test of <sys/types.h> substitute. + Copyright (C) 2011 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>, 2011. */ + +#include <config.h> + +#include <sys/types.h> + +/* Check that the types are all defined. */ +pid_t t1; +size_t t2; +ssize_t t3; +off_t t4; +mode_t t5; + +int +main (void) +{ + return 0; +} diff --git a/gl/tests/test-time.c b/gl/tests/test-time.c index 0c78f36c66..d499a5ca16 100644 --- a/gl/tests/test-time.c +++ b/gl/tests/test-time.c @@ -22,7 +22,13 @@ #include "verify.h" -struct timespec a; +/* Check that the types are all defined. */ +struct timespec t1; +#if 0 +/* POSIX:2008 does not require pid_t in <time.h> unconditionally, and indeed + it's missing on MacOS X 10.5, FreeBSD 6.4, OpenBSD 4.9, mingw. */ +pid_t t2; +#endif /* Check that NULL can be passed through varargs as a pointer type, per POSIX 2008. */ |