Blame SOURCES/0145-Add-grub_util_readlink.patch

6b3c76
From 70ab42b16aa19b381262dc7a75a045d5ef6b2495 Mon Sep 17 00:00:00 2001
a85e8e
From: Peter Jones <pjones@redhat.com>
a85e8e
Date: Wed, 3 Sep 2014 10:01:03 -0400
6b3c76
Subject: [PATCH 145/261] Add grub_util_readlink()
a85e8e
a85e8e
Add grub_util_readlink().  This requires pulling in stat and readlink from
a85e8e
gnulib, which pulls in stat and related headers, but after that the
a85e8e
implementation is straightforward.
a85e8e
a85e8e
Signed-off-by: Peter Jones <pjones@redhat.com>
a85e8e
Reviewed-by: Adam Jackson <ajax@redhat.com>
a85e8e
---
6b3c76
 grub-core/gnulib/Makefile.am          | 177 +++++++-
a85e8e
 grub-core/gnulib/gettimeofday.c       | 154 +++++++
6b3c76
 grub-core/gnulib/pathmax.h            |  83 ++++
a85e8e
 grub-core/gnulib/readlink.c           |  74 ++++
a85e8e
 grub-core/gnulib/stat.c               | 138 +++++++
a85e8e
 grub-core/gnulib/sys_stat.in.h        | 732 ++++++++++++++++++++++++++++++++++
a85e8e
 grub-core/gnulib/sys_time.in.h        | 213 ++++++++++
a85e8e
 grub-core/gnulib/sys_types.in.h       |   2 +
a85e8e
 grub-core/gnulib/time.h               | 586 +++++++++++++++++++++++++++
a85e8e
 grub-core/gnulib/time.in.h            | 274 +++++++++++++
6b3c76
 grub-core/osdep/windows/hostdisk.c    |   6 +
a85e8e
 include/grub/osdep/hostfile_aros.h    |   6 +
a85e8e
 include/grub/osdep/hostfile_unix.h    |   6 +
a85e8e
 include/grub/osdep/hostfile_windows.h |   2 +
a85e8e
 m4/gettimeofday.m4                    | 138 +++++++
a85e8e
 m4/gnulib-cache.m4                    |   3 +-
a85e8e
 m4/gnulib-comp.m4                     |  49 +++
a85e8e
 m4/largefile.m4                       | 146 +++++++
a85e8e
 m4/pathmax.m4                         |  42 ++
a85e8e
 m4/readlink.m4                        |  71 ++++
a85e8e
 m4/stat.m4                            |  71 ++++
a85e8e
 m4/sys_stat_h.m4                      |  96 +++++
a85e8e
 m4/sys_time_h.m4                      | 110 +++++
a85e8e
 m4/time_h.m4                          | 118 ++++++
a85e8e
 24 files changed, 3295 insertions(+), 2 deletions(-)
a85e8e
 create mode 100644 grub-core/gnulib/gettimeofday.c
6b3c76
 create mode 100644 grub-core/gnulib/pathmax.h
a85e8e
 create mode 100644 grub-core/gnulib/readlink.c
a85e8e
 create mode 100644 grub-core/gnulib/stat.c
a85e8e
 create mode 100644 grub-core/gnulib/sys_stat.in.h
a85e8e
 create mode 100644 grub-core/gnulib/sys_time.in.h
a85e8e
 create mode 100644 grub-core/gnulib/time.h
a85e8e
 create mode 100644 grub-core/gnulib/time.in.h
a85e8e
 create mode 100644 m4/gettimeofday.m4
a85e8e
 create mode 100644 m4/largefile.m4
a85e8e
 create mode 100644 m4/pathmax.m4
a85e8e
 create mode 100644 m4/readlink.m4
a85e8e
 create mode 100644 m4/stat.m4
a85e8e
 create mode 100644 m4/sys_stat_h.m4
a85e8e
 create mode 100644 m4/sys_time_h.m4
a85e8e
 create mode 100644 m4/time_h.m4
a85e8e
6b3c76
diff --git a/grub-core/gnulib/Makefile.am b/grub-core/gnulib/Makefile.am
6b3c76
index 3444397fe..b7c5e60e1 100644
6b3c76
--- a/grub-core/gnulib/Makefile.am
6b3c76
+++ b/grub-core/gnulib/Makefile.am
6b3c76
@@ -21,7 +21,7 @@
6b3c76
 # the same distribution terms as the rest of that program.
6b3c76
 #
6b3c76
 # Generated by gnulib-tool.
6b3c76
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=grub-core/gnulib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files argp error fnmatch getdelim getline gettext progname regex
6b3c76
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=grub-core/gnulib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files argp error fnmatch getdelim getline gettext progname readlink regex
6b3c76
 
6b3c76
 AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects
6b3c76
 
6b3c76
@@ -326,6 +326,15 @@ libgnu_a_SOURCES += gettext.h
6b3c76
 
6b3c76
 ## end   gnulib module gettext-h
6b3c76
 
6b3c76
+## begin gnulib module gettimeofday
6b3c76
+
6b3c76
+
6b3c76
+EXTRA_DIST += gettimeofday.c
6b3c76
+
6b3c76
+EXTRA_libgnu_a_SOURCES += gettimeofday.c
6b3c76
+
6b3c76
+## end   gnulib module gettimeofday
6b3c76
+
6b3c76
 ## begin gnulib module havelib
6b3c76
 
6b3c76
 
6b3c76
@@ -596,6 +605,13 @@ EXTRA_libgnu_a_SOURCES += nl_langinfo.c
6b3c76
 
6b3c76
 ## end   gnulib module nl_langinfo
6b3c76
 
6b3c76
+## begin gnulib module pathmax
6b3c76
+
6b3c76
+
6b3c76
+EXTRA_DIST += pathmax.h
6b3c76
+
6b3c76
+## end   gnulib module pathmax
6b3c76
+
6b3c76
 ## begin gnulib module progname
6b3c76
 
6b3c76
 libgnu_a_SOURCES += progname.h progname.c
6b3c76
@@ -611,6 +627,15 @@ EXTRA_libgnu_a_SOURCES += rawmemchr.c
6b3c76
 
6b3c76
 ## end   gnulib module rawmemchr
6b3c76
 
6b3c76
+## begin gnulib module readlink
6b3c76
+
6b3c76
+
6b3c76
+EXTRA_DIST += readlink.c
6b3c76
+
6b3c76
+EXTRA_libgnu_a_SOURCES += readlink.c
6b3c76
+
6b3c76
+## end   gnulib module readlink
6b3c76
+
6b3c76
 ## begin gnulib module realloc-posix
6b3c76
 
6b3c76
 
6b3c76
@@ -725,6 +750,15 @@ EXTRA_DIST += $(top_srcdir)/build-aux/snippet/warn-on-use.h
6b3c76
 
6b3c76
 ## end   gnulib module snippet/warn-on-use
6b3c76
 
6b3c76
+## begin gnulib module stat
6b3c76
+
6b3c76
+
6b3c76
+EXTRA_DIST += stat.c
6b3c76
+
6b3c76
+EXTRA_libgnu_a_SOURCES += stat.c
6b3c76
+
6b3c76
+## end   gnulib module stat
6b3c76
+
6b3c76
 ## begin gnulib module stdalign
6b3c76
 
6b3c76
 BUILT_SOURCES += $(STDALIGN_H)
6b3c76
@@ -1280,6 +1314,102 @@ libgnu_a_SOURCES += strnlen1.h strnlen1.c
6b3c76
 
6b3c76
 ## end   gnulib module strnlen1
6b3c76
 
6b3c76
+## begin gnulib module sys_stat
6b3c76
+
6b3c76
+BUILT_SOURCES += sys/stat.h
6b3c76
+
6b3c76
+# We need the following in order to create <sys/stat.h> when the system
6b3c76
+# has one that is incomplete.
6b3c76
+sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
6b3c76
+	$(AM_V_at)$(MKDIR_P) sys
6b3c76
+	$(AM_V_GEN)rm -f $@-t $@ && \
6b3c76
+	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
6b3c76
+	  sed -e 's|@''GUARD_PREFIX''@|GL|g' \
6b3c76
+	      -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
6b3c76
+	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
6b3c76
+	      -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
6b3c76
+	      -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
6b3c76
+	      -e 's|@''WINDOWS_64_BIT_ST_SIZE''@|$(WINDOWS_64_BIT_ST_SIZE)|g' \
6b3c76
+	      -e 's/@''GNULIB_FCHMODAT''@/$(GNULIB_FCHMODAT)/g' \
6b3c76
+	      -e 's/@''GNULIB_FSTAT''@/$(GNULIB_FSTAT)/g' \
6b3c76
+	      -e 's/@''GNULIB_FSTATAT''@/$(GNULIB_FSTATAT)/g' \
6b3c76
+	      -e 's/@''GNULIB_FUTIMENS''@/$(GNULIB_FUTIMENS)/g' \
6b3c76
+	      -e 's/@''GNULIB_LCHMOD''@/$(GNULIB_LCHMOD)/g' \
6b3c76
+	      -e 's/@''GNULIB_LSTAT''@/$(GNULIB_LSTAT)/g' \
6b3c76
+	      -e 's/@''GNULIB_MKDIRAT''@/$(GNULIB_MKDIRAT)/g' \
6b3c76
+	      -e 's/@''GNULIB_MKFIFO''@/$(GNULIB_MKFIFO)/g' \
6b3c76
+	      -e 's/@''GNULIB_MKFIFOAT''@/$(GNULIB_MKFIFOAT)/g' \
6b3c76
+	      -e 's/@''GNULIB_MKNOD''@/$(GNULIB_MKNOD)/g' \
6b3c76
+	      -e 's/@''GNULIB_MKNODAT''@/$(GNULIB_MKNODAT)/g' \
6b3c76
+	      -e 's/@''GNULIB_STAT''@/$(GNULIB_STAT)/g' \
6b3c76
+	      -e 's/@''GNULIB_UTIMENSAT''@/$(GNULIB_UTIMENSAT)/g' \
6b3c76
+	      -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \
6b3c76
+	      -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \
6b3c76
+	      -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \
6b3c76
+	      -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \
6b3c76
+	      -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \
6b3c76
+	      -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \
6b3c76
+	      -e 's|@''HAVE_MKFIFO''@|$(HAVE_MKFIFO)|g' \
6b3c76
+	      -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \
6b3c76
+	      -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \
6b3c76
+	      -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \
6b3c76
+	      -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \
6b3c76
+	      -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \
6b3c76
+	      -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \
6b3c76
+	      -e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \
6b3c76
+	      -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \
6b3c76
+	      -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \
6b3c76
+	      -e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \
6b3c76
+	      -e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \
6b3c76
+	      -e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \
6b3c76
+	      -e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \
6b3c76
+	      -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
6b3c76
+	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
6b3c76
+	      -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
6b3c76
+	      < $(srcdir)/sys_stat.in.h; \
6b3c76
+	} > $@-t && \
6b3c76
+	mv $@-t $@
6b3c76
+MOSTLYCLEANFILES += sys/stat.h sys/stat.h-t
6b3c76
+MOSTLYCLEANDIRS += sys
6b3c76
+
6b3c76
+EXTRA_DIST += sys_stat.in.h
6b3c76
+
6b3c76
+## end   gnulib module sys_stat
6b3c76
+
6b3c76
+## begin gnulib module sys_time
6b3c76
+
6b3c76
+BUILT_SOURCES += sys/time.h
6b3c76
+
6b3c76
+# We need the following in order to create <sys/time.h> when the system
6b3c76
+# doesn't have one that works with the given compiler.
6b3c76
+sys/time.h: sys_time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
6b3c76
+	$(AM_V_at)$(MKDIR_P) sys
6b3c76
+	$(AM_V_GEN)rm -f $@-t $@ && \
6b3c76
+	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
6b3c76
+	  sed -e 's|@''GUARD_PREFIX''@|GL|g' \
6b3c76
+	      -e 's/@''HAVE_SYS_TIME_H''@/$(HAVE_SYS_TIME_H)/g' \
6b3c76
+	      -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
6b3c76
+	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
6b3c76
+	      -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
6b3c76
+	      -e 's|@''NEXT_SYS_TIME_H''@|$(NEXT_SYS_TIME_H)|g' \
6b3c76
+	      -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \
6b3c76
+	      -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
6b3c76
+	      -e 's/@''HAVE_GETTIMEOFDAY''@/$(HAVE_GETTIMEOFDAY)/g' \
6b3c76
+	      -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \
6b3c76
+	      -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \
6b3c76
+	      -e 's/@''REPLACE_STRUCT_TIMEVAL''@/$(REPLACE_STRUCT_TIMEVAL)/g' \
6b3c76
+	      -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
6b3c76
+	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
6b3c76
+	      -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
6b3c76
+	      < $(srcdir)/sys_time.in.h; \
6b3c76
+	} > $@-t && \
6b3c76
+	mv $@-t $@
6b3c76
+MOSTLYCLEANFILES += sys/time.h sys/time.h-t
6b3c76
+
6b3c76
+EXTRA_DIST += sys_time.in.h
6b3c76
+
6b3c76
+## end   gnulib module sys_time
6b3c76
+
6b3c76
 ## begin gnulib module sys_types
6b3c76
 
6b3c76
 BUILT_SOURCES += sys/types.h
6b3c76
@@ -1334,6 +1464,51 @@ EXTRA_DIST += sysexits.in.h
6b3c76
 
6b3c76
 ## end   gnulib module sysexits
6b3c76
 
6b3c76
+## begin gnulib module time
6b3c76
+
6b3c76
+BUILT_SOURCES += time.h
6b3c76
+
6b3c76
+# We need the following in order to create <time.h> when the system
6b3c76
+# doesn't have one that works with the given compiler.
6b3c76
+time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
6b3c76
+	$(AM_V_GEN)rm -f $@-t $@ && \
6b3c76
+	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
6b3c76
+	  sed -e 's|@''GUARD_PREFIX''@|GL|g' \
6b3c76
+	      -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
6b3c76
+	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
6b3c76
+	      -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
6b3c76
+	      -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \
6b3c76
+	      -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \
6b3c76
+	      -e 's/@''GNULIB_MKTIME''@/$(GNULIB_MKTIME)/g' \
6b3c76
+	      -e 's/@''GNULIB_NANOSLEEP''@/$(GNULIB_NANOSLEEP)/g' \
6b3c76
+	      -e 's/@''GNULIB_STRPTIME''@/$(GNULIB_STRPTIME)/g' \
6b3c76
+	      -e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \
6b3c76
+	      -e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \
6b3c76
+	      -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \
6b3c76
+	      -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \
6b3c76
+	      -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
6b3c76
+	      -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
6b3c76
+	      -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \
6b3c76
+	      -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \
6b3c76
+	      -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
6b3c76
+	      -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
6b3c76
+	      -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
6b3c76
+	      -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
6b3c76
+	      -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \
6b3c76
+	      -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
6b3c76
+	      -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
6b3c76
+	      -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
6b3c76
+	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
6b3c76
+	      -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
6b3c76
+	      < $(srcdir)/time.in.h; \
6b3c76
+	} > $@-t && \
6b3c76
+	mv $@-t $@
6b3c76
+MOSTLYCLEANFILES += time.h time.h-t
6b3c76
+
6b3c76
+EXTRA_DIST += time.in.h
6b3c76
+
6b3c76
+## end   gnulib module time
6b3c76
+
6b3c76
 ## begin gnulib module unistd
6b3c76
 
6b3c76
 BUILT_SOURCES += unistd.h
