Don't call unimplemented syscalls.

Avoid calling syscalls that are stubbed out in Fuchsia. They are
generally harmless, but generate a warning message that makes it
harder to see real warnings/errors.

Change-Id: Ibef205bc01e18e2b86de606f814e8b7b2527980a
diff --git a/patches/gcc-patch.txt b/patches/gcc-patch.txt
index d3db393..486c52f 100644
--- a/patches/gcc-patch.txt
+++ b/patches/gcc-patch.txt
@@ -828,6 +828,104 @@
   #ifdef SIGPIPE
     if (signal (SIGPIPE, SIG_IGN) != SIG_IGN)
       signal (SIGPIPE, fatal_signal);
+diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/gcc/ggc-common.c gcc-6.2.0/gcc/ggc-common.c
+*** gcc-6.2.0-fsf/gcc/ggc-common.c	2016-12-20 13:59:53.022879377 -0800
+--- gcc-6.2.0/gcc/ggc-common.c	2017-01-10 14:54:17.969607414 -0800
+*************** mmap_gt_pch_use_address (void *base, siz
+*** 728,734 ****
+  static double
+  ggc_rlimit_bound (double limit)
+  {
+! #if defined(HAVE_GETRLIMIT)
+    struct rlimit rlim;
+  # if defined (RLIMIT_AS)
+    /* RLIMIT_AS is what POSIX says is the limit on mmap.  Presumably
+--- 728,735 ----
+  static double
+  ggc_rlimit_bound (double limit)
+  {
+! /* Fuchsia: getrlimit is not fully implemented yet.  */
+! #if !defined(__Fuchsia__) && defined(HAVE_GETRLIMIT)
+    struct rlimit rlim;
+  # if defined (RLIMIT_AS)
+    /* RLIMIT_AS is what POSIX says is the limit on mmap.  Presumably
+*************** ggc_rlimit_bound (double limit)
+*** 752,758 ****
+        && rlim.rlim_cur >= 8 * 1024 * 1024)
+      limit = rlim.rlim_cur;
+  # endif /* RLIMIT_AS or RLIMIT_DATA */
+! #endif /* HAVE_GETRLIMIT */
+  
+    return limit;
+  }
+--- 753,759 ----
+        && rlim.rlim_cur >= 8 * 1024 * 1024)
+      limit = rlim.rlim_cur;
+  # endif /* RLIMIT_AS or RLIMIT_DATA */
+! #endif /* !Fuchsia && HAVE_GETRLIMIT */
+  
+    return limit;
+  }
+*************** ggc_min_heapsize_heuristic (void)
+*** 790,796 ****
+       bound of 128M (when RAM >= 1GB).  */
+    phys_kbytes /= 8;
+  
+! #if defined(HAVE_GETRLIMIT) && defined (RLIMIT_RSS)
+    /* Try not to overrun the RSS limit while doing garbage collection.
+       The RSS limit is only advisory, so no margin is subtracted.  */
+   {
+--- 791,798 ----
+       bound of 128M (when RAM >= 1GB).  */
+    phys_kbytes /= 8;
+  
+! /* Fuchsia: getrlimit is not fully implemented yet.  */
+! #if !defined(__Fuchsia__) && defined(HAVE_GETRLIMIT) && defined (RLIMIT_RSS)
+    /* Try not to overrun the RSS limit while doing garbage collection.
+       The RSS limit is only advisory, so no margin is subtracted.  */
+   {
+diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/gcc/opts.c gcc-6.2.0/gcc/opts.c
+*** gcc-6.2.0-fsf/gcc/opts.c	2016-12-20 14:00:05.086836577 -0800
+--- gcc-6.2.0/gcc/opts.c	2017-01-10 14:58:46.448360086 -0800
+*************** setup_core_dumping (diagnostic_context *
+*** 2386,2392 ****
+  #ifdef SIGABRT
+    signal (SIGABRT, SIG_DFL);
+  #endif
+! #if defined(HAVE_SETRLIMIT)
+    {
+      struct rlimit rlim;
+      if (getrlimit (RLIMIT_CORE, &rlim) != 0)
+--- 2386,2393 ----
+  #ifdef SIGABRT
+    signal (SIGABRT, SIG_DFL);
+  #endif
+! /* Fuchsia: remove when getrlimit/setrlimit have been implemented.  */
+! #if !defined(__Fuchsia__) && defined(HAVE_SETRLIMIT)
+    {
+      struct rlimit rlim;
+      if (getrlimit (RLIMIT_CORE, &rlim) != 0)
+diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/gcc/timevar.c gcc-6.2.0/gcc/timevar.c
+*** gcc-6.2.0-fsf/gcc/timevar.c	2016-12-20 14:00:05.594834775 -0800
+--- gcc-6.2.0/gcc/timevar.c	2017-01-10 14:56:40.812936374 -0800
+*************** struct tms
+*** 69,75 ****
+  # define HAVE_SYS_TIME
+  # define HAVE_WALL_TIME
+  #else
+! #ifdef HAVE_GETRUSAGE
+  # if defined HAVE_DECL_GETRUSAGE && !HAVE_DECL_GETRUSAGE
+    extern int getrusage (int, struct rusage *);
+  # endif
+--- 69,76 ----
+  # define HAVE_SYS_TIME
+  # define HAVE_WALL_TIME
+  #else
+! /* Fuchsia: remove when getrusage has been implemented.  */
+! #if !defined(__Fuchsia__) && defined(HAVE_GETRUSAGE)
+  # if defined HAVE_DECL_GETRUSAGE && !HAVE_DECL_GETRUSAGE
+    extern int getrusage (int, struct rusage *);
+  # endif
 diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/libgcc/config/arm/unwind-arm.h gcc-6.2.0/libgcc/config/arm/unwind-arm.h
 *** gcc-6.2.0-fsf/libgcc/config/arm/unwind-arm.h	2016-12-20 14:00:07.118829367 -0800
 --- gcc-6.2.0/libgcc/config/arm/unwind-arm.h	2017-01-10 09:08:36.419550153 -0800
@@ -939,6 +1037,46 @@
   	;;
   i[34567]86-*-dragonfly*)
   	tmake_file="${tmake_file} i386/t-dragonfly i386/t-crtstuff"
+diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/libiberty/lrealpath.c gcc-6.2.0/libiberty/lrealpath.c
+*** gcc-6.2.0-fsf/libiberty/lrealpath.c	2016-12-20 14:00:06.758830644 -0800
+--- gcc-6.2.0/libiberty/lrealpath.c	2017-01-10 15:01:19.863671770 -0800
+*************** components will be simplified.  The retu
+*** 56,62 ****
+  extern char *canonicalize_file_name (const char *);
+  #endif
+  
+! #if defined(HAVE_REALPATH)
+  # if defined (PATH_MAX)
+  #  define REALPATH_LIMIT PATH_MAX
+  # else
+--- 56,63 ----
+  extern char *canonicalize_file_name (const char *);
+  #endif
+  
+! /* Fuchsia: remove when realpath has been implemented.  */
+! #if !defined(__Fuchsia__) && defined(HAVE_REALPATH)
+  # if defined (PATH_MAX)
+  #  define REALPATH_LIMIT PATH_MAX
+  # else
+*************** lrealpath (const char *filename)
+*** 109,115 ****
+       pathconf()) making it impossible to pass a correctly sized buffer
+       to realpath() (it could always overflow).  On those systems, we
+       skip this.  */
+! #if defined (HAVE_REALPATH) && defined (HAVE_UNISTD_H)
+    {
+      /* Find out the max path size.  */
+      long path_max = pathconf ("/", _PC_PATH_MAX);
+--- 110,118 ----
+       pathconf()) making it impossible to pass a correctly sized buffer
+       to realpath() (it could always overflow).  On those systems, we
+       skip this.  */
+! /* Fuchsia: remove from conditional when realpath has been implemented.  */
+! #if defined (HAVE_REALPATH) && defined (HAVE_UNISTD_H) \
+!     && !defined (__Fuchsia__)
+    {
+      /* Find out the max path size.  */
+      long path_max = pathconf ("/", _PC_PATH_MAX);
 diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/libiberty/pex-unix.c gcc-6.2.0/libiberty/pex-unix.c
 *** gcc-6.2.0-fsf/libiberty/pex-unix.c	2016-12-20 14:00:06.758830644 -0800
 --- gcc-6.2.0/libiberty/pex-unix.c	2017-01-10 09:09:16.271408329 -0800
@@ -1047,6 +1185,30 @@
   
         if (pid > 0)
   	break;
+diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/libiberty/stack-limit.c gcc-6.2.0/libiberty/stack-limit.c
+*** gcc-6.2.0-fsf/libiberty/stack-limit.c	2016-12-20 14:00:06.730830744 -0800
+--- gcc-6.2.0/libiberty/stack-limit.c	2017-01-10 14:58:25.856453718 -0800
+*************** Attempt to increase stack size limit to
+*** 46,53 ****
+  void
+  stack_limit_increase (unsigned long pref ATTRIBUTE_UNUSED)
+  {
+  #if defined(HAVE_SETRLIMIT) && defined(HAVE_GETRLIMIT) \
+!     && defined(RLIMIT_STACK) && defined(RLIM_INFINITY)
+    struct rlimit rlim;
+    if (getrlimit (RLIMIT_STACK, &rlim) == 0
+        && rlim.rlim_cur != RLIM_INFINITY
+--- 46,55 ----
+  void
+  stack_limit_increase (unsigned long pref ATTRIBUTE_UNUSED)
+  {
++ /* Fuchsia: remove when getrlimit/setrlimit have been implemented.  */
+  #if defined(HAVE_SETRLIMIT) && defined(HAVE_GETRLIMIT) \
+!     && defined(RLIMIT_STACK) && defined(RLIM_INFINITY) \
+!     && !defined(__Fuchsia__)
+    struct rlimit rlim;
+    if (getrlimit (RLIMIT_STACK, &rlim) == 0
+        && rlim.rlim_cur != RLIM_INFINITY
 diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/libstdc++-v3/configure gcc-6.2.0/libstdc++-v3/configure
 *** gcc-6.2.0-fsf/libstdc++-v3/configure	2016-11-23 09:10:40.968283817 -0800
 --- gcc-6.2.0/libstdc++-v3/configure	2016-11-16 08:49:38.447039849 -0800