Blame SOURCES/0145-Add-grub_util_readlink.patch

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