a85e8e
diff --git a/grub-core/gnulib/gettimeofday.c b/grub-core/gnulib/gettimeofday.c
a85e8e
new file mode 100644
6b3c76
index 000000000..8b2058e8c
a85e8e
--- /dev/null
a85e8e
+++ b/grub-core/gnulib/gettimeofday.c
a85e8e
@@ -0,0 +1,154 @@
a85e8e
+/* Provide gettimeofday for systems that don't have it or for which it's broken.
a85e8e
+
a85e8e
+   Copyright (C) 2001-2003, 2005-2007, 2009-2014 Free Software Foundation, Inc.
a85e8e
+
a85e8e
+   This program is free software; you can redistribute it and/or modify
a85e8e
+   it under the terms of the GNU General Public License as published by
a85e8e
+   the Free Software Foundation; either version 3, or (at your option)
a85e8e
+   any later version.
a85e8e
+
a85e8e
+   This program is distributed in the hope that it will be useful,
a85e8e
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
a85e8e
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a85e8e
+   GNU General Public License for more details.
a85e8e
+
a85e8e
+   You should have received a copy of the GNU General Public License
a85e8e
+   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
a85e8e
+
a85e8e
+/* written by Jim Meyering */
a85e8e
+
a85e8e
+#include <config.h>
a85e8e
+
a85e8e
+/* Specification.  */
a85e8e
+#include <sys/time.h>
a85e8e
+
a85e8e
+#include <time.h>
a85e8e
+
a85e8e
+#if HAVE_SYS_TIMEB_H
a85e8e
+# include <sys/timeb.h>
a85e8e
+#endif
a85e8e
+
a85e8e
+#if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME
a85e8e
+
a85e8e
+/* Work around the bug in some systems whereby gettimeofday clobbers
a85e8e
+   the static buffer that localtime uses for its return value.  The
a85e8e
+   gettimeofday function from Mac OS X 10.0.4 (i.e., Darwin 1.3.7) has
a85e8e
+   this problem.  The tzset replacement is necessary for at least
a85e8e
+   Solaris 2.5, 2.5.1, and 2.6.  */
a85e8e
+
a85e8e
+static struct tm tm_zero_buffer;
a85e8e
+static struct tm *localtime_buffer_addr = &tm_zero_buffer;
a85e8e
+
a85e8e
+# undef localtime
a85e8e
+extern struct tm *localtime (time_t const *);
a85e8e
+
a85e8e
+# undef gmtime
a85e8e
+extern struct tm *gmtime (time_t const *);
a85e8e
+
a85e8e
+/* This is a wrapper for localtime.  It is used only on systems for which
a85e8e
+   gettimeofday clobbers the static buffer used for localtime's result.
a85e8e
+
a85e8e
+   On the first call, record the address of the static buffer that
a85e8e
+   localtime uses for its result.  */
a85e8e
+
a85e8e
+struct tm *
a85e8e
+rpl_localtime (time_t const *timep)
a85e8e
+{
a85e8e
+  struct tm *tm = localtime (timep);
a85e8e
+
a85e8e
+  if (localtime_buffer_addr == &tm_zero_buffer)
a85e8e
+    localtime_buffer_addr = tm;
a85e8e
+
a85e8e
+  return tm;
a85e8e
+}
a85e8e
+
a85e8e
+/* Same as above, since gmtime and localtime use the same buffer.  */
a85e8e
+struct tm *
a85e8e
+rpl_gmtime (time_t const *timep)
a85e8e
+{
a85e8e
+  struct tm *tm = gmtime (timep);
a85e8e
+
a85e8e
+  if (localtime_buffer_addr == &tm_zero_buffer)
a85e8e
+    localtime_buffer_addr = tm;
a85e8e
+
a85e8e
+  return tm;
a85e8e
+}
a85e8e
+
a85e8e
+#endif /* GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME */
a85e8e
+
a85e8e
+#if TZSET_CLOBBERS_LOCALTIME
a85e8e
+
a85e8e
+# undef tzset
a85e8e
+extern void tzset (void);
a85e8e
+
a85e8e
+/* This is a wrapper for tzset, for systems on which tzset may clobber
a85e8e
+   the static buffer used for localtime's result.  */
a85e8e
+void
a85e8e
+rpl_tzset (void)
a85e8e
+{
a85e8e
+  /* Save and restore the contents of the buffer used for localtime's
a85e8e
+     result around the call to tzset.  */
a85e8e
+  struct tm save = *localtime_buffer_addr;
a85e8e
+  tzset ();
a85e8e
+  *localtime_buffer_addr = save;
a85e8e
+}
a85e8e
+#endif
a85e8e
+
a85e8e
+/* This is a wrapper for gettimeofday.  It is used only on systems
a85e8e
+   that lack this function, or whose implementation of this function
a85e8e
+   causes problems.  */
a85e8e
+
a85e8e
+int
a85e8e
+gettimeofday (struct timeval *restrict tv, void *restrict tz)
a85e8e
+{
a85e8e
+#undef gettimeofday
a85e8e
+#if HAVE_GETTIMEOFDAY
a85e8e
+# if GETTIMEOFDAY_CLOBBERS_LOCALTIME
a85e8e
+  /* Save and restore the contents of the buffer used for localtime's
a85e8e
+     result around the call to gettimeofday.  */
a85e8e
+  struct tm save = *localtime_buffer_addr;
a85e8e
+# endif
a85e8e
+
a85e8e
+# if defined timeval /* 'struct timeval' overridden by gnulib?  */
a85e8e
+#  undef timeval
a85e8e
+  struct timeval otv;
a85e8e
+  int result = gettimeofday (&otv, (struct timezone *) tz);
a85e8e
+  if (result == 0)
a85e8e
+    {
a85e8e
+      tv->tv_sec = otv.tv_sec;
a85e8e
+      tv->tv_usec = otv.tv_usec;
a85e8e
+    }
a85e8e
+# else
a85e8e
+  int result = gettimeofday (tv, (struct timezone *) tz);
a85e8e
+# endif
a85e8e
+
a85e8e
+# if GETTIMEOFDAY_CLOBBERS_LOCALTIME
a85e8e
+  *localtime_buffer_addr = save;
a85e8e
+# endif
a85e8e
+
a85e8e
+  return result;
a85e8e
+
a85e8e
+#else
a85e8e
+
a85e8e
+# if HAVE__FTIME
a85e8e
+
a85e8e
+  struct _timeb timebuf;
a85e8e
+  _ftime (&timebuf);
a85e8e
+  tv->tv_sec = timebuf.time;
a85e8e
+  tv->tv_usec = timebuf.millitm * 1000;
a85e8e
+
a85e8e
+# else
a85e8e
+
a85e8e
+#  if !defined OK_TO_USE_1S_CLOCK
a85e8e
+#   error "Only 1-second nominal clock resolution found.  Is that intended?" \
a85e8e
+          "If so, compile with the -DOK_TO_USE_1S_CLOCK option."
a85e8e
+#  endif
a85e8e
+  tv->tv_sec = time (NULL);
a85e8e
+  tv->tv_usec = 0;
a85e8e
+
a85e8e
+# endif
a85e8e
+
a85e8e
+  return 0;
a85e8e
+
a85e8e
+#endif
a85e8e
+}
6b3c76
diff --git a/grub-core/gnulib/pathmax.h b/grub-core/gnulib/pathmax.h
6b3c76
new file mode 100644
6b3c76
index 000000000..33fc3553d
6b3c76
--- /dev/null
6b3c76
+++ b/grub-core/gnulib/pathmax.h
6b3c76
@@ -0,0 +1,83 @@
6b3c76
+/* Define PATH_MAX somehow.  Requires sys/types.h.
6b3c76
+   Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2014 Free Software
6b3c76
+   Foundation, Inc.
6b3c76
+
6b3c76
+   This program is free software; you can redistribute it and/or modify
6b3c76
+   it under the terms of the GNU General Public License as published by
6b3c76
+   the Free Software Foundation; either version 3, or (at your option)
6b3c76
+   any later version.
6b3c76
+
6b3c76
+   This program is distributed in the hope that it will be useful,
6b3c76
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
6b3c76
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6b3c76
+   GNU General Public License for more details.
6b3c76
+
6b3c76
+   You should have received a copy of the GNU General Public License
6b3c76
+   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
6b3c76
+
6b3c76
+#ifndef _PATHMAX_H
6b3c76
+# define _PATHMAX_H
6b3c76
+
6b3c76
+/* POSIX:2008 defines PATH_MAX to be the maximum number of bytes in a filename,
6b3c76
+   including the terminating NUL byte.
6b3c76
+   <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html>
6b3c76
+   PATH_MAX is not defined on systems which have no limit on filename length,
6b3c76
+   such as GNU/Hurd.
6b3c76
+
6b3c76
+   This file does *not* define PATH_MAX always.  Programs that use this file
6b3c76
+   can handle the GNU/Hurd case in several ways:
6b3c76
+     - Either with a package-wide handling, or with a per-file handling,
6b3c76
+     - Either through a
6b3c76
+         #ifdef PATH_MAX
6b3c76
+       or through a fallback like
6b3c76
+         #ifndef PATH_MAX
6b3c76
+         # define PATH_MAX 8192
6b3c76
+         #endif
6b3c76
+       or through a fallback like
6b3c76
+         #ifndef PATH_MAX
6b3c76
+         # define PATH_MAX pathconf ("/", _PC_PATH_MAX)
6b3c76
+         #endif
6b3c76
+ */
6b3c76
+
6b3c76
+# include <unistd.h>
6b3c76
+
6b3c76
+# include <limits.h>
6b3c76
+
6b3c76
+# ifndef _POSIX_PATH_MAX
6b3c76
+#  define _POSIX_PATH_MAX 256
6b3c76
+# endif
6b3c76
+
6b3c76
+/* Don't include sys/param.h if it already has been.  */
6b3c76
+# if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN
6b3c76
+#  include <sys/param.h>
6b3c76
+# endif
6b3c76
+
6b3c76
+# if !defined PATH_MAX && defined MAXPATHLEN
6b3c76
+#  define PATH_MAX MAXPATHLEN
6b3c76
+# endif
6b3c76
+
6b3c76
+# ifdef __hpux
6b3c76
+/* On HP-UX, PATH_MAX designates the maximum number of bytes in a filename,
6b3c76
+   *not* including the terminating NUL byte, and is set to 1023.
6b3c76
+   Additionally, when _XOPEN_SOURCE is defined to 500 or more, PATH_MAX is
6b3c76
+   not defined at all any more.  */
6b3c76
+#  undef PATH_MAX
6b3c76
+#  define PATH_MAX 1024
6b3c76
+# endif
6b3c76
+
6b3c76
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
6b3c76
+/* The page "Naming Files, Paths, and Namespaces" on msdn.microsoft.com,
6b3c76
+   section "Maximum Path Length Limitation",
6b3c76
+   <http://msdn.microsoft.com/en-us/library/aa365247(v=vs.85).aspx#maxpath>
6b3c76
+   explains that the maximum size of a filename, including the terminating
6b3c76
+   NUL byte, is 260 = 3 + 256 + 1.
6b3c76
+   This is the same value as
6b3c76
+     - FILENAME_MAX in <stdio.h>,
6b3c76
+     - _MAX_PATH in <stdlib.h>,
6b3c76
+     - MAX_PATH in <windef.h>.
6b3c76
+   Undefine the original value, because mingw's <limits.h> gets it wrong.  */
6b3c76
+#  undef PATH_MAX
6b3c76
+#  define PATH_MAX 260
6b3c76
+# endif
6b3c76
+
6b3c76
+#endif /* _PATHMAX_H */
a85e8e
diff --git a/grub-core/gnulib/readlink.c b/grub-core/gnulib/readlink.c
a85e8e
new file mode 100644
6b3c76
index 000000000..4c4963951
a85e8e
--- /dev/null
a85e8e
+++ b/grub-core/gnulib/readlink.c
a85e8e
@@ -0,0 +1,74 @@
a85e8e
+/* Stub for readlink().
a85e8e
+   Copyright (C) 2003-2007, 2009-2014 Free Software Foundation, Inc.
a85e8e
+
a85e8e
+   This program is free software: you can redistribute it and/or modify
a85e8e
+   it under the terms of the GNU General Public License as published by
a85e8e
+   the Free Software Foundation; either version 3 of the License, or
a85e8e
+   (at your option) any later version.
a85e8e
+
a85e8e
+   This program is distributed in the hope that it will be useful,
a85e8e
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
a85e8e
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a85e8e
+   GNU General Public License for more details.
a85e8e
+
a85e8e
+   You should have received a copy of the GNU General Public License
a85e8e
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
a85e8e
+
a85e8e
+#include <config.h>
a85e8e
+
a85e8e
+/* Specification.  */
a85e8e
+#include <unistd.h>
a85e8e
+
a85e8e
+#include <errno.h>
a85e8e
+#include <string.h>
a85e8e
+#include <sys/stat.h>
a85e8e
+
a85e8e
+#if !HAVE_READLINK
a85e8e
+
a85e8e
+/* readlink() substitute for systems that don't have a readlink() function,
a85e8e
+   such as DJGPP 2.03 and mingw32.  */
a85e8e
+
a85e8e
+ssize_t
a85e8e
+readlink (const char *name, char *buf _GL_UNUSED,
a85e8e
+          size_t bufsize _GL_UNUSED)
a85e8e
+{
a85e8e
+  struct stat statbuf;
a85e8e
+
a85e8e
+  /* In general we should use lstat() here, not stat().  But on platforms
a85e8e
+     without symbolic links, lstat() - if it exists - would be equivalent to
a85e8e
+     stat(), therefore we can use stat().  This saves us a configure check.  */
a85e8e
+  if (stat (name, &statbuf) >= 0)
a85e8e
+    errno = EINVAL;
a85e8e
+  return -1;
a85e8e
+}
a85e8e
+
a85e8e
+#else /* HAVE_READLINK */
a85e8e
+
a85e8e
+# undef readlink
a85e8e
+
a85e8e
+/* readlink() wrapper that uses correct types, for systems like cygwin
a85e8e
+   1.5.x where readlink returns int, and which rejects trailing slash,
a85e8e
+   for Solaris 9.  */
a85e8e
+
a85e8e
+ssize_t
a85e8e
+rpl_readlink (const char *name, char *buf, size_t bufsize)
a85e8e
+{
a85e8e
+# if READLINK_TRAILING_SLASH_BUG
a85e8e
+  size_t len = strlen (name);
a85e8e
+  if (len && name[len - 1] == '/')
a85e8e
+    {
a85e8e
+      /* Even if name without the slash is a symlink to a directory,
a85e8e
+         both lstat() and stat() must resolve the trailing slash to
a85e8e
+         the directory rather than the symlink.  We can therefore
a85e8e
+         safely use stat() to distinguish between EINVAL and
a85e8e
+         ENOTDIR/ENOENT, avoiding extra overhead of rpl_lstat().  */
a85e8e
+      struct stat st;
a85e8e
+      if (stat (name, &st) == 0)
a85e8e
+        errno = EINVAL;
a85e8e
+      return -1;
a85e8e
+    }
a85e8e
+# endif /* READLINK_TRAILING_SLASH_BUG */
a85e8e
+  return readlink (name, buf, bufsize);
a85e8e
+}
a85e8e
+
a85e8e
+#endif /* HAVE_READLINK */
a85e8e
diff --git a/grub-core/gnulib/stat.c b/grub-core/gnulib/stat.c
a85e8e
new file mode 100644
6b3c76
index 000000000..35f4b0b1a
a85e8e
--- /dev/null
a85e8e
+++ b/grub-core/gnulib/stat.c
a85e8e
@@ -0,0 +1,138 @@
a85e8e
+/* Work around platform bugs in stat.
a85e8e
+   Copyright (C) 2009-2014 Free Software Foundation, Inc.
a85e8e
+
a85e8e
+   This program is free software: you can redistribute it and/or modify
a85e8e
+   it under the terms of the GNU General Public License as published by
a85e8e
+   the Free Software Foundation; either version 3 of the License, or
a85e8e
+   (at your option) any later version.
a85e8e
+
a85e8e
+   This program is distributed in the hope that it will be useful,
a85e8e
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
a85e8e
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a85e8e
+   GNU General Public License for more details.
a85e8e
+
a85e8e
+   You should have received a copy of the GNU General Public License
a85e8e
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
a85e8e
+
a85e8e
+/* written by Eric Blake */
a85e8e
+
a85e8e
+/* If the user's config.h happens to include <sys/stat.h>, let it include only
a85e8e
+   the system's <sys/stat.h> here, so that orig_stat doesn't recurse to
a85e8e
+   rpl_stat.  */
a85e8e
+#define __need_system_sys_stat_h
a85e8e
+#include <config.h>
a85e8e
+
a85e8e
+/* Get the original definition of stat.  It might be defined as a macro.  */
a85e8e
+#include <sys/types.h>
a85e8e
+#include <sys/stat.h>
a85e8e
+#undef __need_system_sys_stat_h
a85e8e
+
a85e8e
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
a85e8e
+# if _GL_WINDOWS_64_BIT_ST_SIZE
a85e8e
+#  undef stat /* avoid warning on mingw64 with _FILE_OFFSET_BITS=64 */
a85e8e
+#  define stat _stati64
a85e8e
+#  define REPLACE_FUNC_STAT_DIR 1
a85e8e
+#  undef REPLACE_FUNC_STAT_FILE
a85e8e
+# elif REPLACE_FUNC_STAT_FILE
a85e8e
+/* mingw64 has a broken stat() function, based on _stat(), in libmingwex.a.
a85e8e
+   Bypass it.  */
a85e8e
+#  define stat _stat
a85e8e
+#  define REPLACE_FUNC_STAT_DIR 1
a85e8e
+#  undef REPLACE_FUNC_STAT_FILE
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+static int
a85e8e
+orig_stat (const char *filename, struct stat *buf)
a85e8e
+{
a85e8e
+  return stat (filename, buf);
a85e8e
+}
a85e8e
+
a85e8e
+/* Specification.  */
a85e8e
+/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
a85e8e
+   eliminates this include because of the preliminary #include <sys/stat.h>
a85e8e
+   above.  */
a85e8e
+#include "sys/stat.h"
a85e8e
+
a85e8e
+#include <errno.h>
a85e8e
+#include <limits.h>
a85e8e
+#include <stdbool.h>
a85e8e
+#include <string.h>
a85e8e
+#include "dosname.h"
a85e8e
+#include "verify.h"
a85e8e
+
a85e8e
+#if REPLACE_FUNC_STAT_DIR
a85e8e
+# include "pathmax.h"
a85e8e
+  /* The only known systems where REPLACE_FUNC_STAT_DIR is needed also
a85e8e
+     have a constant PATH_MAX.  */
a85e8e
+# ifndef PATH_MAX
a85e8e
+#  error "Please port this replacement to your platform"
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+/* Store information about NAME into ST.  Work around bugs with
a85e8e
+   trailing slashes.  Mingw has other bugs (such as st_ino always
a85e8e
+   being 0 on success) which this wrapper does not work around.  But
a85e8e
+   at least this implementation provides the ability to emulate fchdir
a85e8e
+   correctly.  */
a85e8e
+
a85e8e
+int
a85e8e
+rpl_stat (char const *name, struct stat *st)
a85e8e
+{
a85e8e
+  int result = orig_stat (name, st);
a85e8e
+#if REPLACE_FUNC_STAT_FILE
a85e8e
+  /* Solaris 9 mistakenly succeeds when given a non-directory with a
a85e8e
+     trailing slash.  */
a85e8e
+  if (result == 0 && !S_ISDIR (st->st_mode))
a85e8e
+    {
a85e8e
+      size_t len = strlen (name);
a85e8e
+      if (ISSLASH (name[len - 1]))
a85e8e
+        {
a85e8e
+          errno = ENOTDIR;
a85e8e
+          return -1;
a85e8e
+        }
a85e8e
+    }
a85e8e
+#endif /* REPLACE_FUNC_STAT_FILE */
a85e8e
+#if REPLACE_FUNC_STAT_DIR
a85e8e
+
a85e8e
+  if (result == -1 && errno == ENOENT)
a85e8e
+    {
a85e8e
+      /* Due to mingw's oddities, there are some directories (like
a85e8e
+         c:\) where stat() only succeeds with a trailing slash, and
a85e8e
+         other directories (like c:\windows) where stat() only
a85e8e
+         succeeds without a trailing slash.  But we want the two to be
a85e8e
+         synonymous, since chdir() manages either style.  Likewise, Mingw also
a85e8e
+         reports ENOENT for names longer than PATH_MAX, when we want
a85e8e
+         ENAMETOOLONG, and for stat("file/"), when we want ENOTDIR.
a85e8e
+         Fortunately, mingw PATH_MAX is small enough for stack
a85e8e
+         allocation.  */
a85e8e
+      char fixed_name[PATH_MAX + 1] = {0};
a85e8e
+      size_t len = strlen (name);
a85e8e
+      bool check_dir = false;
a85e8e
+      verify (PATH_MAX <= 4096);
a85e8e
+      if (PATH_MAX <= len)
a85e8e
+        errno = ENAMETOOLONG;
a85e8e
+      else if (len)
a85e8e
+        {
a85e8e
+          strcpy (fixed_name, name);
a85e8e
+          if (ISSLASH (fixed_name[len - 1]))
a85e8e
+            {
a85e8e
+              check_dir = true;
a85e8e
+              while (len && ISSLASH (fixed_name[len - 1]))
a85e8e
+                fixed_name[--len] = '\0';
a85e8e
+              if (!len)
a85e8e
+                fixed_name[0] = '/';
a85e8e
+            }
a85e8e
+          else
a85e8e
+            fixed_name[len++] = '/';
a85e8e
+          result = orig_stat (fixed_name, st);
6b3c76
+          if (result == 0 && check_dir && !S_ISDIR (st->st_mode))
6b3c76
+            {
6b3c76
+              result = -1;
6b3c76
+              errno = ENOTDIR;
6b3c76
+            }
6b3c76
+        }
6b3c76
+    }
6b3c76
+#endif /* REPLACE_FUNC_STAT_DIR */
6b3c76
+  return result;
6b3c76
+}
a85e8e
diff --git a/grub-core/gnulib/sys_stat.in.h b/grub-core/gnulib/sys_stat.in.h
a85e8e
new file mode 100644
6b3c76
index 000000000..b47a7ff0a
a85e8e
--- /dev/null
a85e8e
+++ b/grub-core/gnulib/sys_stat.in.h
a85e8e
@@ -0,0 +1,732 @@
a85e8e
+/* Provide a more complete sys/stat header file.
a85e8e
+   Copyright (C) 2005-2014 Free Software Foundation, Inc.
a85e8e
+
a85e8e
+   This program is free software; you can redistribute it and/or modify
a85e8e
+   it under the terms of the GNU General Public License as published by
a85e8e
+   the Free Software Foundation; either version 3, or (at your option)
a85e8e
+   any later version.
a85e8e
+
a85e8e
+   This program is distributed in the hope that it will be useful,
a85e8e
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
a85e8e
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a85e8e
+   GNU General Public License for more details.
a85e8e
+
a85e8e
+   You should have received a copy of the GNU General Public License
a85e8e
+   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
a85e8e
+
a85e8e
+/* Written by Eric Blake, Paul Eggert, and Jim Meyering.  */
a85e8e
+
a85e8e
+/* This file is supposed to be used on platforms where <sys/stat.h> is
a85e8e
+   incomplete.  It is intended to provide definitions and prototypes
a85e8e
+   needed by an application.  Start with what the system provides.  */
a85e8e
+
a85e8e
+#if __GNUC__ >= 3
a85e8e
+@PRAGMA_SYSTEM_HEADER@
a85e8e
+#endif
a85e8e
+@PRAGMA_COLUMNS@
a85e8e
+
a85e8e
+#if defined __need_system_sys_stat_h
a85e8e
+/* Special invocation convention.  */
a85e8e
+
a85e8e
+#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
a85e8e
+
a85e8e
+#else
a85e8e
+/* Normal invocation convention.  */
a85e8e
+
a85e8e
+#ifndef _@GUARD_PREFIX@_SYS_STAT_H
a85e8e
+
a85e8e
+/* Get nlink_t.
a85e8e
+   May also define off_t to a 64-bit type on native Windows.  */
a85e8e
+#include <sys/types.h>
a85e8e
+
a85e8e
+/* Get struct timespec.  */
a85e8e
+#include <time.h>
a85e8e
+
a85e8e
+/* The include_next requires a split double-inclusion guard.  */
a85e8e
+#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
a85e8e
+
a85e8e
+#ifndef _@GUARD_PREFIX@_SYS_STAT_H
a85e8e
+#define _@GUARD_PREFIX@_SYS_STAT_H
a85e8e
+
a85e8e
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
a85e8e
+
a85e8e
+/* The definition of _GL_ARG_NONNULL is copied here.  */
a85e8e
+
a85e8e
+/* The definition of _GL_WARN_ON_USE is copied here.  */
a85e8e
+
a85e8e
+/* Before doing "#define mkdir rpl_mkdir" below, we need to include all
a85e8e
+   headers that may declare mkdir().  Native Windows platforms declare mkdir
a85e8e
+   in <io.h> and/or <direct.h>, not in <unistd.h>.  */
a85e8e
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
a85e8e
+# include <io.h>     /* mingw32, mingw64 */
a85e8e
+# include <direct.h> /* mingw64, MSVC 9 */
a85e8e
+#endif
a85e8e
+
a85e8e
+/* Native Windows platforms declare umask() in <io.h>.  */
a85e8e
+#if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
a85e8e
+# include <io.h>
a85e8e
+#endif
a85e8e
+
a85e8e
+/* Large File Support on native Windows.  */
a85e8e
+#if @WINDOWS_64_BIT_ST_SIZE@
a85e8e
+# define stat _stati64
a85e8e
+#endif
a85e8e
+
a85e8e
+#ifndef S_IFIFO
a85e8e
+# ifdef _S_IFIFO
a85e8e
+#  define S_IFIFO _S_IFIFO
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+#ifndef S_IFMT
a85e8e
+# define S_IFMT 0170000
a85e8e
+#endif
a85e8e
+
a85e8e
+#if STAT_MACROS_BROKEN
a85e8e
+# undef S_ISBLK
a85e8e
+# undef S_ISCHR
a85e8e
+# undef S_ISDIR
a85e8e
+# undef S_ISFIFO
a85e8e
+# undef S_ISLNK
a85e8e
+# undef S_ISNAM
a85e8e
+# undef S_ISMPB
a85e8e
+# undef S_ISMPC
a85e8e
+# undef S_ISNWK
a85e8e
+# undef S_ISREG
a85e8e
+# undef S_ISSOCK
a85e8e
+#endif
a85e8e
+
a85e8e
+#ifndef S_ISBLK
a85e8e
+# ifdef S_IFBLK
a85e8e
+#  define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
a85e8e
+# else
a85e8e
+#  define S_ISBLK(m) 0
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+#ifndef S_ISCHR
a85e8e
+# ifdef S_IFCHR
a85e8e
+#  define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
a85e8e
+# else
a85e8e
+#  define S_ISCHR(m) 0
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+#ifndef S_ISDIR
a85e8e
+# ifdef S_IFDIR
a85e8e
+#  define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
a85e8e
+# else
a85e8e
+#  define S_ISDIR(m) 0
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+#ifndef S_ISDOOR /* Solaris 2.5 and up */
a85e8e
+# define S_ISDOOR(m) 0
a85e8e
+#endif
a85e8e
+
a85e8e
+#ifndef S_ISFIFO
a85e8e
+# ifdef S_IFIFO
a85e8e
+#  define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
a85e8e
+# else
a85e8e
+#  define S_ISFIFO(m) 0
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+#ifndef S_ISLNK
a85e8e
+# ifdef S_IFLNK
a85e8e
+#  define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
a85e8e
+# else
a85e8e
+#  define S_ISLNK(m) 0
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+#ifndef S_ISMPB /* V7 */
a85e8e
+# ifdef S_IFMPB
a85e8e
+#  define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
a85e8e
+#  define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
a85e8e
+# else
a85e8e
+#  define S_ISMPB(m) 0
a85e8e
+#  define S_ISMPC(m) 0
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+#ifndef S_ISMPX /* AIX */
a85e8e
+# define S_ISMPX(m) 0
a85e8e
+#endif
a85e8e
+
a85e8e
+#ifndef S_ISNAM /* Xenix */
a85e8e
+# ifdef S_IFNAM
a85e8e
+#  define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
a85e8e
+# else
a85e8e
+#  define S_ISNAM(m) 0
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+#ifndef S_ISNWK /* HP/UX */
a85e8e
+# ifdef S_IFNWK
a85e8e
+#  define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
a85e8e
+# else
a85e8e
+#  define S_ISNWK(m) 0
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+#ifndef S_ISPORT /* Solaris 10 and up */
a85e8e
+# define S_ISPORT(m) 0
a85e8e
+#endif
a85e8e
+
a85e8e
+#ifndef S_ISREG
a85e8e
+# ifdef S_IFREG
a85e8e
+#  define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
a85e8e
+# else
a85e8e
+#  define S_ISREG(m) 0
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+#ifndef S_ISSOCK
a85e8e
+# ifdef S_IFSOCK
a85e8e
+#  define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
a85e8e
+# else
a85e8e
+#  define S_ISSOCK(m) 0
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+
a85e8e
+#ifndef S_TYPEISMQ
a85e8e
+# define S_TYPEISMQ(p) 0
a85e8e
+#endif
a85e8e
+
a85e8e
+#ifndef S_TYPEISTMO
a85e8e
+# define S_TYPEISTMO(p) 0
a85e8e
+#endif
a85e8e
+
a85e8e
+
a85e8e
+#ifndef S_TYPEISSEM
a85e8e
+# ifdef S_INSEM
a85e8e
+#  define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
a85e8e
+# else
a85e8e
+#  define S_TYPEISSEM(p) 0
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+#ifndef S_TYPEISSHM
a85e8e
+# ifdef S_INSHD
a85e8e
+#  define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
a85e8e
+# else
a85e8e
+#  define S_TYPEISSHM(p) 0
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+/* high performance ("contiguous data") */
a85e8e
+#ifndef S_ISCTG
a85e8e
+# define S_ISCTG(p) 0
a85e8e
+#endif
a85e8e
+
a85e8e
+/* Cray DMF (data migration facility): off line, with data  */
a85e8e
+#ifndef S_ISOFD
a85e8e
+# define S_ISOFD(p) 0
a85e8e
+#endif
a85e8e
+
a85e8e
+/* Cray DMF (data migration facility): off line, with no data  */
a85e8e
+#ifndef S_ISOFL
a85e8e
+# define S_ISOFL(p) 0
a85e8e
+#endif
a85e8e
+
a85e8e
+/* 4.4BSD whiteout */
a85e8e
+#ifndef S_ISWHT
a85e8e
+# define S_ISWHT(m) 0
a85e8e
+#endif
a85e8e
+
a85e8e
+/* If any of the following are undefined,
a85e8e
+   define them to their de facto standard values.  */
a85e8e
+#if !S_ISUID
a85e8e
+# define S_ISUID 04000
a85e8e
+#endif
a85e8e
+#if !S_ISGID
a85e8e
+# define S_ISGID 02000
a85e8e
+#endif
a85e8e
+
a85e8e
+/* S_ISVTX is a common extension to POSIX.  */
a85e8e
+#ifndef S_ISVTX
a85e8e
+# define S_ISVTX 01000
a85e8e
+#endif
a85e8e
+
a85e8e
+#if !S_IRUSR && S_IREAD
a85e8e
+# define S_IRUSR S_IREAD
a85e8e
+#endif
a85e8e
+#if !S_IRUSR
a85e8e
+# define S_IRUSR 00400
a85e8e
+#endif
a85e8e
+#if !S_IRGRP
a85e8e
+# define S_IRGRP (S_IRUSR >> 3)
a85e8e
+#endif
a85e8e
+#if !S_IROTH
a85e8e
+# define S_IROTH (S_IRUSR >> 6)
a85e8e
+#endif
a85e8e
+
a85e8e
+#if !S_IWUSR && S_IWRITE
a85e8e
+# define S_IWUSR S_IWRITE
a85e8e
+#endif
a85e8e
+#if !S_IWUSR
a85e8e
+# define S_IWUSR 00200
a85e8e
+#endif
a85e8e
+#if !S_IWGRP
a85e8e
+# define S_IWGRP (S_IWUSR >> 3)
a85e8e
+#endif
a85e8e
+#if !S_IWOTH
a85e8e
+# define S_IWOTH (S_IWUSR >> 6)
a85e8e
+#endif
a85e8e
+
a85e8e
+#if !S_IXUSR && S_IEXEC
a85e8e
+# define S_IXUSR S_IEXEC
a85e8e
+#endif
a85e8e
+#if !S_IXUSR
a85e8e
+# define S_IXUSR 00100
a85e8e
+#endif
a85e8e
+#if !S_IXGRP
a85e8e
+# define S_IXGRP (S_IXUSR >> 3)
a85e8e
+#endif
a85e8e
+#if !S_IXOTH
a85e8e
+# define S_IXOTH (S_IXUSR >> 6)
a85e8e
+#endif
a85e8e
+
a85e8e
+#if !S_IRWXU
a85e8e
+# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
a85e8e
+#endif
a85e8e
+#if !S_IRWXG
a85e8e
+# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
a85e8e
+#endif
a85e8e
+#if !S_IRWXO
a85e8e
+# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
a85e8e
+#endif
a85e8e
+
a85e8e
+/* S_IXUGO is a common extension to POSIX.  */
a85e8e
+#if !S_IXUGO
a85e8e
+# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
a85e8e
+#endif
a85e8e
+
a85e8e
+#ifndef S_IRWXUGO
a85e8e
+# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
a85e8e
+#endif
a85e8e
+
a85e8e
+/* Macros for futimens and utimensat.  */
a85e8e
+#ifndef UTIME_NOW
a85e8e
+# define UTIME_NOW (-1)
a85e8e
+# define UTIME_OMIT (-2)
a85e8e
+#endif
a85e8e
+
a85e8e
+
a85e8e
+#if @GNULIB_FCHMODAT@
a85e8e
+# if !@HAVE_FCHMODAT@
a85e8e
+_GL_FUNCDECL_SYS (fchmodat, int,
a85e8e
+                  (int fd, char const *file, mode_t mode, int flag)
a85e8e
+                  _GL_ARG_NONNULL ((2)));
a85e8e
+# endif
a85e8e
+_GL_CXXALIAS_SYS (fchmodat, int,
a85e8e
+                  (int fd, char const *file, mode_t mode, int flag));
a85e8e
+_GL_CXXALIASWARN (fchmodat);
a85e8e
+#elif defined GNULIB_POSIXCHECK
a85e8e
+# undef fchmodat
a85e8e
+# if HAVE_RAW_DECL_FCHMODAT
a85e8e
+_GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - "
a85e8e
+                 "use gnulib module openat for portability");
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+
a85e8e
+#if @GNULIB_FSTAT@
a85e8e
+# if @REPLACE_FSTAT@
a85e8e
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#   undef fstat
a85e8e
+#   define fstat rpl_fstat
a85e8e
+#  endif
a85e8e
+_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2)));
a85e8e
+_GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
a85e8e
+# else
a85e8e
+_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
a85e8e
+# endif
a85e8e
+_GL_CXXALIASWARN (fstat);
a85e8e
+#elif @WINDOWS_64_BIT_ST_SIZE@
a85e8e
+/* Above, we define stat to _stati64.  */
a85e8e
+# define fstat _fstati64
a85e8e
+#elif defined GNULIB_POSIXCHECK
a85e8e
+# undef fstat
a85e8e
+# if HAVE_RAW_DECL_FSTAT
a85e8e
+_GL_WARN_ON_USE (fstat, "fstat has portability problems - "
a85e8e
+                 "use gnulib module fstat for portability");
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+
a85e8e
+#if @GNULIB_FSTATAT@
a85e8e
+# if @REPLACE_FSTATAT@
a85e8e
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#   undef fstatat
a85e8e
+#   define fstatat rpl_fstatat
a85e8e
+#  endif
a85e8e
+_GL_FUNCDECL_RPL (fstatat, int,
a85e8e
+                  (int fd, char const *name, struct stat *st, int flags)
a85e8e
+                  _GL_ARG_NONNULL ((2, 3)));
a85e8e
+_GL_CXXALIAS_RPL (fstatat, int,
a85e8e
+                  (int fd, char const *name, struct stat *st, int flags));
a85e8e
+# else
a85e8e
+#  if !@HAVE_FSTATAT@
a85e8e
+_GL_FUNCDECL_SYS (fstatat, int,
a85e8e
+                  (int fd, char const *name, struct stat *st, int flags)
a85e8e
+                  _GL_ARG_NONNULL ((2, 3)));
a85e8e
+#  endif
a85e8e
+_GL_CXXALIAS_SYS (fstatat, int,
a85e8e
+                  (int fd, char const *name, struct stat *st, int flags));
a85e8e
+# endif
a85e8e
+_GL_CXXALIASWARN (fstatat);
a85e8e
+#elif defined GNULIB_POSIXCHECK
a85e8e
+# undef fstatat
a85e8e
+# if HAVE_RAW_DECL_FSTATAT
a85e8e
+_GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
a85e8e
+                 "use gnulib module openat for portability");
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+
a85e8e
+#if @GNULIB_FUTIMENS@
a85e8e
+/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens
a85e8e
+   implementation relies on futimesat, which on Solaris 10 makes an invocation
a85e8e
+   to futimens that is meant to invoke the libc's futimens(), not gnulib's
a85e8e
+   futimens().  */
a85e8e
+# if @REPLACE_FUTIMENS@ || (!@HAVE_FUTIMENS@ && defined __sun)
a85e8e
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#   undef futimens
a85e8e
+#   define futimens rpl_futimens
a85e8e
+#  endif
a85e8e
+_GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2]));
a85e8e
+_GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2]));
a85e8e
+# else
a85e8e
+#  if !@HAVE_FUTIMENS@
a85e8e
+_GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]));
a85e8e
+#  endif
a85e8e
+_GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
a85e8e
+# endif
a85e8e
+# if @HAVE_FUTIMENS@
a85e8e
+_GL_CXXALIASWARN (futimens);
a85e8e
+# endif
a85e8e
+#elif defined GNULIB_POSIXCHECK
a85e8e
+# undef futimens
a85e8e
+# if HAVE_RAW_DECL_FUTIMENS
a85e8e
+_GL_WARN_ON_USE (futimens, "futimens is not portable - "
a85e8e
+                 "use gnulib module futimens for portability");
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+
a85e8e
+#if @GNULIB_LCHMOD@
a85e8e
+/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
a85e8e
+   denotes a symbolic link.  */
a85e8e
+# if !@HAVE_LCHMOD@
a85e8e
+/* The lchmod replacement follows symbolic links.  Callers should take
a85e8e
+   this into account; lchmod should be applied only to arguments that
a85e8e
+   are known to not be symbolic links.  On hosts that lack lchmod,
a85e8e
+   this can lead to race conditions between the check and the
a85e8e
+   invocation of lchmod, but we know of no workarounds that are
a85e8e
+   reliable in general.  You might try requesting support for lchmod
a85e8e
+   from your operating system supplier.  */
a85e8e
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#   define lchmod chmod
a85e8e
+#  endif
a85e8e
+/* Need to cast, because on mingw, the second parameter of chmod is
a85e8e
+                                                int mode.  */
a85e8e
+_GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int,
a85e8e
+                         (const char *filename, mode_t mode));
a85e8e
+# else
a85e8e
+#  if 0 /* assume already declared */
a85e8e
+_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
a85e8e
+                               _GL_ARG_NONNULL ((1)));
a85e8e
+#  endif
a85e8e
+_GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode));
a85e8e
+# endif
a85e8e
+# if @HAVE_LCHMOD@
a85e8e
+_GL_CXXALIASWARN (lchmod);
a85e8e
+# endif
a85e8e
+#elif defined GNULIB_POSIXCHECK
a85e8e
+# undef lchmod
a85e8e
+# if HAVE_RAW_DECL_LCHMOD
a85e8e
+_GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
a85e8e
+                 "use gnulib module lchmod for portability");
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+
a85e8e
+#if @GNULIB_LSTAT@
a85e8e
+# if ! @HAVE_LSTAT@
a85e8e
+/* mingw does not support symlinks, therefore it does not have lstat.  But
a85e8e
+   without links, stat does just fine.  */
a85e8e
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#   define lstat stat
a85e8e
+#  endif
a85e8e
+_GL_CXXALIAS_RPL_1 (lstat, stat, int, (const char *name, struct stat *buf));
a85e8e
+# elif @REPLACE_LSTAT@
a85e8e
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#   undef lstat
a85e8e
+#   define lstat rpl_lstat
a85e8e
+#  endif
a85e8e
+_GL_FUNCDECL_RPL (lstat, int, (const char *name, struct stat *buf)
a85e8e
+                              _GL_ARG_NONNULL ((1, 2)));
a85e8e
+_GL_CXXALIAS_RPL (lstat, int, (const char *name, struct stat *buf));
a85e8e
+# else
a85e8e
+_GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf));
a85e8e
+# endif
a85e8e
+# if @HAVE_LSTAT@
a85e8e
+_GL_CXXALIASWARN (lstat);
a85e8e
+# endif
a85e8e
+#elif defined GNULIB_POSIXCHECK
a85e8e
+# undef lstat
a85e8e
+# if HAVE_RAW_DECL_LSTAT
a85e8e
+_GL_WARN_ON_USE (lstat, "lstat is unportable - "
a85e8e
+                 "use gnulib module lstat for portability");
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+
a85e8e
+#if @REPLACE_MKDIR@
a85e8e
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#  undef mkdir
a85e8e
+#  define mkdir rpl_mkdir
a85e8e
+# endif
a85e8e
+_GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode)
a85e8e
+                              _GL_ARG_NONNULL ((1)));
a85e8e
+_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
a85e8e
+#else
a85e8e
+/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
a85e8e
+   Additionally, it declares _mkdir (and depending on compile flags, an
a85e8e
+   alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
a85e8e
+   which are included above.  */
a85e8e
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
a85e8e
+
a85e8e
+#  if !GNULIB_defined_rpl_mkdir
a85e8e
+static int
a85e8e
+rpl_mkdir (char const *name, mode_t mode)
a85e8e
+{
a85e8e
+  return _mkdir (name);
a85e8e
+}
a85e8e
+#   define GNULIB_defined_rpl_mkdir 1
a85e8e
+#  endif
a85e8e
+
a85e8e
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#   define mkdir rpl_mkdir
a85e8e
+#  endif
a85e8e
+_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
a85e8e
+# else
a85e8e
+_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+_GL_CXXALIASWARN (mkdir);
a85e8e
+
a85e8e
+
a85e8e
+#if @GNULIB_MKDIRAT@
a85e8e
+# if !@HAVE_MKDIRAT@
a85e8e
+_GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)
a85e8e
+                                _GL_ARG_NONNULL ((2)));
a85e8e
+# endif
a85e8e
+_GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
a85e8e
+_GL_CXXALIASWARN (mkdirat);
a85e8e
+#elif defined GNULIB_POSIXCHECK
a85e8e
+# undef mkdirat
a85e8e
+# if HAVE_RAW_DECL_MKDIRAT
a85e8e
+_GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
a85e8e
+                 "use gnulib module openat for portability");
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+
a85e8e
+#if @GNULIB_MKFIFO@
a85e8e
+# if @REPLACE_MKFIFO@
a85e8e
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#   undef mkfifo
a85e8e
+#   define mkfifo rpl_mkfifo
a85e8e
+#  endif
a85e8e
+_GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode)
a85e8e
+                               _GL_ARG_NONNULL ((1)));
a85e8e
+_GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
a85e8e
+# else
a85e8e
+#  if !@HAVE_MKFIFO@
a85e8e
+_GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode)
a85e8e
+                               _GL_ARG_NONNULL ((1)));
a85e8e
+#  endif
a85e8e
+_GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
a85e8e
+# endif
a85e8e
+_GL_CXXALIASWARN (mkfifo);
a85e8e
+#elif defined GNULIB_POSIXCHECK
a85e8e
+# undef mkfifo
a85e8e
+# if HAVE_RAW_DECL_MKFIFO
a85e8e
+_GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
a85e8e
+                 "use gnulib module mkfifo for portability");
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+
a85e8e
+#if @GNULIB_MKFIFOAT@
a85e8e
+# if !@HAVE_MKFIFOAT@
a85e8e
+_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
a85e8e
+                                 _GL_ARG_NONNULL ((2)));
a85e8e
+# endif
a85e8e
+_GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
a85e8e
+_GL_CXXALIASWARN (mkfifoat);
a85e8e
+#elif defined GNULIB_POSIXCHECK
a85e8e
+# undef mkfifoat
a85e8e
+# if HAVE_RAW_DECL_MKFIFOAT
a85e8e
+_GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
a85e8e
+                 "use gnulib module mkfifoat for portability");
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+
a85e8e
+#if @GNULIB_MKNOD@
a85e8e
+# if @REPLACE_MKNOD@
a85e8e
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#   undef mknod
a85e8e
+#   define mknod rpl_mknod
a85e8e
+#  endif
a85e8e
+_GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)
a85e8e
+                              _GL_ARG_NONNULL ((1)));
a85e8e
+_GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
a85e8e
+# else
a85e8e
+#  if !@HAVE_MKNOD@
a85e8e
+_GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev)
a85e8e
+                              _GL_ARG_NONNULL ((1)));
a85e8e
+#  endif
a85e8e
+/* Need to cast, because on OSF/1 5.1, the third parameter is '...'.  */
a85e8e
+_GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev));
a85e8e
+# endif
a85e8e
+_GL_CXXALIASWARN (mknod);
a85e8e
+#elif defined GNULIB_POSIXCHECK
a85e8e
+# undef mknod
a85e8e
+# if HAVE_RAW_DECL_MKNOD
a85e8e
+_GL_WARN_ON_USE (mknod, "mknod is not portable - "
a85e8e
+                 "use gnulib module mknod for portability");
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+
a85e8e
+#if @GNULIB_MKNODAT@
a85e8e
+# if !@HAVE_MKNODAT@
a85e8e
+_GL_FUNCDECL_SYS (mknodat, int,
a85e8e
+                  (int fd, char const *file, mode_t mode, dev_t dev)
a85e8e
+                  _GL_ARG_NONNULL ((2)));
a85e8e
+# endif
a85e8e
+_GL_CXXALIAS_SYS (mknodat, int,
a85e8e
+                  (int fd, char const *file, mode_t mode, dev_t dev));
a85e8e
+_GL_CXXALIASWARN (mknodat);
a85e8e
+#elif defined GNULIB_POSIXCHECK
a85e8e
+# undef mknodat
a85e8e
+# if HAVE_RAW_DECL_MKNODAT
a85e8e
+_GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
a85e8e
+                 "use gnulib module mkfifoat for portability");
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+
a85e8e
+#if @GNULIB_STAT@
a85e8e
+# if @REPLACE_STAT@
a85e8e
+/* We can't use the object-like #define stat rpl_stat, because of
a85e8e
+   struct stat.  This means that rpl_stat will not be used if the user
a85e8e
+   does (stat)(a,b).  Oh well.  */
a85e8e
+#  if defined _AIX && defined stat && defined _LARGE_FILES
a85e8e
+    /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
a85e8e
+       so we have to replace stat64() instead of stat(). */
a85e8e
+#   undef stat64
a85e8e
+#   define stat64(name, st) rpl_stat (name, st)
a85e8e
+#  elif @WINDOWS_64_BIT_ST_SIZE@
a85e8e
+    /* Above, we define stat to _stati64.  */
a85e8e
+#   if defined __MINGW32__ && defined _stati64
a85e8e
+#    ifndef _USE_32BIT_TIME_T
a85e8e
+      /* The system headers define _stati64 to _stat64.  */
a85e8e
+#     undef _stat64
a85e8e
+#     define _stat64(name, st) rpl_stat (name, st)
a85e8e
+#    endif
a85e8e
+#   elif defined _MSC_VER && defined _stati64
a85e8e
+#    ifdef _USE_32BIT_TIME_T
a85e8e
+      /* The system headers define _stati64 to _stat32i64.  */
a85e8e
+#     undef _stat32i64
a85e8e
+#     define _stat32i64(name, st) rpl_stat (name, st)
a85e8e
+#    else
a85e8e
+      /* The system headers define _stati64 to _stat64.  */
a85e8e
+#     undef _stat64
a85e8e
+#     define _stat64(name, st) rpl_stat (name, st)
a85e8e
+#    endif
a85e8e
+#   else
a85e8e
+#    undef _stati64
a85e8e
+#    define _stati64(name, st) rpl_stat (name, st)
a85e8e
+#   endif
a85e8e
+#  elif defined __MINGW32__ && defined stat
a85e8e
+#   ifdef _USE_32BIT_TIME_T
a85e8e
+     /* The system headers define stat to _stat32i64.  */
a85e8e
+#    undef _stat32i64
a85e8e
+#    define _stat32i64(name, st) rpl_stat (name, st)
a85e8e
+#   else
a85e8e
+     /* The system headers define stat to _stat64.  */
a85e8e
+#    undef _stat64
a85e8e
+#    define _stat64(name, st) rpl_stat (name, st)
a85e8e
+#   endif
a85e8e
+#  elif defined _MSC_VER && defined stat
a85e8e
+#   ifdef _USE_32BIT_TIME_T
a85e8e
+     /* The system headers define stat to _stat32.  */
a85e8e
+#    undef _stat32
a85e8e
+#    define _stat32(name, st) rpl_stat (name, st)
a85e8e
+#   else
a85e8e
+     /* The system headers define stat to _stat64i32.  */
a85e8e
+#    undef _stat64i32
a85e8e
+#    define _stat64i32(name, st) rpl_stat (name, st)
a85e8e
+#   endif
a85e8e
+#  else /* !(_AIX ||__MINGW32__ ||  _MSC_VER) */
a85e8e
+#   undef stat
a85e8e
+#   define stat(name, st) rpl_stat (name, st)
a85e8e
+#  endif /* !_LARGE_FILES */
a85e8e
+_GL_EXTERN_C int stat (const char *name, struct stat *buf)
a85e8e
+                      _GL_ARG_NONNULL ((1, 2));
a85e8e
+# endif
a85e8e
+#elif defined GNULIB_POSIXCHECK
a85e8e
+# undef stat
a85e8e
+# if HAVE_RAW_DECL_STAT
a85e8e
+_GL_WARN_ON_USE (stat, "stat is unportable - "
a85e8e
+                 "use gnulib module stat for portability");
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+
a85e8e
+#if @GNULIB_UTIMENSAT@
a85e8e
+/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat
a85e8e
+   implementation relies on futimesat, which on Solaris 10 makes an invocation
a85e8e
+   to utimensat that is meant to invoke the libc's utimensat(), not gnulib's
a85e8e
+   utimensat().  */
a85e8e
+# if @REPLACE_UTIMENSAT@ || (!@HAVE_UTIMENSAT@ && defined __sun)
a85e8e
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#   undef utimensat
a85e8e
+#   define utimensat rpl_utimensat
a85e8e
+#  endif
a85e8e
+_GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
a85e8e
+                                   struct timespec const times[2], int flag)
a85e8e
+                                  _GL_ARG_NONNULL ((2)));
a85e8e
+_GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
a85e8e
+                                   struct timespec const times[2], int flag));
a85e8e
+# else
a85e8e
+#  if !@HAVE_UTIMENSAT@
a85e8e
+_GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
a85e8e
+                                   struct timespec const times[2], int flag)
a85e8e
+                                  _GL_ARG_NONNULL ((2)));
a85e8e
+#  endif
a85e8e
+_GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
a85e8e
+                                   struct timespec const times[2], int flag));
a85e8e
+# endif
a85e8e
+# if @HAVE_UTIMENSAT@
a85e8e
+_GL_CXXALIASWARN (utimensat);
a85e8e
+# endif
a85e8e
+#elif defined GNULIB_POSIXCHECK
a85e8e
+# undef utimensat
a85e8e
+# if HAVE_RAW_DECL_UTIMENSAT
a85e8e
+_GL_WARN_ON_USE (utimensat, "utimensat is not portable - "
a85e8e
+                 "use gnulib module utimensat for portability");
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+
a85e8e
+#endif /* _@GUARD_PREFIX@_SYS_STAT_H */
a85e8e
+#endif /* _@GUARD_PREFIX@_SYS_STAT_H */
a85e8e
+#endif
a85e8e
diff --git a/grub-core/gnulib/sys_time.in.h b/grub-core/gnulib/sys_time.in.h
a85e8e
new file mode 100644
6b3c76
index 000000000..30057ad49
a85e8e
--- /dev/null
a85e8e
+++ b/grub-core/gnulib/sys_time.in.h
a85e8e
@@ -0,0 +1,213 @@
a85e8e
+/* Provide a more complete sys/time.h.
a85e8e
+
a85e8e
+   Copyright (C) 2007-2014 Free Software Foundation, Inc.
a85e8e
+
a85e8e
+   This program is free software; you can redistribute it and/or modify
a85e8e
+   it under the terms of the GNU General Public License as published by
a85e8e
+   the Free Software Foundation; either version 3, or (at your option)
a85e8e
+   any later version.
a85e8e
+
a85e8e
+   This program is distributed in the hope that it will be useful,
a85e8e
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
a85e8e
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a85e8e
+   GNU General Public License for more details.
a85e8e
+
a85e8e
+   You should have received a copy of the GNU General Public License
a85e8e
+   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
a85e8e
+
a85e8e
+/* Written by Paul Eggert.  */
a85e8e
+
a85e8e
+#ifndef _@GUARD_PREFIX@_SYS_TIME_H
a85e8e
+
a85e8e
+#if __GNUC__ >= 3
a85e8e
+@PRAGMA_SYSTEM_HEADER@
a85e8e
+#endif
a85e8e
+@PRAGMA_COLUMNS@
a85e8e
+
a85e8e
+/* On Cygwin and on many BSDish systems, <sys/time.h> includes itself
a85e8e
+   recursively via <sys/select.h>.
a85e8e
+   Simply delegate to the system's header in this case; it is a no-op.
a85e8e
+   Without this extra ifdef, the C++ gettimeofday declaration below
a85e8e
+   would be a forward declaration in gnulib's nested <sys/time.h>.  */
a85e8e
+#if defined _CYGWIN_SYS_TIME_H || defined _SYS_TIME_H || defined _SYS_TIME_H_
a85e8e
+# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
a85e8e
+#else
a85e8e
+
a85e8e
+/* The include_next requires a split double-inclusion guard.  */
a85e8e
+#if @HAVE_SYS_TIME_H@
a85e8e
+# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
a85e8e
+#endif
a85e8e
+
a85e8e
+#ifndef _@GUARD_PREFIX@_SYS_TIME_H
a85e8e
+#define _@GUARD_PREFIX@_SYS_TIME_H
a85e8e
+
a85e8e
+#if ! @HAVE_SYS_TIME_H@
a85e8e
+# include <time.h>
a85e8e
+#endif
a85e8e
+
a85e8e
+/* On native Windows with MSVC, get the 'struct timeval' type.
a85e8e
+   Also, on native Windows with a 64-bit time_t, where we are overriding the
a85e8e
+   'struct timeval' type, get all declarations of system functions whose
a85e8e
+   signature contains 'struct timeval'.  */
a85e8e
+#if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H
a85e8e
+# define _GL_INCLUDING_WINSOCK2_H
a85e8e
+# include <winsock2.h>
a85e8e
+# undef _GL_INCLUDING_WINSOCK2_H
a85e8e
+#endif
a85e8e
+
a85e8e
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
a85e8e
+
a85e8e
+/* The definition of _GL_ARG_NONNULL is copied here.  */
a85e8e
+
a85e8e
+/* The definition of _GL_WARN_ON_USE is copied here.  */
a85e8e
+
a85e8e
+#ifdef __cplusplus
a85e8e
+extern "C" {
a85e8e
+#endif
a85e8e
+
a85e8e
+#if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@
a85e8e
+
a85e8e
+# if @REPLACE_STRUCT_TIMEVAL@
a85e8e
+#  define timeval rpl_timeval
a85e8e
+# endif
a85e8e
+
a85e8e
+# if !GNULIB_defined_struct_timeval
a85e8e
+struct timeval
a85e8e
+{
a85e8e
+  time_t tv_sec;
a85e8e
+  long int tv_usec;
a85e8e
+};
a85e8e
+#  define GNULIB_defined_struct_timeval 1
a85e8e
+# endif
a85e8e
+
a85e8e
+#endif
a85e8e
+
a85e8e
+#ifdef __cplusplus
a85e8e
+}
a85e8e
+#endif
a85e8e
+
a85e8e
+#if @GNULIB_GETTIMEOFDAY@
a85e8e
+# if @REPLACE_GETTIMEOFDAY@
a85e8e
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#   undef gettimeofday
a85e8e
+#   define gettimeofday rpl_gettimeofday
a85e8e
+#  endif
a85e8e
+_GL_FUNCDECL_RPL (gettimeofday, int,
a85e8e
+                  (struct timeval *restrict, void *restrict)
a85e8e
+                  _GL_ARG_NONNULL ((1)));
a85e8e
+_GL_CXXALIAS_RPL (gettimeofday, int,
a85e8e
+                  (struct timeval *restrict, void *restrict));
a85e8e
+# else
a85e8e
+#  if !@HAVE_GETTIMEOFDAY@
a85e8e
+_GL_FUNCDECL_SYS (gettimeofday, int,
a85e8e
+                  (struct timeval *restrict, void *restrict)
a85e8e
+                  _GL_ARG_NONNULL ((1)));
a85e8e
+#  endif
a85e8e
+/* Need to cast, because on glibc systems, by default, the second argument is
a85e8e
+                                                  struct timezone *.  */
a85e8e
+_GL_CXXALIAS_SYS_CAST (gettimeofday, int,
a85e8e
+                       (struct timeval *restrict, void *restrict));
a85e8e
+# endif
a85e8e
+_GL_CXXALIASWARN (gettimeofday);
a85e8e
+#elif defined GNULIB_POSIXCHECK
a85e8e
+# undef gettimeofday
a85e8e
+# if HAVE_RAW_DECL_GETTIMEOFDAY
a85e8e
+_GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - "
a85e8e
+                 "use gnulib module gettimeofday for portability");
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+/* Hide some function declarations from <winsock2.h>.  */
a85e8e
+
a85e8e
+#if defined _MSC_VER && @HAVE_WINSOCK2_H@
a85e8e
+# if !defined _@GUARD_PREFIX@_UNISTD_H
a85e8e
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#   undef close
a85e8e
+#   define close close_used_without_including_unistd_h
a85e8e
+#  else
a85e8e
+     _GL_WARN_ON_USE (close,
a85e8e
+                      "close() used without including <unistd.h>");
a85e8e
+#  endif
a85e8e
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#   undef gethostname
a85e8e
+#   define gethostname gethostname_used_without_including_unistd_h
a85e8e
+#  else
a85e8e
+     _GL_WARN_ON_USE (gethostname,
a85e8e
+                      "gethostname() used without including <unistd.h>");
a85e8e
+#  endif
a85e8e
+# endif
a85e8e
+# if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
a85e8e
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#   undef socket
a85e8e
+#   define socket              socket_used_without_including_sys_socket_h
a85e8e
+#   undef connect
a85e8e
+#   define connect             connect_used_without_including_sys_socket_h
a85e8e
+#   undef accept
a85e8e
+#   define accept              accept_used_without_including_sys_socket_h
a85e8e
+#   undef bind
a85e8e
+#   define bind                bind_used_without_including_sys_socket_h
a85e8e
+#   undef getpeername
a85e8e
+#   define getpeername         getpeername_used_without_including_sys_socket_h
a85e8e
+#   undef getsockname
a85e8e
+#   define getsockname         getsockname_used_without_including_sys_socket_h
a85e8e
+#   undef getsockopt
a85e8e
+#   define getsockopt          getsockopt_used_without_including_sys_socket_h
a85e8e
+#   undef listen
a85e8e
+#   define listen              listen_used_without_including_sys_socket_h
a85e8e
+#   undef recv
a85e8e
+#   define recv                recv_used_without_including_sys_socket_h
a85e8e
+#   undef send
a85e8e
+#   define send                send_used_without_including_sys_socket_h
a85e8e
+#   undef recvfrom
a85e8e
+#   define recvfrom            recvfrom_used_without_including_sys_socket_h
a85e8e
+#   undef sendto
a85e8e
+#   define sendto              sendto_used_without_including_sys_socket_h
a85e8e
+#   undef setsockopt
a85e8e
+#   define setsockopt          setsockopt_used_without_including_sys_socket_h
a85e8e
+#   undef shutdown
a85e8e
+#   define shutdown            shutdown_used_without_including_sys_socket_h
a85e8e
+#  else
a85e8e
+     _GL_WARN_ON_USE (socket,
a85e8e
+                      "socket() used without including <sys/socket.h>");
a85e8e
+     _GL_WARN_ON_USE (connect,
a85e8e
+                      "connect() used without including <sys/socket.h>");
a85e8e
+     _GL_WARN_ON_USE (accept,
a85e8e
+                      "accept() used without including <sys/socket.h>");
a85e8e
+     _GL_WARN_ON_USE (bind,
a85e8e
+                      "bind() used without including <sys/socket.h>");
a85e8e
+     _GL_WARN_ON_USE (getpeername,
a85e8e
+                      "getpeername() used without including <sys/socket.h>");
a85e8e
+     _GL_WARN_ON_USE (getsockname,
a85e8e
+                      "getsockname() used without including <sys/socket.h>");
a85e8e
+     _GL_WARN_ON_USE (getsockopt,
a85e8e
+                      "getsockopt() used without including <sys/socket.h>");
a85e8e
+     _GL_WARN_ON_USE (listen,
a85e8e
+                      "listen() used without including <sys/socket.h>");
a85e8e
+     _GL_WARN_ON_USE (recv,
a85e8e
+                      "recv() used without including <sys/socket.h>");
a85e8e
+     _GL_WARN_ON_USE (send,
a85e8e
+                      "send() used without including <sys/socket.h>");
a85e8e
+     _GL_WARN_ON_USE (recvfrom,
a85e8e
+                      "recvfrom() used without including <sys/socket.h>");
a85e8e
+     _GL_WARN_ON_USE (sendto,
a85e8e
+                      "sendto() used without including <sys/socket.h>");
a85e8e
+     _GL_WARN_ON_USE (setsockopt,
a85e8e
+                      "setsockopt() used without including <sys/socket.h>");
a85e8e
+     _GL_WARN_ON_USE (shutdown,
a85e8e
+                      "shutdown() used without including <sys/socket.h>");
a85e8e
+#  endif
a85e8e
+# endif
a85e8e
+# if !defined _@GUARD_PREFIX@_SYS_SELECT_H
a85e8e
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#   undef select
a85e8e
+#   define select select_used_without_including_sys_select_h
a85e8e
+#  else
a85e8e
+     _GL_WARN_ON_USE (select,
a85e8e
+                      "select() used without including <sys/select.h>");
a85e8e
+#  endif
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+#endif /* _@GUARD_PREFIX@_SYS_TIME_H */
a85e8e
+#endif /* _CYGWIN_SYS_TIME_H */
a85e8e
+#endif /* _@GUARD_PREFIX@_SYS_TIME_H */
a85e8e
diff --git a/grub-core/gnulib/sys_types.in.h b/grub-core/gnulib/sys_types.in.h
6b3c76
index d7da35623..9520c0903 100644
a85e8e
--- a/grub-core/gnulib/sys_types.in.h
a85e8e
+++ b/grub-core/gnulib/sys_types.in.h
a85e8e
@@ -23,7 +23,9 @@
a85e8e
 #ifndef _@GUARD_PREFIX@_SYS_TYPES_H
