dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0145-Add-grub_util_readlink.patch

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