]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Update gnulib files.
authorSimon Josefsson <simon@josefsson.org>
Mon, 10 Nov 2008 11:07:37 +0000 (12:07 +0100)
committerSimon Josefsson <simon@josefsson.org>
Mon, 10 Nov 2008 11:07:37 +0000 (12:07 +0100)
gl/m4/gettimeofday.m4 [new file with mode: 0644]
gl/m4/gnulib-comp.m4
gl/m4/sys_ioctl_h.m4
gl/tests/Makefile.am
lib/gl/m4/include_next.m4
lib/gl/sys_stat.in.h

diff --git a/gl/m4/gettimeofday.m4 b/gl/m4/gettimeofday.m4
new file mode 100644 (file)
index 0000000..b9bbb10
--- /dev/null
@@ -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])
+])
index dca40d50c4078e027da74eaef353077885ea70d7..112fa2ff6dd367a87effc98abc1a574a6a333d19 100644 (file)
@@ -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
index 5488039b6c8bb6f00daa77ea6324e7e9a3b69e41..e0396de8509a114cb133747a29b9370412b5e526 100644 (file)
@@ -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'
index b47ee0946cf50af9d04fc86d55b7f85a3f5b488b..9add07450018f479a02a0251833121d6dc72f3ab 100644 (file)
@@ -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
 
index b6e4d3ae7a92c2e1a7c83b5325a31fadf25f8ff7..c70c4133a06565bc3702d81751a91a0ab8f58339 100644 (file)
@@ -1,4 +1,4 @@
-# include_next.m4 serial 8
+# include_next.m4 serial 9
 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,
@@ -87,6 +87,7 @@ EOF
 AC_DEFUN([gl_CHECK_NEXT_HEADERS],
 [
   AC_REQUIRE([gl_INCLUDE_NEXT])
+  AC_REQUIRE([AC_CANONICAL_HOST])
   AC_CHECK_HEADERS_ONCE([$1])
 
   m4_foreach_w([gl_HEADER_NAME], [$1],
@@ -105,11 +106,22 @@ AC_DEFUN([gl_CHECK_NEXT_HEADERS],
              [AC_LANG_SOURCE(
                 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
               )])
-           dnl eval is necessary to expand ac_cpp.
+           dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
+           dnl that contain only a #include of other header files and no
+           dnl non-comment tokens of their own. This leads to a failure to
+           dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
+           dnl and others. The workaround is to force preservation of comments
+           dnl through option -C. This ensures all necessary #line directives
+           dnl are present. GCC supports option -C as well.
+           case "$host_os" in
+             aix*) gl_absname_cpp="$ac_cpp -C" ;;
+             *)    gl_absname_cpp="$ac_cpp" ;;
+           esac
+           dnl eval is necessary to expand gl_absname_cpp.
            dnl Ultrix and Pyramid sh refuse to redirect output of eval,
            dnl so use subshell.
            AS_VAR_SET([gl_next_header],
-             ['"'`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
+             ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
               sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{
                 s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#
                 s#^/[^/]#//&#
index 9eac5f4d3314436112603b67fbfbe75e6ab1f35e..f46b4d77e93b5c8427326e69d55c4fd24debccfc 100644 (file)
 # define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
 #endif
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
 #if @GNULIB_LSTAT@
 # if ! @HAVE_LSTAT@
 /* mingw does not support symlinks, therefore it does not have lstat.  But
@@ -341,6 +347,12 @@ extern int lchmod (const char *filename, mode_t mode);
      lchmod (f, m))
 #endif
 
+
+#ifdef __cplusplus
+}
+#endif
+
+
 #endif /* _GL_SYS_STAT_H */
 #endif /* _GL_SYS_STAT_H */
 #endif