a85e8e
 
a85e8e
 /* The include_next requires a split double-inclusion guard.  */
a85e8e
+# define _GL_INCLUDING_SYS_TYPES_H
a85e8e
 #@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@
a85e8e
+# undef _GL_INCLUDING_SYS_TYPES_H
a85e8e
 
a85e8e
 #ifndef _@GUARD_PREFIX@_SYS_TYPES_H
a85e8e
 #define _@GUARD_PREFIX@_SYS_TYPES_H
a85e8e
diff --git a/grub-core/gnulib/time.h b/grub-core/gnulib/time.h
a85e8e
new file mode 100644
6b3c76
index 000000000..b9203d556
a85e8e
--- /dev/null
a85e8e
+++ b/grub-core/gnulib/time.h
a85e8e
@@ -0,0 +1,586 @@
a85e8e
+/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
a85e8e
+/* A more-standard <time.h>.
a85e8e
+
a85e8e
+   Copyright (C) 2007-2014 Free Software Foundation, Inc.
a85e8e
+
a85e8e
+   This program is free software; you can redistribute it and/or modify
a85e8e
+   it under the terms of the GNU General Public License as published by
a85e8e
+   the Free Software Foundation; either version 3, or (at your option)
a85e8e
+   any later version.
a85e8e
+
a85e8e
+   This program is distributed in the hope that it will be useful,
a85e8e
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
a85e8e
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a85e8e
+   GNU General Public License for more details.
a85e8e
+
a85e8e
+   You should have received a copy of the GNU General Public License
a85e8e
+   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
a85e8e
+
a85e8e
+#if __GNUC__ >= 3
a85e8e
+#pragma GCC system_header
a85e8e
+#endif
a85e8e
+
a85e8e
+
a85e8e
+/* Don't get in the way of glibc when it includes time.h merely to
a85e8e
+   declare a few standard symbols, rather than to declare all the
a85e8e
+   symbols.  Also, Solaris 8 <time.h> eventually includes itself
a85e8e
+   recursively; if that is happening, just include the system <time.h>
a85e8e
+   without adding our own declarations.  */
a85e8e
+#if (defined __need_time_t || defined __need_clock_t \
a85e8e
+     || defined __need_timespec \
a85e8e
+     || defined _GL_TIME_H)
a85e8e
+
a85e8e
+# include_next <time.h>
a85e8e
+
a85e8e
+#else
a85e8e
+
a85e8e
+# define _GL_TIME_H
a85e8e
+
a85e8e
+# include_next <time.h>
a85e8e
+
a85e8e
+/* NetBSD 5.0 mis-defines NULL.  */
a85e8e
+# include <stddef.h>
a85e8e
+
a85e8e
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
a85e8e
+#ifndef _GL_CXXDEFS_H
a85e8e
+#define _GL_CXXDEFS_H
a85e8e
+
a85e8e
+/* The three most frequent use cases of these macros are:
a85e8e
+
a85e8e
+   * For providing a substitute for a function that is missing on some
a85e8e
+     platforms, but is declared and works fine on the platforms on which
a85e8e
+     it exists:
a85e8e
+
a85e8e
+       #if @GNULIB_FOO@
a85e8e
+       # if !@HAVE_FOO@
a85e8e
+       _GL_FUNCDECL_SYS (foo, ...);
a85e8e
+       # endif
a85e8e
+       _GL_CXXALIAS_SYS (foo, ...);
a85e8e
+       _GL_CXXALIASWARN (foo);
a85e8e
+       #elif defined GNULIB_POSIXCHECK
a85e8e
+       ...
a85e8e
+       #endif
a85e8e
+
a85e8e
+   * For providing a replacement for a function that exists on all platforms,
a85e8e
+     but is broken/insufficient and needs to be replaced on some platforms:
a85e8e
+
a85e8e
+       #if @GNULIB_FOO@
a85e8e
+       # if @REPLACE_FOO@
a85e8e
+       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+       #   undef foo
a85e8e
+       #   define foo rpl_foo
a85e8e
+       #  endif
a85e8e
+       _GL_FUNCDECL_RPL (foo, ...);
a85e8e
+       _GL_CXXALIAS_RPL (foo, ...);
a85e8e
+       # else
a85e8e
+       _GL_CXXALIAS_SYS (foo, ...);
a85e8e
+       # endif
a85e8e
+       _GL_CXXALIASWARN (foo);
a85e8e
+       #elif defined GNULIB_POSIXCHECK
a85e8e
+       ...
a85e8e
+       #endif
a85e8e
+
a85e8e
+   * For providing a replacement for a function that exists on some platforms
a85e8e
+     but is broken/insufficient and needs to be replaced on some of them and
a85e8e
+     is additionally either missing or undeclared on some other platforms:
a85e8e
+
a85e8e
+       #if @GNULIB_FOO@
a85e8e
+       # if @REPLACE_FOO@
a85e8e
+       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+       #   undef foo
a85e8e
+       #   define foo rpl_foo
a85e8e
+       #  endif
a85e8e
+       _GL_FUNCDECL_RPL (foo, ...);
a85e8e
+       _GL_CXXALIAS_RPL (foo, ...);
a85e8e
+       # else
a85e8e
+       #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@
a85e8e
+       _GL_FUNCDECL_SYS (foo, ...);
a85e8e
+       #  endif
a85e8e
+       _GL_CXXALIAS_SYS (foo, ...);
a85e8e
+       # endif
a85e8e
+       _GL_CXXALIASWARN (foo);
a85e8e
+       #elif defined GNULIB_POSIXCHECK
a85e8e
+       ...
a85e8e
+       #endif
a85e8e
+*/
a85e8e
+
a85e8e
+/* _GL_EXTERN_C declaration;
a85e8e
+   performs the declaration with C linkage.  */
a85e8e
+#if defined __cplusplus
a85e8e
+# define _GL_EXTERN_C extern "C"
a85e8e
+#else
a85e8e
+# define _GL_EXTERN_C extern
a85e8e
+#endif
a85e8e
+
a85e8e
+/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
a85e8e
+   declares a replacement function, named rpl_func, with the given prototype,
a85e8e
+   consisting of return type, parameters, and attributes.
a85e8e
+   Example:
a85e8e
+     _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
a85e8e
+                                  _GL_ARG_NONNULL ((1)));
a85e8e
+ */
a85e8e
+#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
a85e8e
+  _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
a85e8e
+#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
a85e8e
+  _GL_EXTERN_C rettype rpl_func parameters_and_attributes
a85e8e
+
a85e8e
+/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
a85e8e
+   declares the system function, named func, with the given prototype,
a85e8e
+   consisting of return type, parameters, and attributes.
a85e8e
+   Example:
a85e8e
+     _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
a85e8e
+                                  _GL_ARG_NONNULL ((1)));
a85e8e
+ */
a85e8e
+#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
a85e8e
+  _GL_EXTERN_C rettype func parameters_and_attributes
a85e8e
+
a85e8e
+/* _GL_CXXALIAS_RPL (func, rettype, parameters);
a85e8e
+   declares a C++ alias called GNULIB_NAMESPACE::func
a85e8e
+   that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
a85e8e
+   Example:
a85e8e
+     _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
a85e8e
+ */
a85e8e
+#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
a85e8e
+  _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
a85e8e
+#if defined __cplusplus && defined GNULIB_NAMESPACE
a85e8e
+# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
a85e8e
+    namespace GNULIB_NAMESPACE                                \
a85e8e
+    {                                                         \
a85e8e
+      rettype (*const func) parameters = ::rpl_func;          \
a85e8e
+    }                                                         \
a85e8e
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a85e8e
+#else
a85e8e
+# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
a85e8e
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a85e8e
+#endif
a85e8e
+
a85e8e
+/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
a85e8e
+   is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
a85e8e
+   except that the C function rpl_func may have a slightly different
a85e8e
+   declaration.  A cast is used to silence the "invalid conversion" error
a85e8e
+   that would otherwise occur.  */
a85e8e
+#if defined __cplusplus && defined GNULIB_NAMESPACE
a85e8e
+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
a85e8e
+    namespace GNULIB_NAMESPACE                                     \
a85e8e
+    {                                                              \
a85e8e
+      rettype (*const func) parameters =                           \
a85e8e
+        reinterpret_cast<rettype(*)parameters>(::rpl_func);        \
a85e8e
+    }                                                              \
a85e8e
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a85e8e
+#else
a85e8e
+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
a85e8e
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a85e8e
+#endif
a85e8e
+
a85e8e
+/* _GL_CXXALIAS_SYS (func, rettype, parameters);
a85e8e
+   declares a C++ alias called GNULIB_NAMESPACE::func
a85e8e
+   that redirects to the system provided function func, if GNULIB_NAMESPACE
a85e8e
+   is defined.
a85e8e
+   Example:
a85e8e
+     _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
a85e8e
+ */
a85e8e
+#if defined __cplusplus && defined GNULIB_NAMESPACE
a85e8e
+  /* If we were to write
a85e8e
+       rettype (*const func) parameters = ::func;
a85e8e
+     like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
a85e8e
+     better (remove an indirection through a 'static' pointer variable),
a85e8e
+     but then the _GL_CXXALIASWARN macro below would cause a warning not only
a85e8e
+     for uses of ::func but also for uses of GNULIB_NAMESPACE::func.  */
a85e8e
+# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
a85e8e
+    namespace GNULIB_NAMESPACE                     \
a85e8e
+    {                                              \
a85e8e
+      static rettype (*func) parameters = ::func;  \
a85e8e
+    }                                              \
a85e8e
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a85e8e
+#else
a85e8e
+# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
a85e8e
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a85e8e
+#endif
a85e8e
+
a85e8e
+/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
a85e8e
+   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
a85e8e
+   except that the C function func may have a slightly different declaration.
a85e8e
+   A cast is used to silence the "invalid conversion" error that would
a85e8e
+   otherwise occur.  */
a85e8e
+#if defined __cplusplus && defined GNULIB_NAMESPACE
a85e8e
+# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
a85e8e
+    namespace GNULIB_NAMESPACE                          \
a85e8e
+    {                                                   \
a85e8e
+      static rettype (*func) parameters =               \
a85e8e
+        reinterpret_cast<rettype(*)parameters>(::func); \
a85e8e
+    }                                                   \
a85e8e
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a85e8e
+#else
a85e8e
+# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
a85e8e
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a85e8e
+#endif
a85e8e
+
a85e8e
+/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
a85e8e
+   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
a85e8e
+   except that the C function is picked among a set of overloaded functions,
a85e8e
+   namely the one with rettype2 and parameters2.  Two consecutive casts
a85e8e
+   are used to silence the "cannot find a match" and "invalid conversion"
a85e8e
+   errors that would otherwise occur.  */
a85e8e
+#if defined __cplusplus && defined GNULIB_NAMESPACE
a85e8e
+  /* The outer cast must be a reinterpret_cast.
a85e8e
+     The inner cast: When the function is defined as a set of overloaded
a85e8e
+     functions, it works as a static_cast<>, choosing the designated variant.
a85e8e
+     When the function is defined as a single variant, it works as a
a85e8e
+     reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
a85e8e
+# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
a85e8e
+    namespace GNULIB_NAMESPACE                                                \
a85e8e
+    {                                                                         \
a85e8e
+      static rettype (*func) parameters =                                     \
a85e8e
+        reinterpret_cast<rettype(*)parameters>(                               \
a85e8e
+          (rettype2(*)parameters2)(::func));                                  \
a85e8e
+    }                                                                         \
a85e8e
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a85e8e
+#else
a85e8e
+# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
a85e8e
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a85e8e
+#endif
a85e8e
+
a85e8e
+/* _GL_CXXALIASWARN (func);
a85e8e
+   causes a warning to be emitted when ::func is used but not when
a85e8e
+   GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
a85e8e
+   variants.  */
a85e8e
+#if defined __cplusplus && defined GNULIB_NAMESPACE
a85e8e
+# define _GL_CXXALIASWARN(func) \
a85e8e
+   _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
a85e8e
+# define _GL_CXXALIASWARN_1(func,namespace) \
a85e8e
+   _GL_CXXALIASWARN_2 (func, namespace)
a85e8e
+/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
a85e8e
+   we enable the warning only when not optimizing.  */
a85e8e
+# if !__OPTIMIZE__
a85e8e
+#  define _GL_CXXALIASWARN_2(func,namespace) \
a85e8e
+    _GL_WARN_ON_USE (func, \
a85e8e
+                     "The symbol ::" #func " refers to the system function. " \
a85e8e
+                     "Use " #namespace "::" #func " instead.")
a85e8e
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
a85e8e
+#  define _GL_CXXALIASWARN_2(func,namespace) \
a85e8e
+     extern __typeof__ (func) func
a85e8e
+# else
a85e8e
+#  define _GL_CXXALIASWARN_2(func,namespace) \
a85e8e
+     _GL_EXTERN_C int _gl_cxxalias_dummy
a85e8e
+# endif
a85e8e
+#else
a85e8e
+# define _GL_CXXALIASWARN(func) \
a85e8e
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a85e8e
+#endif
a85e8e
+
a85e8e
+/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
a85e8e
+   causes a warning to be emitted when the given overloaded variant of ::func
a85e8e
+   is used but not when GNULIB_NAMESPACE::func is used.  */
a85e8e
+#if defined __cplusplus && defined GNULIB_NAMESPACE
a85e8e
+# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
a85e8e
+   _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
a85e8e
+                        GNULIB_NAMESPACE)
a85e8e
+# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
a85e8e
+   _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
a85e8e
+/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
a85e8e
+   we enable the warning only when not optimizing.  */
a85e8e
+# if !__OPTIMIZE__
a85e8e
+#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
a85e8e
+    _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
a85e8e
+                         "The symbol ::" #func " refers to the system function. " \
a85e8e
+                         "Use " #namespace "::" #func " instead.")
a85e8e
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
a85e8e
+#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
a85e8e
+     extern __typeof__ (func) func
a85e8e
+# else
a85e8e
+#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
a85e8e
+     _GL_EXTERN_C int _gl_cxxalias_dummy
a85e8e
+# endif
a85e8e
+#else
a85e8e
+# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
a85e8e
+    _GL_EXTERN_C int _gl_cxxalias_dummy
a85e8e
+#endif
a85e8e
+
a85e8e
+#endif /* _GL_CXXDEFS_H */
a85e8e
+
a85e8e
+/* The definition of _GL_ARG_NONNULL is copied here.  */
a85e8e
+/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
a85e8e
+   that the values passed as arguments n, ..., m must be non-NULL pointers.
a85e8e
+   n = 1 stands for the first argument, n = 2 for the second argument etc.  */
a85e8e
+#ifndef _GL_ARG_NONNULL
a85e8e
+# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
a85e8e
+#  define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
a85e8e
+# else
a85e8e
+#  define _GL_ARG_NONNULL(params)
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+/* The definition of _GL_WARN_ON_USE is copied here.  */
a85e8e
+#ifndef _GL_WARN_ON_USE
a85e8e
+
a85e8e
+# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
a85e8e
+/* A compiler attribute is available in gcc versions 4.3.0 and later.  */
a85e8e
+#  define _GL_WARN_ON_USE(function, message) \
a85e8e
+extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
a85e8e
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
a85e8e
+/* Verify the existence of the function.  */
a85e8e
+#  define _GL_WARN_ON_USE(function, message) \
a85e8e
+extern __typeof__ (function) function
a85e8e
+# else /* Unsupported.  */
a85e8e
+#  define _GL_WARN_ON_USE(function, message) \
a85e8e
+_GL_WARN_EXTERN_C int _gl_warn_on_use
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
a85e8e
+   is like _GL_WARN_ON_USE (function, "string"), except that the function is
a85e8e
+   declared with the given prototype, consisting of return type, parameters,
a85e8e
+   and attributes.
a85e8e
+   This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
a85e8e
+   not work in this case.  */
a85e8e
+#ifndef _GL_WARN_ON_USE_CXX
a85e8e
+# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
a85e8e
+#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
a85e8e
+extern rettype function parameters_and_attributes \
a85e8e
+     __attribute__ ((__warning__ (msg)))
a85e8e
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
a85e8e
+/* Verify the existence of the function.  */
a85e8e
+#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
a85e8e
+extern rettype function parameters_and_attributes
a85e8e
+# else /* Unsupported.  */
a85e8e
+#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
a85e8e
+_GL_WARN_EXTERN_C int _gl_warn_on_use
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+/* _GL_WARN_EXTERN_C declaration;
a85e8e
+   performs the declaration with C linkage.  */
a85e8e
+#ifndef _GL_WARN_EXTERN_C
a85e8e
+# if defined __cplusplus
a85e8e
+#  define _GL_WARN_EXTERN_C extern "C"
a85e8e
+# else
a85e8e
+#  define _GL_WARN_EXTERN_C extern
a85e8e
+# endif
a85e8e
+#endif
a85e8e
+
a85e8e
+/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
a85e8e
+   Or they define it with the wrong member names or define it in <sys/time.h>
a85e8e
+   (e.g., FreeBSD circa 1997).  Stock Mingw prior to 3.0 does not define it,
a85e8e
+   but the pthreads-win32 library defines it in <pthread.h>.  */
a85e8e
+# if ! 1
a85e8e
+#  if 0
a85e8e
+#   include <sys/time.h>
a85e8e
+#  elif 0
a85e8e
+#   include <pthread.h>
a85e8e
+#  else
a85e8e
+
a85e8e
+#   ifdef __cplusplus
a85e8e
+extern "C" {
a85e8e
+#   endif
a85e8e
+
a85e8e
+#   if !GNULIB_defined_struct_timespec
a85e8e
+#    undef timespec
a85e8e
+#    define timespec rpl_timespec
a85e8e
+struct timespec
a85e8e
+{
a85e8e
+  time_t tv_sec;
a85e8e
+  long int tv_nsec;
a85e8e
+};
a85e8e
+#    define GNULIB_defined_struct_timespec 1
a85e8e
+#   endif
a85e8e
+
a85e8e
+#   ifdef __cplusplus
a85e8e
+}
a85e8e
+#   endif
a85e8e
+
a85e8e
+#  endif
a85e8e
+# endif
a85e8e
+
a85e8e
+# if !GNULIB_defined_struct_time_t_must_be_integral
a85e8e
+/* Per http://austingroupbugs.net/view.php?id=327, POSIX requires
a85e8e
+   time_t to be an integer type, even though C99 permits floating
a85e8e
+   point.  We don't know of any implementation that uses floating
a85e8e
+   point, and it is much easier to write code that doesn't have to
a85e8e
+   worry about that corner case, so we force the issue.  */
a85e8e
+struct __time_t_must_be_integral {
a85e8e
+  unsigned int __floating_time_t_unsupported : (time_t) 1;
a85e8e
+};
a85e8e
+#  define GNULIB_defined_struct_time_t_must_be_integral 1
a85e8e
+# endif
a85e8e
+
a85e8e
+/* Sleep for at least RQTP seconds unless interrupted,  If interrupted,
a85e8e
+   return -1 and store the remaining time into RMTP.  See
a85e8e
+   <http://www.opengroup.org/susv3xsh/nanosleep.html>.  */
a85e8e
+# if 0
a85e8e
+#  if GNULIB_PORTCHECK
a85e8e
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#    define nanosleep rpl_nanosleep
a85e8e
+#   endif
a85e8e
+_GL_FUNCDECL_RPL (nanosleep, int,
a85e8e
+                  (struct timespec const *__rqtp, struct timespec *__rmtp)
a85e8e
+                  _GL_ARG_NONNULL ((1)));
a85e8e
+_GL_CXXALIAS_RPL (nanosleep, int,
a85e8e
+                  (struct timespec const *__rqtp, struct timespec *__rmtp));
a85e8e
+#  else
a85e8e
+#   if ! 1
a85e8e
+_GL_FUNCDECL_SYS (nanosleep, int,
a85e8e
+                  (struct timespec const *__rqtp, struct timespec *__rmtp)
a85e8e
+                  _GL_ARG_NONNULL ((1)));
a85e8e
+#   endif
a85e8e
+_GL_CXXALIAS_SYS (nanosleep, int,
a85e8e
+                  (struct timespec const *__rqtp, struct timespec *__rmtp));
a85e8e
+#  endif
a85e8e
+_GL_CXXALIASWARN (nanosleep);
a85e8e
+# endif
a85e8e
+
a85e8e
+/* Return the 'time_t' representation of TP and normalize TP.  */
a85e8e
+# if 0
a85e8e
+#  if GNULIB_PORTCHECK
a85e8e
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#    define mktime rpl_mktime
a85e8e
+#   endif
a85e8e
+_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
a85e8e
+_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
a85e8e
+#  else
a85e8e
+_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
a85e8e
+#  endif
a85e8e
+_GL_CXXALIASWARN (mktime);
a85e8e
+# endif
a85e8e
+
a85e8e
+/* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
a85e8e
+   <http://www.opengroup.org/susv3xsh/localtime_r.html> and
a85e8e
+   <http://www.opengroup.org/susv3xsh/gmtime_r.html>.  */
a85e8e
+# if 0
a85e8e
+#  if GNULIB_PORTCHECK
a85e8e
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#    undef localtime_r
a85e8e
+#    define localtime_r rpl_localtime_r
a85e8e
+#   endif
a85e8e
+_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
a85e8e
+                                             struct tm *restrict __result)
a85e8e
+                                            _GL_ARG_NONNULL ((1, 2)));
a85e8e
+_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
a85e8e
+                                             struct tm *restrict __result));
a85e8e
+#  else
a85e8e
+#   if ! 1
a85e8e
+_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
a85e8e
+                                             struct tm *restrict __result)
a85e8e
+                                            _GL_ARG_NONNULL ((1, 2)));
a85e8e
+#   endif
a85e8e
+_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
a85e8e
+                                             struct tm *restrict __result));
a85e8e
+#  endif
a85e8e
+#  if 1
a85e8e
+_GL_CXXALIASWARN (localtime_r);
a85e8e
+#  endif
a85e8e
+#  if GNULIB_PORTCHECK
a85e8e
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#    undef gmtime_r
a85e8e
+#    define gmtime_r rpl_gmtime_r
a85e8e
+#   endif
a85e8e
+_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
a85e8e
+                                          struct tm *restrict __result)
a85e8e
+                                         _GL_ARG_NONNULL ((1, 2)));
a85e8e
+_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
a85e8e
+                                          struct tm *restrict __result));
a85e8e
+#  else
a85e8e
+#   if ! 1
a85e8e
+_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
a85e8e
+                                          struct tm *restrict __result)
a85e8e
+                                         _GL_ARG_NONNULL ((1, 2)));
a85e8e
+#   endif
a85e8e
+_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
a85e8e
+                                          struct tm *restrict __result));
a85e8e
+#  endif
a85e8e
+#  if 1
a85e8e
+_GL_CXXALIASWARN (gmtime_r);
a85e8e
+#  endif
a85e8e
+# endif
a85e8e
+
a85e8e
+/* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
a85e8e
+   <http://www.opengroup.org/susv3xsh/localtime.html> and
a85e8e
+   <http://www.opengroup.org/susv3xsh/gmtime.html>.  */
a85e8e
+# if 1
a85e8e
+#  if 0
a85e8e
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#    undef localtime
a85e8e
+#    define localtime rpl_localtime
a85e8e
+#   endif
a85e8e
+_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer)
a85e8e
+		                          _GL_ARG_NONNULL ((1)));
a85e8e
+_GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer));
a85e8e
+#  else
a85e8e
+_GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer));
a85e8e
+#  endif
a85e8e
+_GL_CXXALIASWARN (localtime);
a85e8e
+# endif
a85e8e
+
a85e8e
+# if 1
a85e8e
+#  if 0
a85e8e
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#    undef gmtime
a85e8e
+#    define gmtime rpl_gmtime
a85e8e
+#   endif
a85e8e
+_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer)
a85e8e
+                                       _GL_ARG_NONNULL ((1)));
a85e8e
+_GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer));
a85e8e
+#  else
a85e8e
+_GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer));
a85e8e
+#  endif
a85e8e
+_GL_CXXALIASWARN (gmtime);
a85e8e
+# endif
a85e8e
+
a85e8e
+/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
a85e8e
+   the resulting broken-down time into TM.  See
a85e8e
+   <http://www.opengroup.org/susv3xsh/strptime.html>.  */
a85e8e
+# if 0
a85e8e
+#  if ! 1
a85e8e
+_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
a85e8e
+                                     char const *restrict __format,
a85e8e
+                                     struct tm *restrict __tm)
a85e8e
+                                    _GL_ARG_NONNULL ((1, 2, 3)));
a85e8e
+#  endif
a85e8e
+_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
a85e8e
+                                     char const *restrict __format,
a85e8e
+                                     struct tm *restrict __tm));
a85e8e
+_GL_CXXALIASWARN (strptime);
a85e8e
+# endif
a85e8e
+
a85e8e
+/* Convert TM to a time_t value, assuming UTC.  */
a85e8e
+# if 0
a85e8e
+#  if GNULIB_PORTCHECK
a85e8e
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#    undef timegm
a85e8e
+#    define timegm rpl_timegm
a85e8e
+#   endif
a85e8e
+_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
a85e8e
+_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
a85e8e
+#  else
a85e8e
+#   if ! 1
a85e8e
+_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
a85e8e
+#   endif
a85e8e
+_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
a85e8e
+#  endif
a85e8e
+_GL_CXXALIASWARN (timegm);
a85e8e
+# endif
a85e8e
+
a85e8e
+/* Encourage applications to avoid unsafe functions that can overrun
a85e8e
+   buffers when given outlandish struct tm values.  Portable
a85e8e
+   applications should use strftime (or even sprintf) instead.  */
a85e8e
+# if defined GNULIB_POSIXCHECK
a85e8e
+#  undef asctime
a85e8e
+_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
a85e8e
+                 "better use strftime (or even sprintf) instead");
a85e8e
+# endif
a85e8e
+# if defined GNULIB_POSIXCHECK
a85e8e
+#  undef asctime_r
a85e8e
+_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
a85e8e
+                 "better use strftime (or even sprintf) instead");
a85e8e
+# endif
a85e8e
+# if defined GNULIB_POSIXCHECK
a85e8e
+#  undef ctime
a85e8e
+_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
a85e8e
+                 "better use strftime (or even sprintf) instead");
a85e8e
+# endif
a85e8e
+# if defined GNULIB_POSIXCHECK
a85e8e
+#  undef ctime_r
a85e8e
+_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
a85e8e
+                 "better use strftime (or even sprintf) instead");
a85e8e
+# endif
a85e8e
+
a85e8e
+#endif
a85e8e
diff --git a/grub-core/gnulib/time.in.h b/grub-core/gnulib/time.in.h
a85e8e
new file mode 100644
6b3c76
index 000000000..81abdf46e
a85e8e
--- /dev/null
a85e8e
+++ b/grub-core/gnulib/time.in.h
a85e8e
@@ -0,0 +1,274 @@
a85e8e
+/* A more-standard <time.h>.
a85e8e
+
a85e8e
+   Copyright (C) 2007-2014 Free Software Foundation, Inc.
a85e8e
+
a85e8e
+   This program is free software; you can redistribute it and/or modify
a85e8e
+   it under the terms of the GNU General Public License as published by
a85e8e
+   the Free Software Foundation; either version 3, or (at your option)
a85e8e
+   any later version.
a85e8e
+
a85e8e
+   This program is distributed in the hope that it will be useful,
a85e8e
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
a85e8e
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a85e8e
+   GNU General Public License for more details.
a85e8e
+
a85e8e
+   You should have received a copy of the GNU General Public License
a85e8e
+   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
a85e8e
+
a85e8e
+#if __GNUC__ >= 3
a85e8e
+@PRAGMA_SYSTEM_HEADER@
a85e8e
+#endif
a85e8e
+@PRAGMA_COLUMNS@
a85e8e
+
a85e8e
+/* Don't get in the way of glibc when it includes time.h merely to
a85e8e
+   declare a few standard symbols, rather than to declare all the
a85e8e
+   symbols.  Also, Solaris 8 <time.h> eventually includes itself
a85e8e
+   recursively; if that is happening, just include the system <time.h>
a85e8e
+   without adding our own declarations.  */
a85e8e
+#if (defined __need_time_t || defined __need_clock_t \
a85e8e
+     || defined __need_timespec \
a85e8e
+     || defined _@GUARD_PREFIX@_TIME_H)
a85e8e
+
a85e8e
+# @INCLUDE_NEXT@ @NEXT_TIME_H@
a85e8e
+
a85e8e
+#else
a85e8e
+
a85e8e
+# define _@GUARD_PREFIX@_TIME_H
a85e8e
+
a85e8e
+# @INCLUDE_NEXT@ @NEXT_TIME_H@
a85e8e
+
a85e8e
+/* NetBSD 5.0 mis-defines NULL.  */
a85e8e
+# include <stddef.h>
a85e8e
+
a85e8e
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
a85e8e
+
a85e8e
+/* The definition of _GL_ARG_NONNULL is copied here.  */
a85e8e
+
a85e8e
+/* The definition of _GL_WARN_ON_USE is copied here.  */
a85e8e
+
a85e8e
+/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
a85e8e
+   Or they define it with the wrong member names or define it in <sys/time.h>
a85e8e
+   (e.g., FreeBSD circa 1997).  Stock Mingw prior to 3.0 does not define it,
a85e8e
+   but the pthreads-win32 library defines it in <pthread.h>.  */
a85e8e
+# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
a85e8e
+#  if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
a85e8e
+#   include <sys/time.h>
a85e8e
+#  elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
a85e8e
+#   include <pthread.h>
a85e8e
+#  else
a85e8e
+
a85e8e
+#   ifdef __cplusplus
a85e8e
+extern "C" {
a85e8e
+#   endif
a85e8e
+
a85e8e
+#   if !GNULIB_defined_struct_timespec
a85e8e
+#    undef timespec
a85e8e
+#    define timespec rpl_timespec
a85e8e
+struct timespec
a85e8e
+{
a85e8e
+  time_t tv_sec;
a85e8e
+  long int tv_nsec;
a85e8e
+};
a85e8e
+#    define GNULIB_defined_struct_timespec 1
a85e8e
+#   endif
a85e8e
+
a85e8e
+#   ifdef __cplusplus
a85e8e
+}
a85e8e
+#   endif
a85e8e
+
a85e8e
+#  endif
a85e8e
+# endif
a85e8e
+
a85e8e
+# if !GNULIB_defined_struct_time_t_must_be_integral
a85e8e
+/* Per http://austingroupbugs.net/view.php?id=327, POSIX requires
a85e8e
+   time_t to be an integer type, even though C99 permits floating
a85e8e
+   point.  We don't know of any implementation that uses floating
a85e8e
+   point, and it is much easier to write code that doesn't have to
a85e8e
+   worry about that corner case, so we force the issue.  */
a85e8e
+struct __time_t_must_be_integral {
a85e8e
+  unsigned int __floating_time_t_unsupported : (time_t) 1;
a85e8e
+};
a85e8e
+#  define GNULIB_defined_struct_time_t_must_be_integral 1
a85e8e
+# endif
a85e8e
+
a85e8e
+/* Sleep for at least RQTP seconds unless interrupted,  If interrupted,
a85e8e
+   return -1 and store the remaining time into RMTP.  See
a85e8e
+   <http://www.opengroup.org/susv3xsh/nanosleep.html>.  */
a85e8e
+# if @GNULIB_NANOSLEEP@
a85e8e
+#  if @REPLACE_NANOSLEEP@
a85e8e
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#    define nanosleep rpl_nanosleep
a85e8e
+#   endif
a85e8e
+_GL_FUNCDECL_RPL (nanosleep, int,
a85e8e
+                  (struct timespec const *__rqtp, struct timespec *__rmtp)
a85e8e
+                  _GL_ARG_NONNULL ((1)));
a85e8e
+_GL_CXXALIAS_RPL (nanosleep, int,
a85e8e
+                  (struct timespec const *__rqtp, struct timespec *__rmtp));
a85e8e
+#  else
a85e8e
+#   if ! @HAVE_NANOSLEEP@
a85e8e
+_GL_FUNCDECL_SYS (nanosleep, int,
a85e8e
+                  (struct timespec const *__rqtp, struct timespec *__rmtp)
a85e8e
+                  _GL_ARG_NONNULL ((1)));
a85e8e
+#   endif
a85e8e
+_GL_CXXALIAS_SYS (nanosleep, int,
a85e8e
+                  (struct timespec const *__rqtp, struct timespec *__rmtp));
a85e8e
+#  endif
a85e8e
+_GL_CXXALIASWARN (nanosleep);
a85e8e
+# endif
a85e8e
+
a85e8e
+/* Return the 'time_t' representation of TP and normalize TP.  */
a85e8e
+# if @GNULIB_MKTIME@
a85e8e
+#  if @REPLACE_MKTIME@
a85e8e
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#    define mktime rpl_mktime
a85e8e
+#   endif
a85e8e
+_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
a85e8e
+_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
a85e8e
+#  else
a85e8e
+_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
a85e8e
+#  endif
a85e8e
+_GL_CXXALIASWARN (mktime);
a85e8e
+# endif
a85e8e
+
a85e8e
+/* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
a85e8e
+   <http://www.opengroup.org/susv3xsh/localtime_r.html> and
a85e8e
+   <http://www.opengroup.org/susv3xsh/gmtime_r.html>.  */
a85e8e
+# if @GNULIB_TIME_R@
a85e8e
+#  if @REPLACE_LOCALTIME_R@
a85e8e
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#    undef localtime_r
a85e8e
+#    define localtime_r rpl_localtime_r
a85e8e
+#   endif
a85e8e
+_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
a85e8e
+                                             struct tm *restrict __result)
a85e8e
+                                            _GL_ARG_NONNULL ((1, 2)));
a85e8e
+_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
a85e8e
+                                             struct tm *restrict __result));
a85e8e
+#  else
a85e8e
+#   if ! @HAVE_DECL_LOCALTIME_R@
a85e8e
+_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
a85e8e
+                                             struct tm *restrict __result)
a85e8e
+                                            _GL_ARG_NONNULL ((1, 2)));
a85e8e
+#   endif
a85e8e
+_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
a85e8e
+                                             struct tm *restrict __result));
a85e8e
+#  endif
a85e8e
+#  if @HAVE_DECL_LOCALTIME_R@
a85e8e
+_GL_CXXALIASWARN (localtime_r);
a85e8e
+#  endif
a85e8e
+#  if @REPLACE_LOCALTIME_R@
a85e8e
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#    undef gmtime_r
a85e8e
+#    define gmtime_r rpl_gmtime_r
a85e8e
+#   endif
a85e8e
+_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
a85e8e
+                                          struct tm *restrict __result)
a85e8e
+                                         _GL_ARG_NONNULL ((1, 2)));
a85e8e
+_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
a85e8e
+                                          struct tm *restrict __result));
a85e8e
+#  else
a85e8e
+#   if ! @HAVE_DECL_LOCALTIME_R@
a85e8e
+_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
a85e8e
+                                          struct tm *restrict __result)
a85e8e
+                                         _GL_ARG_NONNULL ((1, 2)));
a85e8e
+#   endif
a85e8e
+_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
a85e8e
+                                          struct tm *restrict __result));
a85e8e
+#  endif
a85e8e
+#  if @HAVE_DECL_LOCALTIME_R@
a85e8e
+_GL_CXXALIASWARN (gmtime_r);
a85e8e
+#  endif
a85e8e
+# endif
a85e8e
+
a85e8e
+/* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
a85e8e
+   <http://www.opengroup.org/susv3xsh/localtime.html> and
a85e8e
+   <http://www.opengroup.org/susv3xsh/gmtime.html>.  */
a85e8e
+# if @GNULIB_GETTIMEOFDAY@
a85e8e
+#  if @REPLACE_LOCALTIME@
a85e8e
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#    undef localtime
a85e8e
+#    define localtime rpl_localtime
a85e8e
+#   endif
a85e8e
+_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer)
a85e8e
+		                          _GL_ARG_NONNULL ((1)));
a85e8e
+_GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer));
a85e8e
+#  else
a85e8e
+_GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer));
a85e8e
+#  endif
a85e8e
+_GL_CXXALIASWARN (localtime);
a85e8e
+# endif
a85e8e
+
a85e8e
+# if @GNULIB_GETTIMEOFDAY@
a85e8e
+#  if @REPLACE_GMTIME@
a85e8e
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#    undef gmtime
a85e8e
+#    define gmtime rpl_gmtime
a85e8e
+#   endif
a85e8e
+_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer)
a85e8e
+                                       _GL_ARG_NONNULL ((1)));
a85e8e
+_GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer));
a85e8e
+#  else
a85e8e
+_GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer));
a85e8e
+#  endif
a85e8e
+_GL_CXXALIASWARN (gmtime);
a85e8e
+# endif
a85e8e
+
a85e8e
+/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
a85e8e
+   the resulting broken-down time into TM.  See
a85e8e
+   <http://www.opengroup.org/susv3xsh/strptime.html>.  */
a85e8e
+# if @GNULIB_STRPTIME@
a85e8e
+#  if ! @HAVE_STRPTIME@
a85e8e
+_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
a85e8e
+                                     char const *restrict __format,
a85e8e
+                                     struct tm *restrict __tm)
a85e8e
+                                    _GL_ARG_NONNULL ((1, 2, 3)));
a85e8e
+#  endif
a85e8e
+_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
a85e8e
+                                     char const *restrict __format,
a85e8e
+                                     struct tm *restrict __tm));
a85e8e
+_GL_CXXALIASWARN (strptime);
a85e8e
+# endif
a85e8e
+
a85e8e
+/* Convert TM to a time_t value, assuming UTC.  */
a85e8e
+# if @GNULIB_TIMEGM@
a85e8e
+#  if @REPLACE_TIMEGM@
a85e8e
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
a85e8e
+#    undef timegm
a85e8e
+#    define timegm rpl_timegm
a85e8e
+#   endif
a85e8e
+_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
a85e8e
+_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
a85e8e
+#  else
a85e8e
+#   if ! @HAVE_TIMEGM@
a85e8e
+_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
a85e8e
+#   endif
a85e8e
+_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
a85e8e
+#  endif
a85e8e
+_GL_CXXALIASWARN (timegm);
a85e8e
+# endif
a85e8e
+
a85e8e
+/* Encourage applications to avoid unsafe functions that can overrun
a85e8e
+   buffers when given outlandish struct tm values.  Portable
a85e8e
+   applications should use strftime (or even sprintf) instead.  */
a85e8e
+# if defined GNULIB_POSIXCHECK
a85e8e
+#  undef asctime
a85e8e
+_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
a85e8e
+                 "better use strftime (or even sprintf) instead");
a85e8e
+# endif
a85e8e
+# if defined GNULIB_POSIXCHECK
a85e8e
+#  undef asctime_r
a85e8e
+_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
a85e8e
+                 "better use strftime (or even sprintf) instead");
a85e8e
+# endif
a85e8e
+# if defined GNULIB_POSIXCHECK
a85e8e
+#  undef ctime
a85e8e
+_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
a85e8e
+                 "better use strftime (or even sprintf) instead");
a85e8e
+# endif
a85e8e
+# if defined GNULIB_POSIXCHECK
a85e8e
+#  undef ctime_r
a85e8e
+_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
a85e8e
+                 "better use strftime (or even sprintf) instead");
a85e8e
+# endif
a85e8e
+
a85e8e
+#endif
6b3c76
diff --git a/grub-core/osdep/windows/hostdisk.c b/grub-core/osdep/windows/hostdisk.c
6b3c76
index d390b25fc..9127e9263 100644
6b3c76
--- a/grub-core/osdep/windows/hostdisk.c
6b3c76
+++ b/grub-core/osdep/windows/hostdisk.c
6b3c76
@@ -353,6 +353,12 @@ grub_util_mkdir (const char *dir)
6b3c76
   free (windows_name);
