nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0054-Add-grub_util_readlink.patch

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