f4c76c
From 022a44e0ed6b34a8c5f8c89c25bd9047ff681edd Mon Sep 17 00:00:00 2001
9ccddf
From: Peter Jones <pjones@redhat.com>
9ccddf
Date: Wed, 3 Sep 2014 10:01:03 -0400
f4c76c
Subject: [PATCH 54/74] Add grub_util_readlink()
9ccddf
9ccddf
Add grub_util_readlink().  This requires pulling in stat and readlink from
9ccddf
gnulib, which pulls in stat and related headers, but after that the
9ccddf
implementation is straightforward.
9ccddf
9ccddf
Signed-off-by: Peter Jones <pjones@redhat.com>
9ccddf
Reviewed-by: Adam Jackson <ajax@redhat.com>
9ccddf
---
9ccddf
 grub-core/gnulib/Makefile.am          | 177 +++++++-
9ccddf
 grub-core/gnulib/gettimeofday.c       | 154 +++++++
9ccddf
 grub-core/gnulib/pathmax.h            |  83 ++++
9ccddf
 grub-core/gnulib/readlink.c           |  74 ++++
9ccddf
 grub-core/gnulib/stat.c               | 138 +++++++
9ccddf
 grub-core/gnulib/sys_stat.in.h        | 732 ++++++++++++++++++++++++++++++++++
9ccddf
 grub-core/gnulib/sys_time.in.h        | 213 ++++++++++
9ccddf
 grub-core/gnulib/sys_types.in.h       |   2 +
9ccddf
 grub-core/gnulib/time.h               | 586 +++++++++++++++++++++++++++
9ccddf
 grub-core/gnulib/time.in.h            | 274 +++++++++++++
9ccddf
 grub-core/osdep/windows/hostdisk.c    |   6 +
9ccddf
 include/grub/osdep/hostfile_aros.h    |   6 +
9ccddf
 include/grub/osdep/hostfile_unix.h    |   6 +
9ccddf
 include/grub/osdep/hostfile_windows.h |   2 +
9ccddf
 m4/gettimeofday.m4                    | 138 +++++++
9ccddf
 m4/gnulib-cache.m4                    |   3 +-
9ccddf
 m4/gnulib-comp.m4                     |  49 +++
9ccddf
 m4/largefile.m4                       | 146 +++++++
9ccddf
 m4/pathmax.m4                         |  42 ++
9ccddf
 m4/readlink.m4                        |  71 ++++
9ccddf
 m4/stat.m4                            |  71 ++++
9ccddf
 m4/sys_stat_h.m4                      |  96 +++++
9ccddf
 m4/sys_time_h.m4                      | 110 +++++
9ccddf
 m4/time_h.m4                          | 118 ++++++
9ccddf
 24 files changed, 3295 insertions(+), 2 deletions(-)
9ccddf
 create mode 100644 grub-core/gnulib/gettimeofday.c
9ccddf
 create mode 100644 grub-core/gnulib/pathmax.h
9ccddf
 create mode 100644 grub-core/gnulib/readlink.c
9ccddf
 create mode 100644 grub-core/gnulib/stat.c
9ccddf
 create mode 100644 grub-core/gnulib/sys_stat.in.h
9ccddf
 create mode 100644 grub-core/gnulib/sys_time.in.h
9ccddf
 create mode 100644 grub-core/gnulib/time.h
9ccddf
 create mode 100644 grub-core/gnulib/time.in.h
9ccddf
 create mode 100644 m4/gettimeofday.m4
9ccddf
 create mode 100644 m4/largefile.m4
9ccddf
 create mode 100644 m4/pathmax.m4
9ccddf
 create mode 100644 m4/readlink.m4
9ccddf
 create mode 100644 m4/stat.m4
9ccddf
 create mode 100644 m4/sys_stat_h.m4
9ccddf
 create mode 100644 m4/sys_time_h.m4
9ccddf
 create mode 100644 m4/time_h.m4
9ccddf
9ccddf
diff --git a/grub-core/gnulib/Makefile.am b/grub-core/gnulib/Makefile.am
9ccddf
index 3444397..b7c5e60 100644
9ccddf
--- a/grub-core/gnulib/Makefile.am
9ccddf
+++ b/grub-core/gnulib/Makefile.am
9ccddf
@@ -21,7 +21,7 @@
9ccddf
 # the same distribution terms as the rest of that program.
9ccddf
 #
9ccddf
 # Generated by gnulib-tool.
9ccddf
-# 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
9ccddf
+# 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
9ccddf
 
9ccddf
 AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects
9ccddf
 
9ccddf
@@ -326,6 +326,15 @@ libgnu_a_SOURCES += gettext.h
9ccddf
 
9ccddf
 ## end   gnulib module gettext-h
9ccddf
 
9ccddf
+## begin gnulib module gettimeofday
9ccddf
+
9ccddf
+
9ccddf
+EXTRA_DIST += gettimeofday.c
9ccddf
+
9ccddf
+EXTRA_libgnu_a_SOURCES += gettimeofday.c
9ccddf
+
9ccddf
+## end   gnulib module gettimeofday
9ccddf
+
9ccddf
 ## begin gnulib module havelib
9ccddf
 
9ccddf
 
9ccddf
@@ -596,6 +605,13 @@ EXTRA_libgnu_a_SOURCES += nl_langinfo.c
9ccddf
 
9ccddf
 ## end   gnulib module nl_langinfo
9ccddf
 
9ccddf
+## begin gnulib module pathmax
9ccddf
+
9ccddf
+
9ccddf
+EXTRA_DIST += pathmax.h
9ccddf
+
9ccddf
+## end   gnulib module pathmax
9ccddf
+
9ccddf
 ## begin gnulib module progname
9ccddf
 
9ccddf
 libgnu_a_SOURCES += progname.h progname.c
9ccddf
@@ -611,6 +627,15 @@ EXTRA_libgnu_a_SOURCES += rawmemchr.c
9ccddf
 
9ccddf
 ## end   gnulib module rawmemchr
9ccddf
 
9ccddf
+## begin gnulib module readlink
9ccddf
+
9ccddf
+
9ccddf
+EXTRA_DIST += readlink.c
9ccddf
+
9ccddf
+EXTRA_libgnu_a_SOURCES += readlink.c
9ccddf
+
9ccddf
+## end   gnulib module readlink
9ccddf
+
9ccddf
 ## begin gnulib module realloc-posix
9ccddf
 
9ccddf
 
9ccddf
@@ -725,6 +750,15 @@ EXTRA_DIST += $(top_srcdir)/build-aux/snippet/warn-on-use.h
9ccddf
 
9ccddf
 ## end   gnulib module snippet/warn-on-use
9ccddf
 
9ccddf
+## begin gnulib module stat
9ccddf
+
9ccddf
+
9ccddf
+EXTRA_DIST += stat.c
9ccddf
+
9ccddf
+EXTRA_libgnu_a_SOURCES += stat.c
9ccddf
+
9ccddf
+## end   gnulib module stat
9ccddf
+
9ccddf
 ## begin gnulib module stdalign
9ccddf
 
9ccddf
 BUILT_SOURCES += $(STDALIGN_H)
9ccddf
@@ -1280,6 +1314,102 @@ libgnu_a_SOURCES += strnlen1.h strnlen1.c
9ccddf
 
9ccddf
 ## end   gnulib module strnlen1
9ccddf
 
9ccddf
+## begin gnulib module sys_stat
9ccddf
+
9ccddf
+BUILT_SOURCES += sys/stat.h
9ccddf
+
9ccddf
+# We need the following in order to create <sys stat.h=""> when the system
9ccddf
+# has one that is incomplete.
9ccddf
+sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
9ccddf
+	$(AM_V_at)$(MKDIR_P) sys
9ccddf
+	$(AM_V_GEN)rm -f $@-t $@ && \
9ccddf
+	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
9ccddf
+	  sed -e 's|@''GUARD_PREFIX''@|GL|g' \
9ccddf
+	      -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
9ccddf
+	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
9ccddf
+	      -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
9ccddf
+	      -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
9ccddf
+	      -e 's|@''WINDOWS_64_BIT_ST_SIZE''@|$(WINDOWS_64_BIT_ST_SIZE)|g' \
9ccddf
+	      -e 's/@''GNULIB_FCHMODAT''@/$(GNULIB_FCHMODAT)/g' \
9ccddf
+	      -e 's/@''GNULIB_FSTAT''@/$(GNULIB_FSTAT)/g' \
9ccddf
+	      -e 's/@''GNULIB_FSTATAT''@/$(GNULIB_FSTATAT)/g' \
9ccddf
+	      -e 's/@''GNULIB_FUTIMENS''@/$(GNULIB_FUTIMENS)/g' \
9ccddf
+	      -e 's/@''GNULIB_LCHMOD''@/$(GNULIB_LCHMOD)/g' \
9ccddf
+	      -e 's/@''GNULIB_LSTAT''@/$(GNULIB_LSTAT)/g' \
9ccddf
+	      -e 's/@''GNULIB_MKDIRAT''@/$(GNULIB_MKDIRAT)/g' \
9ccddf
+	      -e 's/@''GNULIB_MKFIFO''@/$(GNULIB_MKFIFO)/g' \
9ccddf
+	      -e 's/@''GNULIB_MKFIFOAT''@/$(GNULIB_MKFIFOAT)/g' \
9ccddf
+	      -e 's/@''GNULIB_MKNOD''@/$(GNULIB_MKNOD)/g' \
9ccddf
+	      -e 's/@''GNULIB_MKNODAT''@/$(GNULIB_MKNODAT)/g' \
9ccddf
+	      -e 's/@''GNULIB_STAT''@/$(GNULIB_STAT)/g' \
9ccddf
+	      -e 's/@''GNULIB_UTIMENSAT''@/$(GNULIB_UTIMENSAT)/g' \
9ccddf
+	      -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \
9ccddf
+	      -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \
9ccddf
+	      -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \
9ccddf
+	      -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \
9ccddf
+	      -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \
9ccddf
+	      -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \
9ccddf
+	      -e 's|@''HAVE_MKFIFO''@|$(HAVE_MKFIFO)|g' \
9ccddf
+	      -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \
9ccddf
+	      -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \
9ccddf
+	      -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \
9ccddf
+	      -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \
9ccddf
+	      -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \
9ccddf
+	      -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \
9ccddf
+	      -e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \
9ccddf
+	      -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \
9ccddf
+	      -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \
9ccddf
+	      -e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \
9ccddf
+	      -e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \
9ccddf
+	      -e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \
9ccddf
+	      -e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \
9ccddf
+	      -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
9ccddf
+	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
9ccddf
+	      -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
9ccddf
+	      < $(srcdir)/sys_stat.in.h; \
9ccddf
+	} > $@-t && \
9ccddf
+	mv $@-t $@
9ccddf
+MOSTLYCLEANFILES += sys/stat.h sys/stat.h-t
9ccddf
+MOSTLYCLEANDIRS += sys
9ccddf
+
9ccddf
+EXTRA_DIST += sys_stat.in.h
9ccddf
+
9ccddf
+## end   gnulib module sys_stat
9ccddf
+
9ccddf
+## begin gnulib module sys_time
9ccddf
+
9ccddf
+BUILT_SOURCES += sys/time.h
9ccddf
+
9ccddf
+# We need the following in order to create <sys time.h=""> when the system
9ccddf
+# doesn't have one that works with the given compiler.
9ccddf
+sys/time.h: sys_time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
9ccddf
+	$(AM_V_at)$(MKDIR_P) sys
9ccddf
+	$(AM_V_GEN)rm -f $@-t $@ && \
9ccddf
+	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
9ccddf
+	  sed -e 's|@''GUARD_PREFIX''@|GL|g' \
9ccddf
+	      -e 's/@''HAVE_SYS_TIME_H''@/$(HAVE_SYS_TIME_H)/g' \
9ccddf
+	      -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
9ccddf
+	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
9ccddf
+	      -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
9ccddf
+	      -e 's|@''NEXT_SYS_TIME_H''@|$(NEXT_SYS_TIME_H)|g' \
9ccddf
+	      -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \
9ccddf
+	      -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
9ccddf
+	      -e 's/@''HAVE_GETTIMEOFDAY''@/$(HAVE_GETTIMEOFDAY)/g' \
9ccddf
+	      -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \
9ccddf
+	      -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \
9ccddf
+	      -e 's/@''REPLACE_STRUCT_TIMEVAL''@/$(REPLACE_STRUCT_TIMEVAL)/g' \
9ccddf
+	      -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
9ccddf
+	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
9ccddf
+	      -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
9ccddf
+	      < $(srcdir)/sys_time.in.h; \
9ccddf
+	} > $@-t && \
9ccddf
+	mv $@-t $@
9ccddf
+MOSTLYCLEANFILES += sys/time.h sys/time.h-t
9ccddf
+
9ccddf
+EXTRA_DIST += sys_time.in.h
9ccddf
+
9ccddf
+## end   gnulib module sys_time
9ccddf
+
9ccddf
 ## begin gnulib module sys_types