6b3c76
 }
6b3c76
 
6b3c76
+ssize_t
6b3c76
+grub_util_readlink (const char *name, char *buf, size_t bufsize)
6b3c76
+{
6b3c76
+  return readlink(name, buf, bufsize);
6b3c76
+}
6b3c76
+
6b3c76
 int
6b3c76
 grub_util_rename (const char *from, const char *to)
6b3c76
 {
a85e8e
diff --git a/include/grub/osdep/hostfile_aros.h b/include/grub/osdep/hostfile_aros.h
6b3c76
index a059c0fa4..161fbb7bd 100644
a85e8e
--- a/include/grub/osdep/hostfile_aros.h
a85e8e
+++ b/include/grub/osdep/hostfile_aros.h
a85e8e
@@ -68,6 +68,12 @@ grub_util_rename (const char *from, const char *to)
a85e8e
   return rename (from, to);
a85e8e
 }
a85e8e
 
a85e8e
+static inline ssize_t
a85e8e
+grub_util_readlink (const char *name, char *buf, size_t bufsize)
a85e8e
+{
a85e8e
+  return readlink(name, buf, bufsize);
a85e8e
+}
a85e8e
+
a85e8e
 #define grub_util_mkdir(a) mkdir ((a), 0755)
a85e8e
 
