diff options
author | Simon Josefsson <simon@josefsson.org> | 2008-11-10 12:07:37 +0100 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2008-11-10 12:07:37 +0100 |
commit | 8db007da11d55f0b3b05a7efbfba05481401db16 (patch) | |
tree | a8ff4a37b74de532dacd46e6eaee2e7c1412fe53 /gl | |
parent | 916cf1d30f6287bd9a7e00ec0dbb597abc7a56e3 (diff) | |
download | gnutls-8db007da11d55f0b3b05a7efbfba05481401db16.tar.gz |
Update gnulib files.
Diffstat (limited to 'gl')
-rw-r--r-- | gl/m4/gettimeofday.m4 | 101 | ||||
-rw-r--r-- | gl/m4/gnulib-comp.m4 | 9 | ||||
-rw-r--r-- | gl/m4/sys_ioctl_h.m4 | 11 | ||||
-rw-r--r-- | gl/tests/Makefile.am | 28 |
4 files changed, 142 insertions, 7 deletions
diff --git a/gl/m4/gettimeofday.m4 b/gl/m4/gettimeofday.m4 new file mode 100644 index 0000000000..b9bbb1081b --- /dev/null +++ b/gl/m4/gettimeofday.m4 @@ -0,0 +1,101 @@ +#serial 11 + +# Copyright (C) 2001, 2002, 2003, 2005, 2007 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +dnl From Jim Meyering. + +AC_DEFUN([gl_FUNC_GETTIMEOFDAY], +[ + AC_REQUIRE([AC_C_RESTRICT]) + AC_REQUIRE([gl_HEADER_SYS_TIME_H]) + AC_CHECK_FUNCS_ONCE([gettimeofday]) + + AC_CACHE_CHECK([for gettimeofday with POSIX signature], + [gl_cv_func_gettimeofday_posix_signature], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <sys/time.h> + struct timeval c; + ]], + [[ + int (*f) (struct timeval *restrict, void *restrict) = gettimeofday; + int x = f (&c, 0); + return !(x | c.tv_sec | c.tv_usec); + ]])], + [gl_cv_func_gettimeofday_posix_signature=yes], + [gl_cv_func_gettimeofday_posix_signature=no])]) + + gl_FUNC_GETTIMEOFDAY_CLOBBER + + if test $gl_cv_func_gettimeofday_posix_signature != yes; then + REPLACE_GETTIMEOFDAY=1 + SYS_TIME_H=sys/time.h + if test $gl_cv_func_gettimeofday_clobber != yes; then + AC_LIBOBJ(gettimeofday) + gl_PREREQ_GETTIMEOFDAY + fi + fi +]) + + +dnl See if gettimeofday clobbers the static buffer that localtime uses +dnl for its return value. The gettimeofday function from Mac OS X 10.0.4 +dnl (i.e., Darwin 1.3.7) has this problem. +dnl +dnl If it does, then arrange to use gettimeofday and localtime only via +dnl the wrapper functions that work around the problem. + +AC_DEFUN([gl_FUNC_GETTIMEOFDAY_CLOBBER], +[ + AC_REQUIRE([gl_HEADER_SYS_TIME_H]) + + AC_CACHE_CHECK([whether gettimeofday clobbers localtime buffer], + [gl_cv_func_gettimeofday_clobber], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include <string.h> + #include <sys/time.h> + #include <time.h> + #include <stdlib.h> + ]], + [[ + time_t t = 0; + struct tm *lt; + struct tm saved_lt; + struct timeval tv; + lt = localtime (&t); + saved_lt = *lt; + gettimeofday (&tv, NULL); + return memcmp (lt, &saved_lt, sizeof (struct tm)) != 0; + ]])], + [gl_cv_func_gettimeofday_clobber=no], + [gl_cv_func_gettimeofday_clobber=yes], + dnl When crosscompiling, assume it is broken. + [gl_cv_func_gettimeofday_clobber=yes])]) + + if test $gl_cv_func_gettimeofday_clobber = yes; then + REPLACE_GETTIMEOFDAY=1 + SYS_TIME_H=sys/time.h + gl_GETTIMEOFDAY_REPLACE_LOCALTIME + AC_DEFINE([GETTIMEOFDAY_CLOBBERS_LOCALTIME], 1, + [Define if gettimeofday clobbers the localtime buffer.]) + fi +]) + +AC_DEFUN([gl_GETTIMEOFDAY_REPLACE_LOCALTIME], [ + AC_LIBOBJ(gettimeofday) + gl_PREREQ_GETTIMEOFDAY + AC_DEFINE([gmtime], [rpl_gmtime], + [Define to rpl_gmtime if the replacement function should be used.]) + AC_DEFINE([localtime], [rpl_localtime], + [Define to rpl_localtime if the replacement function should be used.]) +]) + +# Prerequisites of lib/gettimeofday.c. +AC_DEFUN([gl_PREREQ_GETTIMEOFDAY], [ + AC_CHECK_HEADERS([sys/timeb.h]) + AC_CHECK_FUNCS([_ftime]) +]) diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index dca40d50c4..112fa2ff6d 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 @@ -218,6 +218,7 @@ AC_SUBST([LTALLOCA]) m4_pushdef([gltests_LIBSOURCES_DIR], []) gl_COMMON gl_source_base='gl/tests' + gl_FUNC_GETTIMEOFDAY AC_REQUIRE([gl_HEADER_SYS_SOCKET]) if test "$ac_cv_header_winsock2_h" = yes; then AC_LIBOBJ([ioctl]) @@ -225,6 +226,7 @@ AC_SUBST([LTALLOCA]) fi gl_SYS_IOCTL_MODULE_INDICATOR([ioctl]) gl_MODULE_INDICATOR([ioctl]) + AC_CHECK_HEADERS_ONCE([unistd.h sys/wait.h]) gl_SOCKETS gt_TYPE_WCHAR_T gt_TYPE_WINT_T @@ -420,6 +422,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/getdelim.m4 m4/getline.m4 m4/getpass.m4 + m4/gettimeofday.m4 m4/gnulib-common.m4 m4/include_next.m4 m4/inet_ntop.m4 @@ -474,6 +477,7 @@ AC_DEFUN([gl_FILE_LIST], [ tests/test-getaddrinfo.c tests/test-getdelim.c tests/test-getline.c + tests/test-gettimeofday.c tests/test-lseek.c tests/test-lseek.sh tests/test-netdb.c @@ -481,6 +485,10 @@ AC_DEFUN([gl_FILE_LIST], [ tests/test-perror.c tests/test-perror.sh tests/test-read-file.c + tests/test-select-fd.c + tests/test-select-in.sh + tests/test-select-out.sh + tests/test-select-stdin.c tests/test-select.c tests/test-snprintf.c tests/test-sockets.c @@ -497,6 +505,7 @@ AC_DEFUN([gl_FILE_LIST], [ tests/test-unistd.c tests/test-vasnprintf.c tests/test-wchar.c + tests=lib/gettimeofday.c tests=lib/ioctl.c tests=lib/sockets.c tests=lib/sockets.h diff --git a/gl/m4/sys_ioctl_h.m4 b/gl/m4/sys_ioctl_h.m4 index 5488039b6c..e0396de850 100644 --- a/gl/m4/sys_ioctl_h.m4 +++ b/gl/m4/sys_ioctl_h.m4 @@ -1,4 +1,4 @@ -# sys_ioctl_h.m4 serial 1 +# sys_ioctl_h.m4 serial 2 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, @@ -19,10 +19,13 @@ AC_DEFUN([gl_SYS_IOCTL_H], dnl header file, such as <unistd.h> or <stropts.h>, is needed for that. AC_CACHE_CHECK([whether <sys/ioctl.h> declares ioctl], [gl_cv_decl_ioctl_in_sys_ioctl_h], - [AC_CHECK_DECL([ioctl], + [dnl We cannot use AC_CHECK_DECL because it produces its own messages. + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [AC_INCLUDES_DEFAULT([#include <sys/ioctl.h>])], + [(void) ioctl;])], [gl_cv_decl_ioctl_in_sys_ioctl_h=yes], - [gl_cv_decl_ioctl_in_sys_ioctl_h=no], - [#include <sys/ioctl.h>]) + [gl_cv_decl_ioctl_in_sys_ioctl_h=no]) ]) if test $gl_cv_decl_ioctl_in_sys_ioctl_h != yes; then SYS_IOCTL_H='sys/ioctl.h' diff --git a/gl/tests/Makefile.am b/gl/tests/Makefile.am index b47ee0946c..9add074500 100644 --- a/gl/tests/Makefile.am +++ b/gl/tests/Makefile.am @@ -115,6 +115,24 @@ EXTRA_DIST += test-getline.c ## end gnulib module getline-tests +## begin gnulib module gettimeofday + + +EXTRA_DIST += gettimeofday.c + +EXTRA_libtests_a_SOURCES += gettimeofday.c + +## end gnulib module gettimeofday + +## begin gnulib module gettimeofday-tests + +TESTS += test-gettimeofday +check_PROGRAMS += test-gettimeofday + +EXTRA_DIST += test-gettimeofday.c + +## end gnulib module gettimeofday-tests + ## begin gnulib module ioctl @@ -170,11 +188,15 @@ EXTRA_DIST += test-read-file.c ## begin gnulib module select-tests -TESTS += test-select -check_PROGRAMS += test-select +TESTS += test-select test-select-in.sh test-select-out.sh +# test-select-stdin has to be run by hand. +TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' +check_PROGRAMS += test-select test-select-fd test-select-stdin test_select_LDADD = $(LDADD) @LIBSOCKET@ +test_select_fd_LDADD = $(LDADD) @LIBSOCKET@ +test_select_stdin_LDADD = $(LDADD) @LIBSOCKET@ -EXTRA_DIST += test-select.c +EXTRA_DIST += test-select.c test-select-fd.c test-select-in.sh test-select-out.sh test-select-stdin.c ## end gnulib module select-tests |