components/binutils/patches/output.cc.patch
author William.D.Johnston <William.D.Johnston@oracle.com>
Mon, 03 Oct 2016 16:23:08 -0700
changeset 7028 ab6ecc2d7d06
parent 5057 ab1b43bf588f
permissions -rw-r--r--
24681772 Upgrade Solaris to BIND 9.10.4-P3 24681876 problem in SERVICE/DNS-SERVER
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5057
ab1b43bf588f 21555668 upgrade binutils to 2.25.1
Stefan Teleman <stefan.teleman@oracle.com>
parents: 1123
diff changeset
     1
# Solaris posix_fallocate(3C) will fail if len == 0. Try using
ab1b43bf588f 21555668 upgrade binutils to 2.25.1
Stefan Teleman <stefan.teleman@oracle.com>
parents: 1123
diff changeset
     2
# posix_fallocate(3C) first, and if it fails, fallback to
ab1b43bf588f 21555668 upgrade binutils to 2.25.1
Stefan Teleman <stefan.teleman@oracle.com>
parents: 1123
diff changeset
     3
# ftruncate(3C).
ab1b43bf588f 21555668 upgrade binutils to 2.25.1
Stefan Teleman <stefan.teleman@oracle.com>
parents: 1123
diff changeset
     4
# We aren't building the Gold Linker anyway. This is just for
ab1b43bf588f 21555668 upgrade binutils to 2.25.1
Stefan Teleman <stefan.teleman@oracle.com>
parents: 1123
diff changeset
     5
# those of us who are building and working on the Gold Linker.
ab1b43bf588f 21555668 upgrade binutils to 2.25.1
Stefan Teleman <stefan.teleman@oracle.com>
parents: 1123
diff changeset
     6
# This patch has been submitted to the community.
ab1b43bf588f 21555668 upgrade binutils to 2.25.1
Stefan Teleman <stefan.teleman@oracle.com>
parents: 1123
diff changeset
     7
--- gold/output.cc	2014-10-14 00:32:04.000000000 -0700
ab1b43bf588f 21555668 upgrade binutils to 2.25.1
Stefan Teleman <stefan.teleman@oracle.com>
parents: 1123
diff changeset
     8
+++ gold/output.cc	2015-08-04 11:57:17.805271241 -0700
1123
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     9
@@ -22,6 +22,7 @@
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    10
 
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    11
 #include "gold.h"
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    12
 
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    13
+#include <cstdio>
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    14
 #include <cstdlib>
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    15
 #include <cstring>
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    16
 #include <cerrno>
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    17
@@ -127,9 +128,15 @@
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    18
 static int
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    19
 gold_fallocate(int o, off_t offset, off_t len)
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    20
 {
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    21
-#ifdef HAVE_POSIX_FALLOCATE
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    22
-  if (parameters->options().posix_fallocate())
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    23
-    return ::posix_fallocate(o, offset, len);
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    24
+#if defined(HAVE_POSIX_FALLOCATE)
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    25
+  if (parameters->options().posix_fallocate()) {
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    26
+    // posix_fallocate on Solaris will fail if len == 0
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    27
+    int ret = ::posix_fallocate(o, offset, len);
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    28
+    // try ::ftruncate(3C) is posix_fallocate(3C) failed.
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    29
+    if (ret != 0)
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    30
+      ret = ::ftruncate(o, offset + len);
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    31
+    return ret;
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    32
+  }
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    33
 #endif // defined(HAVE_POSIX_FALLOCATE)
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    34
 #ifdef HAVE_FALLOCATE
cb43164c5dd1 15824357 SUNBT7205968 Upgrade binutils to 2.22
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    35
   if (::fallocate(o, 0, offset, len) == 0)