a85e8e
 struct grub_util_fd
a85e8e
diff --git a/include/grub/osdep/hostfile_unix.h b/include/grub/osdep/hostfile_unix.h
6b3c76
index 9ffe46fa3..17cd3aa8b 100644
a85e8e
--- a/include/grub/osdep/hostfile_unix.h
a85e8e
+++ b/include/grub/osdep/hostfile_unix.h
a85e8e
@@ -71,6 +71,12 @@ grub_util_rename (const char *from, const char *to)
a85e8e
   return rename (from, to);
a85e8e
 }
a85e8e
 
a85e8e
+static inline ssize_t
a85e8e
+grub_util_readlink (const char *name, char *buf, size_t bufsize)
a85e8e
+{
a85e8e
+  return readlink(name, buf, bufsize);
a85e8e
+}
a85e8e
+
a85e8e
 #define grub_util_mkdir(a) mkdir ((a), 0755)
a85e8e
 
a85e8e
 #if defined (__NetBSD__)
a85e8e
diff --git a/include/grub/osdep/hostfile_windows.h b/include/grub/osdep/hostfile_windows.h
6b3c76
index bf6451b6d..8c92d0591 100644
a85e8e
--- a/include/grub/osdep/hostfile_windows.h
a85e8e
+++ b/include/grub/osdep/hostfile_windows.h
a85e8e
@@ -41,6 +41,8 @@ typedef struct grub_util_fd_dir *grub_util_fd_dir_t;
a85e8e
 
