dcavalca / rpms / grub2

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