summaryrefslogtreecommitdiff
path: root/gl
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2009-10-15 08:34:52 +0200
committerSimon Josefsson <simon@josefsson.org>2009-10-15 08:34:52 +0200
commit5f30b74679828c8f0e18f42096d9651b00772aff (patch)
tree6ee9cbb2d290f19a19101ee6090eddeada26b44c /gl
parent55aa014dffb9b95bc3ad55a3d17f92668e416088 (diff)
downloadgnutls-5f30b74679828c8f0e18f42096d9651b00772aff.tar.gz
Update gnulib files.
Diffstat (limited to 'gl')
-rw-r--r--gl/Makefile.am31
-rw-r--r--gl/m4/gnulib-comp.m46
-rw-r--r--gl/m4/sys_stat_h.m45
-rw-r--r--gl/sys_stat.in.h26
-rw-r--r--gl/tests/Makefile.am9
-rw-r--r--gl/tests/test-sys_stat.c27
-rw-r--r--gl/tests/test-time.c35
-rw-r--r--gl/time.in.h127
-rw-r--r--gl/unistd.in.h4
9 files changed, 265 insertions, 5 deletions
diff --git a/gl/Makefile.am b/gl/Makefile.am
index 78642d67ba..e7e93d4114 100644
--- a/gl/Makefile.am
+++ b/gl/Makefile.am
@@ -1014,6 +1014,7 @@ sys/stat.h: sys_stat.in.h
-e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
-e 's|@''GNULIB_FCHMODAT''@|$(GNULIB_FCHMODAT)|g' \
-e 's|@''GNULIB_FSTATAT''@|$(GNULIB_FSTATAT)|g' \
+ -e 's|@''GNULIB_FUTIMENS''@|$(GNULIB_FUTIMENS)|g' \
-e 's|@''GNULIB_LCHMOD''@|$(GNULIB_LCHMOD)|g' \
-e 's|@''GNULIB_LSTAT''@|$(GNULIB_LSTAT)|g' \
-e 's|@''GNULIB_MKDIRAT''@|$(GNULIB_MKDIRAT)|g' \
@@ -1022,6 +1023,7 @@ sys/stat.h: sys_stat.in.h
-e 's|@''GNULIB_STAT''@|$(GNULIB_STAT)|g' \
-e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \
-e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \
+ -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \
-e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \
-e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \
-e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \
@@ -1029,6 +1031,7 @@ sys/stat.h: sys_stat.in.h
-e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \
-e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \
-e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \
+ -e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \
-e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \
-e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \
-e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \
@@ -1068,6 +1071,34 @@ EXTRA_DIST += sys_time.in.h
## end gnulib module sys_time
+## begin gnulib module time
+
+BUILT_SOURCES += time.h
+
+# We need the following in order to create <time.h> when the system
+# doesn't have one that works with the given compiler.
+time.h: time.in.h
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \
+ -e 's|@REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
+ -e 's|@REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
+ -e 's|@REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
+ -e 's|@REPLACE_STRPTIME''@|$(REPLACE_STRPTIME)|g' \
+ -e 's|@REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
+ -e 's|@SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
+ -e 's|@TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
+ < $(srcdir)/time.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += time.h time.h-t
+
+EXTRA_DIST += time.in.h
+
+## end gnulib module time
+
## begin gnulib module unistd
BUILT_SOURCES += unistd.h
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4
index fa0a089aec..045b826d02 100644
--- a/gl/m4/gnulib-comp.m4
+++ b/gl/m4/gnulib-comp.m4
@@ -190,6 +190,7 @@ AC_SUBST([LTALLOCA])
AC_PROG_MKDIR_P
gl_HEADER_SYS_TIME_H
AC_PROG_MKDIR_P
+ gl_HEADER_TIME_H
gl_UNISTD_H
gl_FUNC_VASNPRINTF
gl_VERSION_ETC
@@ -252,7 +253,7 @@ AC_SUBST([LTALLOCA])
gt_TYPE_WINT_T
gl_SYS_IOCTL_H
AC_PROG_MKDIR_P
- AC_CHECK_FUNCS([shutdown])
+ AC_CHECK_FUNCS_ONCE([shutdown])
abs_aux_dir=`cd "$ac_aux_dir"; pwd`
AC_SUBST([abs_aux_dir])
m4_ifval(gltests_LIBSOURCES_LIST, [
@@ -432,6 +433,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/sys_socket.in.h
lib/sys_stat.in.h
lib/sys_time.in.h
+ lib/time.in.h
lib/unistd.in.h
lib/vasnprintf.c
lib/vasnprintf.h
@@ -505,6 +507,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/sys_socket_h.m4
m4/sys_stat_h.m4
m4/sys_time_h.m4
+ m4/time_h.m4
m4/ungetc.m4
m4/unistd_h.m4
m4/vasnprintf.m4
@@ -552,6 +555,7 @@ AC_DEFUN([gl_FILE_LIST], [
tests/test-sys_socket.c
tests/test-sys_stat.c
tests/test-sys_time.c
+ tests/test-time.c
tests/test-unistd.c
tests/test-vasnprintf.c
tests/test-vc-list-files-cvs.sh
diff --git a/gl/m4/sys_stat_h.m4 b/gl/m4/sys_stat_h.m4
index d37fea827b..600489075a 100644
--- a/gl/m4/sys_stat_h.m4
+++ b/gl/m4/sys_stat_h.m4
@@ -1,4 +1,4 @@
-# sys_stat_h.m4 serial 17 -*- Autoconf -*-
+# sys_stat_h.m4 serial 18 -*- Autoconf -*-
dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -41,6 +41,7 @@ AC_DEFUN([gl_SYS_STAT_H_DEFAULTS],
AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) dnl for REPLACE_FCHDIR
GNULIB_FCHMODAT=0; AC_SUBST([GNULIB_FCHMODAT])
GNULIB_FSTATAT=0; AC_SUBST([GNULIB_FSTATAT])
+ GNULIB_FUTIMENS=0; AC_SUBST([GNULIB_FUTIMENS])
GNULIB_LCHMOD=0; AC_SUBST([GNULIB_LCHMOD])
GNULIB_LSTAT=0; AC_SUBST([GNULIB_LSTAT])
GNULIB_MKDIRAT=0; AC_SUBST([GNULIB_MKDIRAT])
@@ -50,6 +51,7 @@ AC_DEFUN([gl_SYS_STAT_H_DEFAULTS],
dnl Assume proper GNU behavior unless another module says otherwise.
HAVE_FCHMODAT=1; AC_SUBST([HAVE_FCHMODAT])
HAVE_FSTATAT=1; AC_SUBST([HAVE_FSTATAT])
+ HAVE_FUTIMENS=1; AC_SUBST([HAVE_FUTIMENS])
HAVE_LCHMOD=1; AC_SUBST([HAVE_LCHMOD])
HAVE_LSTAT=1; AC_SUBST([HAVE_LSTAT])
HAVE_MKDIRAT=1; AC_SUBST([HAVE_MKDIRAT])
@@ -57,6 +59,7 @@ AC_DEFUN([gl_SYS_STAT_H_DEFAULTS],
HAVE_MKNODAT=1; AC_SUBST([HAVE_MKNODAT])
REPLACE_FSTAT=0; AC_SUBST([REPLACE_FSTAT])
REPLACE_FSTATAT=0; AC_SUBST([REPLACE_FSTATAT])
+ REPLACE_FUTIMENS=0; AC_SUBST([REPLACE_FUTIMENS])
REPLACE_LSTAT=0; AC_SUBST([REPLACE_LSTAT])
REPLACE_MKDIR=0; AC_SUBST([REPLACE_MKDIR])
REPLACE_STAT=0; AC_SUBST([REPLACE_STAT])
diff --git a/gl/sys_stat.in.h b/gl/sys_stat.in.h
index b2a7df9587..492fbb69bd 100644
--- a/gl/sys_stat.in.h
+++ b/gl/sys_stat.in.h
@@ -38,6 +38,9 @@
/* Get nlink_t. */
#include <sys/types.h>
+/* Get struct timespec. */
+#include <time.h>
+
/* The include_next requires a split double-inclusion guard. */
#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
@@ -278,6 +281,12 @@
# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
#endif
+/* Macros for futimens and utimensat. */
+#ifndef UTIME_NOW
+# define UTIME_NOW (-1)
+# define UTIME_OMIT (-2)
+#endif
+
#ifdef __cplusplus
extern "C" {
@@ -349,6 +358,23 @@ extern int fstatat (int fd, char const *name, struct stat *st, int flags);
#endif
+#if @GNULIB_FUTIMENS@
+# if @REPLACE_FUTIMENS@
+# undef futimens
+# define futimens rpl_futimens
+# endif
+# if !@HAVE_FUTIMENS@ || @REPLACE_FUTIMENS@
+extern int futimens (int fd, struct timespec const times[2]);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef futimens
+# define futimens(f,t) \
+ (GL_LINK_WARNING ("futimens is not portable - " \
+ "use gnulib module futimens for portability"), \
+ futimens (f, t))
+#endif
+
+
#if @GNULIB_MKDIRAT@
# if !@HAVE_MKDIRAT@
extern int mkdirat (int fd, char const *file, mode_t mode);
diff --git a/gl/tests/Makefile.am b/gl/tests/Makefile.am
index e782748c41..94918936fc 100644
--- a/gl/tests/Makefile.am
+++ b/gl/tests/Makefile.am
@@ -369,6 +369,15 @@ EXTRA_DIST += test-sys_time.c
## end gnulib module sys_time-tests
+## begin gnulib module time-tests
+
+TESTS += test-time
+check_PROGRAMS += test-time
+
+EXTRA_DIST += test-time.c
+
+## end gnulib module time-tests
+
## begin gnulib module unistd-tests
TESTS += test-unistd
diff --git a/gl/tests/test-sys_stat.c b/gl/tests/test-sys_stat.c
index 4b5eb767b7..a73f9b81c6 100644
--- a/gl/tests/test-sys_stat.c
+++ b/gl/tests/test-sys_stat.c
@@ -1,5 +1,5 @@
/* Test of <sys/stat.h> substitute.
- Copyright (C) 2007-2008 Free Software Foundation, Inc.
+ Copyright (C) 2007-2009 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
@@ -253,9 +253,34 @@ verify (!S_ISWHT (S_IFLNK));
verify (!S_ISWHT (S_IFSOCK));
#endif
+/* POSIX 2008 requires traditional encoding of permission constants. */
+verify (S_IRWXU == 00700);
+verify (S_IRUSR == 00400);
+verify (S_IWUSR == 00200);
+verify (S_IXUSR == 00100);
+verify (S_IRWXG == 00070);
+verify (S_IRGRP == 00040);
+verify (S_IWGRP == 00020);
+verify (S_IXGRP == 00010);
+verify (S_IRWXO == 00007);
+verify (S_IROTH == 00004);
+verify (S_IWOTH == 00002);
+verify (S_IXOTH == 00001);
+verify (S_ISUID == 04000);
+verify (S_ISGID == 02000);
+verify (S_ISVTX == 01000);
+
+#if ((0 <= UTIME_NOW && UTIME_NOW < 1000000000) \
+ || (0 <= UTIME_OMIT && UTIME_OMIT < 1000000000) \
+ || UTIME_NOW == UTIME_OMIT)
+invalid UTIME macros
+#endif
+
/* Check the existence of some types. */
nlink_t t1;
+struct timespec t2;
+
int
main ()
{
diff --git a/gl/tests/test-time.c b/gl/tests/test-time.c
new file mode 100644
index 0000000000..ea8143737f
--- /dev/null
+++ b/gl/tests/test-time.c
@@ -0,0 +1,35 @@
+/* Test of <time.h> substitute.
+ Copyright (C) 2007, 2009 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>, 2007. */
+
+#include <config.h>
+
+#include <time.h>
+
+#include "verify.h"
+
+struct timespec a;
+
+/* Check that NULL can be passed through varargs as a pointer type,
+ per POSIX 2008. */
+verify (sizeof NULL == sizeof (void *));
+
+int
+main ()
+{
+ return 0;
+}
diff --git a/gl/time.in.h b/gl/time.in.h
new file mode 100644
index 0000000000..ef8d0ba875
--- /dev/null
+++ b/gl/time.in.h
@@ -0,0 +1,127 @@
+/* A more-standard <time.h>.
+
+ Copyright (C) 2007-2009 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. */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+
+/* Don't get in the way of glibc when it includes time.h merely to
+ declare a few standard symbols, rather than to declare all the
+ symbols. Also, Solaris 8 <time.h> eventually includes itself
+ recursively; if that is happening, just include the system <time.h>
+ without adding our own declarations. */
+#if (defined __need_time_t || defined __need_clock_t \
+ || defined __need_timespec \
+ || defined _GL_TIME_H)
+
+# @INCLUDE_NEXT@ @NEXT_TIME_H@
+
+#else
+
+# define _GL_TIME_H
+
+# @INCLUDE_NEXT@ @NEXT_TIME_H@
+
+/* NetBSD 5.0 mis-defines NULL. */
+#include <stddef.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
+ Or they define it with the wrong member names or define it in <sys/time.h>
+ (e.g., FreeBSD circa 1997). */
+# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
+# if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
+# include <sys/time.h>
+# else
+# undef timespec
+# define timespec rpl_timespec
+struct timespec
+{
+ time_t tv_sec;
+ long int tv_nsec;
+};
+# endif
+# endif
+
+/* Sleep for at least RQTP seconds unless interrupted, If interrupted,
+ return -1 and store the remaining time into RMTP. See
+ <http://www.opengroup.org/susv3xsh/nanosleep.html>. */
+# if @REPLACE_NANOSLEEP@
+# define nanosleep rpl_nanosleep
+int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp);
+# endif
+
+/* Return the 'time_t' representation of TP and normalize TP. */
+# if @REPLACE_MKTIME@
+# define mktime rpl_mktime
+extern time_t mktime (struct tm *__tp);
+# endif
+
+/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
+ <http://www.opengroup.org/susv3xsh/localtime_r.html> and
+ <http://www.opengroup.org/susv3xsh/gmtime_r.html>. */
+# if @REPLACE_LOCALTIME_R@
+# undef localtime_r
+# define localtime_r rpl_localtime_r
+# undef gmtime_r
+# define gmtime_r rpl_gmtime_r
+struct tm *localtime_r (time_t const *restrict __timer,
+ struct tm *restrict __result);
+struct tm *gmtime_r (time_t const *restrict __timer,
+ struct tm *restrict __result);
+# endif
+
+/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
+ the resulting broken-down time into TM. See
+ <http://www.opengroup.org/susv3xsh/strptime.html>. */
+# if @REPLACE_STRPTIME@
+# undef strptime
+# define strptime rpl_strptime
+char *strptime (char const *restrict __buf, char const *restrict __format,
+ struct tm *restrict __tm);
+# endif
+
+/* Convert TM to a time_t value, assuming UTC. */
+# if @REPLACE_TIMEGM@
+# undef timegm
+# define timegm rpl_timegm
+time_t timegm (struct tm *__tm);
+# endif
+
+/* Encourage applications to avoid unsafe functions that can overrun
+ buffers when given outlandish struct tm values. Portable
+ applications should use strftime (or even sprintf) instead. */
+# if GNULIB_PORTCHECK
+# undef asctime
+# define asctime eschew_asctime
+# undef asctime_r
+# define asctime_r eschew_asctime_r
+# undef ctime
+# define ctime eschew_ctime
+# undef ctime_r
+# define ctime_r eschew_ctime_r
+# endif
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
diff --git a/gl/unistd.in.h b/gl/unistd.in.h
index 34da9369c8..c75546743d 100644
--- a/gl/unistd.in.h
+++ b/gl/unistd.in.h
@@ -49,7 +49,7 @@
#endif
/* Get getopt(), optarg, optind, opterr, optopt. */
-#if @GNULIB_UNISTD_H_GETOPT@
+#if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
# include <getopt.h>
#endif
@@ -239,7 +239,7 @@ extern char **environ;
#if @GNULIB_EUIDACCESS@
# if !@HAVE_EUIDACCESS@
-/* Like access(), except that is uses the effective user id and group id of
+/* Like access(), except that it uses the effective user id and group id of
the current process. */
extern int euidaccess (const char *filename, int mode);
# endif