a85e8e
 int
a85e8e
 grub_util_rename (const char *from, const char *to);
a85e8e
+ssize_t
a85e8e
+grub_util_readlink (const char *name, char *buf, size_t bufsize);
a85e8e
 int
a85e8e
 grub_util_unlink (const char *name);
a85e8e
 void
a85e8e
diff --git a/m4/gettimeofday.m4 b/m4/gettimeofday.m4
a85e8e
new file mode 100644
6b3c76
index 000000000..1c2d66ee2
a85e8e
--- /dev/null
a85e8e
+++ b/m4/gettimeofday.m4
a85e8e
@@ -0,0 +1,138 @@
a85e8e
+# serial 21
a85e8e
+
a85e8e
+# Copyright (C) 2001-2003, 2005, 2007, 2009-2014 Free Software Foundation, Inc.
a85e8e
+# This file is free software; the Free Software Foundation
a85e8e
+# gives unlimited permission to copy and/or distribute it,
a85e8e
+# with or without modifications, as long as this notice is preserved.
a85e8e
+
a85e8e
+dnl From Jim Meyering.
a85e8e
+
a85e8e
+AC_DEFUN([gl_FUNC_GETTIMEOFDAY],
a85e8e
+[
a85e8e
+  AC_REQUIRE([AC_C_RESTRICT])
a85e8e
+  AC_REQUIRE([gl_HEADER_SYS_TIME_H])
a85e8e
+  AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS])
a85e8e
+  AC_CHECK_FUNCS_ONCE([gettimeofday])
a85e8e
+
a85e8e
+  gl_gettimeofday_timezone=void
a85e8e
+  if test $ac_cv_func_gettimeofday != yes; then
a85e8e
+    HAVE_GETTIMEOFDAY=0
a85e8e
+  else
a85e8e
+    gl_FUNC_GETTIMEOFDAY_CLOBBER
a85e8e
+    AC_CACHE_CHECK([for gettimeofday with POSIX signature],
a85e8e
+      [gl_cv_func_gettimeofday_posix_signature],
a85e8e
+      [AC_COMPILE_IFELSE(
a85e8e
+         [AC_LANG_PROGRAM(
a85e8e
+            [[#include <sys/time.h>
a85e8e
+              struct timeval c;
a85e8e
+              int gettimeofday (struct timeval *restrict, void *restrict);
a85e8e
+            ]],
a85e8e
+            [[/* glibc uses struct timezone * rather than the POSIX void *
a85e8e
+                 if _GNU_SOURCE is defined.  However, since the only portable
a85e8e
+                 use of gettimeofday uses NULL as the second parameter, and
a85e8e
+                 since the glibc definition is actually more typesafe, it is
a85e8e
+                 not worth wrapping this to get a compliant signature.  */
a85e8e
+              int (*f) (struct timeval *restrict, void *restrict)
a85e8e
+                = gettimeofday;
a85e8e
+              int x = f (&c, 0);
a85e8e
+              return !(x | c.tv_sec | c.tv_usec);
a85e8e
+            ]])],
a85e8e
+          [gl_cv_func_gettimeofday_posix_signature=yes],
a85e8e
+          [AC_COMPILE_IFELSE(
a85e8e
+            [AC_LANG_PROGRAM(
a85e8e
+              [[#include <sys/time.h>
a85e8e
+int gettimeofday (struct timeval *restrict, struct timezone *restrict);
a85e8e
+              ]])],
a85e8e
+            [gl_cv_func_gettimeofday_posix_signature=almost],
a85e8e
+            [gl_cv_func_gettimeofday_posix_signature=no])])])
a85e8e
+    if test $gl_cv_func_gettimeofday_posix_signature = almost; then
a85e8e
+      gl_gettimeofday_timezone='struct timezone'
a85e8e
+    elif test $gl_cv_func_gettimeofday_posix_signature != yes; then
a85e8e
+      REPLACE_GETTIMEOFDAY=1
a85e8e
+    fi
a85e8e
+    dnl If we override 'struct timeval', we also have to override gettimeofday.
a85e8e
+    if test $REPLACE_STRUCT_TIMEVAL = 1; then
a85e8e
+      REPLACE_GETTIMEOFDAY=1
a85e8e
+    fi
a85e8e
+    m4_ifdef([gl_FUNC_TZSET_CLOBBER], [
a85e8e
+      gl_FUNC_TZSET_CLOBBER
a85e8e
+      case "$gl_cv_func_tzset_clobber" in
a85e8e
+        *yes)
a85e8e
+          REPLACE_GETTIMEOFDAY=1
a85e8e
+          gl_GETTIMEOFDAY_REPLACE_LOCALTIME
a85e8e
+          AC_DEFINE([tzset], [rpl_tzset],
a85e8e
+            [Define to rpl_tzset if the wrapper function should be used.])
a85e8e
+          AC_DEFINE([TZSET_CLOBBERS_LOCALTIME], [1],
a85e8e
+            [Define if tzset clobbers localtime's static buffer.])
a85e8e
+          ;;
a85e8e
+      esac
a85e8e
+    ])
a85e8e
+  fi
a85e8e
+  AC_DEFINE_UNQUOTED([GETTIMEOFDAY_TIMEZONE], [$gl_gettimeofday_timezone],
a85e8e
+    [Define this to 'void' or 'struct timezone' to match the system's
a85e8e
+     declaration of the second argument to gettimeofday.])
a85e8e
+])
a85e8e
+
a85e8e
+
a85e8e
+dnl See if gettimeofday clobbers the static buffer that localtime uses
a85e8e
+dnl for its return value.  The gettimeofday function from Mac OS X 10.0.4
a85e8e
+dnl (i.e., Darwin 1.3.7) has this problem.
a85e8e
+dnl
a85e8e
+dnl If it does, then arrange to use gettimeofday and localtime only via
a85e8e
+dnl the wrapper functions that work around the problem.
a85e8e
+
a85e8e
+AC_DEFUN([gl_FUNC_GETTIMEOFDAY_CLOBBER],
a85e8e
+[
a85e8e
+ AC_REQUIRE([gl_HEADER_SYS_TIME_H])
a85e8e
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
a85e8e
+
a85e8e
+ AC_CACHE_CHECK([whether gettimeofday clobbers localtime buffer],
a85e8e
+  [gl_cv_func_gettimeofday_clobber],
a85e8e
+  [AC_RUN_IFELSE(
a85e8e
+     [AC_LANG_PROGRAM(
a85e8e
+        [[#include <string.h>
a85e8e
+          #include <sys/time.h>
a85e8e
+          #include <time.h>
a85e8e
+          #include <stdlib.h>
a85e8e
+        ]],
a85e8e
+        [[
a85e8e
+          time_t t = 0;
a85e8e
+          struct tm *lt;
a85e8e
+          struct tm saved_lt;
a85e8e
+          struct timeval tv;
a85e8e
+          lt = localtime (&t);
a85e8e
+          saved_lt = *lt;
a85e8e
+          gettimeofday (&tv, NULL);
a85e8e
+          return memcmp (lt, &saved_lt, sizeof (struct tm)) != 0;
a85e8e
+        ]])],
a85e8e
+     [gl_cv_func_gettimeofday_clobber=no],
a85e8e
+     [gl_cv_func_gettimeofday_clobber=yes],
a85e8e
+     [# When cross-compiling:
a85e8e
+      case "$host_os" in
a85e8e
+                # Guess all is fine on glibc systems.
a85e8e
+        *-gnu*) gl_cv_func_gettimeofday_clobber="guessing no" ;;
a85e8e
+                # If we don't know, assume the worst.
a85e8e
+        *)      gl_cv_func_gettimeofday_clobber="guessing yes" ;;
a85e8e
+      esac
a85e8e
+     ])])
a85e8e
+
a85e8e
+ case "$gl_cv_func_gettimeofday_clobber" in
a85e8e
+   *yes)
a85e8e
+     REPLACE_GETTIMEOFDAY=1
a85e8e
+     gl_GETTIMEOFDAY_REPLACE_LOCALTIME
a85e8e
+     AC_DEFINE([GETTIMEOFDAY_CLOBBERS_LOCALTIME], [1],
a85e8e
+       [Define if gettimeofday clobbers the localtime buffer.])
a85e8e
+     ;;
a85e8e
+ esac
a85e8e
+])
a85e8e
+
a85e8e
+AC_DEFUN([gl_GETTIMEOFDAY_REPLACE_LOCALTIME], [
a85e8e
+  REPLACE_GMTIME=1
a85e8e
+  REPLACE_LOCALTIME=1
a85e8e
+])
a85e8e
+
a85e8e
+# Prerequisites of lib/gettimeofday.c.
a85e8e
+AC_DEFUN([gl_PREREQ_GETTIMEOFDAY], [
a85e8e
+  AC_CHECK_HEADERS([sys/timeb.h])
a85e8e
+  AC_CHECK_FUNCS([_ftime])
a85e8e
+])
a85e8e
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
6b3c76
index 408918440..ef2ec5bcc 100644
a85e8e
--- a/m4/gnulib-cache.m4
a85e8e
+++ b/m4/gnulib-cache.m4
a85e8e
@@ -27,7 +27,7 @@
a85e8e
 
a85e8e
 
a85e8e
 # Specification in the form of a command-line invocation:
a85e8e
-#   gnulib-tool --import --dir=. --lib=libgnu --source-base=grub-core/gnulib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files argp error fnmatch getdelim getline gettext progname regex
a85e8e
+#   gnulib-tool --import --dir=. --lib=libgnu --source-base=grub-core/gnulib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files argp error fnmatch getdelim getline gettext progname readlink regex
a85e8e
 
a85e8e
 # Specification in the form of a few gnulib-tool.m4 macro invocations:
a85e8e
 gl_LOCAL_DIR([])
a85e8e
@@ -39,6 +39,7 @@ gl_MODULES([
a85e8e
   getline
a85e8e
   gettext
a85e8e
   progname
a85e8e
+  readlink
a85e8e
   regex
a85e8e
 ])
a85e8e
 gl_AVOID([])
