summaryrefslogtreecommitdiff
path: root/gl/m4
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2010-02-17 10:10:47 +0100
committerSimon Josefsson <simon@josefsson.org>2010-02-17 10:10:47 +0100
commitdb3a3b93e599669172d46d81c3db3eb661640996 (patch)
treee0d9da491762dead0f4f742555a17e32f8f782df /gl/m4
parent8728945992cce0019e0d286181d81dcd9d280d0d (diff)
downloadgnutls-db3a3b93e599669172d46d81c3db3eb661640996.tar.gz
Update gnulib files.
Diffstat (limited to 'gl/m4')
-rw-r--r--gl/m4/getdelim.m465
-rw-r--r--gl/m4/getline.m438
-rw-r--r--gl/m4/gettimeofday.m461
-rw-r--r--gl/m4/gnulib-comp.m41
-rw-r--r--gl/m4/stdio_h.m43
-rw-r--r--gl/m4/sys_time_h.m444
6 files changed, 155 insertions, 57 deletions
diff --git a/gl/m4/getdelim.m4 b/gl/m4/getdelim.m4
index 9e5ad5baaf..4beb1501c2 100644
--- a/gl/m4/getdelim.m4
+++ b/gl/m4/getdelim.m4
@@ -1,6 +1,6 @@
-# getdelim.m4 serial 5
+# getdelim.m4 serial 6
-dnl Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
+dnl Copyright (C) 2005-2007, 2009-2010 Free Software Foundation, Inc.
dnl
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -15,16 +15,71 @@ AC_DEFUN([gl_FUNC_GETDELIM],
dnl Persuade glibc <stdio.h> to declare getdelim().
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
- AC_REPLACE_FUNCS([getdelim])
AC_CHECK_DECLS_ONCE([getdelim])
- if test $ac_cv_func_getdelim = no; then
- gl_PREREQ_GETDELIM
+ AC_CHECK_FUNCS_ONCE([getdelim])
+ if test $ac_cv_func_getdelim = yes; then
+ dnl Found it in some library. Verify that it works.
+ AC_CACHE_CHECK([for working getdelim function], [gl_cv_func_working_getdelim],
+ [echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
+# include <stdio.h>
+# include <stdlib.h>
+# include <string.h>
+ int main ()
+ {
+ FILE *in = fopen ("./conftest.data", "r");
+ if (!in)
+ return 1;
+ {
+ /* Test result for a NULL buffer and a zero size.
+ Based on a test program from Karl Heuer. */
+ char *line = NULL;
+ size_t siz = 0;
+ int len = getdelim (&line, &siz, '\n', in);
+ if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
+ return 1;
+ }
+ {
+ /* Test result for a NULL buffer and a non-zero size.
+ This crashes on FreeBSD 8.0. */
+ char *line = NULL;
+ size_t siz = (size_t)(~0) / 4;
+ if (getdelim (&line, &siz, '\n', in) == -1)
+ return 1;
+ }
+ return 0;
+ }
+ ]])], [gl_cv_func_working_getdelim=yes] dnl The library version works.
+ , [gl_cv_func_working_getdelim=no] dnl The library version does NOT work.
+ , dnl We're cross compiling. Assume it works on glibc2 systems.
+ [AC_EGREP_CPP([Lucky GNU user],
+ [
+#include <features.h>
+#ifdef __GNU_LIBRARY__
+ #if (__GLIBC__ >= 2)
+ Lucky GNU user
+ #endif
+#endif
+ ],
+ [gl_cv_func_working_getdelim=yes],
+ [gl_cv_func_working_getdelim=no])]
+ )])
+ else
+ gl_cv_func_working_getdelim=no
fi
if test $ac_cv_have_decl_getdelim = no; then
HAVE_DECL_GETDELIM=0
fi
+
+ if test $gl_cv_func_working_getdelim = no; then
+ if test $ac_cv_func_getdelim = yes; then
+ REPLACE_GETDELIM=1
+ fi
+ AC_LIBOBJ([getdelim])
+ gl_PREREQ_GETDELIM
+ fi
])
# Prerequisites of lib/getdelim.c.
diff --git a/gl/m4/getline.m4 b/gl/m4/getline.m4
index 5b8a712fbc..83005600d6 100644
--- a/gl/m4/getline.m4
+++ b/gl/m4/getline.m4
@@ -1,4 +1,4 @@
-# getline.m4 serial 20
+# getline.m4 serial 21
dnl Copyright (C) 1998-2003, 2005-2007, 2009-2010 Free Software Foundation,
dnl Inc.
@@ -24,26 +24,39 @@ AC_DEFUN([gl_FUNC_GETLINE],
gl_getline_needs_run_time_check=no
AC_CHECK_FUNC([getline],
- dnl Found it in some library. Verify that it works.
- gl_getline_needs_run_time_check=yes,
- am_cv_func_working_getline=no)
+ [dnl Found it in some library. Verify that it works.
+ gl_getline_needs_run_time_check=yes],
+ [am_cv_func_working_getline=no])
if test $gl_getline_needs_run_time_check = yes; then
AC_CACHE_CHECK([for working getline function], [am_cv_func_working_getline],
- [echo fooN |tr -d '\012'|tr N '\012' > conftest.data
+ [echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data
AC_RUN_IFELSE([AC_LANG_SOURCE([[
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
int main ()
- { /* Based on a test program from Karl Heuer. */
- char *line = NULL;
- size_t siz = 0;
- int len;
+ {
FILE *in = fopen ("./conftest.data", "r");
if (!in)
return 1;
- len = getline (&line, &siz, in);
- exit ((len == 4 && line && strcmp (line, "foo\n") == 0) ? 0 : 1);
+ {
+ /* Test result for a NULL buffer and a zero size.
+ Based on a test program from Karl Heuer. */
+ char *line = NULL;
+ size_t siz = 0;
+ int len = getline (&line, &siz, in);
+ if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
+ return 1;
+ }
+ {
+ /* Test result for a NULL buffer and a non-zero size.
+ This crashes on FreeBSD 8.0. */
+ char *line = NULL;
+ size_t siz = (size_t)(~0) / 4;
+ if (getline (&line, &siz, in) == -1)
+ return 1;
+ }
+ return 0;
}
]])], [am_cv_func_working_getline=yes] dnl The library version works.
, [am_cv_func_working_getline=no] dnl The library version does NOT work.
@@ -67,6 +80,9 @@ AC_DEFUN([gl_FUNC_GETLINE],
fi
if test $am_cv_func_working_getline = no; then
+ dnl Set REPLACE_GETLINE always: Even if we have not found the broken
+ dnl getline function among $LIBS, it may exist in libinet and the
+ dnl executable may be linked with -linet.
REPLACE_GETLINE=1
AC_LIBOBJ([getline])
diff --git a/gl/m4/gettimeofday.m4 b/gl/m4/gettimeofday.m4
index 735123e6dc..32e4f29a9f 100644
--- a/gl/m4/gettimeofday.m4
+++ b/gl/m4/gettimeofday.m4
@@ -1,4 +1,4 @@
-# serial 12
+# serial 14
# Copyright (C) 2001-2003, 2005, 2007, 2009-2010 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
@@ -11,33 +11,49 @@ AC_DEFUN([gl_FUNC_GETTIMEOFDAY],
[
AC_REQUIRE([AC_C_RESTRICT])
AC_REQUIRE([gl_HEADER_SYS_TIME_H])
+ AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS])
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
+ gl_gettimeofday_timezone=void
+ if test $ac_cv_func_gettimeofday = yes; then
+ gl_FUNC_GETTIMEOFDAY_CLOBBER
+ 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 gettimeofday (struct timeval *restrict, void *restrict);
+ ]],
+ [[/* glibc uses struct timezone * rather than the POSIX void *
+ if _GNU_SOURCE is defined. However, since the only portable
+ use of gettimeofday uses NULL as the second parameter, and
+ since the glibc definition is actually more typesafe, it is
+ not worth wrapping this to get a compliant signature. */
+ 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],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <sys/time.h>
+int gettimeofday (struct timeval *restrict, struct timezone *restrict);
+ ]])],
+ [gl_cv_func_gettimeofday_posix_signature=almost],
+ [gl_cv_func_gettimeofday_posix_signature=no])])])
+ if test $gl_cv_func_gettimeofday_posix_signature = almost; then
+ gl_gettimeofday_timezone='struct timezone'
+ elif test $gl_cv_func_gettimeofday_posix_signature != yes; then
+ REPLACE_GETTIMEOFDAY=1
AC_LIBOBJ([gettimeofday])
gl_PREREQ_GETTIMEOFDAY
fi
fi
+ AC_DEFINE_UNQUOTED([GETTIMEOFDAY_TIMEZONE], [$gl_gettimeofday_timezone],
+ [Define this to 'void' or 'struct timezone' to match the system's
+ declaration of the second argument to gettimeofday.])
])
@@ -78,7 +94,6 @@ AC_DEFUN([gl_FUNC_GETTIMEOFDAY_CLOBBER],
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.])
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4
index 9ee2c0a593..4f08319901 100644
--- a/gl/m4/gnulib-comp.m4
+++ b/gl/m4/gnulib-comp.m4
@@ -238,6 +238,7 @@ AC_SUBST([LTALLOCA])
gl_source_base='gl/tests'
gl_FUNC_UNGETC_WORKS
gl_FUNC_GETTIMEOFDAY
+ gl_SYS_TIME_MODULE_INDICATOR([gettimeofday])
AC_C_BIGENDIAN
AC_C_BIGENDIAN
AC_REQUIRE([gl_HEADER_SYS_SOCKET])
diff --git a/gl/m4/stdio_h.m4 b/gl/m4/stdio_h.m4
index 20af579d14..781fa8d388 100644
--- a/gl/m4/stdio_h.m4
+++ b/gl/m4/stdio_h.m4
@@ -1,4 +1,4 @@
-# stdio_h.m4 serial 24
+# stdio_h.m4 serial 25
dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -111,6 +111,7 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
REPLACE_FSEEKO=0; AC_SUBST([REPLACE_FSEEKO])
REPLACE_FTELL=0; AC_SUBST([REPLACE_FTELL])
REPLACE_FTELLO=0; AC_SUBST([REPLACE_FTELLO])
+ REPLACE_GETDELIM=0; AC_SUBST([REPLACE_GETDELIM])
REPLACE_GETLINE=0; AC_SUBST([REPLACE_GETLINE])
REPLACE_OBSTACK_PRINTF=0; AC_SUBST([REPLACE_OBSTACK_PRINTF])
REPLACE_PERROR=0; AC_SUBST([REPLACE_PERROR])
diff --git a/gl/m4/sys_time_h.m4 b/gl/m4/sys_time_h.m4
index 9c16487957..b14bc4ba2b 100644
--- a/gl/m4/sys_time_h.m4
+++ b/gl/m4/sys_time_h.m4
@@ -1,5 +1,5 @@
# Configure a replacement for <sys/time.h>.
-# serial 2
+# serial 3
# Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
@@ -19,15 +19,13 @@ AC_DEFUN([gl_HEADER_SYS_TIME_H],
AC_DEFUN([gl_HEADER_SYS_TIME_H_BODY],
[
AC_REQUIRE([AC_C_RESTRICT])
+ AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS])
AC_CHECK_HEADERS_ONCE([sys/time.h])
gl_CHECK_NEXT_HEADERS([sys/time.h])
- if test $ac_cv_header_sys_time_h = yes; then
- HAVE_SYS_TIME_H=1
- else
+ if test $ac_cv_header_sys_time_h != yes; then
HAVE_SYS_TIME_H=0
fi
- AC_SUBST([HAVE_SYS_TIME_H])
AC_CACHE_CHECK([for struct timeval], [gl_cv_sys_struct_timeval],
[AC_COMPILE_IFELSE(
@@ -40,20 +38,32 @@ AC_DEFUN([gl_HEADER_SYS_TIME_H_BODY],
[[static struct timeval x; x.tv_sec = x.tv_usec;]])],
[gl_cv_sys_struct_timeval=yes],
[gl_cv_sys_struct_timeval=no])])
- if test $gl_cv_sys_struct_timeval = yes; then
- HAVE_STRUCT_TIMEVAL=1
- else
+ if test $gl_cv_sys_struct_timeval != yes; then
HAVE_STRUCT_TIMEVAL=0
fi
- AC_SUBST([HAVE_STRUCT_TIMEVAL])
+ dnl Check for declarations of anything we want to poison if the
+ dnl corresponding gnulib module is not in use.
+ gl_WARN_ON_USE_PREPARE([[
+#if HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#include <time.h>
+ ]], [gettimeofday])
+])
+
+AC_DEFUN([gl_SYS_TIME_MODULE_INDICATOR],
+[
+ dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+ AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS])
+ GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+])
+
+AC_DEFUN([gl_HEADER_SYS_TIME_H_DEFAULTS],
+[
+ GNULIB_GETTIMEOFDAY=0; AC_SUBST([GNULIB_GETTIMEOFDAY])
dnl Assume POSIX behavior unless another module says otherwise.
- REPLACE_GETTIMEOFDAY=0
- AC_SUBST([REPLACE_GETTIMEOFDAY])
- if test $HAVE_SYS_TIME_H = 0 || test $HAVE_STRUCT_TIMEVAL = 0; then
- SYS_TIME_H=sys/time.h
- else
- SYS_TIME_H=
- fi
- AC_SUBST([SYS_TIME_H])
+ HAVE_STRUCT_TIMEVAL=1; AC_SUBST([HAVE_STRUCT_TIMEVAL])
+ HAVE_SYS_TIME_H=1; AC_SUBST([HAVE_SYS_TIME_H])
+ REPLACE_GETTIMEOFDAY=0; AC_SUBST([REPLACE_GETTIMEOFDAY])
])