Blame SOURCES/0145-Add-grub_util_readlink.patch

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