a85e8e
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
6b3c76
index 7a19f60d8..66fd0eda9 100644
a85e8e
--- a/m4/gnulib-comp.m4
a85e8e
+++ b/m4/gnulib-comp.m4
a85e8e
@@ -60,10 +60,13 @@ AC_DEFUN([gl_EARLY],
a85e8e
   # Code from module getopt-posix:
a85e8e
   # Code from module gettext:
a85e8e
   # Code from module gettext-h:
a85e8e
+  # Code from module gettimeofday:
a85e8e
   # Code from module havelib:
a85e8e
   # Code from module include_next:
a85e8e
   # Code from module intprops:
a85e8e
   # Code from module langinfo:
a85e8e
+  # Code from module largefile:
a85e8e
+  AC_REQUIRE([AC_SYS_LARGEFILE])
a85e8e
   # Code from module localcharset:
a85e8e
   # Code from module locale:
a85e8e
   # Code from module localeconv:
a85e8e
@@ -81,8 +84,10 @@ AC_DEFUN([gl_EARLY],
a85e8e
   # Code from module multiarch:
a85e8e
   # Code from module nl_langinfo:
a85e8e
   # Code from module nocrash:
a85e8e
+  # Code from module pathmax:
a85e8e
   # Code from module progname:
a85e8e
   # Code from module rawmemchr:
a85e8e
+  # Code from module readlink:
a85e8e
   # Code from module realloc-posix:
a85e8e
   # Code from module regex:
a85e8e
   # Code from module size_max:
a85e8e
@@ -92,6 +97,7 @@ AC_DEFUN([gl_EARLY],
a85e8e
   # Code from module snippet/c++defs:
a85e8e
   # Code from module snippet/warn-on-use:
a85e8e
   # Code from module ssize_t:
a85e8e
+  # Code from module stat:
a85e8e
   # Code from module stdalign:
a85e8e
   # Code from module stdbool:
a85e8e
   # Code from module stddef:
a85e8e
@@ -108,8 +114,11 @@ AC_DEFUN([gl_EARLY],
a85e8e
   # Code from module strndup:
a85e8e
   # Code from module strnlen:
a85e8e
   # Code from module strnlen1:
a85e8e
+  # Code from module sys_stat:
a85e8e
+  # Code from module sys_time:
a85e8e
   # Code from module sys_types:
a85e8e
   # Code from module sysexits:
a85e8e
+  # Code from module time:
a85e8e
   # Code from module unistd:
a85e8e
   # Code from module unitypes:
a85e8e
   # Code from module uniwidth/base:
a85e8e
@@ -211,7 +220,14 @@ AC_DEFUN([gl_INIT],
a85e8e
   AM_GNU_GETTEXT_VERSION([0.18.1])
a85e8e
   AC_SUBST([LIBINTL])
a85e8e
   AC_SUBST([LTLIBINTL])
a85e8e
+  gl_FUNC_GETTIMEOFDAY
a85e8e
+  if test $HAVE_GETTIMEOFDAY = 0 || test $REPLACE_GETTIMEOFDAY = 1; then
a85e8e
+    AC_LIBOBJ([gettimeofday])
a85e8e
+    gl_PREREQ_GETTIMEOFDAY
a85e8e
+  fi
a85e8e
+  gl_SYS_TIME_MODULE_INDICATOR([gettimeofday])
a85e8e
   gl_LANGINFO_H
a85e8e
+  AC_REQUIRE([gl_LARGEFILE])
a85e8e
   gl_LOCALCHARSET
a85e8e
   LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(abs_top_builddir)/$gl_source_base\""
a85e8e
   AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT])
a85e8e
@@ -284,6 +300,7 @@ AC_DEFUN([gl_INIT],
a85e8e
     AC_LIBOBJ([nl_langinfo])
a85e8e
   fi
a85e8e
   gl_LANGINFO_MODULE_INDICATOR([nl_langinfo])
a85e8e
+  gl_PATHMAX
a85e8e
   AC_CHECK_DECLS([program_invocation_name], [], [], [#include <errno.h>])
a85e8e
   AC_CHECK_DECLS([program_invocation_short_name], [], [], [#include <errno.h>])
a85e8e
   gl_FUNC_RAWMEMCHR
a85e8e
@@ -292,6 +309,12 @@ AC_DEFUN([gl_INIT],
a85e8e
     gl_PREREQ_RAWMEMCHR
a85e8e
   fi
a85e8e
   gl_STRING_MODULE_INDICATOR([rawmemchr])
a85e8e
+  gl_FUNC_READLINK
a85e8e
+  if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then
a85e8e
+    AC_LIBOBJ([readlink])
a85e8e
+    gl_PREREQ_READLINK
a85e8e
+  fi
a85e8e
+  gl_UNISTD_MODULE_INDICATOR([readlink])
a85e8e
   gl_FUNC_REALLOC_POSIX
a85e8e
   if test $REPLACE_REALLOC = 1; then
a85e8e
     AC_LIBOBJ([realloc])
a85e8e
@@ -309,6 +332,12 @@ AC_DEFUN([gl_INIT],
a85e8e
   fi
a85e8e
   gl_UNISTD_MODULE_INDICATOR([sleep])
a85e8e
   gt_TYPE_SSIZE_T
a85e8e
+  gl_FUNC_STAT
a85e8e
+  if test $REPLACE_STAT = 1; then
a85e8e
+    AC_LIBOBJ([stat])
a85e8e
+    gl_PREREQ_STAT
a85e8e
+  fi
a85e8e
+  gl_SYS_STAT_MODULE_INDICATOR([stat])
a85e8e
   gl_STDALIGN_H
a85e8e
   AM_STDBOOL_H
a85e8e
   gl_STDDEF_H
a85e8e
@@ -355,9 +384,14 @@ AC_DEFUN([gl_INIT],
a85e8e
     gl_PREREQ_STRNLEN
a85e8e
   fi
a85e8e
   gl_STRING_MODULE_INDICATOR([strnlen])
a85e8e
+  gl_HEADER_SYS_STAT_H
a85e8e
+  AC_PROG_MKDIR_P
a85e8e
+  gl_HEADER_SYS_TIME_H
a85e8e
+  AC_PROG_MKDIR_P
a85e8e
   gl_SYS_TYPES_H
a85e8e
   AC_PROG_MKDIR_P
a85e8e
   gl_SYSEXITS
a85e8e
+  gl_HEADER_TIME_H
a85e8e
   gl_UNISTD_H
a85e8e
   gl_LIBUNISTRING_LIBHEADER([0.9], [unitypes.h])
a85e8e
   gl_LIBUNISTRING_LIBHEADER([0.9], [uniwidth.h])
a85e8e
@@ -562,6 +596,7 @@ AC_DEFUN([gl_FILE_LIST], [
a85e8e
   lib/getopt1.c
a85e8e
   lib/getopt_int.h
a85e8e
   lib/gettext.h
a85e8e
+  lib/gettimeofday.c
a85e8e
   lib/intprops.h
a85e8e
   lib/itold.c
a85e8e
   lib/langinfo.in.h
a85e8e
@@ -587,6 +622,7 @@ AC_DEFUN([gl_FILE_LIST], [
a85e8e
   lib/msvc-nothrow.c
a85e8e
   lib/msvc-nothrow.h
a85e8e
   lib/nl_langinfo.c
a85e8e
+  lib/pathmax.h
a85e8e
   lib/printf-args.c
a85e8e
   lib/printf-args.h
a85e8e
   lib/printf-parse.c
a85e8e
@@ -595,6 +631,7 @@ AC_DEFUN([gl_FILE_LIST], [
a85e8e
   lib/progname.h
a85e8e
   lib/rawmemchr.c
a85e8e
   lib/rawmemchr.valgrind
a85e8e
+  lib/readlink.c
a85e8e
   lib/realloc.c
a85e8e
   lib/ref-add.sin
a85e8e
   lib/ref-del.sin
a85e8e
@@ -606,6 +643,7 @@ AC_DEFUN([gl_FILE_LIST], [
a85e8e
   lib/regexec.c
a85e8e
   lib/size_max.h
a85e8e
   lib/sleep.c
a85e8e
+  lib/stat.c
a85e8e
   lib/stdalign.in.h
a85e8e
   lib/stdbool.in.h
a85e8e
   lib/stddef.in.h
a85e8e
@@ -627,8 +665,11 @@ AC_DEFUN([gl_FILE_LIST], [
a85e8e
   lib/strnlen.c
a85e8e
   lib/strnlen1.c
a85e8e
   lib/strnlen1.h
a85e8e
+  lib/sys_stat.in.h
a85e8e
+  lib/sys_time.in.h
a85e8e
   lib/sys_types.in.h
a85e8e
   lib/sysexits.in.h
a85e8e
+  lib/time.in.h
a85e8e
   lib/unistd.c
a85e8e
   lib/unistd.in.h
a85e8e
   lib/unitypes.in.h
a85e8e
@@ -667,6 +708,7 @@ AC_DEFUN([gl_FILE_LIST], [
a85e8e
   m4/getline.m4
a85e8e
   m4/getopt.m4
a85e8e
   m4/gettext.m4
a85e8e
+  m4/gettimeofday.m4
a85e8e
   m4/glibc2.m4
a85e8e
   m4/glibc21.m4
a85e8e
   m4/gnulib-common.m4
a85e8e
@@ -681,6 +723,7 @@ AC_DEFUN([gl_FILE_LIST], [
a85e8e
   m4/inttypes-pri.m4
a85e8e
   m4/inttypes_h.m4
a85e8e
   m4/langinfo_h.m4
a85e8e
+  m4/largefile.m4
a85e8e
   m4/lcmessage.m4
a85e8e
   m4/lib-ld.m4
a85e8e
   m4/lib-link.m4
a85e8e
@@ -712,16 +755,19 @@ AC_DEFUN([gl_FILE_LIST], [
a85e8e
   m4/nls.m4
a85e8e
   m4/nocrash.m4
a85e8e
   m4/off_t.m4
a85e8e
+  m4/pathmax.m4
a85e8e
   m4/po.m4
a85e8e
   m4/printf-posix.m4
a85e8e
   m4/printf.m4
a85e8e
   m4/progtest.m4
a85e8e
   m4/rawmemchr.m4
a85e8e
+  m4/readlink.m4
a85e8e
   m4/realloc.m4
a85e8e
   m4/regex.m4
a85e8e
   m4/size_max.m4
a85e8e
   m4/sleep.m4
a85e8e
   m4/ssize_t.m4
a85e8e
+  m4/stat.m4
a85e8e
   m4/stdalign.m4
a85e8e
   m4/stdbool.m4
a85e8e
   m4/stddef_h.m4
a85e8e
@@ -737,9 +783,12 @@ AC_DEFUN([gl_FILE_LIST], [
a85e8e
   m4/strndup.m4
a85e8e
   m4/strnlen.m4
a85e8e
   m4/sys_socket_h.m4
a85e8e
+  m4/sys_stat_h.m4
a85e8e
+  m4/sys_time_h.m4
a85e8e
   m4/sys_types_h.m4
a85e8e
   m4/sysexits.m4
a85e8e
   m4/threadlib.m4
a85e8e
+  m4/time_h.m4
a85e8e
   m4/uintmax_t.m4
a85e8e
   m4/unistd_h.m4
a85e8e
   m4/vasnprintf.m4
a85e8e
diff --git a/m4/largefile.m4 b/m4/largefile.m4
a85e8e
new file mode 100644
6b3c76
index 000000000..a1b564ad9
a85e8e
--- /dev/null
a85e8e
+++ b/m4/largefile.m4
a85e8e
@@ -0,0 +1,146 @@
a85e8e
+# Enable large files on systems where this is not the default.
a85e8e
+
a85e8e
+# Copyright 1992-1996, 1998-2014 Free Software Foundation, Inc.
a85e8e
+# This file is free software; the Free Software Foundation
a85e8e
+# gives unlimited permission to copy and/or distribute it,
a85e8e
+# with or without modifications, as long as this notice is preserved.
a85e8e
+
a85e8e
+# The following implementation works around a problem in autoconf <= 2.69;
a85e8e
+# AC_SYS_LARGEFILE does not configure for large inodes on Mac OS X 10.5,
a85e8e
+# or configures them incorrectly in some cases.
a85e8e
+m4_version_prereq([2.70], [] ,[
a85e8e
+
a85e8e
+# _AC_SYS_LARGEFILE_TEST_INCLUDES
a85e8e
+# -------------------------------
a85e8e
+m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES],
a85e8e
+[@%:@include <sys/types.h>
a85e8e
+ /* Check that off_t can represent 2**63 - 1 correctly.
a85e8e
+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
a85e8e
+    since some C++ compilers masquerading as C compilers
a85e8e
+    incorrectly reject 9223372036854775807.  */
a85e8e
+@%:@define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
a85e8e
+  int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721
a85e8e
+                       && LARGE_OFF_T % 2147483647 == 1)
a85e8e
+                      ? 1 : -1]];[]dnl
a85e8e
+])
a85e8e
+
a85e8e
+
a85e8e
+# _AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE,
a85e8e
+#                               CACHE-VAR,
a85e8e
+#                               DESCRIPTION,
a85e8e
+#                               PROLOGUE, [FUNCTION-BODY])
a85e8e
+# --------------------------------------------------------
a85e8e
+m4_define([_AC_SYS_LARGEFILE_MACRO_VALUE],
a85e8e
+[AC_CACHE_CHECK([for $1 value needed for large files], [$3],
a85e8e
+[while :; do
a85e8e
+  m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
a85e8e
+    [AC_LANG_PROGRAM([$5], [$6])],
a85e8e
+    [$3=no; break])
a85e8e
+  m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
a85e8e
+    [AC_LANG_PROGRAM([@%:@define $1 $2
a85e8e
+$5], [$6])],
a85e8e
+    [$3=$2; break])
a85e8e
+  $3=unknown
a85e8e
+  break
a85e8e
+done])
a85e8e
+case $$3 in #(
a85e8e
+  no | unknown) ;;
a85e8e
+  *) AC_DEFINE_UNQUOTED([$1], [$$3], [$4]);;
a85e8e
+esac
a85e8e
+rm -rf conftest*[]dnl
a85e8e
+])# _AC_SYS_LARGEFILE_MACRO_VALUE
a85e8e
+
a85e8e
+
a85e8e
+# AC_SYS_LARGEFILE
a85e8e
+# ----------------
a85e8e
+# By default, many hosts won't let programs access large files;
a85e8e
+# one must use special compiler options to get large-file access to work.
a85e8e
+# For more details about this brain damage please see:
a85e8e
+# http://www.unix-systems.org/version2/whatsnew/lfs20mar.html
a85e8e
+AC_DEFUN([AC_SYS_LARGEFILE],
a85e8e
+[AC_ARG_ENABLE(largefile,
a85e8e
+               [  --disable-largefile     omit support for large files])
a85e8e
+if test "$enable_largefile" != no; then
a85e8e
+
a85e8e
+  AC_CACHE_CHECK([for special C compiler options needed for large files],
a85e8e
+    ac_cv_sys_largefile_CC,
a85e8e
+    [ac_cv_sys_largefile_CC=no
a85e8e
+     if test "$GCC" != yes; then
a85e8e
+       ac_save_CC=$CC
a85e8e
+       while :; do
a85e8e
+         # IRIX 6.2 and later do not support large files by default,
a85e8e
+         # so use the C compiler's -n32 option if that helps.
a85e8e
+         AC_LANG_CONFTEST([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_INCLUDES])])
a85e8e
+         AC_COMPILE_IFELSE([], [break])
a85e8e
+         CC="$CC -n32"
a85e8e
+         AC_COMPILE_IFELSE([], [ac_cv_sys_largefile_CC=' -n32'; break])
a85e8e
+         break
a85e8e
+       done
a85e8e
+       CC=$ac_save_CC
a85e8e
+       rm -f conftest.$ac_ext
a85e8e
+    fi])
a85e8e
+  if test "$ac_cv_sys_largefile_CC" != no; then
a85e8e
+    CC=$CC$ac_cv_sys_largefile_CC
a85e8e
+  fi
a85e8e
+
a85e8e
+  _AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
a85e8e
+    ac_cv_sys_file_offset_bits,
a85e8e
+    [Number of bits in a file offset, on hosts where this is settable.],
a85e8e
+    [_AC_SYS_LARGEFILE_TEST_INCLUDES])
a85e8e
+  if test $ac_cv_sys_file_offset_bits = unknown; then
a85e8e
+    _AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
a85e8e
+      ac_cv_sys_large_files,
a85e8e
+      [Define for large files, on AIX-style hosts.],
a85e8e
+      [_AC_SYS_LARGEFILE_TEST_INCLUDES])
a85e8e
+  fi
a85e8e
+
a85e8e
+  AC_DEFINE([_DARWIN_USE_64_BIT_INODE], [1],
a85e8e
+    [Enable large inode numbers on Mac OS X 10.5.])
a85e8e
+fi
a85e8e
+])# AC_SYS_LARGEFILE
a85e8e
+])# m4_version_prereq 2.70
a85e8e
+
a85e8e
+# Enable large files on systems where this is implemented by Gnulib, not by the
a85e8e
+# system headers.
a85e8e
+# Set the variables WINDOWS_64_BIT_OFF_T, WINDOWS_64_BIT_ST_SIZE if Gnulib
a85e8e
+# overrides ensure that off_t or 'struct size.st_size' are 64-bit, respectively.
a85e8e
+AC_DEFUN([gl_LARGEFILE],
a85e8e
+[
a85e8e
+  AC_REQUIRE([AC_CANONICAL_HOST])
a85e8e
+  case "$host_os" in
a85e8e
+    mingw*)
a85e8e
+      dnl Native Windows.
a85e8e
+      dnl mingw64 defines off_t to a 64-bit type already, if
a85e8e
+      dnl _FILE_OFFSET_BITS=64, which is ensured by AC_SYS_LARGEFILE.
a85e8e
+      AC_CACHE_CHECK([for 64-bit off_t], [gl_cv_type_off_t_64],
a85e8e
+        [AC_COMPILE_IFELSE(
a85e8e
+           [AC_LANG_PROGRAM(
a85e8e
+              [[#include <sys/types.h>
a85e8e
+                int verify_off_t_size[sizeof (off_t) >= 8 ? 1 : -1];
a85e8e
+              ]],
a85e8e
+              [[]])],
a85e8e
+           [gl_cv_type_off_t_64=yes], [gl_cv_type_off_t_64=no])
a85e8e
+        ])
a85e8e
+      if test $gl_cv_type_off_t_64 = no; then
a85e8e
+        WINDOWS_64_BIT_OFF_T=1
a85e8e
+      else
a85e8e
+        WINDOWS_64_BIT_OFF_T=0
a85e8e
+      fi
a85e8e
+      dnl But all native Windows platforms (including mingw64) have a 32-bit
a85e8e
+      dnl st_size member in 'struct stat'.
a85e8e
+      WINDOWS_64_BIT_ST_SIZE=1
a85e8e
+      ;;
a85e8e
+    *)
a85e8e
+      dnl Nothing to do on gnulib's side.
a85e8e
+      dnl A 64-bit off_t is
a85e8e
+      dnl   - already the default on Mac OS X, FreeBSD, NetBSD, OpenBSD, IRIX,
a85e8e
+      dnl     OSF/1, Cygwin,
a85e8e
+      dnl   - enabled by _FILE_OFFSET_BITS=64 (ensured by AC_SYS_LARGEFILE) on
a85e8e
+      dnl     glibc, HP-UX, Solaris,
a85e8e
+      dnl   - enabled by _LARGE_FILES=1 (ensured by AC_SYS_LARGEFILE) on AIX,
a85e8e
+      dnl   - impossible to achieve on Minix 3.1.8.
a85e8e
+      WINDOWS_64_BIT_OFF_T=0
a85e8e
+      WINDOWS_64_BIT_ST_SIZE=0
a85e8e
+      ;;
a85e8e
+  esac
a85e8e
+])
a85e8e
diff --git a/m4/pathmax.m4 b/m4/pathmax.m4
a85e8e
new file mode 100644
6b3c76
index 000000000..114f91f04
a85e8e
--- /dev/null
a85e8e
+++ b/m4/pathmax.m4
a85e8e
@@ -0,0 +1,42 @@
a85e8e
+# pathmax.m4 serial 10
a85e8e
+dnl Copyright (C) 2002-2003, 2005-2006, 2009-2014 Free Software Foundation,
a85e8e
+dnl Inc.
a85e8e
+dnl This file is free software; the Free Software Foundation
a85e8e
+dnl gives unlimited permission to copy and/or distribute it,
a85e8e
+dnl with or without modifications, as long as this notice is preserved.
a85e8e
+
a85e8e
+AC_DEFUN([gl_PATHMAX],
a85e8e
+[
a85e8e
+  dnl Prerequisites of lib/pathmax.h.
a85e8e
+  AC_CHECK_HEADERS_ONCE([sys/param.h])
a85e8e
+])
a85e8e
+
a85e8e
+# Expands to a piece of C program that defines PATH_MAX in the same way as
a85e8e
+# "pathmax.h" will do.
a85e8e
+AC_DEFUN([gl_PATHMAX_SNIPPET], [[
a85e8e
+/* Arrange to define PATH_MAX, like "pathmax.h" does. */
a85e8e
+#if HAVE_UNISTD_H
a85e8e
+# include <unistd.h>
a85e8e
+#endif
a85e8e
+#include <limits.h>
a85e8e
+#if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN
a85e8e
+# include <sys/param.h>
a85e8e
+#endif
a85e8e
+#if !defined PATH_MAX && defined MAXPATHLEN
a85e8e
+# define PATH_MAX MAXPATHLEN
a85e8e
+#endif
a85e8e
+#ifdef __hpux
a85e8e
+# undef PATH_MAX
a85e8e
+# define PATH_MAX 1024
a85e8e
+#endif
a85e8e
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
a85e8e
+# undef PATH_MAX
a85e8e
+# define PATH_MAX 260
a85e8e
+#endif
a85e8e
+]])
a85e8e
+
a85e8e
+# Prerequisites of gl_PATHMAX_SNIPPET.
a85e8e
+AC_DEFUN([gl_PATHMAX_SNIPPET_PREREQ],
a85e8e
+[
a85e8e
+  AC_CHECK_HEADERS_ONCE([unistd.h sys/param.h])
a85e8e
+])
a85e8e
diff --git a/m4/readlink.m4 b/m4/readlink.m4
a85e8e
new file mode 100644
6b3c76
index 000000000..f9ce868c2
a85e8e
--- /dev/null
a85e8e
+++ b/m4/readlink.m4
a85e8e
@@ -0,0 +1,71 @@
a85e8e
+# readlink.m4 serial 12
a85e8e
+dnl Copyright (C) 2003, 2007, 2009-2014 Free Software Foundation, Inc.
a85e8e
+dnl This file is free software; the Free Software Foundation
a85e8e
+dnl gives unlimited permission to copy and/or distribute it,
a85e8e
+dnl with or without modifications, as long as this notice is preserved.
a85e8e
+
a85e8e
+AC_DEFUN([gl_FUNC_READLINK],
a85e8e
+[
a85e8e
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
a85e8e
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
a85e8e
+  AC_CHECK_FUNCS_ONCE([readlink])
a85e8e
+  if test $ac_cv_func_readlink = no; then
a85e8e
+    HAVE_READLINK=0
a85e8e
+  else
a85e8e
+    AC_CACHE_CHECK([whether readlink signature is correct],
a85e8e
+      [gl_cv_decl_readlink_works],
a85e8e
+      [AC_COMPILE_IFELSE(
a85e8e
+         [AC_LANG_PROGRAM(
a85e8e
+           [[#include <unistd.h>
a85e8e
+      /* Cause compilation failure if original declaration has wrong type.  */
a85e8e
+      ssize_t readlink (const char *, char *, size_t);]])],
a85e8e
+         [gl_cv_decl_readlink_works=yes], [gl_cv_decl_readlink_works=no])])
a85e8e
+    dnl Solaris 9 ignores trailing slash.
a85e8e
+    dnl FreeBSD 7.2 dereferences only one level of links with trailing slash.
a85e8e
+    AC_CACHE_CHECK([whether readlink handles trailing slash correctly],
a85e8e
+      [gl_cv_func_readlink_works],
a85e8e
+      [# We have readlink, so assume ln -s works.
a85e8e
+       ln -s conftest.no-such conftest.link
a85e8e
+       ln -s conftest.link conftest.lnk2
a85e8e
+       AC_RUN_IFELSE(
a85e8e
+         [AC_LANG_PROGRAM(
a85e8e
+           [[#include <unistd.h>
a85e8e
+]], [[char buf[20];
a85e8e
+      return readlink ("conftest.lnk2/", buf, sizeof buf) != -1;]])],
a85e8e
+         [gl_cv_func_readlink_works=yes], [gl_cv_func_readlink_works=no],
a85e8e
+         [case "$host_os" in
a85e8e
+                    # Guess yes on glibc systems.
a85e8e
+            *-gnu*) gl_cv_func_readlink_works="guessing yes" ;;
a85e8e
+                    # If we don't know, assume the worst.
a85e8e
+            *)      gl_cv_func_readlink_works="guessing no" ;;
a85e8e
+          esac
a85e8e
+         ])
a85e8e
+      rm -f conftest.link conftest.lnk2])
a85e8e
+    case "$gl_cv_func_readlink_works" in
a85e8e
+      *yes)
a85e8e
+        if test "$gl_cv_decl_readlink_works" != yes; then
a85e8e
+          REPLACE_READLINK=1
a85e8e
+        fi
a85e8e
+        ;;
a85e8e
+      *)
a85e8e
+        AC_DEFINE([READLINK_TRAILING_SLASH_BUG], [1], [Define to 1 if readlink
a85e8e
+          fails to recognize a trailing slash.])
a85e8e
+        REPLACE_READLINK=1
a85e8e
+        ;;
a85e8e
+    esac
a85e8e
+  fi
a85e8e
+])
a85e8e
+
a85e8e
+# Like gl_FUNC_READLINK, except prepare for separate compilation
a85e8e
+# (no REPLACE_READLINK, no AC_LIBOBJ).
a85e8e
+AC_DEFUN([gl_FUNC_READLINK_SEPARATE],
a85e8e
+[
a85e8e
+  AC_CHECK_FUNCS_ONCE([readlink])
a85e8e
+  gl_PREREQ_READLINK
a85e8e
+])
a85e8e
+
a85e8e
+# Prerequisites of lib/readlink.c.
a85e8e
+AC_DEFUN([gl_PREREQ_READLINK],
a85e8e
+[
a85e8e
+  :
a85e8e
+])
a85e8e
diff --git a/m4/stat.m4 b/m4/stat.m4
a85e8e
new file mode 100644
6b3c76
index 000000000..1ae327b36
a85e8e
--- /dev/null
a85e8e
+++ b/m4/stat.m4
a85e8e
@@ -0,0 +1,71 @@
a85e8e
+# serial 11
a85e8e
+
a85e8e
+# Copyright (C) 2009-2014 Free Software Foundation, Inc.
a85e8e
+#
a85e8e
+# This file is free software; the Free Software Foundation
a85e8e
+# gives unlimited permission to copy and/or distribute it,
a85e8e
+# with or without modifications, as long as this notice is preserved.
a85e8e
+
a85e8e
+AC_DEFUN([gl_FUNC_STAT],
a85e8e
+[
a85e8e
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
a85e8e
+  AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
a85e8e
+  AC_CHECK_FUNCS_ONCE([lstat])
a85e8e
+  dnl mingw is the only known platform where stat(".") and stat("./") differ
a85e8e
+  AC_CACHE_CHECK([whether stat handles trailing slashes on directories],
a85e8e
+      [gl_cv_func_stat_dir_slash],
a85e8e
+      [AC_RUN_IFELSE(
a85e8e
+         [AC_LANG_PROGRAM(
a85e8e
+           [[#include <sys/stat.h>
a85e8e
+]], [[struct stat st; return stat (".", &st) != stat ("./", &st);]])],
a85e8e
+         [gl_cv_func_stat_dir_slash=yes], [gl_cv_func_stat_dir_slash=no],
a85e8e
+         [case $host_os in
a85e8e
+            mingw*) gl_cv_func_stat_dir_slash="guessing no";;
a85e8e
+            *) gl_cv_func_stat_dir_slash="guessing yes";;
a85e8e
+          esac])])
a85e8e
+  dnl AIX 7.1, Solaris 9, mingw64 mistakenly succeed on stat("file/").
a85e8e
+  dnl (For mingw, this is due to a broken stat() override in libmingwex.a.)
a85e8e
+  dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/").
a85e8e
+  AC_CACHE_CHECK([whether stat handles trailing slashes on files],
a85e8e
+      [gl_cv_func_stat_file_slash],
a85e8e
+      [touch conftest.tmp
a85e8e
+       # Assume that if we have lstat, we can also check symlinks.
a85e8e
+       if test $ac_cv_func_lstat = yes; then
a85e8e
+         ln -s conftest.tmp conftest.lnk
a85e8e
+       fi
a85e8e
+       AC_RUN_IFELSE(
a85e8e
+         [AC_LANG_PROGRAM(
a85e8e
+           [[#include <sys/stat.h>
a85e8e
+]], [[int result = 0;
a85e8e
+      struct stat st;
a85e8e
+      if (!stat ("conftest.tmp/", &st))
a85e8e
+        result |= 1;
a85e8e
+#if HAVE_LSTAT
a85e8e
+      if (!stat ("conftest.lnk/", &st))
a85e8e
+        result |= 2;
a85e8e
+#endif
a85e8e
+      return result;
a85e8e
+           ]])],
a85e8e
+         [gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no],
a85e8e
+         [case "$host_os" in
a85e8e
+                    # Guess yes on glibc systems.
a85e8e
+            *-gnu*) gl_cv_func_stat_file_slash="guessing yes" ;;
a85e8e
+                    # If we don't know, assume the worst.
a85e8e
+            *)      gl_cv_func_stat_file_slash="guessing no" ;;
a85e8e
+          esac
a85e8e
+         ])
a85e8e
+       rm -f conftest.tmp conftest.lnk])
a85e8e
+  case $gl_cv_func_stat_dir_slash in
a85e8e
+    *no) REPLACE_STAT=1
a85e8e
+      AC_DEFINE([REPLACE_FUNC_STAT_DIR], [1], [Define to 1 if stat needs
a85e8e
+        help when passed a directory name with a trailing slash]);;
a85e8e
+  esac
a85e8e
+  case $gl_cv_func_stat_file_slash in
a85e8e
+    *no) REPLACE_STAT=1
a85e8e
+      AC_DEFINE([REPLACE_FUNC_STAT_FILE], [1], [Define to 1 if stat needs
a85e8e
+        help when passed a file name with a trailing slash]);;
a85e8e
+  esac
a85e8e
+])
a85e8e
+
a85e8e
+# Prerequisites of lib/stat.c.
a85e8e
+AC_DEFUN([gl_PREREQ_STAT], [:])
a85e8e
diff --git a/m4/sys_stat_h.m4 b/m4/sys_stat_h.m4
a85e8e
new file mode 100644
6b3c76
index 000000000..eaa7642ba
a85e8e
--- /dev/null
a85e8e
+++ b/m4/sys_stat_h.m4
a85e8e
@@ -0,0 +1,96 @@
a85e8e
+# sys_stat_h.m4 serial 28   -*- Autoconf -*-
a85e8e
+dnl Copyright (C) 2006-2014 Free Software Foundation, Inc.
a85e8e
+dnl This file is free software; the Free Software Foundation
a85e8e
+dnl gives unlimited permission to copy and/or distribute it,
a85e8e
+dnl with or without modifications, as long as this notice is preserved.
a85e8e
+
a85e8e
+dnl From Eric Blake.
a85e8e
+dnl Provide a GNU-like <sys/stat.h>.
a85e8e
+
a85e8e
+AC_DEFUN([gl_HEADER_SYS_STAT_H],
a85e8e
+[
a85e8e
+  AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
a85e8e
+
a85e8e
+  dnl Check for broken stat macros.
a85e8e
+  AC_REQUIRE([AC_HEADER_STAT])
a85e8e
+
a85e8e
+  gl_CHECK_NEXT_HEADERS([sys/stat.h])
a85e8e
+
a85e8e
+  dnl Ensure the type mode_t gets defined.
a85e8e
+  AC_REQUIRE([AC_TYPE_MODE_T])
a85e8e
+
a85e8e
+  dnl Whether to override 'struct stat'.
a85e8e
+  m4_ifdef([gl_LARGEFILE], [
a85e8e
+    AC_REQUIRE([gl_LARGEFILE])
a85e8e
+  ], [
a85e8e
+    WINDOWS_64_BIT_ST_SIZE=0
a85e8e
+  ])
a85e8e
+  AC_SUBST([WINDOWS_64_BIT_ST_SIZE])
a85e8e
+  if test $WINDOWS_64_BIT_ST_SIZE = 1; then
a85e8e
+    AC_DEFINE([_GL_WINDOWS_64_BIT_ST_SIZE], [1],
a85e8e
+      [Define to 1 if Gnulib overrides 'struct stat' on Windows so that
a85e8e
+       struct stat.st_size becomes 64-bit.])
a85e8e
+  fi
a85e8e
+
a85e8e
+  dnl Define types that are supposed to be defined in <sys/types.h> or
a85e8e
+  dnl <sys/stat.h>.
a85e8e
+  AC_CHECK_TYPE([nlink_t], [],
a85e8e
+    [AC_DEFINE([nlink_t], [int],
a85e8e
+       [Define to the type of st_nlink in struct stat, or a supertype.])],
a85e8e
+    [#include <sys/types.h>
a85e8e
+     #include <sys/stat.h>])
a85e8e
+
a85e8e
+  dnl Check for declarations of anything we want to poison if the
a85e8e
+  dnl corresponding gnulib module is not in use.
a85e8e
+  gl_WARN_ON_USE_PREPARE([[#include <sys/stat.h>
a85e8e
+    ]], [fchmodat fstat fstatat futimens lchmod lstat mkdirat mkfifo mkfifoat
a85e8e
+    mknod mknodat stat utimensat])
a85e8e
+]) # gl_HEADER_SYS_STAT_H
a85e8e
+
a85e8e
+AC_DEFUN([gl_SYS_STAT_MODULE_INDICATOR],
a85e8e
+[
a85e8e
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
a85e8e
+  AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
a85e8e
+  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
a85e8e
+  dnl Define it also as a C macro, for the benefit of the unit tests.
a85e8e
+  gl_MODULE_INDICATOR_FOR_TESTS([$1])
a85e8e
+])
a85e8e
+
a85e8e
+AC_DEFUN([gl_SYS_STAT_H_DEFAULTS],
a85e8e
+[
a85e8e
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) dnl for REPLACE_FCHDIR
a85e8e
+  GNULIB_FCHMODAT=0;    AC_SUBST([GNULIB_FCHMODAT])
a85e8e
+  GNULIB_FSTAT=0;       AC_SUBST([GNULIB_FSTAT])
a85e8e
+  GNULIB_FSTATAT=0;     AC_SUBST([GNULIB_FSTATAT])
a85e8e
+  GNULIB_FUTIMENS=0;    AC_SUBST([GNULIB_FUTIMENS])
a85e8e
+  GNULIB_LCHMOD=0;      AC_SUBST([GNULIB_LCHMOD])
a85e8e
+  GNULIB_LSTAT=0;       AC_SUBST([GNULIB_LSTAT])
a85e8e
+  GNULIB_MKDIRAT=0;     AC_SUBST([GNULIB_MKDIRAT])
a85e8e
+  GNULIB_MKFIFO=0;      AC_SUBST([GNULIB_MKFIFO])
a85e8e
+  GNULIB_MKFIFOAT=0;    AC_SUBST([GNULIB_MKFIFOAT])
a85e8e
+  GNULIB_MKNOD=0;       AC_SUBST([GNULIB_MKNOD])
a85e8e
+  GNULIB_MKNODAT=0;     AC_SUBST([GNULIB_MKNODAT])
a85e8e
+  GNULIB_STAT=0;        AC_SUBST([GNULIB_STAT])
a85e8e
+  GNULIB_UTIMENSAT=0;   AC_SUBST([GNULIB_UTIMENSAT])
a85e8e
+  dnl Assume proper GNU behavior unless another module says otherwise.
a85e8e
+  HAVE_FCHMODAT=1;      AC_SUBST([HAVE_FCHMODAT])
a85e8e
+  HAVE_FSTATAT=1;       AC_SUBST([HAVE_FSTATAT])
a85e8e
+  HAVE_FUTIMENS=1;      AC_SUBST([HAVE_FUTIMENS])
a85e8e
+  HAVE_LCHMOD=1;        AC_SUBST([HAVE_LCHMOD])
a85e8e
+  HAVE_LSTAT=1;         AC_SUBST([HAVE_LSTAT])
a85e8e
+  HAVE_MKDIRAT=1;       AC_SUBST([HAVE_MKDIRAT])
a85e8e
+  HAVE_MKFIFO=1;        AC_SUBST([HAVE_MKFIFO])
a85e8e
+  HAVE_MKFIFOAT=1;      AC_SUBST([HAVE_MKFIFOAT])
a85e8e
+  HAVE_MKNOD=1;         AC_SUBST([HAVE_MKNOD])
a85e8e
+  HAVE_MKNODAT=1;       AC_SUBST([HAVE_MKNODAT])
a85e8e
+  HAVE_UTIMENSAT=1;     AC_SUBST([HAVE_UTIMENSAT])
a85e8e
+  REPLACE_FSTAT=0;      AC_SUBST([REPLACE_FSTAT])
a85e8e
+  REPLACE_FSTATAT=0;    AC_SUBST([REPLACE_FSTATAT])
a85e8e
+  REPLACE_FUTIMENS=0;   AC_SUBST([REPLACE_FUTIMENS])
a85e8e
+  REPLACE_LSTAT=0;      AC_SUBST([REPLACE_LSTAT])
a85e8e
+  REPLACE_MKDIR=0;      AC_SUBST([REPLACE_MKDIR])
a85e8e
+  REPLACE_MKFIFO=0;     AC_SUBST([REPLACE_MKFIFO])
a85e8e
+  REPLACE_MKNOD=0;      AC_SUBST([REPLACE_MKNOD])
a85e8e
+  REPLACE_STAT=0;       AC_SUBST([REPLACE_STAT])
a85e8e
+  REPLACE_UTIMENSAT=0;  AC_SUBST([REPLACE_UTIMENSAT])
a85e8e
+])
a85e8e
diff --git a/m4/sys_time_h.m4 b/m4/sys_time_h.m4
a85e8e
new file mode 100644
6b3c76
index 000000000..5c79300f8
a85e8e
--- /dev/null
a85e8e
+++ b/m4/sys_time_h.m4
a85e8e
@@ -0,0 +1,110 @@
a85e8e
+# Configure a replacement for <sys/time.h>.
a85e8e
+# serial 8
a85e8e
+
a85e8e
+# Copyright (C) 2007, 2009-2014 Free Software Foundation, Inc.
a85e8e
+# This file is free software; the Free Software Foundation
a85e8e
+# gives unlimited permission to copy and/or distribute it,
a85e8e
+# with or without modifications, as long as this notice is preserved.
a85e8e
+
a85e8e
+# Written by Paul Eggert and Martin Lambers.
a85e8e
+
a85e8e
+AC_DEFUN([gl_HEADER_SYS_TIME_H],
a85e8e
+[
a85e8e
+  dnl Use AC_REQUIRE here, so that the REPLACE_GETTIMEOFDAY=0 statement
a85e8e
+  dnl below is expanded once only, before all REPLACE_GETTIMEOFDAY=1
a85e8e
+  dnl statements that occur in other macros.
a85e8e
+  AC_REQUIRE([gl_HEADER_SYS_TIME_H_BODY])
a85e8e
+])
a85e8e
+
a85e8e
+AC_DEFUN([gl_HEADER_SYS_TIME_H_BODY],
a85e8e
+[
a85e8e
+  AC_REQUIRE([AC_C_RESTRICT])
a85e8e
+  AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS])
a85e8e
+  AC_CHECK_HEADERS_ONCE([sys/time.h])
a85e8e
+  gl_CHECK_NEXT_HEADERS([sys/time.h])
a85e8e
+
a85e8e
+  if test $ac_cv_header_sys_time_h != yes; then
a85e8e
+    HAVE_SYS_TIME_H=0
a85e8e
+  fi
a85e8e
+
a85e8e
+  dnl On native Windows with MSVC, 'struct timeval' is defined in <winsock2.h>
a85e8e
+  dnl only. So include that header in the list.
a85e8e
+  gl_PREREQ_SYS_H_WINSOCK2
a85e8e
+  AC_CACHE_CHECK([for struct timeval], [gl_cv_sys_struct_timeval],
a85e8e
+    [AC_COMPILE_IFELSE(
a85e8e
+       [AC_LANG_PROGRAM(
a85e8e
+          [[#if HAVE_SYS_TIME_H
a85e8e
+             #include <sys/time.h>
a85e8e
+            #endif
a85e8e
+            #include <time.h>
a85e8e
+            #if HAVE_WINSOCK2_H
a85e8e
+            # include <winsock2.h>
a85e8e
+            #endif
a85e8e
+          ]],
a85e8e
+          [[static struct timeval x; x.tv_sec = x.tv_usec;]])],
a85e8e
+       [gl_cv_sys_struct_timeval=yes],
a85e8e
+       [gl_cv_sys_struct_timeval=no])
a85e8e
+    ])
a85e8e
+  if test $gl_cv_sys_struct_timeval != yes; then
a85e8e
+    HAVE_STRUCT_TIMEVAL=0
a85e8e
+  else
a85e8e
+    dnl On native Windows with a 64-bit 'time_t', 'struct timeval' is defined
a85e8e
+    dnl (in <sys/time.h> and <winsock2.h> for mingw64, in <winsock2.h> only
a85e8e
+    dnl for MSVC) with a tv_sec field of type 'long' (32-bit!), which is
a85e8e
+    dnl smaller than the 'time_t' type mandated by POSIX.
a85e8e
+    dnl On OpenBSD 5.1 amd64, tv_sec is 64 bits and time_t 32 bits, but
a85e8e
+    dnl that is good enough.
a85e8e
+    AC_CACHE_CHECK([for wide-enough struct timeval.tv_sec member],
a85e8e
+      [gl_cv_sys_struct_timeval_tv_sec],
a85e8e
+      [AC_COMPILE_IFELSE(
a85e8e
+         [AC_LANG_PROGRAM(
a85e8e
+            [[#if HAVE_SYS_TIME_H
a85e8e
+               #include <sys/time.h>
a85e8e
+              #endif
a85e8e
+              #include <time.h>
a85e8e
+              #if HAVE_WINSOCK2_H
a85e8e
+              # include <winsock2.h>
a85e8e
+              #endif
a85e8e
+            ]],
a85e8e
+            [[static struct timeval x;
a85e8e
+              typedef int verify_tv_sec_type[
a85e8e
+                sizeof (time_t) <= sizeof x.tv_sec ? 1 : -1
a85e8e
+              ];
a85e8e
+            ]])],
a85e8e
+         [gl_cv_sys_struct_timeval_tv_sec=yes],
a85e8e
+         [gl_cv_sys_struct_timeval_tv_sec=no])
a85e8e
+      ])
a85e8e
+    if test $gl_cv_sys_struct_timeval_tv_sec != yes; then
a85e8e
+      REPLACE_STRUCT_TIMEVAL=1
a85e8e
+    fi
a85e8e
+  fi
a85e8e
+
a85e8e
+  dnl Check for declarations of anything we want to poison if the
a85e8e
+  dnl corresponding gnulib module is not in use.
a85e8e
+  gl_WARN_ON_USE_PREPARE([[
a85e8e
+#if HAVE_SYS_TIME_H
a85e8e
+# include <sys/time.h>
a85e8e
+#endif
a85e8e
+#include <time.h>
a85e8e
+    ]], [gettimeofday])
a85e8e
+])
a85e8e
+
a85e8e
+AC_DEFUN([gl_SYS_TIME_MODULE_INDICATOR],
a85e8e
+[
a85e8e
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
a85e8e
+  AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS])
a85e8e
+  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
a85e8e
+  dnl Define it also as a C macro, for the benefit of the unit tests.
a85e8e
+  gl_MODULE_INDICATOR_FOR_TESTS([$1])
a85e8e
+])
a85e8e
+
a85e8e
+AC_DEFUN([gl_HEADER_SYS_TIME_H_DEFAULTS],
a85e8e
+[
a85e8e
+  GNULIB_GETTIMEOFDAY=0;     AC_SUBST([GNULIB_GETTIMEOFDAY])
a85e8e
+  dnl Assume POSIX behavior unless another module says otherwise.
a85e8e
+  HAVE_GETTIMEOFDAY=1;       AC_SUBST([HAVE_GETTIMEOFDAY])
a85e8e
+  HAVE_STRUCT_TIMEVAL=1;     AC_SUBST([HAVE_STRUCT_TIMEVAL])
a85e8e
+  HAVE_SYS_TIME_H=1;         AC_SUBST([HAVE_SYS_TIME_H])
a85e8e
+  REPLACE_GETTIMEOFDAY=0;    AC_SUBST([REPLACE_GETTIMEOFDAY])
a85e8e
+  REPLACE_STRUCT_TIMEVAL=0;  AC_SUBST([REPLACE_STRUCT_TIMEVAL])
a85e8e
+])
a85e8e
diff --git a/m4/time_h.m4 b/m4/time_h.m4
a85e8e
new file mode 100644
6b3c76
index 000000000..9852778f9
a85e8e
--- /dev/null
a85e8e
+++ b/m4/time_h.m4
a85e8e
@@ -0,0 +1,118 @@
a85e8e
+# Configure a more-standard replacement for <time.h>.
a85e8e
+
a85e8e
+# Copyright (C) 2000-2001, 2003-2007, 2009-2014 Free Software Foundation, Inc.
a85e8e
+
a85e8e
+# serial 8
a85e8e
+
a85e8e
+# This file is free software; the Free Software Foundation
a85e8e
+# gives unlimited permission to copy and/or distribute it,
a85e8e
+# with or without modifications, as long as this notice is preserved.
a85e8e
+
a85e8e
+# Written by Paul Eggert and Jim Meyering.
a85e8e
+
a85e8e
+AC_DEFUN([gl_HEADER_TIME_H],
a85e8e
+[
a85e8e
+  dnl Use AC_REQUIRE here, so that the default behavior below is expanded
a85e8e
+  dnl once only, before all statements that occur in other macros.
a85e8e
+  AC_REQUIRE([gl_HEADER_TIME_H_BODY])
a85e8e
+])
a85e8e
+
a85e8e
+AC_DEFUN([gl_HEADER_TIME_H_BODY],
a85e8e
+[
a85e8e
+  AC_REQUIRE([AC_C_RESTRICT])
a85e8e
+  AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
a85e8e
+  gl_NEXT_HEADERS([time.h])
a85e8e
+  AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
a85e8e
+])
a85e8e
+
a85e8e
+dnl Check whether 'struct timespec' is declared
a85e8e
+dnl in time.h, sys/time.h, or pthread.h.
a85e8e
+
a85e8e
+AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
a85e8e
+[
a85e8e
+  AC_CHECK_HEADERS_ONCE([sys/time.h])
a85e8e
+  AC_CACHE_CHECK([for struct timespec in <time.h>],
a85e8e
+    [gl_cv_sys_struct_timespec_in_time_h],
a85e8e
+    [AC_COMPILE_IFELSE(
a85e8e
+       [AC_LANG_PROGRAM(
a85e8e
+          [[#include <time.h>
a85e8e
+          ]],
a85e8e
+          [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
a85e8e
+       [gl_cv_sys_struct_timespec_in_time_h=yes],
a85e8e
+       [gl_cv_sys_struct_timespec_in_time_h=no])])
a85e8e
+
a85e8e
+  TIME_H_DEFINES_STRUCT_TIMESPEC=0
a85e8e
+  SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0
a85e8e
+  PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0
a85e8e
+  if test $gl_cv_sys_struct_timespec_in_time_h = yes; then
a85e8e
+    TIME_H_DEFINES_STRUCT_TIMESPEC=1
a85e8e
+  else
a85e8e
+    AC_CACHE_CHECK([for struct timespec in <sys/time.h>],
a85e8e
+      [gl_cv_sys_struct_timespec_in_sys_time_h],
a85e8e
+      [AC_COMPILE_IFELSE(
a85e8e
+         [AC_LANG_PROGRAM(
a85e8e
+            [[#include <sys/time.h>
a85e8e
+            ]],
a85e8e
+            [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
a85e8e
+         [gl_cv_sys_struct_timespec_in_sys_time_h=yes],
a85e8e
+         [gl_cv_sys_struct_timespec_in_sys_time_h=no])])
a85e8e
+    if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then
a85e8e
+      SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1
a85e8e
+    else
a85e8e
+      AC_CACHE_CHECK([for struct timespec in <pthread.h>],
a85e8e
+        [gl_cv_sys_struct_timespec_in_pthread_h],
a85e8e
+        [AC_COMPILE_IFELSE(
a85e8e
+           [AC_LANG_PROGRAM(
a85e8e
+              [[#include <pthread.h>
a85e8e
+              ]],
a85e8e
+              [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
a85e8e
+           [gl_cv_sys_struct_timespec_in_pthread_h=yes],
a85e8e
+           [gl_cv_sys_struct_timespec_in_pthread_h=no])])
a85e8e
+      if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then
a85e8e
+        PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1
a85e8e
+      fi
a85e8e
+    fi
a85e8e
+  fi
a85e8e
+  AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC])
a85e8e
+  AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC])
a85e8e
+  AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC])
a85e8e
+])
a85e8e
+
a85e8e
+AC_DEFUN([gl_TIME_MODULE_INDICATOR],
a85e8e
+[
a85e8e
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
a85e8e
+  AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
a85e8e
+  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
a85e8e
+  dnl Define it also as a C macro, for the benefit of the unit tests.
a85e8e
+  gl_MODULE_INDICATOR_FOR_TESTS([$1])
a85e8e
+])
a85e8e
+
a85e8e
+AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS],
a85e8e
+[
a85e8e
+  GNULIB_MKTIME=0;                       AC_SUBST([GNULIB_MKTIME])
a85e8e
+  GNULIB_NANOSLEEP=0;                    AC_SUBST([GNULIB_NANOSLEEP])
a85e8e
+  GNULIB_STRPTIME=0;                     AC_SUBST([GNULIB_STRPTIME])
a85e8e
+  GNULIB_TIMEGM=0;                       AC_SUBST([GNULIB_TIMEGM])
a85e8e
+  GNULIB_TIME_R=0;                       AC_SUBST([GNULIB_TIME_R])
a85e8e
+  dnl Assume proper GNU behavior unless another module says otherwise.
a85e8e
+  HAVE_DECL_LOCALTIME_R=1;               AC_SUBST([HAVE_DECL_LOCALTIME_R])
a85e8e
+  HAVE_NANOSLEEP=1;                      AC_SUBST([HAVE_NANOSLEEP])
a85e8e
+  HAVE_STRPTIME=1;                       AC_SUBST([HAVE_STRPTIME])
a85e8e
+  HAVE_TIMEGM=1;                         AC_SUBST([HAVE_TIMEGM])
a85e8e
+  dnl If another module says to replace or to not replace, do that.
a85e8e
+  dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK;
a85e8e
+  dnl this lets maintainers check for portability.
a85e8e
+  REPLACE_LOCALTIME_R=GNULIB_PORTCHECK;  AC_SUBST([REPLACE_LOCALTIME_R])
a85e8e
+  REPLACE_MKTIME=GNULIB_PORTCHECK;       AC_SUBST([REPLACE_MKTIME])
a85e8e
+  REPLACE_NANOSLEEP=GNULIB_PORTCHECK;    AC_SUBST([REPLACE_NANOSLEEP])
a85e8e
+  REPLACE_TIMEGM=GNULIB_PORTCHECK;       AC_SUBST([REPLACE_TIMEGM])
a85e8e
+
a85e8e
+  dnl Hack so that the time module doesn't depend on the sys_time module.
a85e8e
+  dnl First, default GNULIB_GETTIMEOFDAY to 0 if sys_time is absent.
a85e8e
+  : ${GNULIB_GETTIMEOFDAY=0};            AC_SUBST([GNULIB_GETTIMEOFDAY])
a85e8e
+  dnl Second, it's OK to not use GNULIB_PORTCHECK for REPLACE_GMTIME
a85e8e
+  dnl and REPLACE_LOCALTIME, as portability to Solaris 2.6 and earlier
a85e8e
+  dnl is no longer a big deal.
a85e8e
+  REPLACE_GMTIME=0;                      AC_SUBST([REPLACE_GMTIME])
a85e8e
+  REPLACE_LOCALTIME=0;                   AC_SUBST([REPLACE_LOCALTIME])
a85e8e
+])
6b3c76
-- 
6b3c76
2.13.5
6b3c76