9ccddf
 
9ccddf
 BUILT_SOURCES += sys/types.h
9ccddf
@@ -1334,6 +1464,51 @@ EXTRA_DIST += sysexits.in.h
9ccddf
 
9ccddf
 ## end   gnulib module sysexits
9ccddf
 
9ccddf
+## begin gnulib module time
9ccddf
+
9ccddf
+BUILT_SOURCES += time.h
9ccddf
+
9ccddf
+# We need the following in order to create <time.h> when the system
9ccddf
+# doesn't have one that works with the given compiler.
9ccddf
+time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
9ccddf
+	$(AM_V_GEN)rm -f $@-t $@ && \
9ccddf
+	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
9ccddf
+	  sed -e 's|@''GUARD_PREFIX''@|GL|g' \
9ccddf
+	      -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
9ccddf
+	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
9ccddf
+	      -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
9ccddf
+	      -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \
9ccddf
+	      -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \
9ccddf
+	      -e 's/@''GNULIB_MKTIME''@/$(GNULIB_MKTIME)/g' \
9ccddf
+	      -e 's/@''GNULIB_NANOSLEEP''@/$(GNULIB_NANOSLEEP)/g' \
9ccddf
+	      -e 's/@''GNULIB_STRPTIME''@/$(GNULIB_STRPTIME)/g' \
9ccddf
+	      -e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \
9ccddf
+	      -e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \
9ccddf
+	      -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \
9ccddf
+	      -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \
9ccddf
+	      -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
9ccddf
+	      -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
9ccddf
+	      -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \
9ccddf
+	      -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \
9ccddf
+	      -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
9ccddf
+	      -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
9ccddf
+	      -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
9ccddf
+	      -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
9ccddf
+	      -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \
9ccddf
+	      -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
9ccddf
+	      -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
9ccddf
+	      -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
9ccddf
+	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
9ccddf
+	      -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
9ccddf
+	      < $(srcdir)/time.in.h; \
9ccddf
+	} > $@-t && \
9ccddf
+	mv $@-t $@
9ccddf
+MOSTLYCLEANFILES += time.h time.h-t
9ccddf
+
9ccddf
+EXTRA_DIST += time.in.h
9ccddf
+
9ccddf
+## end   gnulib module time
9ccddf
+
9ccddf
 ## begin gnulib module unistd
9ccddf
 
9ccddf
 BUILT_SOURCES += unistd.h
