nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0145-Add-grub_util_readlink.patch

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