9ccddf
diff --git a/grub-core/gnulib/gettimeofday.c b/grub-core/gnulib/gettimeofday.c
9ccddf
new file mode 100644
9ccddf
index 0000000..8b2058e
9ccddf
--- /dev/null
9ccddf
+++ b/grub-core/gnulib/gettimeofday.c
9ccddf
@@ -0,0 +1,154 @@
9ccddf
+/* Provide gettimeofday for systems that don't have it or for which it's broken.
9ccddf
+
9ccddf
+   Copyright (C) 2001-2003, 2005-2007, 2009-2014 Free Software Foundation, Inc.
9ccddf
+
9ccddf
+   This program is free software; you can redistribute it and/or modify
9ccddf
+   it under the terms of the GNU General Public License as published by
9ccddf
+   the Free Software Foundation; either version 3, or (at your option)
9ccddf
+   any later version.
9ccddf
+
9ccddf
+   This program is distributed in the hope that it will be useful,
9ccddf
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
9ccddf
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9ccddf
+   GNU General Public License for more details.
9ccddf
+
9ccddf
+   You should have received a copy of the GNU General Public License
9ccddf
+   along with this program; if not, see <http: www.gnu.org="" licenses=""/>.  */
9ccddf
+
9ccddf
+/* written by Jim Meyering */
9ccddf
+
9ccddf
+#include <config.h>
9ccddf
+
9ccddf
+/* Specification.  */
9ccddf
+#include <sys time.h="">
9ccddf
+
9ccddf
+#include <time.h>
9ccddf
+
9ccddf
+#if HAVE_SYS_TIMEB_H
9ccddf
+# include <sys timeb.h="">
9ccddf
+#endif
9ccddf
+
9ccddf
+#if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME
9ccddf
+
9ccddf
+/* Work around the bug in some systems whereby gettimeofday clobbers
9ccddf
+   the static buffer that localtime uses for its return value.  The
9ccddf
+   gettimeofday function from Mac OS X 10.0.4 (i.e., Darwin 1.3.7) has
9ccddf
+   this problem.  The tzset replacement is necessary for at least
9ccddf
+   Solaris 2.5, 2.5.1, and 2.6.  */
9ccddf
+
9ccddf
+static struct tm tm_zero_buffer;
9ccddf
+static struct tm *localtime_buffer_addr = &tm_zero_buffer;
9ccddf
+
9ccddf
+# undef localtime
9ccddf
+extern struct tm *localtime (time_t const *);
9ccddf
+
9ccddf
+# undef gmtime
9ccddf
+extern struct tm *gmtime (time_t const *);
9ccddf
+
9ccddf
+/* This is a wrapper for localtime.  It is used only on systems for which
9ccddf
+   gettimeofday clobbers the static buffer used for localtime's result.
9ccddf
+
9ccddf
+   On the first call, record the address of the static buffer that
9ccddf
+   localtime uses for its result.  */
9ccddf
+
9ccddf
+struct tm *
9ccddf
+rpl_localtime (time_t const *timep)
9ccddf
+{
9ccddf
+  struct tm *tm = localtime (timep);
9ccddf
+
9ccddf
+  if (localtime_buffer_addr == &tm_zero_buffer)
9ccddf
+    localtime_buffer_addr = tm;
9ccddf
+
9ccddf
+  return tm;
9ccddf
+}
9ccddf
+
9ccddf
+/* Same as above, since gmtime and localtime use the same buffer.  */
9ccddf
+struct tm *
9ccddf
+rpl_gmtime (time_t const *timep)
9ccddf
+{
9ccddf
+  struct tm *tm = gmtime (timep);
9ccddf
+
9ccddf
+  if (localtime_buffer_addr == &tm_zero_buffer)
9ccddf
+    localtime_buffer_addr = tm;
9ccddf
+
9ccddf
+  return tm;
9ccddf
+}
9ccddf
+
9ccddf
+#endif /* GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME */
9ccddf
+
9ccddf
+#if TZSET_CLOBBERS_LOCALTIME
9ccddf
+
9ccddf
+# undef tzset
9ccddf
+extern void tzset (void);
9ccddf
+
9ccddf
+/* This is a wrapper for tzset, for systems on which tzset may clobber
9ccddf
+   the static buffer used for localtime's result.  */
9ccddf
+void
9ccddf
+rpl_tzset (void)
9ccddf
+{
9ccddf
+  /* Save and restore the contents of the buffer used for localtime's
9ccddf
+     result around the call to tzset.  */
9ccddf
+  struct tm save = *localtime_buffer_addr;
9ccddf
+  tzset ();
9ccddf
+  *localtime_buffer_addr = save;
9ccddf
+}
9ccddf
+#endif
9ccddf
+
9ccddf
+/* This is a wrapper for gettimeofday.  It is used only on systems
9ccddf
+   that lack this function, or whose implementation of this function
9ccddf
+   causes problems.  */
9ccddf
+
9ccddf
+int
9ccddf
+gettimeofday (struct timeval *restrict tv, void *restrict tz)
9ccddf
+{
9ccddf
+#undef gettimeofday
9ccddf
+#if HAVE_GETTIMEOFDAY
9ccddf
+# if GETTIMEOFDAY_CLOBBERS_LOCALTIME
9ccddf
+  /* Save and restore the contents of the buffer used for localtime's
9ccddf
+     result around the call to gettimeofday.  */
9ccddf
+  struct tm save = *localtime_buffer_addr;
9ccddf
+# endif
9ccddf
+
9ccddf
+# if defined timeval /* 'struct timeval' overridden by gnulib?  */
9ccddf
+#  undef timeval
9ccddf
+  struct timeval otv;
9ccddf
+  int result = gettimeofday (&otv, (struct timezone *) tz);
9ccddf
+  if (result == 0)
9ccddf
+    {
9ccddf
+      tv->tv_sec = otv.tv_sec;
9ccddf
+      tv->tv_usec = otv.tv_usec;
9ccddf
+    }
9ccddf
+# else
9ccddf
+  int result = gettimeofday (tv, (struct timezone *) tz);
9ccddf
+# endif
9ccddf
+
9ccddf
+# if GETTIMEOFDAY_CLOBBERS_LOCALTIME
9ccddf
+  *localtime_buffer_addr = save;
9ccddf
+# endif
9ccddf
+
9ccddf
+  return result;
9ccddf
+
9ccddf
+#else
9ccddf
+
9ccddf
+# if HAVE__FTIME
9ccddf
+
9ccddf
+  struct _timeb timebuf;
9ccddf
+  _ftime (&timebuf);
9ccddf
+  tv->tv_sec = timebuf.time;
9ccddf
+  tv->tv_usec = timebuf.millitm * 1000;
9ccddf
+
9ccddf
+# else
9ccddf
+
9ccddf
+#  if !defined OK_TO_USE_1S_CLOCK
9ccddf
+#   error "Only 1-second nominal clock resolution found.  Is that intended?" \
9ccddf
+          "If so, compile with the -DOK_TO_USE_1S_CLOCK option."
9ccddf
+#  endif
9ccddf
+  tv->tv_sec = time (NULL);
9ccddf
+  tv->tv_usec = 0;
9ccddf
+
9ccddf
+# endif
9ccddf
+
9ccddf
+  return 0;
9ccddf
+
9ccddf
+#endif
9ccddf
+}
9ccddf
diff --git a/grub-core/gnulib/pathmax.h b/grub-core/gnulib/pathmax.h
9ccddf
new file mode 100644
9ccddf
index 0000000..33fc355
9ccddf
--- /dev/null
9ccddf
+++ b/grub-core/gnulib/pathmax.h
9ccddf
@@ -0,0 +1,83 @@
9ccddf
+/* Define PATH_MAX somehow.  Requires sys/types.h.
9ccddf
+   Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2014 Free Software
9ccddf
+   Foundation, Inc.
9ccddf
+
9ccddf
+   This program is free software; you can redistribute it and/or modify
9ccddf
+   it under the terms of the GNU General Public License as published by
9ccddf
+   the Free Software Foundation; either version 3, or (at your option)
9ccddf
+   any later version.
9ccddf
+
9ccddf
+   This program is distributed in the hope that it will be useful,
9ccddf
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
9ccddf
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9ccddf
+   GNU General Public License for more details.
9ccddf
+
9ccddf
+   You should have received a copy of the GNU General Public License
9ccddf
+   along with this program; if not, see <http: www.gnu.org="" licenses=""/>.  */
9ccddf
+
9ccddf
+#ifndef _PATHMAX_H
9ccddf
+# define _PATHMAX_H
9ccddf
+
9ccddf
+/* POSIX:2008 defines PATH_MAX to be the maximum number of bytes in a filename,
9ccddf
+   including the terminating NUL byte.
9ccddf
+   <http: pubs.opengroup.org="" onlinepubs="" 9699919799="" basedefs="" limits.h.html="">
9ccddf
+   PATH_MAX is not defined on systems which have no limit on filename length,
9ccddf
+   such as GNU/Hurd.
9ccddf
+
9ccddf
+   This file does *not* define PATH_MAX always.  Programs that use this file
9ccddf
+   can handle the GNU/Hurd case in several ways:
9ccddf
+     - Either with a package-wide handling, or with a per-file handling,
9ccddf
+     - Either through a
9ccddf
+         #ifdef PATH_MAX
9ccddf
+       or through a fallback like
9ccddf
+         #ifndef PATH_MAX
9ccddf
+         # define PATH_MAX 8192
9ccddf
+         #endif
9ccddf
+       or through a fallback like
9ccddf
+         #ifndef PATH_MAX
9ccddf
+         # define PATH_MAX pathconf ("/", _PC_PATH_MAX)
9ccddf
+         #endif
9ccddf
+ */
9ccddf
+
9ccddf
+# include <unistd.h>
9ccddf
+
9ccddf
+# include <limits.h>
9ccddf
+
9ccddf
+# ifndef _POSIX_PATH_MAX
9ccddf
+#  define _POSIX_PATH_MAX 256
9ccddf
+# endif
9ccddf
+
9ccddf
+/* Don't include sys/param.h if it already has been.  */
9ccddf
+# if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN
9ccddf
+#  include <sys param.h="">
9ccddf
+# endif
9ccddf
+
9ccddf
+# if !defined PATH_MAX && defined MAXPATHLEN
9ccddf
+#  define PATH_MAX MAXPATHLEN
9ccddf
+# endif
9ccddf
+
9ccddf
+# ifdef __hpux
9ccddf
+/* On HP-UX, PATH_MAX designates the maximum number of bytes in a filename,
9ccddf
+   *not* including the terminating NUL byte, and is set to 1023.
9ccddf
+   Additionally, when _XOPEN_SOURCE is defined to 500 or more, PATH_MAX is
9ccddf
+   not defined at all any more.  */
9ccddf
+#  undef PATH_MAX
9ccddf
+#  define PATH_MAX 1024
9ccddf
+# endif
9ccddf
+
9ccddf
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
9ccddf
+/* The page "Naming Files, Paths, and Namespaces" on msdn.microsoft.com,
9ccddf
+   section "Maximum Path Length Limitation",
9ccddf
+   <http: msdn.microsoft.com="" en-us="" library="" aa365247(v="vs.85).aspx#maxpath">
9ccddf
+   explains that the maximum size of a filename, including the terminating
9ccddf
+   NUL byte, is 260 = 3 + 256 + 1.
9ccddf
+   This is the same value as
9ccddf
+     - FILENAME_MAX in <stdio.h>,
9ccddf
+     - _MAX_PATH in <stdlib.h>,
9ccddf
+     - MAX_PATH in <windef.h>.
9ccddf
+   Undefine the original value, because mingw's <limits.h> gets it wrong.  */
9ccddf
+#  undef PATH_MAX
9ccddf
+#  define PATH_MAX 260
9ccddf
+# endif
9ccddf
+
9ccddf
+#endif /* _PATHMAX_H */
9ccddf
diff --git a/grub-core/gnulib/readlink.c b/grub-core/gnulib/readlink.c
9ccddf
new file mode 100644
9ccddf
index 0000000..4c49639
9ccddf
--- /dev/null
9ccddf
+++ b/grub-core/gnulib/readlink.c
9ccddf
@@ -0,0 +1,74 @@
9ccddf
+/* Stub for readlink().
9ccddf
+   Copyright (C) 2003-2007, 2009-2014 Free Software Foundation, Inc.
9ccddf
+
9ccddf
+   This program is free software: you can redistribute it and/or modify
9ccddf
+   it under the terms of the GNU General Public License as published by
9ccddf
+   the Free Software Foundation; either version 3 of the License, or
9ccddf
+   (at your option) any later version.
9ccddf
+
9ccddf
+   This program is distributed in the hope that it will be useful,
9ccddf
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
9ccddf
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9ccddf
+   GNU General Public License for more details.
9ccddf
+
9ccddf
+   You should have received a copy of the GNU General Public License
9ccddf
+   along with this program.  If not, see <http: www.gnu.org="" licenses=""/>.  */
9ccddf
+
9ccddf
+#include <config.h>
9ccddf
+
9ccddf
+/* Specification.  */
9ccddf
+#include <unistd.h>
9ccddf
+
9ccddf
+#include <errno.h>
9ccddf
+#include <string.h>
9ccddf
+#include <sys stat.h="">
9ccddf
+
9ccddf
+#if !HAVE_READLINK
9ccddf
+
9ccddf
+/* readlink() substitute for systems that don't have a readlink() function,
9ccddf
+   such as DJGPP 2.03 and mingw32.  */
9ccddf
+
9ccddf
+ssize_t
9ccddf
+readlink (const char *name, char *buf _GL_UNUSED,
9ccddf
+          size_t bufsize _GL_UNUSED)
9ccddf
+{
9ccddf
+  struct stat statbuf;
9ccddf
+
9ccddf
+  /* In general we should use lstat() here, not stat().  But on platforms
9ccddf
+     without symbolic links, lstat() - if it exists - would be equivalent to
9ccddf
+     stat(), therefore we can use stat().  This saves us a configure check.  */
9ccddf
+  if (stat (name, &statbuf) >= 0)
9ccddf
+    errno = EINVAL;
9ccddf
+  return -1;
9ccddf
+}
9ccddf
+
9ccddf
+#else /* HAVE_READLINK */
9ccddf
+
9ccddf
+# undef readlink
9ccddf
+
9ccddf
+/* readlink() wrapper that uses correct types, for systems like cygwin
9ccddf
+   1.5.x where readlink returns int, and which rejects trailing slash,
9ccddf
+   for Solaris 9.  */
9ccddf
+
9ccddf
+ssize_t
9ccddf
+rpl_readlink (const char *name, char *buf, size_t bufsize)
9ccddf
+{
9ccddf
+# if READLINK_TRAILING_SLASH_BUG
9ccddf
+  size_t len = strlen (name);
9ccddf
+  if (len && name[len - 1] == '/')
9ccddf
+    {
9ccddf
+      /* Even if name without the slash is a symlink to a directory,
9ccddf
+         both lstat() and stat() must resolve the trailing slash to
9ccddf
+         the directory rather than the symlink.  We can therefore
9ccddf
+         safely use stat() to distinguish between EINVAL and
9ccddf
+         ENOTDIR/ENOENT, avoiding extra overhead of rpl_lstat().  */
9ccddf
+      struct stat st;
9ccddf
+      if (stat (name, &st) == 0)
9ccddf
+        errno = EINVAL;
9ccddf
+      return -1;
9ccddf
+    }
9ccddf
+# endif /* READLINK_TRAILING_SLASH_BUG */
9ccddf
+  return readlink (name, buf, bufsize);
9ccddf
+}
9ccddf
+
9ccddf
+#endif /* HAVE_READLINK */
9ccddf
diff --git a/grub-core/gnulib/stat.c b/grub-core/gnulib/stat.c
9ccddf
new file mode 100644
9ccddf
index 0000000..35f4b0b
9ccddf
--- /dev/null
9ccddf
+++ b/grub-core/gnulib/stat.c
9ccddf
@@ -0,0 +1,138 @@
9ccddf
+/* Work around platform bugs in stat.
9ccddf
+   Copyright (C) 2009-2014 Free Software Foundation, Inc.
9ccddf
+
9ccddf
+   This program is free software: you can redistribute it and/or modify
9ccddf
+   it under the terms of the GNU General Public License as published by
9ccddf
+   the Free Software Foundation; either version 3 of the License, or
9ccddf
+   (at your option) any later version.
9ccddf
+
9ccddf
+   This program is distributed in the hope that it will be useful,
9ccddf
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
9ccddf
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9ccddf
+   GNU General Public License for more details.
9ccddf
+
9ccddf
+   You should have received a copy of the GNU General Public License
9ccddf
+   along with this program.  If not, see <http: www.gnu.org="" licenses=""/>.  */
9ccddf
+
9ccddf
+/* written by Eric Blake */
9ccddf
+
9ccddf
+/* If the user's config.h happens to include <sys stat.h="">, let it include only
9ccddf
+   the system's <sys stat.h=""> here, so that orig_stat doesn't recurse to
9ccddf
+   rpl_stat.  */
9ccddf
+#define __need_system_sys_stat_h
9ccddf
+#include <config.h>
9ccddf
+
9ccddf
+/* Get the original definition of stat.  It might be defined as a macro.  */
9ccddf
+#include <sys types.h="">
9ccddf
+#include <sys stat.h="">
9ccddf
+#undef __need_system_sys_stat_h
9ccddf
+
9ccddf
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
9ccddf
+# if _GL_WINDOWS_64_BIT_ST_SIZE
9ccddf
+#  undef stat /* avoid warning on mingw64 with _FILE_OFFSET_BITS=64 */
9ccddf
+#  define stat _stati64
9ccddf
+#  define REPLACE_FUNC_STAT_DIR 1
9ccddf
+#  undef REPLACE_FUNC_STAT_FILE
9ccddf
+# elif REPLACE_FUNC_STAT_FILE
9ccddf
+/* mingw64 has a broken stat() function, based on _stat(), in libmingwex.a.
9ccddf
+   Bypass it.  */
9ccddf
+#  define stat _stat
9ccddf
+#  define REPLACE_FUNC_STAT_DIR 1
9ccddf
+#  undef REPLACE_FUNC_STAT_FILE
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+static int
9ccddf
+orig_stat (const char *filename, struct stat *buf)
9ccddf
+{
9ccddf
+  return stat (filename, buf);
9ccddf
+}
9ccddf
+
9ccddf
+/* Specification.  */
9ccddf
+/* Write "sys/stat.h" here, not <sys stat.h="">, otherwise OSF/1 5.1 DTK cc
9ccddf
+   eliminates this include because of the preliminary #include <sys stat.h="">
9ccddf
+   above.  */
9ccddf
+#include "sys/stat.h"
9ccddf
+
9ccddf
+#include <errno.h>
9ccddf
+#include <limits.h>
9ccddf
+#include <stdbool.h>
9ccddf
+#include <string.h>
9ccddf
+#include "dosname.h"
9ccddf
+#include "verify.h"
9ccddf
+
9ccddf
+#if REPLACE_FUNC_STAT_DIR
9ccddf
+# include "pathmax.h"
9ccddf
+  /* The only known systems where REPLACE_FUNC_STAT_DIR is needed also
9ccddf
+     have a constant PATH_MAX.  */
9ccddf
+# ifndef PATH_MAX
9ccddf
+#  error "Please port this replacement to your platform"
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+/* Store information about NAME into ST.  Work around bugs with
9ccddf
+   trailing slashes.  Mingw has other bugs (such as st_ino always
9ccddf
+   being 0 on success) which this wrapper does not work around.  But
9ccddf
+   at least this implementation provides the ability to emulate fchdir
9ccddf
+   correctly.  */
9ccddf
+
9ccddf
+int
9ccddf
+rpl_stat (char const *name, struct stat *st)
9ccddf
+{
9ccddf
+  int result = orig_stat (name, st);
9ccddf
+#if REPLACE_FUNC_STAT_FILE
9ccddf
+  /* Solaris 9 mistakenly succeeds when given a non-directory with a
9ccddf
+     trailing slash.  */
9ccddf
+  if (result == 0 && !S_ISDIR (st->st_mode))
9ccddf
+    {
9ccddf
+      size_t len = strlen (name);
9ccddf
+      if (ISSLASH (name[len - 1]))
9ccddf
+        {
9ccddf
+          errno = ENOTDIR;
9ccddf
+          return -1;
9ccddf
+        }
9ccddf
+    }
9ccddf
+#endif /* REPLACE_FUNC_STAT_FILE */
9ccddf
+#if REPLACE_FUNC_STAT_DIR
9ccddf
+
9ccddf
+  if (result == -1 && errno == ENOENT)
9ccddf
+    {
9ccddf
+      /* Due to mingw's oddities, there are some directories (like
9ccddf
+         c:\) where stat() only succeeds with a trailing slash, and
9ccddf
+         other directories (like c:\windows) where stat() only
9ccddf
+         succeeds without a trailing slash.  But we want the two to be
9ccddf
+         synonymous, since chdir() manages either style.  Likewise, Mingw also
9ccddf
+         reports ENOENT for names longer than PATH_MAX, when we want
9ccddf
+         ENAMETOOLONG, and for stat("file/"), when we want ENOTDIR.
9ccddf
+         Fortunately, mingw PATH_MAX is small enough for stack
9ccddf
+         allocation.  */
9ccddf
+      char fixed_name[PATH_MAX + 1] = {0};
9ccddf
+      size_t len = strlen (name);
9ccddf
+      bool check_dir = false;
9ccddf
+      verify (PATH_MAX <= 4096);
9ccddf
+      if (PATH_MAX <= len)
9ccddf
+        errno = ENAMETOOLONG;
9ccddf
+      else if (len)
9ccddf
+        {
9ccddf
+          strcpy (fixed_name, name);
9ccddf
+          if (ISSLASH (fixed_name[len - 1]))
9ccddf
+            {
9ccddf
+              check_dir = true;
9ccddf
+              while (len && ISSLASH (fixed_name[len - 1]))
9ccddf
+                fixed_name[--len] = '\0';
9ccddf
+              if (!len)
9ccddf
+                fixed_name[0] = '/';
9ccddf
+            }
9ccddf
+          else
9ccddf
+            fixed_name[len++] = '/';
9ccddf
+          result = orig_stat (fixed_name, st);
9ccddf
+          if (result == 0 && check_dir && !S_ISDIR (st->st_mode))
9ccddf
+            {
9ccddf
+              result = -1;
9ccddf
+              errno = ENOTDIR;
9ccddf
+            }
9ccddf
+        }
9ccddf
+    }
9ccddf
+#endif /* REPLACE_FUNC_STAT_DIR */
9ccddf
+  return result;
9ccddf
+}
9ccddf
diff --git a/grub-core/gnulib/sys_stat.in.h b/grub-core/gnulib/sys_stat.in.h
9ccddf
new file mode 100644
9ccddf
index 0000000..b47a7ff
9ccddf
--- /dev/null
9ccddf
+++ b/grub-core/gnulib/sys_stat.in.h
9ccddf
@@ -0,0 +1,732 @@
9ccddf
+/* Provide a more complete sys/stat header file.
9ccddf
+   Copyright (C) 2005-2014 Free Software Foundation, Inc.
9ccddf
+
9ccddf
+   This program is free software; you can redistribute it and/or modify
9ccddf
+   it under the terms of the GNU General Public License as published by
9ccddf
+   the Free Software Foundation; either version 3, or (at your option)
9ccddf
+   any later version.
9ccddf
+
9ccddf
+   This program is distributed in the hope that it will be useful,
9ccddf
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
9ccddf
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9ccddf
+   GNU General Public License for more details.
9ccddf
+
9ccddf
+   You should have received a copy of the GNU General Public License
9ccddf
+   along with this program; if not, see <http: www.gnu.org="" licenses=""/>.  */
9ccddf
+
9ccddf
+/* Written by Eric Blake, Paul Eggert, and Jim Meyering.  */
9ccddf
+
9ccddf
+/* This file is supposed to be used on platforms where <sys stat.h=""> is
9ccddf
+   incomplete.  It is intended to provide definitions and prototypes
9ccddf
+   needed by an application.  Start with what the system provides.  */
9ccddf
+
9ccddf
+#if __GNUC__ >= 3
9ccddf
+@PRAGMA_SYSTEM_HEADER@
9ccddf
+#endif
9ccddf
+@PRAGMA_COLUMNS@
9ccddf
+
9ccddf
+#if defined __need_system_sys_stat_h
9ccddf
+/* Special invocation convention.  */
9ccddf
+
9ccddf
+#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
9ccddf
+
9ccddf
+#else
9ccddf
+/* Normal invocation convention.  */
9ccddf
+
9ccddf
+#ifndef _@GUARD_PREFIX@_SYS_STAT_H
9ccddf
+
9ccddf
+/* Get nlink_t.
9ccddf
+   May also define off_t to a 64-bit type on native Windows.  */
9ccddf
+#include <sys types.h="">
9ccddf
+
9ccddf
+/* Get struct timespec.  */
9ccddf
+#include <time.h>
9ccddf
+
9ccddf
+/* The include_next requires a split double-inclusion guard.  */
9ccddf
+#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
9ccddf
+
9ccddf
+#ifndef _@GUARD_PREFIX@_SYS_STAT_H
9ccddf
+#define _@GUARD_PREFIX@_SYS_STAT_H
9ccddf
+
9ccddf
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
9ccddf
+
9ccddf
+/* The definition of _GL_ARG_NONNULL is copied here.  */
9ccddf
+
9ccddf
+/* The definition of _GL_WARN_ON_USE is copied here.  */
9ccddf
+
9ccddf
+/* Before doing "#define mkdir rpl_mkdir" below, we need to include all
9ccddf
+   headers that may declare mkdir().  Native Windows platforms declare mkdir
9ccddf
+   in <io.h> and/or <direct.h>, not in <unistd.h>.  */
9ccddf
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
9ccddf
+# include <io.h>     /* mingw32, mingw64 */
9ccddf
+# include <direct.h> /* mingw64, MSVC 9 */
9ccddf
+#endif
9ccddf
+
9ccddf
+/* Native Windows platforms declare umask() in <io.h>.  */
9ccddf
+#if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
9ccddf
+# include <io.h>
9ccddf
+#endif
9ccddf
+
9ccddf
+/* Large File Support on native Windows.  */
9ccddf
+#if @WINDOWS_64_BIT_ST_SIZE@
9ccddf
+# define stat _stati64
9ccddf
+#endif
9ccddf
+
9ccddf
+#ifndef S_IFIFO
9ccddf
+# ifdef _S_IFIFO
9ccddf
+#  define S_IFIFO _S_IFIFO
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+#ifndef S_IFMT
9ccddf
+# define S_IFMT 0170000
9ccddf
+#endif
9ccddf
+
9ccddf
+#if STAT_MACROS_BROKEN
9ccddf
+# undef S_ISBLK
9ccddf
+# undef S_ISCHR
9ccddf
+# undef S_ISDIR
9ccddf
+# undef S_ISFIFO
9ccddf
+# undef S_ISLNK
9ccddf
+# undef S_ISNAM
9ccddf
+# undef S_ISMPB
9ccddf
+# undef S_ISMPC
9ccddf
+# undef S_ISNWK
9ccddf
+# undef S_ISREG
9ccddf
+# undef S_ISSOCK
9ccddf
+#endif
9ccddf
+
9ccddf
+#ifndef S_ISBLK
9ccddf
+# ifdef S_IFBLK
9ccddf
+#  define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
9ccddf
+# else
9ccddf
+#  define S_ISBLK(m) 0
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+#ifndef S_ISCHR
9ccddf
+# ifdef S_IFCHR
9ccddf
+#  define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
9ccddf
+# else
9ccddf
+#  define S_ISCHR(m) 0
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+#ifndef S_ISDIR
9ccddf
+# ifdef S_IFDIR
9ccddf
+#  define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
9ccddf
+# else
9ccddf
+#  define S_ISDIR(m) 0
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+#ifndef S_ISDOOR /* Solaris 2.5 and up */
9ccddf
+# define S_ISDOOR(m) 0
9ccddf
+#endif
9ccddf
+
9ccddf
+#ifndef S_ISFIFO
9ccddf
+# ifdef S_IFIFO
9ccddf
+#  define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
9ccddf
+# else
9ccddf
+#  define S_ISFIFO(m) 0
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+#ifndef S_ISLNK
9ccddf
+# ifdef S_IFLNK
9ccddf
+#  define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
9ccddf
+# else
9ccddf
+#  define S_ISLNK(m) 0
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+#ifndef S_ISMPB /* V7 */
9ccddf
+# ifdef S_IFMPB
9ccddf
+#  define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
9ccddf
+#  define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
9ccddf
+# else
9ccddf
+#  define S_ISMPB(m) 0
9ccddf
+#  define S_ISMPC(m) 0
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+#ifndef S_ISMPX /* AIX */
9ccddf
+# define S_ISMPX(m) 0
9ccddf
+#endif
9ccddf
+
9ccddf
+#ifndef S_ISNAM /* Xenix */
9ccddf
+# ifdef S_IFNAM
9ccddf
+#  define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
9ccddf
+# else
9ccddf
+#  define S_ISNAM(m) 0
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+#ifndef S_ISNWK /* HP/UX */
9ccddf
+# ifdef S_IFNWK
9ccddf
+#  define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
9ccddf
+# else
9ccddf
+#  define S_ISNWK(m) 0
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+#ifndef S_ISPORT /* Solaris 10 and up */
9ccddf
+# define S_ISPORT(m) 0
9ccddf
+#endif
9ccddf
+
9ccddf
+#ifndef S_ISREG
9ccddf
+# ifdef S_IFREG
9ccddf
+#  define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
9ccddf
+# else
9ccddf
+#  define S_ISREG(m) 0
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+#ifndef S_ISSOCK
9ccddf
+# ifdef S_IFSOCK
9ccddf
+#  define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
9ccddf
+# else
9ccddf
+#  define S_ISSOCK(m) 0
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+
9ccddf
+#ifndef S_TYPEISMQ
9ccddf
+# define S_TYPEISMQ(p) 0
9ccddf
+#endif
9ccddf
+
9ccddf
+#ifndef S_TYPEISTMO
9ccddf
+# define S_TYPEISTMO(p) 0
9ccddf
+#endif
9ccddf
+
9ccddf
+
9ccddf
+#ifndef S_TYPEISSEM
9ccddf
+# ifdef S_INSEM
9ccddf
+#  define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
9ccddf
+# else
9ccddf
+#  define S_TYPEISSEM(p) 0
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+#ifndef S_TYPEISSHM
9ccddf
+# ifdef S_INSHD
9ccddf
+#  define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
9ccddf
+# else
9ccddf
+#  define S_TYPEISSHM(p) 0
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+/* high performance ("contiguous data") */
9ccddf
+#ifndef S_ISCTG
9ccddf
+# define S_ISCTG(p) 0
9ccddf
+#endif
9ccddf
+
9ccddf
+/* Cray DMF (data migration facility): off line, with data  */
9ccddf
+#ifndef S_ISOFD
9ccddf
+# define S_ISOFD(p) 0
9ccddf
+#endif
9ccddf
+
9ccddf
+/* Cray DMF (data migration facility): off line, with no data  */
9ccddf
+#ifndef S_ISOFL
9ccddf
+# define S_ISOFL(p) 0
9ccddf
+#endif
9ccddf
+
9ccddf
+/* 4.4BSD whiteout */
9ccddf
+#ifndef S_ISWHT
9ccddf
+# define S_ISWHT(m) 0
9ccddf
+#endif
9ccddf
+
9ccddf
+/* If any of the following are undefined,
9ccddf
+   define them to their de facto standard values.  */
9ccddf
+#if !S_ISUID
9ccddf
+# define S_ISUID 04000
9ccddf
+#endif
9ccddf
+#if !S_ISGID
9ccddf
+# define S_ISGID 02000
9ccddf
+#endif
9ccddf
+
9ccddf
+/* S_ISVTX is a common extension to POSIX.  */
9ccddf
+#ifndef S_ISVTX
9ccddf
+# define S_ISVTX 01000
9ccddf
+#endif
9ccddf
+
9ccddf
+#if !S_IRUSR && S_IREAD
9ccddf
+# define S_IRUSR S_IREAD
9ccddf
+#endif
9ccddf
+#if !S_IRUSR
9ccddf
+# define S_IRUSR 00400
9ccddf
+#endif
9ccddf
+#if !S_IRGRP
9ccddf
+# define S_IRGRP (S_IRUSR >> 3)
9ccddf
+#endif
9ccddf
+#if !S_IROTH
9ccddf
+# define S_IROTH (S_IRUSR >> 6)
9ccddf
+#endif
9ccddf
+
9ccddf
+#if !S_IWUSR && S_IWRITE
9ccddf
+# define S_IWUSR S_IWRITE
9ccddf
+#endif
9ccddf
+#if !S_IWUSR
9ccddf
+# define S_IWUSR 00200
9ccddf
+#endif
9ccddf
+#if !S_IWGRP
9ccddf
+# define S_IWGRP (S_IWUSR >> 3)
9ccddf
+#endif
9ccddf
+#if !S_IWOTH
9ccddf
+# define S_IWOTH (S_IWUSR >> 6)
9ccddf
+#endif
9ccddf
+
9ccddf
+#if !S_IXUSR && S_IEXEC
9ccddf
+# define S_IXUSR S_IEXEC
9ccddf
+#endif
9ccddf
+#if !S_IXUSR
9ccddf
+# define S_IXUSR 00100
9ccddf
+#endif
9ccddf
+#if !S_IXGRP
9ccddf
+# define S_IXGRP (S_IXUSR >> 3)
9ccddf
+#endif
9ccddf
+#if !S_IXOTH
9ccddf
+# define S_IXOTH (S_IXUSR >> 6)
9ccddf
+#endif
9ccddf
+
9ccddf
+#if !S_IRWXU
9ccddf
+# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
9ccddf
+#endif
9ccddf
+#if !S_IRWXG
9ccddf
+# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
9ccddf
+#endif
9ccddf
+#if !S_IRWXO
9ccddf
+# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
9ccddf
+#endif
9ccddf
+
9ccddf
+/* S_IXUGO is a common extension to POSIX.  */
9ccddf
+#if !S_IXUGO
9ccddf
+# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
9ccddf
+#endif
9ccddf
+
9ccddf
+#ifndef S_IRWXUGO
9ccddf
+# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
9ccddf
+#endif
9ccddf
+
9ccddf
+/* Macros for futimens and utimensat.  */
9ccddf
+#ifndef UTIME_NOW
9ccddf
+# define UTIME_NOW (-1)
9ccddf
+# define UTIME_OMIT (-2)
9ccddf
+#endif
9ccddf
+
9ccddf
+
9ccddf
+#if @GNULIB_FCHMODAT@
9ccddf
+# if !@HAVE_FCHMODAT@
9ccddf
+_GL_FUNCDECL_SYS (fchmodat, int,
9ccddf
+                  (int fd, char const *file, mode_t mode, int flag)
9ccddf
+                  _GL_ARG_NONNULL ((2)));
9ccddf
+# endif
9ccddf
+_GL_CXXALIAS_SYS (fchmodat, int,
9ccddf
+                  (int fd, char const *file, mode_t mode, int flag));
9ccddf
+_GL_CXXALIASWARN (fchmodat);
9ccddf
+#elif defined GNULIB_POSIXCHECK
9ccddf
+# undef fchmodat
9ccddf
+# if HAVE_RAW_DECL_FCHMODAT
9ccddf
+_GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - "
9ccddf
+                 "use gnulib module openat for portability");
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+
9ccddf
+#if @GNULIB_FSTAT@
9ccddf
+# if @REPLACE_FSTAT@
9ccddf
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
9ccddf
+#   undef fstat
9ccddf
+#   define fstat rpl_fstat
9ccddf
+#  endif
9ccddf
+_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2)));
9ccddf
+_GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
9ccddf
+# else
9ccddf
+_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
9ccddf
+# endif
9ccddf
+_GL_CXXALIASWARN (fstat);
9ccddf
+#elif @WINDOWS_64_BIT_ST_SIZE@
9ccddf
+/* Above, we define stat to _stati64.  */
9ccddf
+# define fstat _fstati64
9ccddf
+#elif defined GNULIB_POSIXCHECK
9ccddf
+# undef fstat
9ccddf
+# if HAVE_RAW_DECL_FSTAT
9ccddf
+_GL_WARN_ON_USE (fstat, "fstat has portability problems - "
9ccddf
+                 "use gnulib module fstat for portability");
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+
9ccddf
+#if @GNULIB_FSTATAT@
9ccddf
+# if @REPLACE_FSTATAT@
9ccddf
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
9ccddf
+#   undef fstatat
9ccddf
+#   define fstatat rpl_fstatat
9ccddf
+#  endif
9ccddf
+_GL_FUNCDECL_RPL (fstatat, int,
9ccddf
+                  (int fd, char const *name, struct stat *st, int flags)
9ccddf
+                  _GL_ARG_NONNULL ((2, 3)));
9ccddf
+_GL_CXXALIAS_RPL (fstatat, int,
9ccddf
+                  (int fd, char const *name, struct stat *st, int flags));
9ccddf
+# else
9ccddf
+#  if !@HAVE_FSTATAT@
9ccddf
+_GL_FUNCDECL_SYS (fstatat, int,
9ccddf
+                  (int fd, char const *name, struct stat *st, int flags)
9ccddf
+                  _GL_ARG_NONNULL ((2, 3)));
9ccddf
+#  endif
9ccddf
+_GL_CXXALIAS_SYS (fstatat, int,
9ccddf
+                  (int fd, char const *name, struct stat *st, int flags));
9ccddf
+# endif
9ccddf
+_GL_CXXALIASWARN (fstatat);
9ccddf
+#elif defined GNULIB_POSIXCHECK
9ccddf
+# undef fstatat
9ccddf
+# if HAVE_RAW_DECL_FSTATAT
9ccddf
+_GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
9ccddf
+                 "use gnulib module openat for portability");
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+
9ccddf
+#if @GNULIB_FUTIMENS@
9ccddf
+/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens
9ccddf
+   implementation relies on futimesat, which on Solaris 10 makes an invocation
9ccddf
+   to futimens that is meant to invoke the libc's futimens(), not gnulib's
9ccddf
+   futimens().  */
9ccddf
+# if @REPLACE_FUTIMENS@ || (!@HAVE_FUTIMENS@ && defined __sun)
9ccddf
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
9ccddf
+#   undef futimens
9ccddf
+#   define futimens rpl_futimens
9ccddf
+#  endif
9ccddf
+_GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2]));
9ccddf
+_GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2]));
9ccddf
+# else
9ccddf
+#  if !@HAVE_FUTIMENS@
9ccddf
+_GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]));
9ccddf
+#  endif
9ccddf
+_GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
9ccddf
+# endif
9ccddf
+# if @HAVE_FUTIMENS@
9ccddf
+_GL_CXXALIASWARN (futimens);
9ccddf
+# endif
9ccddf
+#elif defined GNULIB_POSIXCHECK
9ccddf
+# undef futimens
9ccddf
+# if HAVE_RAW_DECL_FUTIMENS
9ccddf
+_GL_WARN_ON_USE (futimens, "futimens is not portable - "
9ccddf
+                 "use gnulib module futimens for portability");
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+
9ccddf
+#if @GNULIB_LCHMOD@
9ccddf
+/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
9ccddf
+   denotes a symbolic link.  */
9ccddf
+# if !@HAVE_LCHMOD@
9ccddf
+/* The lchmod replacement follows symbolic links.  Callers should take
9ccddf
+   this into account; lchmod should be applied only to arguments that
9ccddf
+   are known to not be symbolic links.  On hosts that lack lchmod,
9ccddf
+   this can lead to race conditions between the check and the
9ccddf
+   invocation of lchmod, but we know of no workarounds that are
9ccddf
+   reliable in general.  You might try requesting support for lchmod
9ccddf
+   from your operating system supplier.  */
9ccddf
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
9ccddf
+#   define lchmod chmod
9ccddf
+#  endif
9ccddf
+/* Need to cast, because on mingw, the second parameter of chmod is
9ccddf
+                                                int mode.  */
9ccddf
+_GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int,
9ccddf
+                         (const char *filename, mode_t mode));
9ccddf
+# else
9ccddf
+#  if 0 /* assume already declared */
9ccddf
+_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
9ccddf
+                               _GL_ARG_NONNULL ((1)));
9ccddf
+#  endif
9ccddf
+_GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode));
9ccddf
+# endif
9ccddf
+# if @HAVE_LCHMOD@
9ccddf
+_GL_CXXALIASWARN (lchmod);
9ccddf
+# endif
9ccddf
+#elif defined GNULIB_POSIXCHECK
9ccddf
+# undef lchmod
9ccddf
+# if HAVE_RAW_DECL_LCHMOD
9ccddf
+_GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
9ccddf
+                 "use gnulib module lchmod for portability");
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+
9ccddf
+#if @GNULIB_LSTAT@
9ccddf
+# if ! @HAVE_LSTAT@
9ccddf
+/* mingw does not support symlinks, therefore it does not have lstat.  But
9ccddf
+   without links, stat does just fine.  */
9ccddf
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
9ccddf
+#   define lstat stat
9ccddf
+#  endif
9ccddf
+_GL_CXXALIAS_RPL_1 (lstat, stat, int, (const char *name, struct stat *buf));
9ccddf
+# elif @REPLACE_LSTAT@
9ccddf
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
9ccddf
+#   undef lstat
9ccddf
+#   define lstat rpl_lstat
9ccddf
+#  endif
9ccddf
+_GL_FUNCDECL_RPL (lstat, int, (const char *name, struct stat *buf)
9ccddf
+                              _GL_ARG_NONNULL ((1, 2)));
9ccddf
+_GL_CXXALIAS_RPL (lstat, int, (const char *name, struct stat *buf));
9ccddf
+# else
9ccddf
+_GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf));
9ccddf
+# endif
9ccddf
+# if @HAVE_LSTAT@
9ccddf
+_GL_CXXALIASWARN (lstat);
9ccddf
+# endif
9ccddf
+#elif defined GNULIB_POSIXCHECK
9ccddf
+# undef lstat
9ccddf
+# if HAVE_RAW_DECL_LSTAT
9ccddf
+_GL_WARN_ON_USE (lstat, "lstat is unportable - "
9ccddf
+                 "use gnulib module lstat for portability");
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+
9ccddf
+#if @REPLACE_MKDIR@
9ccddf
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
9ccddf
+#  undef mkdir
9ccddf
+#  define mkdir rpl_mkdir
9ccddf
+# endif
9ccddf
+_GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode)
9ccddf
+                              _GL_ARG_NONNULL ((1)));
9ccddf
+_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
9ccddf
+#else
9ccddf
+/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
9ccddf
+   Additionally, it declares _mkdir (and depending on compile flags, an
9ccddf
+   alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
9ccddf
+   which are included above.  */
9ccddf
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
9ccddf
+
9ccddf
+#  if !GNULIB_defined_rpl_mkdir
9ccddf
+static int
9ccddf
+rpl_mkdir (char const *name, mode_t mode)
9ccddf
+{
9ccddf
+  return _mkdir (name);
9ccddf
+}
9ccddf
+#   define GNULIB_defined_rpl_mkdir 1
9ccddf
+#  endif
9ccddf
+
9ccddf
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
9ccddf
+#   define mkdir rpl_mkdir
9ccddf
+#  endif
9ccddf
+_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
9ccddf
+# else
9ccddf
+_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+_GL_CXXALIASWARN (mkdir);
9ccddf
+
9ccddf
+
9ccddf
+#if @GNULIB_MKDIRAT@
9ccddf
+# if !@HAVE_MKDIRAT@
9ccddf
+_GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)
9ccddf
+                                _GL_ARG_NONNULL ((2)));
9ccddf
+# endif
9ccddf
+_GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
9ccddf
+_GL_CXXALIASWARN (mkdirat);
9ccddf
+#elif defined GNULIB_POSIXCHECK
9ccddf
+# undef mkdirat
9ccddf
+# if HAVE_RAW_DECL_MKDIRAT
9ccddf
+_GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
9ccddf
+                 "use gnulib module openat for portability");
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+
9ccddf
+#if @GNULIB_MKFIFO@
9ccddf
+# if @REPLACE_MKFIFO@
9ccddf
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
9ccddf
+#   undef mkfifo
9ccddf
+#   define mkfifo rpl_mkfifo
9ccddf
+#  endif
9ccddf
+_GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode)
9ccddf
+                               _GL_ARG_NONNULL ((1)));
9ccddf
+_GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
9ccddf
+# else
9ccddf
+#  if !@HAVE_MKFIFO@
9ccddf
+_GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode)
9ccddf
+                               _GL_ARG_NONNULL ((1)));
9ccddf
+#  endif
9ccddf
+_GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
9ccddf
+# endif
9ccddf
+_GL_CXXALIASWARN (mkfifo);
9ccddf
+#elif defined GNULIB_POSIXCHECK
9ccddf
+# undef mkfifo
9ccddf
+# if HAVE_RAW_DECL_MKFIFO
9ccddf
+_GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
9ccddf
+                 "use gnulib module mkfifo for portability");
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+
9ccddf
+#if @GNULIB_MKFIFOAT@
9ccddf
+# if !@HAVE_MKFIFOAT@
9ccddf
+_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
9ccddf
+                                 _GL_ARG_NONNULL ((2)));
9ccddf
+# endif
9ccddf
+_GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
9ccddf
+_GL_CXXALIASWARN (mkfifoat);
9ccddf
+#elif defined GNULIB_POSIXCHECK
9ccddf
+# undef mkfifoat
9ccddf
+# if HAVE_RAW_DECL_MKFIFOAT
9ccddf
+_GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
9ccddf
+                 "use gnulib module mkfifoat for portability");
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+
9ccddf
+#if @GNULIB_MKNOD@
9ccddf
+# if @REPLACE_MKNOD@
9ccddf
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
9ccddf
+#   undef mknod
9ccddf
+#   define mknod rpl_mknod
9ccddf
+#  endif
9ccddf
+_GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)
9ccddf
+                              _GL_ARG_NONNULL ((1)));
9ccddf
+_GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
9ccddf
+# else
9ccddf
+#  if !@HAVE_MKNOD@
9ccddf
+_GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev)
9ccddf
+                              _GL_ARG_NONNULL ((1)));
9ccddf
+#  endif
9ccddf
+/* Need to cast, because on OSF/1 5.1, the third parameter is '...'.  */
9ccddf
+_GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev));
9ccddf
+# endif
9ccddf
+_GL_CXXALIASWARN (mknod);
9ccddf
+#elif defined GNULIB_POSIXCHECK
9ccddf
+# undef mknod
9ccddf
+# if HAVE_RAW_DECL_MKNOD
9ccddf
+_GL_WARN_ON_USE (mknod, "mknod is not portable - "
9ccddf
+                 "use gnulib module mknod for portability");
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+
9ccddf
+#if @GNULIB_MKNODAT@
9ccddf
+# if !@HAVE_MKNODAT@
9ccddf
+_GL_FUNCDECL_SYS (mknodat, int,
9ccddf
+                  (int fd, char const *file, mode_t mode, dev_t dev)
9ccddf
+                  _GL_ARG_NONNULL ((2)));
9ccddf
+# endif
9ccddf
+_GL_CXXALIAS_SYS (mknodat, int,
9ccddf
+                  (int fd, char const *file, mode_t mode, dev_t dev));
9ccddf
+_GL_CXXALIASWARN (mknodat);
9ccddf
+#elif defined GNULIB_POSIXCHECK
9ccddf
+# undef mknodat
9ccddf
+# if HAVE_RAW_DECL_MKNODAT
9ccddf
+_GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
9ccddf
+                 "use gnulib module mkfifoat for portability");
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+
9ccddf
+#if @GNULIB_STAT@
9ccddf
+# if @REPLACE_STAT@
9ccddf
+/* We can't use the object-like #define stat rpl_stat, because of
9ccddf
+   struct stat.  This means that rpl_stat will not be used if the user
9ccddf
+   does (stat)(a,b).  Oh well.  */
9ccddf
+#  if defined _AIX && defined stat && defined _LARGE_FILES
9ccddf
+    /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
9ccddf
+       so we have to replace stat64() instead of stat(). */
9ccddf
+#   undef stat64
9ccddf
+#   define stat64(name, st) rpl_stat (name, st)
9ccddf
+#  elif @WINDOWS_64_BIT_ST_SIZE@
9ccddf
+    /* Above, we define stat to _stati64.  */
9ccddf
+#   if defined __MINGW32__ && defined _stati64
9ccddf
+#    ifndef _USE_32BIT_TIME_T
9ccddf
+      /* The system headers define _stati64 to _stat64.  */
9ccddf
+#     undef _stat64
9ccddf
+#     define _stat64(name, st) rpl_stat (name, st)
9ccddf
+#    endif
9ccddf
+#   elif defined _MSC_VER && defined _stati64
9ccddf
+#    ifdef _USE_32BIT_TIME_T
9ccddf
+      /* The system headers define _stati64 to _stat32i64.  */
9ccddf
+#     undef _stat32i64
9ccddf
+#     define _stat32i64(name, st) rpl_stat (name, st)
9ccddf
+#    else
9ccddf
+      /* The system headers define _stati64 to _stat64.  */
9ccddf
+#     undef _stat64
9ccddf
+#     define _stat64(name, st) rpl_stat (name, st)
9ccddf
+#    endif
9ccddf
+#   else
9ccddf
+#    undef _stati64
9ccddf
+#    define _stati64(name, st) rpl_stat (name, st)
9ccddf
+#   endif
9ccddf
+#  elif defined __MINGW32__ && defined stat
9ccddf
+#   ifdef _USE_32BIT_TIME_T
9ccddf
+     /* The system headers define stat to _stat32i64.  */
9ccddf
+#    undef _stat32i64
9ccddf
+#    define _stat32i64(name, st) rpl_stat (name, st)
9ccddf
+#   else
9ccddf
+     /* The system headers define stat to _stat64.  */
9ccddf
+#    undef _stat64
9ccddf
+#    define _stat64(name, st) rpl_stat (name, st)
9ccddf
+#   endif
9ccddf
+#  elif defined _MSC_VER && defined stat
9ccddf
+#   ifdef _USE_32BIT_TIME_T
9ccddf
+     /* The system headers define stat to _stat32.  */
9ccddf
+#    undef _stat32
9ccddf
+#    define _stat32(name, st) rpl_stat (name, st)
9ccddf
+#   else
9ccddf
+     /* The system headers define stat to _stat64i32.  */
9ccddf
+#    undef _stat64i32
9ccddf
+#    define _stat64i32(name, st) rpl_stat (name, st)
9ccddf
+#   endif
9ccddf
+#  else /* !(_AIX ||__MINGW32__ ||  _MSC_VER) */
9ccddf
+#   undef stat
9ccddf
+#   define stat(name, st) rpl_stat (name, st)
9ccddf
+#  endif /* !_LARGE_FILES */
9ccddf
+_GL_EXTERN_C int stat (const char *name, struct stat *buf)
9ccddf
+                      _GL_ARG_NONNULL ((1, 2));
9ccddf
+# endif
9ccddf
+#elif defined GNULIB_POSIXCHECK
9ccddf
+# undef stat
9ccddf
+# if HAVE_RAW_DECL_STAT
9ccddf
+_GL_WARN_ON_USE (stat, "stat is unportable - "
9ccddf
+                 "use gnulib module stat for portability");
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+
9ccddf
+#if @GNULIB_UTIMENSAT@
9ccddf
+/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat
9ccddf
+   implementation relies on futimesat, which on Solaris 10 makes an invocation
9ccddf
+   to utimensat that is meant to invoke the libc's utimensat(), not gnulib's
9ccddf
+   utimensat().  */
9ccddf
+# if @REPLACE_UTIMENSAT@ || (!@HAVE_UTIMENSAT@ && defined __sun)
9ccddf
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
9ccddf
+#   undef utimensat
9ccddf
+#   define utimensat rpl_utimensat
9ccddf
+#  endif
9ccddf
+_GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
9ccddf
+                                   struct timespec const times[2], int flag)
9ccddf
+                                  _GL_ARG_NONNULL ((2)));
9ccddf
+_GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
9ccddf
+                                   struct timespec const times[2], int flag));
9ccddf
+# else
9ccddf
+#  if !@HAVE_UTIMENSAT@
9ccddf
+_GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
9ccddf
+                                   struct timespec const times[2], int flag)
9ccddf
+                                  _GL_ARG_NONNULL ((2)));
9ccddf
+#  endif
9ccddf
+_GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
9ccddf
+                                   struct timespec const times[2], int flag));
9ccddf
+# endif
9ccddf
+# if @HAVE_UTIMENSAT@
9ccddf
+_GL_CXXALIASWARN (utimensat);
9ccddf
+# endif
9ccddf
+#elif defined GNULIB_POSIXCHECK
9ccddf
+# undef utimensat
9ccddf
+# if HAVE_RAW_DECL_UTIMENSAT
9ccddf
+_GL_WARN_ON_USE (utimensat, "utimensat is not portable - "
9ccddf
+                 "use gnulib module utimensat for portability");
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+
9ccddf
+#endif /* _@GUARD_PREFIX@_SYS_STAT_H */
9ccddf
+#endif /* _@GUARD_PREFIX@_SYS_STAT_H */
9ccddf
+#endif
9ccddf
diff --git a/grub-core/gnulib/sys_time.in.h b/grub-core/gnulib/sys_time.in.h
9ccddf
new file mode 100644
9ccddf
index 0000000..30057ad
9ccddf
--- /dev/null
9ccddf
+++ b/grub-core/gnulib/sys_time.in.h
9ccddf
@@ -0,0 +1,213 @@
9ccddf
+/* Provide a more complete sys/time.h.
9ccddf
+
9ccddf
+   Copyright (C) 2007-2014 Free Software Foundation, Inc.
9ccddf
+
9ccddf
+   This program is free software; you can redistribute it and/or modify
9ccddf
+   it under the terms of the GNU General Public License as published by
9ccddf
+   the Free Software Foundation; either version 3, or (at your option)
9ccddf
+   any later version.
9ccddf
+
9ccddf
+   This program is distributed in the hope that it will be useful,
9ccddf
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
9ccddf
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9ccddf
+   GNU General Public License for more details.
9ccddf
+
9ccddf
+   You should have received a copy of the GNU General Public License
9ccddf
+   along with this program; if not, see <http: www.gnu.org="" licenses=""/>.  */
9ccddf
+
9ccddf
+/* Written by Paul Eggert.  */
9ccddf
+
9ccddf
+#ifndef _@GUARD_PREFIX@_SYS_TIME_H
9ccddf
+
9ccddf
+#if __GNUC__ >= 3
9ccddf
+@PRAGMA_SYSTEM_HEADER@
9ccddf
+#endif
9ccddf
+@PRAGMA_COLUMNS@
9ccddf
+
9ccddf
+/* On Cygwin and on many BSDish systems, <sys time.h=""> includes itself
9ccddf
+   recursively via <sys select.h="">.
9ccddf
+   Simply delegate to the system's header in this case; it is a no-op.
9ccddf
+   Without this extra ifdef, the C++ gettimeofday declaration below
9ccddf
+   would be a forward declaration in gnulib's nested <sys time.h="">.  */
9ccddf
+#if defined _CYGWIN_SYS_TIME_H || defined _SYS_TIME_H || defined _SYS_TIME_H_
9ccddf
+# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
9ccddf
+#else
9ccddf
+
9ccddf
+/* The include_next requires a split double-inclusion guard.  */
9ccddf
+#if @HAVE_SYS_TIME_H@
9ccddf
+# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
9ccddf
+#endif
9ccddf
+
9ccddf
+#ifndef _@GUARD_PREFIX@_SYS_TIME_H
9ccddf
+#define _@GUARD_PREFIX@_SYS_TIME_H
9ccddf
+
9ccddf
+#if ! @HAVE_SYS_TIME_H@
9ccddf
+# include <time.h>
9ccddf
+#endif
9ccddf
+
9ccddf
+/* On native Windows with MSVC, get the 'struct timeval' type.
9ccddf
+   Also, on native Windows with a 64-bit time_t, where we are overriding the
9ccddf
+   'struct timeval' type, get all declarations of system functions whose
9ccddf
+   signature contains 'struct timeval'.  */
9ccddf
+#if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H
9ccddf
+# define _GL_INCLUDING_WINSOCK2_H
9ccddf
+# include <winsock2.h>
9ccddf
+# undef _GL_INCLUDING_WINSOCK2_H
9ccddf
+#endif
9ccddf
+
9ccddf
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
9ccddf
+
9ccddf
+/* The definition of _GL_ARG_NONNULL is copied here.  */
9ccddf
+
9ccddf
+/* The definition of _GL_WARN_ON_USE is copied here.  */
9ccddf
+
9ccddf
+#ifdef __cplusplus
9ccddf
+extern "C" {
9ccddf
+#endif
9ccddf
+
9ccddf
+#if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@
9ccddf
+
9ccddf
+# if @REPLACE_STRUCT_TIMEVAL@
9ccddf
+#  define timeval rpl_timeval
9ccddf
+# endif
9ccddf
+
9ccddf
+# if !GNULIB_defined_struct_timeval
9ccddf
+struct timeval
9ccddf
+{
9ccddf
+  time_t tv_sec;
9ccddf
+  long int tv_usec;
9ccddf
+};
9ccddf
+#  define GNULIB_defined_struct_timeval 1
9ccddf
+# endif
9ccddf
+
9ccddf
+#endif
9ccddf
+
9ccddf
+#ifdef __cplusplus
9ccddf
+}
9ccddf
+#endif
9ccddf
+
9ccddf
+#if @GNULIB_GETTIMEOFDAY@
9ccddf
+# if @REPLACE_GETTIMEOFDAY@
9ccddf
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
9ccddf
+#   undef gettimeofday
9ccddf
+#   define gettimeofday rpl_gettimeofday
9ccddf
+#  endif
9ccddf
+_GL_FUNCDECL_RPL (gettimeofday, int,
9ccddf
+                  (struct timeval *restrict, void *restrict)
9ccddf
+                  _GL_ARG_NONNULL ((1)));
9ccddf
+_GL_CXXALIAS_RPL (gettimeofday, int,
9ccddf
+                  (struct timeval *restrict, void *restrict));
9ccddf
+# else
9ccddf
+#  if !@HAVE_GETTIMEOFDAY@
9ccddf
+_GL_FUNCDECL_SYS (gettimeofday, int,
9ccddf
+                  (struct timeval *restrict, void *restrict)
9ccddf
+                  _GL_ARG_NONNULL ((1)));
9ccddf
+#  endif
9ccddf
+/* Need to cast, because on glibc systems, by default, the second argument is
9ccddf
+                                                  struct timezone *.  */
9ccddf
+_GL_CXXALIAS_SYS_CAST (gettimeofday, int,
9ccddf
+                       (struct timeval *restrict, void *restrict));
9ccddf
+# endif
9ccddf
+_GL_CXXALIASWARN (gettimeofday);
9ccddf
+#elif defined GNULIB_POSIXCHECK
9ccddf
+# undef gettimeofday
9ccddf
+# if HAVE_RAW_DECL_GETTIMEOFDAY
9ccddf
+_GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - "
9ccddf
+                 "use gnulib module gettimeofday for portability");
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+/* Hide some function declarations from <winsock2.h>.  */
9ccddf
+
9ccddf
+#if defined _MSC_VER && @HAVE_WINSOCK2_H@
9ccddf
+# if !defined _@GUARD_PREFIX@_UNISTD_H
9ccddf
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
9ccddf
+#   undef close
9ccddf
+#   define close close_used_without_including_unistd_h
9ccddf
+#  else
9ccddf
+     _GL_WARN_ON_USE (close,
9ccddf
+                      "close() used without including <unistd.h>");
9ccddf
+#  endif
9ccddf
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
9ccddf
+#   undef gethostname
9ccddf
+#   define gethostname gethostname_used_without_including_unistd_h
9ccddf
+#  else
9ccddf
+     _GL_WARN_ON_USE (gethostname,
9ccddf
+                      "gethostname() used without including <unistd.h>");
9ccddf
+#  endif
9ccddf
+# endif
9ccddf
+# if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
9ccddf
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
9ccddf
+#   undef socket
9ccddf
+#   define socket              socket_used_without_including_sys_socket_h
9ccddf
+#   undef connect
9ccddf
+#   define connect             connect_used_without_including_sys_socket_h
9ccddf
+#   undef accept
9ccddf
+#   define accept              accept_used_without_including_sys_socket_h
9ccddf
+#   undef bind
9ccddf
+#   define bind                bind_used_without_including_sys_socket_h
9ccddf
+#   undef getpeername
9ccddf
+#   define getpeername         getpeername_used_without_including_sys_socket_h
9ccddf
+#   undef getsockname
9ccddf
+#   define getsockname         getsockname_used_without_including_sys_socket_h
9ccddf
+#   undef getsockopt
9ccddf
+#   define getsockopt          getsockopt_used_without_including_sys_socket_h
9ccddf
+#   undef listen
9ccddf
+#   define listen              listen_used_without_including_sys_socket_h
9ccddf
+#   undef recv
9ccddf
+#   define recv                recv_used_without_including_sys_socket_h
9ccddf
+#   undef send
9ccddf
+#   define send                send_used_without_including_sys_socket_h
9ccddf
+#   undef recvfrom
9ccddf
+#   define recvfrom            recvfrom_used_without_including_sys_socket_h
9ccddf
+#   undef sendto
9ccddf
+#   define sendto              sendto_used_without_including_sys_socket_h
9ccddf
+#   undef setsockopt
9ccddf
+#   define setsockopt          setsockopt_used_without_including_sys_socket_h
9ccddf
+#   undef shutdown
9ccddf
+#   define shutdown            shutdown_used_without_including_sys_socket_h
9ccddf
+#  else
9ccddf
+     _GL_WARN_ON_USE (socket,
9ccddf
+                      "socket() used without including <sys socket.h="">");
9ccddf
+     _GL_WARN_ON_USE (connect,
9ccddf
+                      "connect() used without including <sys socket.h="">");
9ccddf
+     _GL_WARN_ON_USE (accept,
9ccddf
+                      "accept() used without including <sys socket.h="">");
9ccddf
+     _GL_WARN_ON_USE (bind,
9ccddf
+                      "bind() used without including <sys socket.h="">");
9ccddf
+     _GL_WARN_ON_USE (getpeername,
9ccddf
+                      "getpeername() used without including <sys socket.h="">");
9ccddf
+     _GL_WARN_ON_USE (getsockname,
9ccddf
+                      "getsockname() used without including <sys socket.h="">");
9ccddf
+     _GL_WARN_ON_USE (getsockopt,
9ccddf
+                      "getsockopt() used without including <sys socket.h="">");
9ccddf
+     _GL_WARN_ON_USE (listen,
9ccddf
+                      "listen() used without including <sys socket.h="">");
9ccddf
+     _GL_WARN_ON_USE (recv,
9ccddf
+                      "recv() used without including <sys socket.h="">");
9ccddf
+     _GL_WARN_ON_USE (send,
9ccddf
+                      "send() used without including <sys socket.h="">");
9ccddf
+     _GL_WARN_ON_USE (recvfrom,
9ccddf
+                      "recvfrom() used without including <sys socket.h="">");
9ccddf
+     _GL_WARN_ON_USE (sendto,
9ccddf
+                      "sendto() used without including <sys socket.h="">");
9ccddf
+     _GL_WARN_ON_USE (setsockopt,
9ccddf
+                      "setsockopt() used without including <sys socket.h="">");
9ccddf
+     _GL_WARN_ON_USE (shutdown,
9ccddf
+                      "shutdown() used without including <sys socket.h="">");
9ccddf
+#  endif
9ccddf
+# endif
9ccddf
+# if !defined _@GUARD_PREFIX@_SYS_SELECT_H
9ccddf
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
9ccddf
+#   undef select
9ccddf
+#   define select select_used_without_including_sys_select_h
9ccddf
+#  else
9ccddf
+     _GL_WARN_ON_USE (select,
9ccddf
+                      "select() used without including <sys select.h="">");
9ccddf
+#  endif
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+#endif /* _@GUARD_PREFIX@_SYS_TIME_H */
9ccddf
+#endif /* _CYGWIN_SYS_TIME_H */
9ccddf
+#endif /* _@GUARD_PREFIX@_SYS_TIME_H */
9ccddf
diff --git a/grub-core/gnulib/sys_types.in.h b/grub-core/gnulib/sys_types.in.h
9ccddf
index d7da356..9520c09 100644
9ccddf
--- a/grub-core/gnulib/sys_types.in.h
9ccddf
+++ b/grub-core/gnulib/sys_types.in.h
9ccddf
@@ -23,7 +23,9 @@
9ccddf
 #ifndef _@GUARD_PREFIX@_SYS_TYPES_H
9ccddf
 
9ccddf
 /* The include_next requires a split double-inclusion guard.  */
9ccddf
+# define _GL_INCLUDING_SYS_TYPES_H
9ccddf
 #@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@
9ccddf
+# undef _GL_INCLUDING_SYS_TYPES_H
9ccddf
 
9ccddf
 #ifndef _@GUARD_PREFIX@_SYS_TYPES_H
9ccddf
 #define _@GUARD_PREFIX@_SYS_TYPES_H
9ccddf
diff --git a/grub-core/gnulib/time.h b/grub-core/gnulib/time.h
9ccddf
new file mode 100644
9ccddf
index 0000000..b9203d5
9ccddf
--- /dev/null
9ccddf
+++ b/grub-core/gnulib/time.h
9ccddf
@@ -0,0 +1,586 @@
9ccddf
+/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
9ccddf
+/* A more-standard <time.h>.
9ccddf
+
9ccddf
+   Copyright (C) 2007-2014 Free Software Foundation, Inc.
9ccddf
+
9ccddf
+   This program is free software; you can redistribute it and/or modify
9ccddf
+   it under the terms of the GNU General Public License as published by
9ccddf
+   the Free Software Foundation; either version 3, or (at your option)
9ccddf
+   any later version.
9ccddf
+
9ccddf
+   This program is distributed in the hope that it will be useful,
9ccddf
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
9ccddf
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9ccddf
+   GNU General Public License for more details.
9ccddf
+
9ccddf
+   You should have received a copy of the GNU General Public License
9ccddf
+   along with this program; if not, see <http: www.gnu.org="" licenses=""/>.  */
9ccddf
+
9ccddf
+#if __GNUC__ >= 3
9ccddf
+#pragma GCC system_header
9ccddf
+#endif
9ccddf
+
9ccddf
+
9ccddf
+/* Don't get in the way of glibc when it includes time.h merely to
9ccddf
+   declare a few standard symbols, rather than to declare all the
9ccddf
+   symbols.  Also, Solaris 8 <time.h> eventually includes itself
9ccddf
+   recursively; if that is happening, just include the system <time.h>
9ccddf
+   without adding our own declarations.  */
9ccddf
+#if (defined __need_time_t || defined __need_clock_t \
9ccddf
+     || defined __need_timespec \
9ccddf
+     || defined _GL_TIME_H)
9ccddf
+
9ccddf
+# include_next <time.h>
9ccddf
+
9ccddf
+#else
9ccddf
+
9ccddf
+# define _GL_TIME_H
9ccddf
+
9ccddf
+# include_next <time.h>
9ccddf
+
9ccddf
+/* NetBSD 5.0 mis-defines NULL.  */
9ccddf
+# include <stddef.h>
9ccddf
+
9ccddf
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
9ccddf
+#ifndef _GL_CXXDEFS_H
9ccddf
+#define _GL_CXXDEFS_H
9ccddf
+
9ccddf
+/* The three most frequent use cases of these macros are:
9ccddf
+
9ccddf
+   * For providing a substitute for a function that is missing on some
9ccddf
+     platforms, but is declared and works fine on the platforms on which
9ccddf
+     it exists:
9ccddf
+
9ccddf
+       #if @GNULIB_FOO@
9ccddf
+       # if !@HAVE_FOO@
9ccddf
+       _GL_FUNCDECL_SYS (foo, ...);
9ccddf
+       # endif
9ccddf
+       _GL_CXXALIAS_SYS (foo, ...);
9ccddf
+       _GL_CXXALIASWARN (foo);
9ccddf
+       #elif defined GNULIB_POSIXCHECK
9ccddf
+       ...
9ccddf
+       #endif
9ccddf
+
9ccddf
+   * For providing a replacement for a function that exists on all platforms,
9ccddf
+     but is broken/insufficient and needs to be replaced on some platforms:
9ccddf
+
9ccddf
+       #if @GNULIB_FOO@
9ccddf
+       # if @REPLACE_FOO@
9ccddf
+       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
9ccddf
+       #   undef foo
9ccddf
+       #   define foo rpl_foo
9ccddf
+       #  endif
9ccddf
+       _GL_FUNCDECL_RPL (foo, ...);
9ccddf
+       _GL_CXXALIAS_RPL (foo, ...);
9ccddf
+       # else
9ccddf
+       _GL_CXXALIAS_SYS (foo, ...);
9ccddf
+       # endif
9ccddf
+       _GL_CXXALIASWARN (foo);
9ccddf
+       #elif defined GNULIB_POSIXCHECK
9ccddf
+       ...
9ccddf
+       #endif
9ccddf
+
9ccddf
+   * For providing a replacement for a function that exists on some platforms
9ccddf
+     but is broken/insufficient and needs to be replaced on some of them and
9ccddf
+     is additionally either missing or undeclared on some other platforms:
9ccddf
+
9ccddf
+       #if @GNULIB_FOO@
9ccddf
+       # if @REPLACE_FOO@
9ccddf
+       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
9ccddf
+       #   undef foo
9ccddf
+       #   define foo rpl_foo
9ccddf
+       #  endif
9ccddf
+       _GL_FUNCDECL_RPL (foo, ...);
9ccddf
+       _GL_CXXALIAS_RPL (foo, ...);
9ccddf
+       # else
9ccddf
+       #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@
9ccddf
+       _GL_FUNCDECL_SYS (foo, ...);
9ccddf
+       #  endif
9ccddf
+       _GL_CXXALIAS_SYS (foo, ...);
9ccddf
+       # endif
9ccddf
+       _GL_CXXALIASWARN (foo);
9ccddf
+       #elif defined GNULIB_POSIXCHECK
9ccddf
+       ...
9ccddf
+       #endif
9ccddf
+*/
9ccddf
+
9ccddf
+/* _GL_EXTERN_C declaration;
9ccddf
+   performs the declaration with C linkage.  */
9ccddf
+#if defined __cplusplus
9ccddf
+# define _GL_EXTERN_C extern "C"
9ccddf
+#else
9ccddf
+# define _GL_EXTERN_C extern
9ccddf
+#endif
9ccddf
+
9ccddf
+/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
9ccddf
+   declares a replacement function, named rpl_func, with the given prototype,
9ccddf
+   consisting of return type, parameters, and attributes.
9ccddf
+   Example:
9ccddf
+     _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
9ccddf
+                                  _GL_ARG_NONNULL ((1)));
9ccddf
+ */
9ccddf
+#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
9ccddf
+  _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
9ccddf
+#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
9ccddf
+  _GL_EXTERN_C rettype rpl_func parameters_and_attributes
9ccddf
+
9ccddf
+/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
9ccddf
+   declares the system function, named func, with the given prototype,
9ccddf
+   consisting of return type, parameters, and attributes.
9ccddf
+   Example:
9ccddf
+     _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
9ccddf
+                                  _GL_ARG_NONNULL ((1)));
9ccddf
+ */
9ccddf
+#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
9ccddf
+  _GL_EXTERN_C rettype func parameters_and_attributes
9ccddf
+
9ccddf
+/* _GL_CXXALIAS_RPL (func, rettype, parameters);
9ccddf
+   declares a C++ alias called GNULIB_NAMESPACE::func
9ccddf
+   that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
9ccddf
+   Example:
9ccddf
+     _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
9ccddf
+ */
9ccddf
+#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
9ccddf
+  _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
9ccddf
+#if defined __cplusplus && defined GNULIB_NAMESPACE
9ccddf
+# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
9ccddf
+    namespace GNULIB_NAMESPACE                                \
9ccddf
+    {                                                         \
9ccddf
+      rettype (*const func) parameters = ::rpl_func;          \
9ccddf
+    }                                                         \
9ccddf
+    _GL_EXTERN_C int _gl_cxxalias_dummy
9ccddf
+#else
9ccddf
+# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
9ccddf
+    _GL_EXTERN_C int _gl_cxxalias_dummy
9ccddf
+#endif
9ccddf
+
9ccddf
+/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
9ccddf
+   is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
9ccddf
+   except that the C function rpl_func may have a slightly different
9ccddf
+   declaration.  A cast is used to silence the "invalid conversion" error
9ccddf
+   that would otherwise occur.  */
9ccddf
+#if defined __cplusplus && defined GNULIB_NAMESPACE
9ccddf
+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
9ccddf
+    namespace GNULIB_NAMESPACE                                     \
9ccddf
+    {                                                              \
9ccddf
+      rettype (*const func) parameters =                           \
9ccddf
+        reinterpret_cast<rettype(*)parameters>(::rpl_func);        \
9ccddf
+    }                                                              \
9ccddf
+    _GL_EXTERN_C int _gl_cxxalias_dummy
9ccddf
+#else
9ccddf
+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
9ccddf
+    _GL_EXTERN_C int _gl_cxxalias_dummy
9ccddf
+#endif
9ccddf
+
9ccddf
+/* _GL_CXXALIAS_SYS (func, rettype, parameters);
9ccddf
+   declares a C++ alias called GNULIB_NAMESPACE::func
9ccddf
+   that redirects to the system provided function func, if GNULIB_NAMESPACE
9ccddf
+   is defined.
9ccddf
+   Example:
9ccddf
+     _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
9ccddf
+ */
9ccddf
+#if defined __cplusplus && defined GNULIB_NAMESPACE
9ccddf
+  /* If we were to write
9ccddf
+       rettype (*const func) parameters = ::func;
9ccddf
+     like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
9ccddf
+     better (remove an indirection through a 'static' pointer variable),
9ccddf
+     but then the _GL_CXXALIASWARN macro below would cause a warning not only
9ccddf
+     for uses of ::func but also for uses of GNULIB_NAMESPACE::func.  */
9ccddf
+# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
9ccddf
+    namespace GNULIB_NAMESPACE                     \
9ccddf
+    {                                              \
9ccddf
+      static rettype (*func) parameters = ::func;  \
9ccddf
+    }                                              \
9ccddf
+    _GL_EXTERN_C int _gl_cxxalias_dummy
9ccddf
+#else
9ccddf
+# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
9ccddf
+    _GL_EXTERN_C int _gl_cxxalias_dummy
9ccddf
+#endif
9ccddf
+
9ccddf
+/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
9ccddf
+   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
9ccddf
+   except that the C function func may have a slightly different declaration.
9ccddf
+   A cast is used to silence the "invalid conversion" error that would
9ccddf
+   otherwise occur.  */
9ccddf
+#if defined __cplusplus && defined GNULIB_NAMESPACE
9ccddf
+# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
9ccddf
+    namespace GNULIB_NAMESPACE                          \
9ccddf
+    {                                                   \
9ccddf
+      static rettype (*func) parameters =               \
9ccddf
+        reinterpret_cast<rettype(*)parameters>(::func); \
9ccddf
+    }                                                   \
9ccddf
+    _GL_EXTERN_C int _gl_cxxalias_dummy
9ccddf
+#else
9ccddf
+# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
9ccddf
+    _GL_EXTERN_C int _gl_cxxalias_dummy
9ccddf
+#endif
9ccddf
+
9ccddf
+/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
9ccddf
+   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
9ccddf
+   except that the C function is picked among a set of overloaded functions,
9ccddf
+   namely the one with rettype2 and parameters2.  Two consecutive casts
9ccddf
+   are used to silence the "cannot find a match" and "invalid conversion"
9ccddf
+   errors that would otherwise occur.  */
9ccddf
+#if defined __cplusplus && defined GNULIB_NAMESPACE
9ccddf
+  /* The outer cast must be a reinterpret_cast.
9ccddf
+     The inner cast: When the function is defined as a set of overloaded
9ccddf
+     functions, it works as a static_cast<>, choosing the designated variant.
9ccddf
+     When the function is defined as a single variant, it works as a
9ccddf
+     reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
9ccddf
+# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
9ccddf
+    namespace GNULIB_NAMESPACE                                                \
9ccddf
+    {                                                                         \
9ccddf
+      static rettype (*func) parameters =                                     \
9ccddf
+        reinterpret_cast<rettype(*)parameters>(                               \
9ccddf
+          (rettype2(*)parameters2)(::func));                                  \
9ccddf
+    }                                                                         \
9ccddf
+    _GL_EXTERN_C int _gl_cxxalias_dummy
9ccddf
+#else
9ccddf
+# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
9ccddf
+    _GL_EXTERN_C int _gl_cxxalias_dummy
9ccddf
+#endif
9ccddf
+
9ccddf
+/* _GL_CXXALIASWARN (func);
9ccddf
+   causes a warning to be emitted when ::func is used but not when
9ccddf
+   GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
9ccddf
+   variants.  */
9ccddf
+#if defined __cplusplus && defined GNULIB_NAMESPACE
9ccddf
+# define _GL_CXXALIASWARN(func) \
9ccddf
+   _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
9ccddf
+# define _GL_CXXALIASWARN_1(func,namespace) \
9ccddf
+   _GL_CXXALIASWARN_2 (func, namespace)
9ccddf
+/* To work around GCC bug <http: gcc.gnu.org="" bugzilla="" show_bug.cgi?id="43881">,
9ccddf
+   we enable the warning only when not optimizing.  */
9ccddf
+# if !__OPTIMIZE__
9ccddf
+#  define _GL_CXXALIASWARN_2(func,namespace) \
9ccddf
+    _GL_WARN_ON_USE (func, \
9ccddf
+                     "The symbol ::" #func " refers to the system function. " \
9ccddf
+                     "Use " #namespace "::" #func " instead.")
9ccddf
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
9ccddf
+#  define _GL_CXXALIASWARN_2(func,namespace) \
9ccddf
+     extern __typeof__ (func) func
9ccddf
+# else
9ccddf
+#  define _GL_CXXALIASWARN_2(func,namespace) \
9ccddf
+     _GL_EXTERN_C int _gl_cxxalias_dummy
9ccddf
+# endif
9ccddf
+#else
9ccddf
+# define _GL_CXXALIASWARN(func) \
9ccddf
+    _GL_EXTERN_C int _gl_cxxalias_dummy
9ccddf
+#endif
9ccddf
+
9ccddf
+/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
9ccddf
+   causes a warning to be emitted when the given overloaded variant of ::func
9ccddf
+   is used but not when GNULIB_NAMESPACE::func is used.  */
9ccddf
+#if defined __cplusplus && defined GNULIB_NAMESPACE
9ccddf
+# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
9ccddf
+   _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
9ccddf
+                        GNULIB_NAMESPACE)
9ccddf
+# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
9ccddf
+   _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
9ccddf
+/* To work around GCC bug <http: gcc.gnu.org="" bugzilla="" show_bug.cgi?id="43881">,
9ccddf
+   we enable the warning only when not optimizing.  */
9ccddf
+# if !__OPTIMIZE__
9ccddf
+#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
9ccddf
+    _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
9ccddf
+                         "The symbol ::" #func " refers to the system function. " \
9ccddf
+                         "Use " #namespace "::" #func " instead.")
9ccddf
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
9ccddf
+#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
9ccddf
+     extern __typeof__ (func) func
9ccddf
+# else
9ccddf
+#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
9ccddf
+     _GL_EXTERN_C int _gl_cxxalias_dummy
9ccddf
+# endif
9ccddf
+#else
9ccddf
+# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
9ccddf
+    _GL_EXTERN_C int _gl_cxxalias_dummy
9ccddf
+#endif
9ccddf
+
9ccddf
+#endif /* _GL_CXXDEFS_H */
9ccddf
+
9ccddf
+/* The definition of _GL_ARG_NONNULL is copied here.  */
9ccddf
+/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
9ccddf
+   that the values passed as arguments n, ..., m must be non-NULL pointers.
9ccddf
+   n = 1 stands for the first argument, n = 2 for the second argument etc.  */
9ccddf
+#ifndef _GL_ARG_NONNULL
9ccddf
+# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
9ccddf
+#  define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
9ccddf
+# else
9ccddf
+#  define _GL_ARG_NONNULL(params)
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+/* The definition of _GL_WARN_ON_USE is copied here.  */
9ccddf
+#ifndef _GL_WARN_ON_USE
9ccddf
+
9ccddf
+# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
9ccddf
+/* A compiler attribute is available in gcc versions 4.3.0 and later.  */
9ccddf
+#  define _GL_WARN_ON_USE(function, message) \
9ccddf
+extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
9ccddf
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
9ccddf
+/* Verify the existence of the function.  */
9ccddf
+#  define _GL_WARN_ON_USE(function, message) \
9ccddf
+extern __typeof__ (function) function
9ccddf
+# else /* Unsupported.  */
9ccddf
+#  define _GL_WARN_ON_USE(function, message) \
9ccddf
+_GL_WARN_EXTERN_C int _gl_warn_on_use
9ccddf
+# endif
9ccddf
+#endif
9ccddf
+
9ccddf
+/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
9ccddf
+   is like _GL_WARN_ON_USE (function, "string"), except that the function is
9ccddf
+   declared with the given prototype, consisting of return type, parameters,
9ccddf
+   and attributes.
9ccddf
+   This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
9ccddf
+   not work in this case.  */
9ccddf
+#ifndef _GL_WARN_ON_USE_CXX
9ccddf
+# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
9ccddf
+#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
9ccddf
+extern rettype function parameters_and_attributes \
9ccddf
+     __attribute__ ((__warning__ (msg)))
9ccddf
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
9ccddf
+/* Verify the existence of the function.  */
9ccddf
+#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
9ccddf
+extern rettype function parameters_and_attributes
9ccddf
+# else /* Unsupported.  */
9ccddf
+#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
9ccddf
+_GL_WARN_EXTERN_C int _gl_warn_on_use