pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

compiler-rt-git: clang-format patches



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Mon Jul 3 20:36:36 2017 +0200
Changeset:	83306b46ee8747e1a169724352c7eade2f69c6ff

Modified Files:
	compiler-rt-git/distinfo
	compiler-rt-git/patches/patch-cmake_config-ix.cmake
	compiler-rt-git/patches/patch-lib_asan_asan__interceptors.cc
	compiler-rt-git/patches/patch-lib_asan_asan__interceptors.h
	compiler-rt-git/patches/patch-lib_asan_asan__linux.cc
	compiler-rt-git/patches/patch-lib_asan_asan__malloc__linux.cc
	compiler-rt-git/patches/patch-lib_asan_asan__stack.h
	compiler-rt-git/patches/patch-lib_asan_scripts_asan__symbolize.py
	compiler-rt-git/patches/patch-lib_interception_interception.h
	compiler-rt-git/patches/patch-lib_interception_interception__linux.cc
	compiler-rt-git/patches/patch-lib_interception_interception__linux.h
	compiler-rt-git/patches/patch-lib_sanitizer__common_CMakeLists.txt
	compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__internal__defs.h
	compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__libignore.cc
	compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__linux.cc
	compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__linux.h
	compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__linux__libcdep.cc
	compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__netbsd.h
	compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__platform.h
	compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__platform__interceptors.h
	compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.cc
	compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.h
	compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__procmaps.h
	compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__procmaps__common.cc
	compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc
	compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__syscall__generic.inc
	compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__unwind__linux__libcdep.cc

Log Message:
compiler-rt-git: clang-format patches

This is another round to prepare this code for upstream.

Sponsored by <The NetBSD Foundation>

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=83306b46ee8747e1a169724352c7eade2f69c6ff

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 compiler-rt-git/distinfo                           |  52 ++--
 .../patches/patch-cmake_config-ix.cmake            |   2 +-
 .../patches/patch-lib_asan_asan__interceptors.cc   |   2 +-
 .../patches/patch-lib_asan_asan__interceptors.h    |   2 +-
 .../patches/patch-lib_asan_asan__linux.cc          |  15 +-
 .../patches/patch-lib_asan_asan__malloc__linux.cc  |   2 +-
 .../patches/patch-lib_asan_asan__stack.h           |   7 +-
 .../patch-lib_asan_scripts_asan__symbolize.py      |   2 +-
 .../patches/patch-lib_interception_interception.h  |   8 +-
 .../patch-lib_interception_interception__linux.cc  |  15 +-
 .../patch-lib_interception_interception__linux.h   |   2 +-
 .../patch-lib_sanitizer__common_CMakeLists.txt     |   2 +-
 ...b_sanitizer__common_sanitizer__internal__defs.h |   8 +-
 ...h-lib_sanitizer__common_sanitizer__libignore.cc |   4 +-
 ...patch-lib_sanitizer__common_sanitizer__linux.cc | 102 +++----
 .../patch-lib_sanitizer__common_sanitizer__linux.h |   2 +-
 ..._sanitizer__common_sanitizer__linux__libcdep.cc |  29 +-
 ...patch-lib_sanitizer__common_sanitizer__netbsd.h |   2 +-
 ...tch-lib_sanitizer__common_sanitizer__platform.h |  17 +-
 ...zer__common_sanitizer__platform__interceptors.h |  58 ++--
 ...r__common_sanitizer__platform__limits__posix.cc |  98 ++++---
 ...er__common_sanitizer__platform__limits__posix.h | 292 +++++++++++++--------
 ...tch-lib_sanitizer__common_sanitizer__procmaps.h |   4 +-
 ...anitizer__common_sanitizer__procmaps__common.cc |   4 +-
 ...anitizer__common_sanitizer__procmaps__netbsd.cc |  17 +-
 ...nitizer__common_sanitizer__syscall__generic.inc |   2 +-
 ...er__common_sanitizer__unwind__linux__libcdep.cc |   2 +-
 27 files changed, 423 insertions(+), 329 deletions(-)

diffs:
diff --git a/compiler-rt-git/distinfo b/compiler-rt-git/distinfo
index d37adf0207..a57ce0ffff 100644
--- a/compiler-rt-git/distinfo
+++ b/compiler-rt-git/distinfo
@@ -12,29 +12,29 @@ Size (libcxx-3.6.2.src.tar.xz) = 944020 bytes
 SHA1 (llvm-3.6.2.src.tar.xz) = 7a00257eb2bc9431e4c77c3a36b033072c54bc7e
 RMD160 (llvm-3.6.2.src.tar.xz) = 521cbc5fe2925ea3c6e90c7a31f752a04045c972
 Size (llvm-3.6.2.src.tar.xz) = 12802380 bytes
-SHA1 (patch-cmake_config-ix.cmake) = a8f965c384da0da76054e26e3d8670e972ab1deb
-SHA1 (patch-lib_asan_asan__interceptors.cc) = 9a61c5625f1c7a4e5338623bd528fa5d92869abc
-SHA1 (patch-lib_asan_asan__interceptors.h) = 75b6bb46fe25c8ed4d82aeab30d8eb4c925436e2
-SHA1 (patch-lib_asan_asan__linux.cc) = a7ba455bdc33669052f95a2253132a4028859869
-SHA1 (patch-lib_asan_asan__malloc__linux.cc) = 243e11352b9f5e83aa5c4d5d7e2a8f5808d0eb78
-SHA1 (patch-lib_asan_asan__stack.h) = 287566e2bc220d8fe5045df47058ac54ad907e1a
-SHA1 (patch-lib_asan_scripts_asan__symbolize.py) = fbae70f476433262306ae5fb5904bbf8e0b0d8e0
-SHA1 (patch-lib_interception_interception.h) = 4854b9cd428eb2a9c3508e687408b52a3a3183ca
-SHA1 (patch-lib_interception_interception__linux.cc) = fca6d1801ffa7abfedd9a40d8330a03453b551b4
-SHA1 (patch-lib_interception_interception__linux.h) = 23b5b738f5b3535da7beaa5d08952e076b65014a
-SHA1 (patch-lib_sanitizer__common_CMakeLists.txt) = 510c6b5b5c3824b2aea3c8e34427f3a27f8d10db
-SHA1 (patch-lib_sanitizer__common_sanitizer__internal__defs.h) = 19cd534bcb183b9f1da6b36efb00785c3af0eed4
-SHA1 (patch-lib_sanitizer__common_sanitizer__libignore.cc) = 2721e3264296f9ea0debc3d6efddedba67600d47
-SHA1 (patch-lib_sanitizer__common_sanitizer__linux.cc) = 6a219c12f896ad54c8990df2f54239cc6e86f971
-SHA1 (patch-lib_sanitizer__common_sanitizer__linux.h) = 0d02a7c4cc61bcf6a3156ffa2fd8d940cca3ab74
-SHA1 (patch-lib_sanitizer__common_sanitizer__linux__libcdep.cc) = 08e701e72e5afcdff009580b23e16e91dfc6eac1
-SHA1 (patch-lib_sanitizer__common_sanitizer__netbsd.h) = c70b84e9ab3e6874912e8675834c2cb42e83aab6
-SHA1 (patch-lib_sanitizer__common_sanitizer__platform.h) = 629173ae6deaa0f61d52f78ee0db619ce6acb10f
-SHA1 (patch-lib_sanitizer__common_sanitizer__platform__interceptors.h) = 4ca8ee9d1ab04f51e55a8df86c1b88efebe2da3c
-SHA1 (patch-lib_sanitizer__common_sanitizer__platform__limits__posix.cc) = 10179f35182196dc6f23796ce72f6fb2d5f97ccd
-SHA1 (patch-lib_sanitizer__common_sanitizer__platform__limits__posix.h) = 74cbca2057071357ec2ef35477c73fd1a55cbbad
-SHA1 (patch-lib_sanitizer__common_sanitizer__procmaps.h) = e304954272f2624d823b29b9eb7aa6bb001f7c47
-SHA1 (patch-lib_sanitizer__common_sanitizer__procmaps__common.cc) = 2f270afc2c316b99ad3c25c09896ac98c988f557
-SHA1 (patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc) = fb4518f4f9dd589d7d35a8bc9e5e76d6dceb8476
-SHA1 (patch-lib_sanitizer__common_sanitizer__syscall__generic.inc) = 42ad08df9a330a8755220e995230b8f16467c425
-SHA1 (patch-lib_sanitizer__common_sanitizer__unwind__linux__libcdep.cc) = dac542d9c711d132c972de407233f25880f3163a
+SHA1 (patch-cmake_config-ix.cmake) = 0558457785a6069a28eb6c3525bc9f545bbc59cb
+SHA1 (patch-lib_asan_asan__interceptors.cc) = 9786a54c62e081c7194efa26139f8539ad1e8c41
+SHA1 (patch-lib_asan_asan__interceptors.h) = 520419376759f2991c6f74f4c2a5ef62851d7838
+SHA1 (patch-lib_asan_asan__linux.cc) = 31dd5c3978d64ccc28c8af037a967c2360d71cff
+SHA1 (patch-lib_asan_asan__malloc__linux.cc) = 8125ba85983cab81779a2ebe0849ba3e65040eb4
+SHA1 (patch-lib_asan_asan__stack.h) = 58aa9e67cf2a92863fd3bd545074dff136bed7c5
+SHA1 (patch-lib_asan_scripts_asan__symbolize.py) = 95024c8d49fdcbdbf5ccc9013e54ad9b3f469e14
+SHA1 (patch-lib_interception_interception.h) = e6826deb85420ac5c7d9594d5d4364767d22389f
+SHA1 (patch-lib_interception_interception__linux.cc) = 9748f01fb3621c51197a435422e658b9f694dc01
+SHA1 (patch-lib_interception_interception__linux.h) = 8ab24466d85d19d0c5dd35c5867a7cc958009143
+SHA1 (patch-lib_sanitizer__common_CMakeLists.txt) = a563a3b1c04ae343dc7c6646a846f48b96c9e8de
+SHA1 (patch-lib_sanitizer__common_sanitizer__internal__defs.h) = 3e2f5c06d54209d981835d11e272f7cff9086ffb
+SHA1 (patch-lib_sanitizer__common_sanitizer__libignore.cc) = 57eb2b213bd0eb664524aa0e047d5e73d4956ad2
+SHA1 (patch-lib_sanitizer__common_sanitizer__linux.cc) = dc5bd14b37758e9197d3a8022f5d4a24bf26642a
+SHA1 (patch-lib_sanitizer__common_sanitizer__linux.h) = bdec0460d99a5f05b6e54d075032ead845a1c984
+SHA1 (patch-lib_sanitizer__common_sanitizer__linux__libcdep.cc) = b9bf8727fe9bf471e749c2176829f7b9a74c2be9
+SHA1 (patch-lib_sanitizer__common_sanitizer__netbsd.h) = a4b6a100cbff1d35c4bf40b49b555062cc1bfbaa
+SHA1 (patch-lib_sanitizer__common_sanitizer__platform.h) = ffb31dccce9824c81f3686de47c4b1e79bda3e1e
+SHA1 (patch-lib_sanitizer__common_sanitizer__platform__interceptors.h) = b985ae53dafddfc5b4112eae65cab49176fc1989
+SHA1 (patch-lib_sanitizer__common_sanitizer__platform__limits__posix.cc) = 216496ec38f40a1c1d6905e006039860c4c1d48d
+SHA1 (patch-lib_sanitizer__common_sanitizer__platform__limits__posix.h) = e08fe4e4ec66fa79c803b9c64014b921b37c01df
+SHA1 (patch-lib_sanitizer__common_sanitizer__procmaps.h) = 2bc9a7c32f0a7d18fe4d0d465b9b42547abbd989
+SHA1 (patch-lib_sanitizer__common_sanitizer__procmaps__common.cc) = 5a407e496f92dfd2dd78a3b2582d7c695e2547fb
+SHA1 (patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc) = 83f8088cb990ebc5a85e319f1d4990d04196d67a
+SHA1 (patch-lib_sanitizer__common_sanitizer__syscall__generic.inc) = 34bf19462835dd65d33dec1224fde9c61aa94cff
+SHA1 (patch-lib_sanitizer__common_sanitizer__unwind__linux__libcdep.cc) = cf7e016fff0f57e7bcae93696ec05e5cff7b7093
diff --git a/compiler-rt-git/patches/patch-cmake_config-ix.cmake b/compiler-rt-git/patches/patch-cmake_config-ix.cmake
index 753ab06ec8..ce66005418 100644
--- a/compiler-rt-git/patches/patch-cmake_config-ix.cmake
+++ b/compiler-rt-git/patches/patch-cmake_config-ix.cmake
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- cmake/config-ix.cmake.orig	2017-07-03 15:33:06.516370306 +0000
+--- cmake/config-ix.cmake.orig	2017-07-03 15:33:06.000000000 +0000
 +++ cmake/config-ix.cmake
 @@ -441,7 +441,7 @@ set(COMPILER_RT_SANITIZERS_TO_BUILD ${AL
  list_replace(COMPILER_RT_SANITIZERS_TO_BUILD all "${ALL_SANITIZERS}")
diff --git a/compiler-rt-git/patches/patch-lib_asan_asan__interceptors.cc b/compiler-rt-git/patches/patch-lib_asan_asan__interceptors.cc
index f7b77aa3ef..3722150a17 100644
--- a/compiler-rt-git/patches/patch-lib_asan_asan__interceptors.cc
+++ b/compiler-rt-git/patches/patch-lib_asan_asan__interceptors.cc
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/asan/asan_interceptors.cc.orig	2017-07-03 15:33:06.520942325 +0000
+--- lib/asan/asan_interceptors.cc.orig	2017-07-03 15:33:06.000000000 +0000
 +++ lib/asan/asan_interceptors.cc
 @@ -424,6 +424,11 @@ INTERCEPTOR(int, swapcontext, struct uco
  }
diff --git a/compiler-rt-git/patches/patch-lib_asan_asan__interceptors.h b/compiler-rt-git/patches/patch-lib_asan_asan__interceptors.h
index 7457f7f9e8..4bcdfa0ec3 100644
--- a/compiler-rt-git/patches/patch-lib_asan_asan__interceptors.h
+++ b/compiler-rt-git/patches/patch-lib_asan_asan__interceptors.h
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/asan/asan_interceptors.h.orig	2017-07-03 15:33:06.521004205 +0000
+--- lib/asan/asan_interceptors.h.orig	2017-07-03 15:33:06.000000000 +0000
 +++ lib/asan/asan_interceptors.h
 @@ -34,7 +34,7 @@
  # define ASAN_INTERCEPT_FORK 0
diff --git a/compiler-rt-git/patches/patch-lib_asan_asan__linux.cc b/compiler-rt-git/patches/patch-lib_asan_asan__linux.cc
index 69eec063ba..c968e6a128 100644
--- a/compiler-rt-git/patches/patch-lib_asan_asan__linux.cc
+++ b/compiler-rt-git/patches/patch-lib_asan_asan__linux.cc
@@ -1,8 +1,8 @@
 $NetBSD$
 
---- lib/asan/asan_linux.cc.orig	2017-07-03 15:33:06.521305430 +0000
+--- lib/asan/asan_linux.cc.orig	2017-07-03 15:33:06.000000000 +0000
 +++ lib/asan/asan_linux.cc
-@@ -13,13 +13,14 @@
+@@ -13,7 +13,7 @@
  //===----------------------------------------------------------------------===//
  
  #include "sanitizer_common/sanitizer_platform.h"
@@ -11,21 +11,22 @@ $NetBSD$
  
  #include "asan_interceptors.h"
  #include "asan_internal.h"
- #include "asan_thread.h"
+@@ -21,6 +21,7 @@
  #include "sanitizer_common/sanitizer_flags.h"
  #include "sanitizer_common/sanitizer_freebsd.h"
-+#include "sanitizer_common/sanitizer_netbsd.h"
  #include "sanitizer_common/sanitizer_libc.h"
++#include "sanitizer_common/sanitizer_netbsd.h"
  #include "sanitizer_common/sanitizer_procmaps.h"
  
+ #include <sys/time.h>
 @@ -42,6 +43,10 @@
  #if SANITIZER_ANDROID || SANITIZER_FREEBSD
  #include <ucontext.h>
  extern "C" void* _DYNAMIC;
 +#elif SANITIZER_NETBSD
++#include <link_elf.h>
 +#include <ucontext.h>
-+#include <link_elf.h>   
-+extern Elf_Dyn  _DYNAMIC;
++extern Elf_Dyn _DYNAMIC;
  #else
  #include <sys/ucontext.h>
  #include <link.h>
@@ -50,4 +51,4 @@ $NetBSD$
  } // namespace __asan
  
 -#endif // SANITIZER_FREEBSD || SANITIZER_LINUX
-+#endif // SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
++#endif  // SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
diff --git a/compiler-rt-git/patches/patch-lib_asan_asan__malloc__linux.cc b/compiler-rt-git/patches/patch-lib_asan_asan__malloc__linux.cc
index 2c1140135f..0b4f7460bd 100644
--- a/compiler-rt-git/patches/patch-lib_asan_asan__malloc__linux.cc
+++ b/compiler-rt-git/patches/patch-lib_asan_asan__malloc__linux.cc
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/asan/asan_malloc_linux.cc.orig	2017-07-03 15:33:06.521563494 +0000
+--- lib/asan/asan_malloc_linux.cc.orig	2017-07-03 15:33:06.000000000 +0000
 +++ lib/asan/asan_malloc_linux.cc
 @@ -15,7 +15,7 @@
  //===----------------------------------------------------------------------===//
diff --git a/compiler-rt-git/patches/patch-lib_asan_asan__stack.h b/compiler-rt-git/patches/patch-lib_asan_asan__stack.h
index 726d7e7baa..e9f3b055e3 100644
--- a/compiler-rt-git/patches/patch-lib_asan_asan__stack.h
+++ b/compiler-rt-git/patches/patch-lib_asan_asan__stack.h
@@ -1,13 +1,14 @@
 $NetBSD$
 
---- lib/asan/asan_stack.h.orig	2017-07-03 15:33:06.523226694 +0000
+--- lib/asan/asan_stack.h.orig	2017-07-03 15:33:06.000000000 +0000
 +++ lib/asan/asan_stack.h
-@@ -44,7 +44,7 @@ void GetStackTraceWithPcBpAndContext(Buf
+@@ -44,7 +44,8 @@ void GetStackTraceWithPcBpAndContext(Buf
        // On FreeBSD the slow unwinding that leverages _Unwind_Backtrace()
        // yields the call stack of the signal's handler and not of the code
        // that raised the signal (as it does on Linux).
 -      if (SANITIZER_FREEBSD && t->isInDeadlySignal()) fast = true;
-+      if ((SANITIZER_FREEBSD || SANITIZER_NETBSD) && t->isInDeadlySignal()) fast = true;
++      if ((SANITIZER_FREEBSD || SANITIZER_NETBSD) && t->isInDeadlySignal())
++        fast = true;
        uptr stack_top = t->stack_top();
        uptr stack_bottom = t->stack_bottom();
        ScopedUnwinding unwind_scope(t);
diff --git a/compiler-rt-git/patches/patch-lib_asan_scripts_asan__symbolize.py b/compiler-rt-git/patches/patch-lib_asan_scripts_asan__symbolize.py
index cb5e3c82b5..d93b60957c 100644
--- a/compiler-rt-git/patches/patch-lib_asan_scripts_asan__symbolize.py
+++ b/compiler-rt-git/patches/patch-lib_asan_scripts_asan__symbolize.py
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/asan/scripts/asan_symbolize.py.orig	2017-07-03 15:33:06.524556193 +0000
+--- lib/asan/scripts/asan_symbolize.py.orig	2017-07-03 15:33:06.000000000 +0000
 +++ lib/asan/scripts/asan_symbolize.py
 @@ -280,7 +280,7 @@ def BreakpadSymbolizerFactory(binary):
  def SystemSymbolizerFactory(system, addr, binary, arch):
diff --git a/compiler-rt-git/patches/patch-lib_interception_interception.h b/compiler-rt-git/patches/patch-lib_interception_interception.h
index 071d4cde13..7faa04119b 100644
--- a/compiler-rt-git/patches/patch-lib_interception_interception.h
+++ b/compiler-rt-git/patches/patch-lib_interception_interception.h
@@ -1,16 +1,18 @@
 $NetBSD$
 
---- lib/interception/interception.h.orig	2017-07-03 15:33:06.543884557 +0000
+--- lib/interception/interception.h.orig	2017-07-03 15:33:06.000000000 +0000
 +++ lib/interception/interception.h
-@@ -15,7 +15,7 @@
+@@ -15,8 +15,8 @@
  #ifndef INTERCEPTION_H
  #define INTERCEPTION_H
  
 -#if !defined(__linux__) && !defined(__FreeBSD__) && \
+-  !defined(__APPLE__) && !defined(_WIN32)
 +#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && \
-   !defined(__APPLE__) && !defined(_WIN32)
++    !defined(__APPLE__) && !defined(_WIN32)
  # error "Interception doesn't work on this operating system."
  #endif
+ 
 @@ -129,7 +129,7 @@ const interpose_substitution substitutio
      extern "C" ret_type func(__VA_ARGS__);
  # define DECLARE_WRAPPER_WINAPI(ret_type, func, ...) \
diff --git a/compiler-rt-git/patches/patch-lib_interception_interception__linux.cc b/compiler-rt-git/patches/patch-lib_interception_interception__linux.cc
index e6ae2dfb54..06d8d980c3 100644
--- a/compiler-rt-git/patches/patch-lib_interception_interception__linux.cc
+++ b/compiler-rt-git/patches/patch-lib_interception_interception__linux.cc
@@ -1,8 +1,8 @@
 $NetBSD$
 
---- lib/interception/interception_linux.cc.orig	2017-07-03 15:33:06.543936170 +0000
+--- lib/interception/interception_linux.cc.orig	2017-07-03 15:33:06.000000000 +0000
 +++ lib/interception/interception_linux.cc
-@@ -12,14 +12,28 @@
+@@ -12,14 +12,26 @@
  // Linux-specific interception methods.
  //===----------------------------------------------------------------------===//
  
@@ -15,8 +15,7 @@ $NetBSD$
 +#ifdef __NetBSD__
 +static int mystrcmp(const char *s1, const char *s2) {
 +  while (*s1 == *s2++)
-+    if (*s1++ == 0)
-+      return (0);
++    if (*s1++ == 0) return (0);
 +  return (*(const unsigned char *)s1 - *(const unsigned char *)--s2);
 +}
 +#endif
@@ -26,15 +25,15 @@ $NetBSD$
      uptr real, uptr wrapper) {
 +#ifdef __NetBSD__
 +  // XXX: Until I come up with something better to deal with renames.
-+  if (mystrcmp(func_name, "sigaction") == 0)
-+    func_name = "__sigaction14";
++  if (mystrcmp(func_name, "sigaction") == 0) func_name = "__sigaction14";
 +#endif
    *func_addr = (uptr)dlsym(RTLD_NEXT, func_name);
    return real == wrapper;
  }
-@@ -33,4 +47,4 @@ void *GetFuncAddrVer(const char *func_na
- }  // namespace __interception
+@@ -32,5 +44,4 @@ void *GetFuncAddrVer(const char *func_na
  
+ }  // namespace __interception
  
+-
 -#endif  // __linux__ || __FreeBSD__
 +#endif  // __linux__ || __FreeBSD__ || __NetBSD__
diff --git a/compiler-rt-git/patches/patch-lib_interception_interception__linux.h b/compiler-rt-git/patches/patch-lib_interception_interception__linux.h
index 8ff9a790f3..0535469d53 100644
--- a/compiler-rt-git/patches/patch-lib_interception_interception__linux.h
+++ b/compiler-rt-git/patches/patch-lib_interception_interception__linux.h
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/interception/interception_linux.h.orig	2017-07-03 15:33:06.543980100 +0000
+--- lib/interception/interception_linux.h.orig	2017-07-03 15:33:06.000000000 +0000
 +++ lib/interception/interception_linux.h
 @@ -12,7 +12,7 @@
  // Linux-specific interception methods.
diff --git a/compiler-rt-git/patches/patch-lib_sanitizer__common_CMakeLists.txt b/compiler-rt-git/patches/patch-lib_sanitizer__common_CMakeLists.txt
index c900c1d508..27f2c14464 100644
--- a/compiler-rt-git/patches/patch-lib_sanitizer__common_CMakeLists.txt
+++ b/compiler-rt-git/patches/patch-lib_sanitizer__common_CMakeLists.txt
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/sanitizer_common/CMakeLists.txt.orig	2017-07-03 15:33:06.550862958 +0000
+--- lib/sanitizer_common/CMakeLists.txt.orig	2017-07-03 15:33:06.000000000 +0000
 +++ lib/sanitizer_common/CMakeLists.txt
 @@ -22,6 +22,7 @@ set(SANITIZER_SOURCES_NOTERMINATION
    sanitizer_procmaps_freebsd.cc
diff --git a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__internal__defs.h b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__internal__defs.h
index 9766d715bc..35fdb035cb 100644
--- a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__internal__defs.h
+++ b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__internal__defs.h
@@ -1,13 +1,15 @@
 $NetBSD$
 
---- lib/sanitizer_common/sanitizer_internal_defs.h.orig	2017-07-03 15:33:06.556591130 +0000
+--- lib/sanitizer_common/sanitizer_internal_defs.h.orig	2017-07-03 15:33:06.000000000 +0000
 +++ lib/sanitizer_common/sanitizer_internal_defs.h
-@@ -133,7 +133,7 @@ typedef int pid_t;
+@@ -133,8 +133,8 @@ typedef int pid_t;
  // _FILE_OFFSET_BITS. This definition of OFF_T matches the ABI of system calls
  // like pread and mmap, as opposed to pread64 and mmap64.
  // FreeBSD, Mac and Linux/x86-64 are special.
 -#if SANITIZER_FREEBSD || SANITIZER_MAC || \
+-  (SANITIZER_LINUX && defined(__x86_64__))
 +#if SANITIZER_FREEBSD || SANITIZER_NETBSD || SANITIZER_MAC || \
-   (SANITIZER_LINUX && defined(__x86_64__))
++    (SANITIZER_LINUX && defined(__x86_64__))
  typedef u64 OFF_T;
  #else
+ typedef uptr OFF_T;
diff --git a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__libignore.cc b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__libignore.cc
index c8c239299c..464bd0d300 100644
--- a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__libignore.cc
+++ b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__libignore.cc
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/sanitizer_common/sanitizer_libignore.cc.orig	2017-07-03 15:33:06.556851079 +0000
+--- lib/sanitizer_common/sanitizer_libignore.cc.orig	2017-07-03 15:33:06.000000000 +0000
 +++ lib/sanitizer_common/sanitizer_libignore.cc
 @@ -9,7 +9,7 @@
  
@@ -16,4 +16,4 @@ $NetBSD$
  } // namespace __sanitizer
  
 -#endif // #if SANITIZER_FREEBSD || SANITIZER_LINUX
-+#endif // #if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
++#endif  // #if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
diff --git a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__linux.cc b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__linux.cc
index a2e2245ec3..51d205ea50 100644
--- a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__linux.cc
+++ b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__linux.cc
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/sanitizer_common/sanitizer_linux.cc.orig	2017-07-03 15:33:06.557337873 +0000
+--- lib/sanitizer_common/sanitizer_linux.cc.orig	2017-07-03 15:33:06.000000000 +0000
 +++ lib/sanitizer_common/sanitizer_linux.cc
 @@ -14,7 +14,7 @@
  
@@ -32,10 +32,10 @@ $NetBSD$
  #endif  // SANITIZER_FREEBSD
  
 +#if SANITIZER_NETBSD
-+#include <limits.h>     // For NAME_MAX
++#include <limits.h>  // For NAME_MAX
 +#include <sys/sysctl.h>
 +extern char **environ;  // provided by crt1
-+#endif  // SANITIZER_NETBSD 
++#endif                  // SANITIZER_NETBSD
 +
  #if !SANITIZER_ANDROID
  #include <sys/signal.h>
@@ -45,18 +45,18 @@ $NetBSD$
  uptr internal_mmap(void *addr, uptr length, int prot, int flags, int fd,
                     OFF_T offset) {
 -#if SANITIZER_FREEBSD || SANITIZER_LINUX_USES_64BIT_SYSCALLS
-+#if SANITIZER_NETBSD     
++#if SANITIZER_NETBSD
 +  return internal_syscall_ptr(SYSCALL(mmap), addr, length, prot, flags, fd,
 +                              (long)0, offset);
 +#elif SANITIZER_FREEBSD || SANITIZER_LINUX_USES_64BIT_SYSCALLS
    return internal_syscall(SYSCALL(mmap), (uptr)addr, length, prot, flags, fd,
                            offset);
  #else
-@@ -174,26 +187,38 @@ uptr internal_open(const char *filename,
+@@ -174,26 +187,39 @@ uptr internal_open(const char *filename,
  
  uptr internal_read(fd_t fd, void *buf, uptr count) {
    sptr res;
-+#ifdef SANITIZER_NETBSD  
++#ifdef SANITIZER_NETBSD
 +  HANDLE_EINTR(res, internal_syscall_ptr(SYSCALL(read), fd, buf, count));
 +#else
    HANDLE_EINTR(res, (sptr)internal_syscall(SYSCALL(read), fd, (uptr)buf,
@@ -88,11 +88,12 @@ $NetBSD$
  }
  
 -#if !SANITIZER_LINUX_USES_64BIT_SYSCALLS && !SANITIZER_FREEBSD
-+#if !SANITIZER_LINUX_USES_64BIT_SYSCALLS && !SANITIZER_FREEBSD && !SANITIZER_NETBSD
++#if !SANITIZER_LINUX_USES_64BIT_SYSCALLS && !SANITIZER_FREEBSD && \
++    !SANITIZER_NETBSD
  static void stat64_to_stat(struct stat64 *in, struct stat *out) {
    internal_memset(out, 0, sizeof(*out));
    out->st_dev = in->st_dev;
-@@ -234,7 +259,7 @@ static void kernel_stat_to_stat(struct k
+@@ -234,7 +260,7 @@ static void kernel_stat_to_stat(struct k
  #endif
  
  uptr internal_stat(const char *path, void *buf) {
@@ -101,7 +102,7 @@ $NetBSD$
    return internal_syscall(SYSCALL(fstatat), AT_FDCWD, (uptr)path,
                            (uptr)buf, 0);
  #elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
-@@ -259,7 +284,9 @@ uptr internal_stat(const char *path, voi
+@@ -259,7 +285,9 @@ uptr internal_stat(const char *path, voi
  }
  
  uptr internal_lstat(const char *path, void *buf) {
@@ -112,7 +113,7 @@ $NetBSD$
    return internal_syscall(SYSCALL(fstatat), AT_FDCWD, (uptr)path,
                            (uptr)buf, AT_SYMLINK_NOFOLLOW);
  #elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
-@@ -284,7 +311,7 @@ uptr internal_lstat(const char *path, vo
+@@ -284,7 +312,7 @@ uptr internal_lstat(const char *path, vo
  }
  
  uptr internal_fstat(fd_t fd, void *buf) {
@@ -121,7 +122,7 @@ $NetBSD$
  # if SANITIZER_MIPS64
    // For mips64, fstat syscall fills buffer in the format of kernel_stat
    struct kernel_stat kbuf;
-@@ -318,7 +345,9 @@ uptr internal_dup2(int oldfd, int newfd)
+@@ -318,7 +346,9 @@ uptr internal_dup2(int oldfd, int newfd)
  }
  
  uptr internal_readlink(const char *path, char *buf, uptr bufsize) {
@@ -132,7 +133,7 @@ $NetBSD$
    return internal_syscall(SYSCALL(readlinkat), AT_FDCWD,
                            (uptr)path, (uptr)buf, bufsize);
  #else
-@@ -348,7 +377,7 @@ uptr internal_sched_yield() {
+@@ -348,7 +378,7 @@ uptr internal_sched_yield() {
  }
  
  void internal__exit(int exitcode) {
@@ -141,7 +142,7 @@ $NetBSD$
    internal_syscall(SYSCALL(exit), exitcode);
  #else
    internal_syscall(SYSCALL(exit_group), exitcode);
-@@ -387,19 +416,25 @@ bool FileExists(const char *filename) {
+@@ -387,19 +417,25 @@ bool FileExists(const char *filename) {
  tid_t GetTid() {
  #if SANITIZER_FREEBSD
    return (uptr)pthread_self();
@@ -168,7 +169,7 @@ $NetBSD$
    return (u64)tv.tv_sec * 1000*1000*1000 + tv.tv_usec * 1000;
  }
  
-@@ -407,7 +442,7 @@ u64 NanoTime() {
+@@ -407,7 +443,7 @@ u64 NanoTime() {
  // 'environ' array (on FreeBSD) and does not use libc. This function should be
  // called first inside __asan_init.
  const char *GetEnv(const char *name) {
@@ -177,7 +178,7 @@ $NetBSD$
    if (::environ != 0) {
      uptr NameLen = internal_strlen(name);
      for (char **Env = ::environ; *Env != 0; Env++) {
-@@ -541,6 +576,8 @@ void BlockingMutex::Lock() {
+@@ -541,6 +577,8 @@ void BlockingMutex::Lock() {
    while (atomic_exchange(m, MtxSleeping, memory_order_acquire) != MtxUnlocked) {
  #if SANITIZER_FREEBSD
      _umtx_op(m, UMTX_OP_WAIT_UINT, MtxSleeping, 0, 0);
@@ -186,16 +187,16 @@ $NetBSD$
  #else
      internal_syscall(SYSCALL(futex), (uptr)m, FUTEX_WAIT, MtxSleeping, 0, 0, 0);
  #endif
-@@ -554,6 +591,8 @@ void BlockingMutex::Unlock() {
+@@ -554,6 +592,8 @@ void BlockingMutex::Unlock() {
    if (v == MtxSleeping) {
  #if SANITIZER_FREEBSD
      _umtx_op(m, UMTX_OP_WAKE, 1, 0, 0);
 +#elif SANITIZER_NETBSD
-+    /* No userspace futex-like synchromization */
++                   /* No userspace futex-like synchromization */
  #else
      internal_syscall(SYSCALL(futex), (uptr)m, FUTEX_WAKE, 1, 0, 0, 0);
  #endif
-@@ -569,6 +608,17 @@ void BlockingMutex::CheckLocked() {
+@@ -569,6 +609,17 @@ void BlockingMutex::CheckLocked() {
  // The actual size of this structure is specified by d_reclen.
  // Note that getdents64 uses a different structure format. We only provide the
  // 32-bit syscall here.
@@ -203,17 +204,17 @@ $NetBSD$
 +// struct dirent is different for Linux and us. At this moment, we use only
 +// d_fileno (Linux call this d_ino), d_reclen, and d_name.
 +struct linux_dirent {
-+  u64  d_ino;     // d_fileno
-+  u16  d_reclen;
-+  u16  d_namlen;  // not used
-+  u8   d_type;    // not used
++  u64 d_ino;  // d_fileno
++  u16 d_reclen;
++  u16 d_namlen;  // not used
++  u8 d_type;     // not used
 +  char d_name[NAME_MAX + 1];
 +};
 +#else
  struct linux_dirent {
  #if SANITIZER_X32 || defined(__aarch64__)
    u64 d_ino;
-@@ -583,16 +633,34 @@ struct linux_dirent {
+@@ -583,16 +634,34 @@ struct linux_dirent {
  #endif
    char               d_name[256];
  };
@@ -222,15 +223,15 @@ $NetBSD$
  // Syscall wrappers.
  uptr internal_ptrace(int request, int pid, void *addr, void *data) {
 +#if SANITIZER_NETBSD
-+// XXX We need additional work for ptrace:
-+//   - for request, we use PT_FOO whereas Linux uses PTRACE_FOO
-+//   - data is int for us, but void * for Linux
-+//   - Linux sometimes uses data in the case where we use addr instead
-+// At this moment, this function is used only within
-+// "#if SANITIZER_LINUX && defined(__x86_64__)" block in
-+// sanitizer_stoptheworld_linux_libcdep.cc.
++  // XXX We need additional work for ptrace:
++  //   - for request, we use PT_FOO whereas Linux uses PTRACE_FOO
++  //   - data is int for us, but void * for Linux
++  //   - Linux sometimes uses data in the case where we use addr instead
++  // At this moment, this function is used only within
++  // "#if SANITIZER_LINUX && defined(__x86_64__)" block in
++  // sanitizer_stoptheworld_linux_libcdep.cc.
 +  return internal_syscall_ptr(SYSCALL(ptrace), request, pid, (uptr)addr,
-+                          (uptr)data);
++                              (uptr)data);
 +#else
    return internal_syscall(SYSCALL(ptrace), request, pid, (uptr)addr,
                            (uptr)data);
@@ -248,7 +249,7 @@ $NetBSD$
  }
  
  uptr internal_getpid() {
-@@ -604,7 +672,9 @@ uptr internal_getppid() {
+@@ -604,7 +673,9 @@ uptr internal_getppid() {
  }
  
  uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count) {
@@ -259,7 +260,7 @@ $NetBSD$
    return internal_syscall(SYSCALL(getdirentries), fd, (uptr)dirp, count, NULL);
  #elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
    return internal_syscall(SYSCALL(getdents64), fd, (uptr)dirp, count);
-@@ -614,7 +684,11 @@ uptr internal_getdents(fd_t fd, struct l
+@@ -614,7 +685,11 @@ uptr internal_getdents(fd_t fd, struct l
  }
  
  uptr internal_lseek(fd_t fd, OFF_T offset, int whence) {
@@ -271,7 +272,7 @@ $NetBSD$
  }
  
  #if SANITIZER_LINUX
-@@ -706,7 +780,7 @@ int internal_sigaction_syscall(int signu
+@@ -706,7 +781,7 @@ int internal_sigaction_syscall(int signu
  
  uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set,
      __sanitizer_sigset_t *oldset) {
@@ -280,22 +281,21 @@ $NetBSD$
    return internal_syscall(SYSCALL(sigprocmask), how, set, oldset);
  #else
    __sanitizer_kernel_sigset_t *k_set = (__sanitizer_kernel_sigset_t *)set;
-@@ -829,8 +903,12 @@ uptr GetPageSize() {
+@@ -829,8 +904,12 @@ uptr GetPageSize() {
  }
  
  uptr ReadBinaryName(/*out*/char *buf, uptr buf_len) {
--#if SANITIZER_FREEBSD
--  const int Mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
 +#if SANITIZER_FREEBSD || SANITIZER_NETBSD
-+# if SANITIZER_FREEBSD
-+  const int Mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
-+# else
-+  const int Mib[4] = { CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME };
-+# endif
+ #if SANITIZER_FREEBSD
+-  const int Mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
++  const int Mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
++#else
++  const int Mib[4] = {CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME};
++#endif
    const char *default_module_name = "kern.proc.pathname";
    size_t Size = buf_len;
    bool IsErr = (sysctl(Mib, ARRAY_SIZE(Mib), buf, &Size, NULL, 0) != 0);
-@@ -1474,6 +1552,8 @@ SignalContext::WriteFlag SignalContext::
+@@ -1474,6 +1553,8 @@ SignalContext::WriteFlag SignalContext::
    static const uptr PF_WRITE = 1U << 1;
  #if SANITIZER_FREEBSD
    uptr err = ucontext->uc_mcontext.mc_err;
@@ -304,33 +304,33 @@ $NetBSD$
  #else
    uptr err = ucontext->uc_mcontext.gregs[REG_ERR];
  #endif
-@@ -1520,6 +1600,11 @@ void GetPcSpBp(void *context, uptr *pc, 
+@@ -1520,6 +1601,11 @@ void GetPcSpBp(void *context, uptr *pc, 
    *pc = ucontext->uc_mcontext.mc_rip;
    *bp = ucontext->uc_mcontext.mc_rbp;
    *sp = ucontext->uc_mcontext.mc_rsp;
-+# elif SANITIZER_NETBSD
-+  ucontext_t *ucontext = (ucontext_t*)context;
++#elif SANITIZER_NETBSD
++  ucontext_t *ucontext = (ucontext_t *)context;
 +  *pc = ucontext->uc_mcontext.__gregs[_REG_RIP];
 +  *bp = ucontext->uc_mcontext.__gregs[_REG_RBP];
 +  *sp = ucontext->uc_mcontext.__gregs[_REG_RSP];
  # else
    ucontext_t *ucontext = (ucontext_t*)context;
    *pc = ucontext->uc_mcontext.gregs[REG_RIP];
-@@ -1532,6 +1617,11 @@ void GetPcSpBp(void *context, uptr *pc, 
+@@ -1532,6 +1618,11 @@ void GetPcSpBp(void *context, uptr *pc, 
    *pc = ucontext->uc_mcontext.mc_eip;
    *bp = ucontext->uc_mcontext.mc_ebp;
    *sp = ucontext->uc_mcontext.mc_esp;
-+# elif SANITIZER_NETBSD
-+  ucontext_t *ucontext = (ucontext_t*)context;
++#elif SANITIZER_NETBSD
++  ucontext_t *ucontext = (ucontext_t *)context;
 +  *pc = ucontext->uc_mcontext.__gregs[_REG_EIP];
 +  *bp = ucontext->uc_mcontext.__gregs[_REG_EBP];
 +  *sp = ucontext->uc_mcontext.__gregs[_REG_ESP];
  # else
    ucontext_t *ucontext = (ucontext_t*)context;
    *pc = ucontext->uc_mcontext.gregs[REG_EIP];
-@@ -1632,4 +1722,4 @@ bool GetRandom(void *buffer, uptr length
+@@ -1632,4 +1723,4 @@ bool GetRandom(void *buffer, uptr length
  
  } // namespace __sanitizer
  
 -#endif // SANITIZER_FREEBSD || SANITIZER_LINUX
-+#endif // SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
++#endif  // SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
diff --git a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__linux.h b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__linux.h
index 565bc65cd7..2f3913ce2e 100644
--- a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__linux.h
+++ b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__linux.h
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/sanitizer_common/sanitizer_linux.h.orig	2017-07-03 15:33:06.557405759 +0000
+--- lib/sanitizer_common/sanitizer_linux.h.orig	2017-07-03 15:33:06.000000000 +0000
 +++ lib/sanitizer_common/sanitizer_linux.h
 @@ -14,7 +14,7 @@
  #define SANITIZER_LINUX_H
diff --git a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__linux__libcdep.cc b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__linux__libcdep.cc
index e4ec2fb347..09c4cbe10e 100644
--- a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__linux__libcdep.cc
+++ b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__linux__libcdep.cc
@@ -1,8 +1,8 @@
 $NetBSD$
 
---- lib/sanitizer_common/sanitizer_linux_libcdep.cc.orig	2017-07-03 15:33:06.557567721 +0000
+--- lib/sanitizer_common/sanitizer_linux_libcdep.cc.orig	2017-07-03 15:33:06.000000000 +0000
 +++ lib/sanitizer_common/sanitizer_linux_libcdep.cc
-@@ -14,13 +14,14 @@
+@@ -14,7 +14,7 @@
  
  #include "sanitizer_platform.h"
  
@@ -11,40 +11,41 @@ $NetBSD$
  
  #include "sanitizer_allocator_internal.h"
  #include "sanitizer_atomic.h"
- #include "sanitizer_common.h"
+@@ -22,6 +22,7 @@
  #include "sanitizer_flags.h"
  #include "sanitizer_freebsd.h"
-+#include "sanitizer_netbsd.h"
  #include "sanitizer_linux.h"
++#include "sanitizer_netbsd.h"
  #include "sanitizer_placement_new.h"
  #include "sanitizer_procmaps.h"
-@@ -151,7 +152,7 @@ bool SanitizerGetThreadName(char *name, 
+ #include "sanitizer_stacktrace.h"
+@@ -151,7 +152,8 @@ bool SanitizerGetThreadName(char *name, 
  #endif
  }
  
 -#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO
-+#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && !SANITIZER_NETBSD
++#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && \
++    !SANITIZER_NETBSD
  static uptr g_tls_size;
  
  #ifdef __i386__
-@@ -179,7 +180,7 @@ void InitTlsSize() {
+@@ -179,7 +181,8 @@ void InitTlsSize() {
  }
  #else
  void InitTlsSize() { }
 -#endif  // !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO
-+#endif  // !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && !SANITIZER_NETBSD
++#endif  // !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO &&
++        // !SANITIZER_NETBSD
  
  #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) \
      || defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) \
-@@ -336,6 +337,12 @@ uptr ThreadSelf() {
+@@ -336,6 +339,10 @@ uptr ThreadSelf() {
  }
  #endif  // SANITIZER_FREEBSD
  
-+#if SANITIZER_NETBSD                                                                                                                                                                          
-+uptr ThreadSelf() {
-+  return (uptr)pthread_self();
-+}
-+#endif // SANITIZER_NETBSD
++#if SANITIZER_NETBSD
++uptr ThreadSelf() { return (uptr)pthread_self(); }
++#endif  // SANITIZER_NETBSD
 +
  #if !SANITIZER_GO
  static void GetTls(uptr *addr, uptr *size) {
diff --git a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__netbsd.h b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__netbsd.h
index 114c5d6967..383e3ac780 100644
--- a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__netbsd.h
+++ b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__netbsd.h
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/sanitizer_common/sanitizer_netbsd.h.orig	2017-07-03 15:44:10.252636298 +0000
+--- lib/sanitizer_common/sanitizer_netbsd.h.orig	2017-07-03 18:33:56.808690628 +0000
 +++ lib/sanitizer_common/sanitizer_netbsd.h
 @@ -0,0 +1,20 @@
 +//===-- sanitizer_freebsd.h -------------------------------------*- C++ -*-===//
diff --git a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__platform.h b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__platform.h
index bd7a78f6ef..41e30222d2 100644
--- a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__platform.h
+++ b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__platform.h
@@ -1,35 +1,38 @@
 $NetBSD$
 
---- lib/sanitizer_common/sanitizer_platform.h.orig	2017-07-03 15:33:06.558504013 +0000
+--- lib/sanitizer_common/sanitizer_platform.h.orig	2017-07-03 15:33:06.000000000 +0000
 +++ lib/sanitizer_common/sanitizer_platform.h
-@@ -13,7 +13,7 @@
+@@ -13,8 +13,8 @@
  #ifndef SANITIZER_PLATFORM_H
  #define SANITIZER_PLATFORM_H
  
 -#if !defined(__linux__) && !defined(__FreeBSD__) && \
+-  !defined(__APPLE__) && !defined(_WIN32)
 +#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && \
-   !defined(__APPLE__) && !defined(_WIN32)
++    !defined(__APPLE__) && !defined(_WIN32)
  # error "This operating system is not supported"
  #endif
+ 
 @@ -30,6 +30,12 @@
  # define SANITIZER_FREEBSD 0
  #endif
  
 +#if defined(__NetBSD__)
-+# define SANITIZER_NETBSD 1
++#define SANITIZER_NETBSD 1
 +#else
-+# define SANITIZER_NETBSD 0
++#define SANITIZER_NETBSD 0
 +#endif
 +
  #if defined(__APPLE__)
  # define SANITIZER_MAC     1
  # include <TargetConditionals.h>
-@@ -79,7 +85,7 @@
+@@ -79,7 +85,8 @@
  # define SANITIZER_ANDROID 0
  #endif
  
 -#define SANITIZER_POSIX (SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_MAC)
-+#define SANITIZER_POSIX (SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD || SANITIZER_MAC)
++#define SANITIZER_POSIX \
++  (SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD || SANITIZER_MAC)
  
  #if __LP64__ || defined(_WIN64)
  #  define SANITIZER_WORDSIZE 64
diff --git a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__platform__interceptors.h b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__platform__interceptors.h
index f3744febfe..453404f73d 100644
--- a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__platform__interceptors.h
+++ b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__platform__interceptors.h
@@ -1,15 +1,15 @@
 $NetBSD$
 
---- lib/sanitizer_common/sanitizer_platform_interceptors.h.orig	2017-07-03 15:33:06.558600953 +0000
+--- lib/sanitizer_common/sanitizer_platform_interceptors.h.orig	2017-07-03 15:33:06.000000000 +0000
 +++ lib/sanitizer_common/sanitizer_platform_interceptors.h
 @@ -49,6 +49,12 @@
  # define SI_FREEBSD 0
  #endif
  
 +#if SANITIZER_NETBSD
-+# define SI_NETBSD 1
++#define SI_NETBSD 1
 +#else
-+# define SI_NETBSD 0
++#define SI_NETBSD 0
 +#endif
 +
  #if SANITIZER_LINUX
@@ -24,25 +24,26 @@ $NetBSD$
  
  #define SANITIZER_INTERCEPT_READ   SI_NOT_WINDOWS
  #define SANITIZER_INTERCEPT_PREAD  SI_NOT_WINDOWS
-@@ -127,7 +133,7 @@
+@@ -127,7 +133,8 @@
  #define SANITIZER_INTERCEPT_READV SI_NOT_WINDOWS
  #define SANITIZER_INTERCEPT_WRITEV SI_NOT_WINDOWS
  
 -#define SANITIZER_INTERCEPT_PREADV SI_FREEBSD || SI_LINUX_NOT_ANDROID
-+#define SANITIZER_INTERCEPT_PREADV SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID
++#define SANITIZER_INTERCEPT_PREADV \
++  SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID
  #define SANITIZER_INTERCEPT_PWRITEV SI_LINUX_NOT_ANDROID
  #define SANITIZER_INTERCEPT_PREADV64 SI_LINUX_NOT_ANDROID
  #define SANITIZER_INTERCEPT_PWRITEV64 SI_LINUX_NOT_ANDROID
-@@ -142,7 +148,7 @@
+@@ -142,7 +149,7 @@
  
  #ifndef SANITIZER_INTERCEPT_PRINTF
  # define SANITIZER_INTERCEPT_PRINTF SI_NOT_WINDOWS
 -# define SANITIZER_INTERCEPT_PRINTF_L SI_FREEBSD
-+# define SANITIZER_INTERCEPT_PRINTF_L SI_FREEBSD || SI_NETBSD
++#define SANITIZER_INTERCEPT_PRINTF_L SI_FREEBSD || SI_NETBSD
  # define SANITIZER_INTERCEPT_ISOC99_PRINTF SI_LINUX_NOT_ANDROID
  #endif
  
-@@ -151,13 +157,13 @@
+@@ -151,13 +158,14 @@
  
  #define SANITIZER_INTERCEPT_GETPWNAM_AND_FRIENDS SI_NOT_WINDOWS
  #define SANITIZER_INTERCEPT_GETPWNAM_R_AND_FRIENDS \
@@ -53,14 +54,15 @@ $NetBSD$
 +  SI_FREEBSD || SI_NETBSD || SI_MAC || SI_LINUX_NOT_ANDROID
  #define SANITIZER_INTERCEPT_FGETPWENT SI_LINUX_NOT_ANDROID
 -#define SANITIZER_INTERCEPT_GETPWENT_R SI_FREEBSD || SI_LINUX_NOT_ANDROID
-+#define SANITIZER_INTERCEPT_GETPWENT_R SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID
++#define SANITIZER_INTERCEPT_GETPWENT_R \
++  SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID
  #define SANITIZER_INTERCEPT_SETPWENT SI_MAC || SI_LINUX_NOT_ANDROID
 -#define SANITIZER_INTERCEPT_CLOCK_GETTIME SI_FREEBSD || SI_LINUX
 +#define SANITIZER_INTERCEPT_CLOCK_GETTIME SI_FREEBSD || SI_NETBSD || SI_LINUX
  #define SANITIZER_INTERCEPT_GETITIMER SI_NOT_WINDOWS
  #define SANITIZER_INTERCEPT_TIME SI_NOT_WINDOWS
  #define SANITIZER_INTERCEPT_GLOB SI_LINUX_NOT_ANDROID
-@@ -200,41 +206,41 @@
+@@ -200,41 +208,43 @@
  #define SANITIZER_INTERCEPT_MBSNRTOWCS SI_MAC || SI_LINUX_NOT_ANDROID
  #define SANITIZER_INTERCEPT_WCSTOMBS SI_NOT_WINDOWS
  #define SANITIZER_INTERCEPT_WCSNRTOMBS \
@@ -99,23 +101,26 @@ $NetBSD$
  #define SANITIZER_INTERCEPT_SIGPENDING SI_NOT_WINDOWS
  #define SANITIZER_INTERCEPT_SIGPROCMASK SI_NOT_WINDOWS
 -#define SANITIZER_INTERCEPT_BACKTRACE SI_FREEBSD || SI_LINUX_NOT_ANDROID
-+#define SANITIZER_INTERCEPT_BACKTRACE SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID
++#define SANITIZER_INTERCEPT_BACKTRACE \
++  SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID
  #define SANITIZER_INTERCEPT_GETMNTENT SI_LINUX
  #define SANITIZER_INTERCEPT_GETMNTENT_R SI_LINUX_NOT_ANDROID
  #define SANITIZER_INTERCEPT_STATFS SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID
  #define SANITIZER_INTERCEPT_STATFS64 \
    (SI_MAC && !SI_IOS) || SI_LINUX_NOT_ANDROID
 -#define SANITIZER_INTERCEPT_STATVFS SI_FREEBSD || SI_LINUX_NOT_ANDROID
-+#define SANITIZER_INTERCEPT_STATVFS SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID
++#define SANITIZER_INTERCEPT_STATVFS \
++  SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID
  #define SANITIZER_INTERCEPT_STATVFS64 SI_LINUX_NOT_ANDROID
  #define SANITIZER_INTERCEPT_INITGROUPS SI_NOT_WINDOWS
  #define SANITIZER_INTERCEPT_ETHER_NTOA_ATON SI_NOT_WINDOWS
-@@ -242,18 +248,18 @@
+@@ -242,18 +252,19 @@
    SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID
  #define SANITIZER_INTERCEPT_ETHER_R SI_FREEBSD || SI_LINUX_NOT_ANDROID
  #define SANITIZER_INTERCEPT_SHMCTL \
 -  ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && SANITIZER_WORDSIZE == 64)
-+  SI_NETBSD || ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && SANITIZER_WORDSIZE == 64)
++  SI_NETBSD ||                     \
++      ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && SANITIZER_WORDSIZE == 64)
  #define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID
  #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_NOT_WINDOWS
  #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GETINHERITSCHED \
@@ -133,19 +138,21 @@ $NetBSD$
  #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETROBUST SI_LINUX_NOT_ANDROID
  #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETROBUST_NP SI_LINUX_NOT_ANDROID
  #define SANITIZER_INTERCEPT_PTHREAD_RWLOCKATTR_GETPSHARED SI_NOT_WINDOWS
-@@ -272,29 +278,29 @@
+@@ -272,29 +283,31 @@
  #define SANITIZER_INTERCEPT_LGAMMAL_R SI_LINUX_NOT_ANDROID
  #define SANITIZER_INTERCEPT_DRAND48_R SI_LINUX_NOT_ANDROID
  #define SANITIZER_INTERCEPT_RAND_R \
 -  SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID
 -#define SANITIZER_INTERCEPT_ICONV SI_FREEBSD || SI_LINUX_NOT_ANDROID
 +  SI_FREEBSD || SI_NETBSD || SI_MAC || SI_LINUX_NOT_ANDROID
-+#define SANITIZER_INTERCEPT_ICONV SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID
++#define SANITIZER_INTERCEPT_ICONV \
++  SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID
  #define SANITIZER_INTERCEPT_TIMES SI_NOT_WINDOWS
  
  // FIXME: getline seems to be available on OSX 10.7
 -#define SANITIZER_INTERCEPT_GETLINE SI_FREEBSD || SI_LINUX_NOT_ANDROID
-+#define SANITIZER_INTERCEPT_GETLINE SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID
++#define SANITIZER_INTERCEPT_GETLINE \
++  SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID
  
 -#define SANITIZER_INTERCEPT__EXIT SI_LINUX || SI_FREEBSD || SI_MAC
 +#define SANITIZER_INTERCEPT__EXIT SI_LINUX || SI_FREEBSD || SI_NETBSD || SI_MAC
@@ -171,7 +178,7 @@ $NetBSD$
  #define SANITIZER_INTERCEPT_CAPGET SI_LINUX_NOT_ANDROID
  #if SI_LINUX && defined(__arm__)
  #define SANITIZER_INTERCEPT_AEABI_MEM 1
-@@ -302,32 +308,32 @@
+@@ -302,32 +315,33 @@
  #define SANITIZER_INTERCEPT_AEABI_MEM 0
  #endif
  #define SANITIZER_INTERCEPT___BZERO SI_MAC
@@ -192,7 +199,7 @@ $NetBSD$
  #ifndef SANITIZER_INTERCEPT_DLOPEN_DLCLOSE
  #define SANITIZER_INTERCEPT_DLOPEN_DLCLOSE \
 -    SI_FREEBSD || SI_LINUX_NOT_ANDROID || SI_MAC
-+    SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID || SI_MAC
++  SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID || SI_MAC
  #endif
  
 -#define SANITIZER_INTERCEPT_GETPASS SI_LINUX_NOT_ANDROID || SI_MAC
@@ -208,20 +215,22 @@ $NetBSD$
 +#define SANITIZER_INTERCEPT_MINCORE SI_LINUX || SI_NETBSD
  #define SANITIZER_INTERCEPT_PROCESS_VM_READV SI_LINUX
 -#define SANITIZER_INTERCEPT_CTERMID SI_LINUX || SI_MAC || SI_FREEBSD
-+#define SANITIZER_INTERCEPT_CTERMID SI_LINUX || SI_MAC || SI_FREEBSD || SI_NETBSD
++#define SANITIZER_INTERCEPT_CTERMID \
++  SI_LINUX || SI_MAC || SI_FREEBSD || SI_NETBSD
  #define SANITIZER_INTERCEPT_CTERMID_R SI_MAC || SI_FREEBSD
  
  #define SANITIZER_INTERCEPTOR_HOOKS SI_LINUX || SI_MAC || SI_WINDOWS
-@@ -335,7 +341,7 @@
+@@ -335,7 +349,8 @@
  #define SANITIZER_INTERCEPT_SEND_SENDTO SI_NOT_WINDOWS
  #define SANITIZER_INTERCEPT_EVENTFD_READ_WRITE SI_LINUX
  
 -#define SANITIZER_INTERCEPT_STAT (SI_FREEBSD || SI_MAC || SI_ANDROID)
-+#define SANITIZER_INTERCEPT_STAT (SI_FREEBSD || SI_MAC || SI_ANDROID || SI_NETBSD)
++#define SANITIZER_INTERCEPT_STAT \
++  (SI_FREEBSD || SI_MAC || SI_ANDROID || SI_NETBSD)
  #define SANITIZER_INTERCEPT___XSTAT !SANITIZER_INTERCEPT_STAT && SI_NOT_WINDOWS
  #define SANITIZER_INTERCEPT___XSTAT64 SI_LINUX_NOT_ANDROID
  #define SANITIZER_INTERCEPT___LXSTAT SANITIZER_INTERCEPT___XSTAT
-@@ -345,12 +351,12 @@
+@@ -345,12 +360,13 @@
  #define SANITIZER_INTERCEPT_UTMPX SI_LINUX_NOT_ANDROID || SI_MAC || SI_FREEBSD
  
  #define SANITIZER_INTERCEPT_GETLOADAVG \
@@ -232,7 +241,8 @@ $NetBSD$
 -#define SANITIZER_INTERCEPT_MEMALIGN (!SI_FREEBSD && !SI_MAC)
 -#define SANITIZER_INTERCEPT_PVALLOC (!SI_FREEBSD && !SI_MAC)
 -#define SANITIZER_INTERCEPT_CFREE (!SI_FREEBSD && !SI_MAC)
-+#define SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO (!SI_FREEBSD && !SI_MAC && !SI_NETBSD)
++#define SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO \
++  (!SI_FREEBSD && !SI_MAC && !SI_NETBSD)
 +#define SANITIZER_INTERCEPT_MEMALIGN (!SI_FREEBSD && !SI_MAC && !SI_NETBSD)
 +#define SANITIZER_INTERCEPT_PVALLOC (!SI_FREEBSD && !SI_MAC && !SI_NETBSD)
 +#define SANITIZER_INTERCEPT_CFREE (!SI_FREEBSD && !SI_MAC && !SI_NETBSD)
diff --git a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.cc b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.cc
index 9f08406d45..025227704f 100644
--- a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.cc
+++ b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.cc
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/sanitizer_common/sanitizer_platform_limits_posix.cc.orig	2017-07-03 15:33:06.558965384 +0000
+--- lib/sanitizer_common/sanitizer_platform_limits_posix.cc.orig	2017-07-03 15:33:06.000000000 +0000
 +++ lib/sanitizer_common/sanitizer_platform_limits_posix.cc
 @@ -14,7 +14,7 @@
  
@@ -36,10 +36,10 @@ $NetBSD$
 +#endif
  
 +#if SANITIZER_FREEBSD
-+# include <sys/consio.h>
-+# include <sys/kbio.h>
-+# include <sys/link_elf.h>
-+# include <net/ethernet.h>
++#include <net/ethernet.h>
++#include <sys/consio.h>
++#include <sys/kbio.h>
++#include <sys/link_elf.h>
  #define _KERNEL  // to declare 'shminfo' structure
  # include <sys/shm.h>
  #undef _KERNEL
@@ -49,11 +49,11 @@ $NetBSD$
  
 -#if SANITIZER_FREEBSD || SANITIZER_IOS
 +#if SANITIZER_NETBSD
-+# include <net/if_ether.h>
-+# include <sys/shm.h>
-+# include <link_elf.h>
-+# define statfs statvfs
-+# define d_ino d_fileno 
++#include <link_elf.h>
++#include <net/if_ether.h>
++#include <sys/shm.h>
++#define statfs statvfs
++#define d_ino d_fileno
 +#endif
 +
 +#if SANITIZER_FREEBSD || SANITIZER_IOS || SANITIZER_NETBSD
@@ -70,10 +70,10 @@ $NetBSD$
    unsigned struct_utsname_sz = sizeof(struct utsname);
    unsigned struct_stat_sz = sizeof(struct stat);
 -#if !SANITIZER_IOS && !SANITIZER_FREEBSD
-+#if !SANITIZER_IOS && !SANITIZER_FREEBSD  && !SANITIZER_NETBSD
++#if !SANITIZER_IOS && !SANITIZER_FREEBSD && !SANITIZER_NETBSD
    unsigned struct_stat64_sz = sizeof(struct stat64);
 -#endif // !SANITIZER_IOS && !SANITIZER_FREEBSD
-+#endif // !SANITIZER_IOS && !SANITIZER_FREEBSD && !SANITIZER_NETBSD
++#endif  // !SANITIZER_IOS && !SANITIZER_FREEBSD && !SANITIZER_NETBSD
    unsigned struct_rusage_sz = sizeof(struct rusage);
    unsigned struct_tm_sz = sizeof(struct tm);
    unsigned struct_passwd_sz = sizeof(struct passwd);
@@ -88,31 +88,35 @@ $NetBSD$
    unsigned struct_utimbuf_sz = sizeof(struct utimbuf);
    unsigned struct_itimerspec_sz = sizeof(struct itimerspec);
 -#endif // SANITIZER_LINUX || SANITIZER_FREEBSD
-+#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
++#endif  // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
  
  #if SANITIZER_LINUX && !SANITIZER_ANDROID
    unsigned struct_ustat_sz = sizeof(struct ustat);
-@@ -258,12 +268,12 @@ namespace __sanitizer {
+@@ -258,12 +268,14 @@ namespace __sanitizer {
    unsigned struct_statvfs64_sz = sizeof(struct statvfs64);
  #endif // SANITIZER_LINUX && !SANITIZER_ANDROID
  
 -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
-+#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \
++    !SANITIZER_ANDROID
    unsigned struct_timex_sz = sizeof(struct timex);
    unsigned struct_msqid_ds_sz = sizeof(struct msqid_ds);
    unsigned struct_mq_attr_sz = sizeof(struct mq_attr);
    unsigned struct_statvfs_sz = sizeof(struct statvfs);
 -#endif // (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
-+#endif // (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && !SANITIZER_ANDROID
++#endif  // (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) &&
++        // !SANITIZER_ANDROID
  
    uptr sig_ign = (uptr)SIG_IGN;
    uptr sig_dfl = (uptr)SIG_DFL;
-@@ -274,9 +284,16 @@ namespace __sanitizer {
+@@ -273,10 +285,17 @@ namespace __sanitizer {
+   int e_tabsz = (int)E_TABSZ;
  #endif
  
- 
+-
 -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
-+#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \
++    !SANITIZER_ANDROID
    unsigned struct_shminfo_sz = sizeof(struct shminfo);
 +#if !SANITIZER_NETBSD
    unsigned struct_shm_info_sz = sizeof(struct shm_info);
@@ -125,43 +129,50 @@ $NetBSD$
    int shmctl_ipc_stat = (int)IPC_STAT;
    int shmctl_ipc_info = (int)IPC_INFO;
    int shmctl_shm_info = (int)SHM_INFO;
-@@ -310,7 +327,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(El
+@@ -310,9 +329,10 @@ unsigned struct_ElfW_Phdr_sz = sizeof(El
  unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
  #endif
  
 -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
-+#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && !SANITIZER_ANDROID
-   int glob_nomatch = GLOB_NOMATCH;
-   int glob_altdirfunc = GLOB_ALTDIRFUNC;
+-  int glob_nomatch = GLOB_NOMATCH;
+-  int glob_altdirfunc = GLOB_ALTDIRFUNC;
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \
++    !SANITIZER_ANDROID
++int glob_nomatch = GLOB_NOMATCH;
++int glob_altdirfunc = GLOB_ALTDIRFUNC;
  #endif
-@@ -452,7 +469,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(El
+ 
+ #if SANITIZER_LINUX && !SANITIZER_ANDROID && \
+@@ -452,7 +472,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(El
    unsigned struct_seq_event_rec_sz = sizeof(struct seq_event_rec);
    unsigned struct_synth_info_sz = sizeof(struct synth_info);
    unsigned struct_vt_mode_sz = sizeof(struct vt_mode);
 -#endif // SANITIZER_LINUX || SANITIZER_FREEBSD
-+#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
++#endif  // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
  
  #if SANITIZER_LINUX && !SANITIZER_ANDROID
    unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct);
-@@ -479,7 +496,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(El
+@@ -479,7 +499,8 @@ unsigned struct_ElfW_Phdr_sz = sizeof(El
    unsigned struct_unimapinit_sz = sizeof(struct unimapinit);
  #endif // SANITIZER_LINUX && !SANITIZER_ANDROID
  
 -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
-+#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \
++    !SANITIZER_ANDROID
    unsigned struct_audio_buf_info_sz = sizeof(struct audio_buf_info);
    unsigned struct_ppp_stats_sz = sizeof(struct ppp_stats);
  #endif // (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
-@@ -535,7 +552,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(El
+@@ -535,7 +556,8 @@ unsigned struct_ElfW_Phdr_sz = sizeof(El
    unsigned IOCTL_TIOCSPGRP = TIOCSPGRP;
    unsigned IOCTL_TIOCSTI = TIOCSTI;
    unsigned IOCTL_TIOCSWINSZ = TIOCSWINSZ;
 -#if ((SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID)
-+#if ((SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && !SANITIZER_ANDROID)
++#if ((SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \
++     !SANITIZER_ANDROID)
    unsigned IOCTL_SIOCGETSGCNT = SIOCGETSGCNT;
    unsigned IOCTL_SIOCGETVIFCNT = SIOCGETVIFCNT;
  #endif
-@@ -975,7 +992,7 @@ COMPILER_CHECK(IOC_NR(0x12345678) == _IO
+@@ -975,7 +997,7 @@ COMPILER_CHECK(IOC_NR(0x12345678) == _IO
  COMPILER_CHECK(IOC_TYPE(0x12345678) == _IOC_TYPE(0x12345678));
  #endif // SANITIZER_LINUX
  
@@ -170,19 +181,20 @@ $NetBSD$
  // There are more undocumented fields in dl_phdr_info that we are not interested
  // in.
  COMPILER_CHECK(sizeof(__sanitizer_dl_phdr_info) <= sizeof(dl_phdr_info));
-@@ -983,9 +1000,9 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi
+@@ -983,9 +1005,10 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi
  CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_name);
  CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr);
  CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum);
 -#endif // SANITIZER_LINUX || SANITIZER_FREEBSD
-+#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
++#endif  // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
  
 -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
-+#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \
++    !SANITIZER_ANDROID
  CHECK_TYPE_SIZE(glob_t);
  CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc);
  CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv);
-@@ -1037,7 +1054,7 @@ COMPILER_CHECK(sizeof(__sanitizer_dirent
+@@ -1037,7 +1060,7 @@ COMPILER_CHECK(sizeof(__sanitizer_dirent
  CHECK_SIZE_AND_OFFSET(dirent, d_ino);
  #if SANITIZER_MAC
  CHECK_SIZE_AND_OFFSET(dirent, d_seekoff);
@@ -191,23 +203,24 @@ $NetBSD$
  // There is no 'd_off' field on FreeBSD.
  #else
  CHECK_SIZE_AND_OFFSET(dirent, d_off);
-@@ -1134,11 +1151,14 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno
+@@ -1134,11 +1157,15 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno
  
  CHECK_TYPE_SIZE(ether_addr);
  
 -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
-+#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \
++    !SANITIZER_ANDROID
  CHECK_TYPE_SIZE(ipc_perm);
  # if SANITIZER_FREEBSD
  CHECK_SIZE_AND_OFFSET(ipc_perm, key);
  CHECK_SIZE_AND_OFFSET(ipc_perm, seq);
-+# elif SANITIZER_NETBSD
++#elif SANITIZER_NETBSD
 +CHECK_SIZE_AND_OFFSET(ipc_perm, _key);
 +CHECK_SIZE_AND_OFFSET(ipc_perm, _seq);
  # else
  CHECK_SIZE_AND_OFFSET(ipc_perm, __key);
  CHECK_SIZE_AND_OFFSET(ipc_perm, __seq);
-@@ -1175,20 +1195,20 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_next)
+@@ -1175,20 +1202,20 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_next)
  CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_name);
  CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_addr);
  CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_netmask);
@@ -219,7 +232,7 @@ $NetBSD$
  #undef ifa_dstaddr
  #endif
 -# if SANITIZER_FREEBSD
-+# if SANITIZER_FREEBSD || SANITIZER_NETBSD
++#if SANITIZER_FREEBSD || SANITIZER_NETBSD
  CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr);
  # else
  COMPILER_CHECK(sizeof(((__sanitizer_ifaddrs *)nullptr)->ifa_dstaddr) ==
@@ -227,13 +240,14 @@ $NetBSD$
  COMPILER_CHECK(offsetof(__sanitizer_ifaddrs, ifa_dstaddr) ==
                 offsetof(ifaddrs, ifa_ifu));
 -# endif // SANITIZER_FREEBSD
-+# endif // SANITIZER_FREEBSD || SANITIZER_NETBSD
++#endif  // SANITIZER_FREEBSD || SANITIZER_NETBSD
  #else
  CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr);
  #endif // SANITIZER_LINUX
-@@ -1289,4 +1309,4 @@ CHECK_TYPE_SIZE(sem_t);
+@@ -1289,4 +1316,5 @@ CHECK_TYPE_SIZE(sem_t);
  COMPILER_CHECK(ARM_VFPREGS_SIZE == ARM_VFPREGS_SIZE_ASAN);
  #endif
  
 -#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC
-+#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC || SANITIZER_NETBSD
++#endif  // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC ||
++        // SANITIZER_NETBSD
diff --git a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.h b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.h
index aa83e85128..e419c0f4ce 100644
--- a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.h
+++ b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.h
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/sanitizer_common/sanitizer_platform_limits_posix.h.orig	2017-07-03 15:33:06.559211156 +0000
+--- lib/sanitizer_common/sanitizer_platform_limits_posix.h.orig	2017-07-03 15:33:06.000000000 +0000
 +++ lib/sanitizer_common/sanitizer_platform_limits_posix.h
 @@ -18,18 +18,31 @@
  #include "sanitizer_internal_defs.h"
@@ -18,11 +18,11 @@ $NetBSD$
 -#include <sys/_types.h>
 +#elif SANITIZER_NETBSD
 +#if defined(__x86_64__)
-+# define GET_LINK_MAP_BY_DLOPEN_HANDLE(handle) \
-+    ((link_map*)((handle) == nullptr ? nullptr : ((char*)(handle) + 608)))
++#define GET_LINK_MAP_BY_DLOPEN_HANDLE(handle) \
++  ((link_map *)((handle) == nullptr ? nullptr : ((char *)(handle) + 608)))
 +#elif defined(__i386__)
-+# define GET_LINK_MAP_BY_DLOPEN_HANDLE(handle) \
-+    ((link_map*)((handle) == nullptr ? nullptr : ((char*)(handle) + 324)))
++#define GET_LINK_MAP_BY_DLOPEN_HANDLE(handle) \
++  ((link_map *)((handle) == nullptr ? nullptr : ((char *)(handle) + 324)))
 +#else
 +#error Port sanitizer_platform_limits_posix.h.
 +#endif
@@ -73,7 +73,7 @@ $NetBSD$
  #elif !defined(__sparc__)
    const unsigned struct___old_kernel_stat_sz = 32;
  #endif
-+#endif // SANITIZER_LINUX || SANITIZER_FREEBSD
++#endif  // SANITIZER_LINUX || SANITIZER_FREEBSD
 +
 +#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
  
@@ -92,27 +92,27 @@ $NetBSD$
      u64   aio_reserved3;
 +#elif SANITIZER_NETBSD
 +#if defined(__x86_64__)
-+    u64   aio_offset;
-+    u64   aio_buf;
-+    u64   aio_nbytes;
-+    u32   aio_fildes;
-+    u32   aio_lio_opcode;
-+    u64   aio_reqprio;
-+    u8    aio_sigevent[32];
-+    u32   _state;
-+    u32   _errno;
-+    u64   _retval;
++    u64 aio_offset;
++    u64 aio_buf;
++    u64 aio_nbytes;
++    u32 aio_fildes;
++    u32 aio_lio_opcode;
++    u64 aio_reqprio;
++    u8 aio_sigevent[32];
++    u32 _state;
++    u32 _errno;
++    u64 _retval;
 +#elif defined(__i386__)
-+    u64   aio_offset;
-+    u32   aio_buf;
-+    u32   aio_nbytes;
-+    u32   aio_fildes;
-+    u32   aio_lio_opcode;
-+    u32   aio_reqprio;
-+    u8    aio_sigevent[20];
-+    u32   _state;
-+    u32   _errno;
-+    u32   _retval;
++    u64 aio_offset;
++    u32 aio_buf;
++    u32 aio_nbytes;
++    u32 aio_fildes;
++    u32 aio_lio_opcode;
++    u32 aio_reqprio;
++    u8 aio_sigevent[20];
++    u32 _state;
++    u32 _errno;
++    u32 _retval;
 +#else
 +#error port this to your platform
 +#endif
@@ -147,19 +147,19 @@ $NetBSD$
      unsigned long ___unused[4];
 +#else
 +#if defined(__x86_64__)
-+    u64   name;
-+    u32   namelen;
-+    u64   oldp;
-+    u64   oldlenp;
-+    u64   newp;
-+    u64   newlen;
++    u64 name;
++    u32 namelen;
++    u64 oldp;
++    u64 oldlenp;
++    u64 newp;
++    u64 newlen;
 +#elif defined(__i386__)
-+    u32   name;
-+    u32   namelen;
-+    u32   oldp;
-+    u32   oldlenp;
-+    u32   newp;
-+    u32   newlen;
++    u32 name;
++    u32 namelen;
++    u32 oldp;
++    u32 oldlenp;
++    u32 newp;
++    u32 newlen;
 +#else
 +#error port this
 +#endif
@@ -189,11 +189,11 @@ $NetBSD$
  #endif
    };
 -#endif // SANITIZER_LINUX || SANITIZER_FREEBSD
-+#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
++#endif  // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
  
  #if SANITIZER_ANDROID
    struct __sanitizer_mallinfo {
-@@ -324,14 +407,37 @@ namespace __sanitizer {
+@@ -324,14 +407,39 @@ namespace __sanitizer {
      unsigned long shm_dtime;
      unsigned long shm_ctime;
    };
@@ -223,17 +223,19 @@ $NetBSD$
  #endif
  
 -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
-+#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \
++    !SANITIZER_ANDROID
    extern unsigned struct_msqid_ds_sz;
    extern unsigned struct_mq_attr_sz;
    extern unsigned struct_timex_sz;
    extern unsigned struct_statvfs_sz;
 -#endif  // (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
-+#endif  // (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && !SANITIZER_ANDROID
++#endif  // (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) &&
++        // !SANITIZER_ANDROID
  
    struct __sanitizer_iovec {
      void *iov_base;
-@@ -351,6 +457,9 @@ namespace __sanitizer {
+@@ -351,6 +459,9 @@ namespace __sanitizer {
  # endif
      void *ifa_dstaddr; // (struct sockaddr *)
      void *ifa_data;
@@ -243,7 +245,7 @@ $NetBSD$
    };
  #endif  // !SANITIZER_ANDROID
  
-@@ -376,13 +485,24 @@ namespace __sanitizer {
+@@ -376,13 +487,24 @@ namespace __sanitizer {
    const int __sanitizer_XDR_FREE = 2;
  #endif
  
@@ -270,7 +272,7 @@ $NetBSD$
      char *pw_class;
  #endif
  #if !(SANITIZER_ANDROID && (SANITIZER_WORDSIZE == 32))
-@@ -390,8 +510,8 @@ namespace __sanitizer {
+@@ -390,8 +512,8 @@ namespace __sanitizer {
  #endif
      char *pw_dir;
      char *pw_shell;
@@ -281,7 +283,7 @@ $NetBSD$
  #endif
  #if SANITIZER_FREEBSD
      int pw_fields;
-@@ -405,12 +525,6 @@ namespace __sanitizer {
+@@ -405,12 +527,6 @@ namespace __sanitizer {
      char **gr_mem;
    };
  
@@ -294,7 +296,7 @@ $NetBSD$
    struct __sanitizer_timeb {
      __sanitizer_time_t time;
      unsigned short millitm;
-@@ -447,7 +561,7 @@ namespace __sanitizer {
+@@ -447,7 +563,7 @@ namespace __sanitizer {
    };
  #endif
  
@@ -303,7 +305,7 @@ $NetBSD$
    struct __sanitizer_msghdr {
      void *msg_name;
      unsigned msg_namelen;
-@@ -497,6 +611,16 @@ namespace __sanitizer {
+@@ -497,6 +613,16 @@ namespace __sanitizer {
      unsigned short d_reclen;
      // more fields that we don't care about
    };
@@ -311,7 +313,7 @@ $NetBSD$
 +  struct __sanitizer_dirent {
 +    u64 d_fileno;
 +    u16 d_reclen;
-+#if 0 // not needed here?
++#if 0  // not needed here?
 +    u16 d_namlen;
 +    u8  d_type;
 +    u8  d_name[512];
@@ -320,7 +322,7 @@ $NetBSD$
  #elif SANITIZER_ANDROID || defined(__x86_64__)
    struct __sanitizer_dirent {
      unsigned long long d_ino;
-@@ -523,7 +647,7 @@ namespace __sanitizer {
+@@ -523,7 +649,7 @@ namespace __sanitizer {
  #endif
  
  // 'clock_t' is 32 bits wide on x64 FreeBSD
@@ -329,7 +331,7 @@ $NetBSD$
    typedef int __sanitizer_clock_t;
  #elif defined(__x86_64__) && !defined(_LP64)
    typedef long long __sanitizer_clock_t;
-@@ -531,7 +655,7 @@ namespace __sanitizer {
+@@ -531,7 +657,7 @@ namespace __sanitizer {
    typedef long __sanitizer_clock_t;
  #endif
  
@@ -338,7 +340,7 @@ $NetBSD$
    typedef int __sanitizer_clockid_t;
  #endif
  
-@@ -562,8 +686,22 @@ namespace __sanitizer {
+@@ -562,8 +688,22 @@ namespace __sanitizer {
    typedef struct {
      unsigned long fds_bits[1024 / (8 * sizeof(long))];
    } __sanitizer___kernel_fd_set;
@@ -361,7 +363,7 @@ $NetBSD$
    // This thing depends on the platform. We are only interested in the upper
    // limit. Verified with a compiler assert in .cc.
    const int pthread_attr_t_max_sz = 128;
-@@ -571,6 +709,7 @@ namespace __sanitizer {
+@@ -571,6 +711,7 @@ namespace __sanitizer {
      char size[pthread_attr_t_max_sz]; // NOLINT
      void *align;
    };
@@ -369,18 +371,18 @@ $NetBSD$
  
  #if SANITIZER_ANDROID
  # if SANITIZER_MIPS
-@@ -590,6 +729,10 @@ namespace __sanitizer {
+@@ -590,6 +731,10 @@ namespace __sanitizer {
       // uint32_t * 4
       unsigned int __bits[4];
    };
 +#elif SANITIZER_NETBSD
 +  struct __sanitizer_sigset_t {
-+     u32 __bits[4];
++    u32 __bits[4];
 +  };
  #endif
  
    // Linux system headers define the 'sa_handler' and 'sa_sigaction' macros.
-@@ -622,6 +765,15 @@ namespace __sanitizer {
+@@ -622,6 +767,15 @@ namespace __sanitizer {
      uptr sa_flags;
      void (*sa_restorer)();
    };
@@ -396,7 +398,7 @@ $NetBSD$
  #else // !SANITIZER_ANDROID
    struct __sanitizer_sigaction {
  #if defined(__mips__) && !SANITIZER_FREEBSD
-@@ -640,6 +792,7 @@ namespace __sanitizer {
+@@ -640,6 +794,7 @@ namespace __sanitizer {
  #else
      __sanitizer_sigset_t sa_mask;
  #endif
@@ -404,7 +406,7 @@ $NetBSD$
  #ifndef __mips__
  #if defined(__sparc__)
  #if __GLIBC_PREREQ (2, 20)
-@@ -670,7 +823,7 @@ namespace __sanitizer {
+@@ -670,7 +825,7 @@ namespace __sanitizer {
    };
  #endif // !SANITIZER_ANDROID
  
@@ -413,7 +415,7 @@ $NetBSD$
    typedef __sanitizer_sigset_t __sanitizer_kernel_sigset_t;
  #elif defined(__mips__)
    struct __sanitizer_kernel_sigset_t {
-@@ -717,7 +870,7 @@ namespace __sanitizer {
+@@ -717,7 +872,7 @@ namespace __sanitizer {
    extern int af_inet6;
    uptr __sanitizer_in_addr_sz(int af);
  
@@ -422,7 +424,7 @@ $NetBSD$
    struct __sanitizer_dl_phdr_info {
      uptr dlpi_addr;
      const char *dlpi_name;
-@@ -733,7 +886,7 @@ namespace __sanitizer {
+@@ -733,7 +888,7 @@ namespace __sanitizer {
      int ai_family;
      int ai_socktype;
      int ai_protocol;
@@ -431,7 +433,7 @@ $NetBSD$
      unsigned ai_addrlen;
      char *ai_canonname;
      void *ai_addr;
-@@ -759,7 +912,7 @@ namespace __sanitizer {
+@@ -759,7 +914,7 @@ namespace __sanitizer {
      short revents;
    };
  
@@ -440,28 +442,28 @@ $NetBSD$
    typedef unsigned __sanitizer_nfds_t;
  #else
    typedef unsigned long __sanitizer_nfds_t;
-@@ -779,7 +932,7 @@ namespace __sanitizer {
+@@ -779,7 +934,7 @@ namespace __sanitizer {
      int (*gl_lstat)(const char *, void *);
      int (*gl_stat)(const char *, void *);
    };
 -# elif SANITIZER_FREEBSD
-+# elif SANITIZER_FREEBSD || SANITIZER_NETBSD
++#elif SANITIZER_FREEBSD || SANITIZER_NETBSD
    struct __sanitizer_glob_t {
      uptr gl_pathc;
      uptr gl_matchc;
-@@ -793,9 +946,9 @@ namespace __sanitizer {
+@@ -793,9 +948,9 @@ namespace __sanitizer {
      int (*gl_lstat)(const char*, void* /* struct stat* */);
      int (*gl_stat)(const char*, void* /* struct stat* */);
    };
 -# endif  // SANITIZER_FREEBSD
-+# endif  // SANITIZER_FREEBSD || SANITIZER_NETBSD
++#endif  // SANITIZER_FREEBSD || SANITIZER_NETBSD
  
 -# if SANITIZER_LINUX || SANITIZER_FREEBSD
-+# if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
++#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
    extern int glob_nomatch;
    extern int glob_altdirfunc;
  # endif
-@@ -807,7 +960,7 @@ namespace __sanitizer {
+@@ -807,7 +962,7 @@ namespace __sanitizer {
      uptr we_wordc;
      char **we_wordv;
      uptr we_offs;
@@ -470,81 +472,137 @@ $NetBSD$
      char *we_strings;
      uptr we_nbytes;
  #endif
-@@ -832,6 +985,37 @@ namespace __sanitizer {
+@@ -832,6 +987,37 @@ namespace __sanitizer {
      int _fileno;
    };
  # define SANITIZER_HAS_STRUCT_FILE 1
 +#elif SANITIZER_NETBSD
 +  struct __sanitizer_FILE {
 +    unsigned char *_p;
-+    int     _r;
-+    int     _w;
++    int _r;
++    int _w;
 +    unsigned short _flags;
-+    short   _file;
-+    struct  {
-+        unsigned char *_base;
-+        int     _size;
++    short _file;
++    struct {
++      unsigned char *_base;
++      int _size;
 +    } _bf;
-+    int     _lbfsize;
-+    void    *_cookie;
-+    int     (*_close)(void *);
-+    u64 (*_read) (void *, void *, uptr);
-+    u64 (*_seek) (void *, u64, int);
++    int _lbfsize;
++    void *_cookie;
++    int (*_close)(void *);
++    u64 (*_read)(void *, void *, uptr);
++    u64 (*_seek)(void *, u64, int);
 +    uptr (*_write)(void *, const void *, uptr);
 +    struct {
-+        unsigned char *_base;
-+        int     _size;
++      unsigned char *_base;
++      int _size;
 +    } _ext;
 +    unsigned char *_up;
-+    int     _ur;
++    int _ur;
 +    unsigned char _ubuf[3];
 +    unsigned char _nbuf[1];
-+    int     (*_flush)(void *);
-+    char    _lb_unused[sizeof(uptr)];
-+    int     _blksize;
++    int (*_flush)(void *);
++    char _lb_unused[sizeof(uptr)];
++    int _blksize;
 +    u64 _offset;
 +  };
-+# define SANITIZER_HAS_STRUCT_FILE 0 // not ported
++#define SANITIZER_HAS_STRUCT_FILE 0  // not ported
  #else
    typedef void __sanitizer_FILE;
  # define SANITIZER_HAS_STRUCT_FILE 0
-@@ -864,7 +1048,7 @@ namespace __sanitizer {
+@@ -864,7 +1050,8 @@ namespace __sanitizer {
    extern int ptrace_geteventmsg;
  #endif
  
 -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
-+#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \
++    !SANITIZER_ANDROID
    extern unsigned struct_shminfo_sz;
    extern unsigned struct_shm_info_sz;
    extern int shmctl_ipc_stat;
-@@ -923,6 +1107,7 @@ struct __sanitizer_cookie_io_functions_t
+@@ -923,6 +1110,7 @@ struct __sanitizer_cookie_io_functions_t
  };
  #endif
  
-+#if 1 // !SANITIZER_NETBSD
++#if 1  // !SANITIZER_NETBSD
  #define IOC_NRBITS 8
  #define IOC_TYPEBITS 8
  #if defined(__powerpc__) || defined(__powerpc64__) || defined(__mips__) || \
-@@ -966,13 +1151,17 @@ struct __sanitizer_cookie_io_functions_t
+@@ -966,39 +1154,43 @@ struct __sanitizer_cookie_io_functions_t
  #else
  #define IOC_SIZE(nr) (((nr) >> IOC_SIZESHIFT) & IOC_SIZEMASK)
  #endif
 +#endif
  
-   extern unsigned struct_ifreq_sz;
-   extern unsigned struct_termios_sz;
-   extern unsigned struct_winsize_sz;
- 
--#if SANITIZER_LINUX
+-  extern unsigned struct_ifreq_sz;
+-  extern unsigned struct_termios_sz;
+-  extern unsigned struct_winsize_sz;
++extern unsigned struct_ifreq_sz;
++extern unsigned struct_termios_sz;
++extern unsigned struct_winsize_sz;
++
 +#if SANITIZER_LINUX || SANITIZER_NETBSD
-   extern unsigned struct_arpreq_sz;
++extern unsigned struct_arpreq_sz;
 +#endif
-+
-+#if SANITIZER_LINUX
-   extern unsigned struct_cdrom_msf_sz;
-   extern unsigned struct_cdrom_multisession_sz;
-   extern unsigned struct_cdrom_read_audio_sz;
-@@ -1006,6 +1195,9 @@ struct __sanitizer_cookie_io_functions_t
+ 
+ #if SANITIZER_LINUX
+-  extern unsigned struct_arpreq_sz;
+-  extern unsigned struct_cdrom_msf_sz;
+-  extern unsigned struct_cdrom_multisession_sz;
+-  extern unsigned struct_cdrom_read_audio_sz;
+-  extern unsigned struct_cdrom_subchnl_sz;
+-  extern unsigned struct_cdrom_ti_sz;
+-  extern unsigned struct_cdrom_tocentry_sz;
+-  extern unsigned struct_cdrom_tochdr_sz;
+-  extern unsigned struct_cdrom_volctrl_sz;
+-  extern unsigned struct_ff_effect_sz;
+-  extern unsigned struct_floppy_drive_params_sz;
+-  extern unsigned struct_floppy_drive_struct_sz;
+-  extern unsigned struct_floppy_fdc_state_sz;
+-  extern unsigned struct_floppy_max_errors_sz;
+-  extern unsigned struct_floppy_raw_cmd_sz;
+-  extern unsigned struct_floppy_struct_sz;
+-  extern unsigned struct_floppy_write_errors_sz;
+-  extern unsigned struct_format_descr_sz;
+-  extern unsigned struct_hd_driveid_sz;
+-  extern unsigned struct_hd_geometry_sz;
+-  extern unsigned struct_input_absinfo_sz;
+-  extern unsigned struct_input_id_sz;
+-  extern unsigned struct_mtpos_sz;
+-  extern unsigned struct_termio_sz;
+-  extern unsigned struct_vt_consize_sz;
+-  extern unsigned struct_vt_sizes_sz;
+-  extern unsigned struct_vt_stat_sz;
++extern unsigned struct_cdrom_msf_sz;
++extern unsigned struct_cdrom_multisession_sz;
++extern unsigned struct_cdrom_read_audio_sz;
++extern unsigned struct_cdrom_subchnl_sz;
++extern unsigned struct_cdrom_ti_sz;
++extern unsigned struct_cdrom_tocentry_sz;
++extern unsigned struct_cdrom_tochdr_sz;
++extern unsigned struct_cdrom_volctrl_sz;
++extern unsigned struct_ff_effect_sz;
++extern unsigned struct_floppy_drive_params_sz;
++extern unsigned struct_floppy_drive_struct_sz;
++extern unsigned struct_floppy_fdc_state_sz;
++extern unsigned struct_floppy_max_errors_sz;
++extern unsigned struct_floppy_raw_cmd_sz;
++extern unsigned struct_floppy_struct_sz;
++extern unsigned struct_floppy_write_errors_sz;
++extern unsigned struct_format_descr_sz;
++extern unsigned struct_hd_driveid_sz;
++extern unsigned struct_hd_geometry_sz;
++extern unsigned struct_input_absinfo_sz;
++extern unsigned struct_input_id_sz;
++extern unsigned struct_mtpos_sz;
++extern unsigned struct_termio_sz;
++extern unsigned struct_vt_consize_sz;
++extern unsigned struct_vt_sizes_sz;
++extern unsigned struct_vt_stat_sz;
+ #endif  // SANITIZER_LINUX
+ 
+ #if SANITIZER_LINUX || SANITIZER_FREEBSD
+@@ -1006,6 +1198,9 @@ struct __sanitizer_cookie_io_functions_t
    extern unsigned struct_copr_debug_buf_sz;
    extern unsigned struct_copr_msg_sz;
    extern unsigned struct_midi_info_sz;
@@ -554,38 +612,41 @@ $NetBSD$
    extern unsigned struct_mtget_sz;
    extern unsigned struct_mtop_sz;
    extern unsigned struct_rtentry_sz;
-@@ -1013,7 +1205,7 @@ struct __sanitizer_cookie_io_functions_t
+@@ -1013,7 +1208,7 @@ struct __sanitizer_cookie_io_functions_t
    extern unsigned struct_seq_event_rec_sz;
    extern unsigned struct_synth_info_sz;
    extern unsigned struct_vt_mode_sz;
 -#endif // SANITIZER_LINUX || SANITIZER_FREEBSD
-+#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
++#endif  // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
  
  #if SANITIZER_LINUX && !SANITIZER_ANDROID
    extern unsigned struct_ax25_parms_struct_sz;
-@@ -1035,10 +1227,10 @@ struct __sanitizer_cookie_io_functions_t
+@@ -1035,10 +1230,12 @@ struct __sanitizer_cookie_io_functions_t
    extern unsigned struct_unimapinit_sz;
  #endif  // SANITIZER_LINUX && !SANITIZER_ANDROID
  
 -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
-+#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \
++    !SANITIZER_ANDROID
    extern unsigned struct_audio_buf_info_sz;
    extern unsigned struct_ppp_stats_sz;
 -#endif  // (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
-+#endif  // (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && !SANITIZER_ANDROID
++#endif  // (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) &&
++        // !SANITIZER_ANDROID
  
  #if !SANITIZER_ANDROID && !SANITIZER_MAC
    extern unsigned struct_sioc_sg_req_sz;
-@@ -1095,7 +1287,7 @@ struct __sanitizer_cookie_io_functions_t
+@@ -1095,7 +1292,8 @@ struct __sanitizer_cookie_io_functions_t
    extern unsigned IOCTL_TIOCSPGRP;
    extern unsigned IOCTL_TIOCSTI;
    extern unsigned IOCTL_TIOCSWINSZ;
 -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
-+#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \
++    !SANITIZER_ANDROID
    extern unsigned IOCTL_SIOCGETSGCNT;
    extern unsigned IOCTL_SIOCGETVIFCNT;
  #endif
-@@ -1258,10 +1450,10 @@ struct __sanitizer_cookie_io_functions_t
+@@ -1258,10 +1456,10 @@ struct __sanitizer_cookie_io_functions_t
    extern unsigned IOCTL_VT_RESIZEX;
    extern unsigned IOCTL_VT_SENDSIG;
  #endif  // SANITIZER_LINUX
@@ -594,11 +655,11 @@ $NetBSD$
    extern unsigned IOCTL_MTIOCGET;
    extern unsigned IOCTL_MTIOCTOP;
 -  extern unsigned IOCTL_SIOCADDRT;
-+  extern unsigned IOCTL_SIOCADDRT;//
++  extern unsigned IOCTL_SIOCADDRT;  //
    extern unsigned IOCTL_SIOCDELRT;
    extern unsigned IOCTL_SNDCTL_DSP_GETBLKSIZE;
    extern unsigned IOCTL_SNDCTL_DSP_GETFMTS;
-@@ -1359,7 +1551,7 @@ struct __sanitizer_cookie_io_functions_t
+@@ -1359,7 +1557,7 @@ struct __sanitizer_cookie_io_functions_t
    extern unsigned IOCTL_VT_RELDISP;
    extern unsigned IOCTL_VT_SETMODE;
    extern unsigned IOCTL_VT_WAITACTIVE;
@@ -607,12 +668,13 @@ $NetBSD$
  
  #if SANITIZER_LINUX && !SANITIZER_ANDROID
    extern unsigned IOCTL_CYGETDEFTHRESH;
-@@ -1448,21 +1640,27 @@ struct __sanitizer_cookie_io_functions_t
+@@ -1448,21 +1646,28 @@ struct __sanitizer_cookie_io_functions_t
    extern unsigned IOCTL_TIOCSSERIAL;
  #endif  // SANITIZER_LINUX && !SANITIZER_ANDROID
  
 -#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
-+#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && \
++    !SANITIZER_ANDROID
 +#if !SANITIZER_NETBSD
    extern unsigned IOCTL_GIO_SCRNMAP;
 +#endif
diff --git a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__procmaps.h b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__procmaps.h
index fac3d0b1c6..7df23a6c7d 100644
--- a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__procmaps.h
+++ b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__procmaps.h
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/sanitizer_common/sanitizer_procmaps.h.orig	2017-07-03 15:33:06.559675042 +0000
+--- lib/sanitizer_common/sanitizer_procmaps.h.orig	2017-07-03 15:33:06.000000000 +0000
 +++ lib/sanitizer_common/sanitizer_procmaps.h
 @@ -20,7 +20,7 @@
  
@@ -25,7 +25,7 @@ $NetBSD$
    // FIXME: Hide implementation details for different platforms in
    // platform-specific files.
 -# if SANITIZER_FREEBSD || SANITIZER_LINUX
-+# if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
++#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
    ProcSelfMapsBuff proc_self_maps_;
    const char *current_;
  
diff --git a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__procmaps__common.cc b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__procmaps__common.cc
index f1ded5011c..2d1aa6d5df 100644
--- a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__procmaps__common.cc
+++ b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__procmaps__common.cc
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/sanitizer_common/sanitizer_procmaps_common.cc.orig	2017-07-03 15:33:06.559737270 +0000
+--- lib/sanitizer_common/sanitizer_procmaps_common.cc.orig	2017-07-03 15:33:06.000000000 +0000
 +++ lib/sanitizer_common/sanitizer_procmaps_common.cc
 @@ -12,7 +12,7 @@
  
@@ -16,4 +16,4 @@ $NetBSD$
  } // namespace __sanitizer
  
 -#endif // SANITIZER_FREEBSD || SANITIZER_LINUX
-+#endif // SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
++#endif  // SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
diff --git a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc
index 81662834ef..97130d4617 100644
--- a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc
+++ b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc
@@ -1,8 +1,8 @@
 $NetBSD$
 
---- lib/sanitizer_common/sanitizer_procmaps_netbsd.cc.orig	2017-07-03 15:46:54.034469045 +0000
+--- lib/sanitizer_common/sanitizer_procmaps_netbsd.cc.orig	2017-07-03 18:33:56.810198571 +0000
 +++ lib/sanitizer_common/sanitizer_procmaps_netbsd.cc
-@@ -0,0 +1,79 @@
+@@ -0,0 +1,78 @@
 +//===-- sanitizer_procmaps_freebsd.cc -------------------------------------===//
 +//
 +// This file is distributed under the University of Illinois Open Source
@@ -18,14 +18,14 @@ $NetBSD$
 +#include "sanitizer_common.h"
 +#include "sanitizer_procmaps.h"
 +
-+#include <unistd.h>
 +#include <sys/sysctl.h>
++#include <unistd.h>
 +
 +namespace __sanitizer {
 +
 +void ReadProcMaps(ProcSelfMapsBuff *proc_maps) {
 +  struct kinfo_vmentry *kiv;
-+  const int Mib[] = { CTL_VM, VM_PROC, VM_PROC_MAP, getpid(), sizeof(*kiv) };
++  const int Mib[] = {CTL_VM, VM_PROC, VM_PROC_MAP, getpid(), sizeof(*kiv)};
 +  size_t Size = 0;
 +  int Err = sysctl(Mib, __arraycount(Mib), NULL, &Size, NULL, 0);
 +  CHECK_EQ(Err, 0);
@@ -37,7 +37,7 @@ $NetBSD$
 +  Err = sysctl(Mib, __arraycount(Mib), VmMap, &Size, NULL, 0);
 +  CHECK_EQ(Err, 0);
 +
-+  proc_maps->data = (char*)VmMap;
++  proc_maps->data = (char *)VmMap;
 +  proc_maps->mmaped_size = MmapedSize;
 +  proc_maps->len = Size;
 +}
@@ -54,7 +54,7 @@ $NetBSD$
 +  if (!end) end = &dummy;
 +  if (!offset) offset = &dummy;
 +  if (!protection) protection = &dummy;
-+  struct kinfo_vmentry *VmEntry = (struct kinfo_vmentry*)current_;
++  struct kinfo_vmentry *VmEntry = (struct kinfo_vmentry *)current_;
 +
 +  *start = (uptr)VmEntry->kve_start;
 +  *end = (uptr)VmEntry->kve_end;
@@ -69,9 +69,8 @@ $NetBSD$
 +    *protection |= kProtectionExecute;
 +
 +  if (filename != NULL && filename_size > 0) {
-+    internal_snprintf(filename,
-+                      Min(filename_size, (uptr)PATH_MAX),
-+                      "%s", VmEntry->kve_path);
++    internal_snprintf(filename, Min(filename_size, (uptr)PATH_MAX), "%s",
++                      VmEntry->kve_path);
 +  }
 +
 +  current_ += sizeof(*VmEntry);
diff --git a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__syscall__generic.inc b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__syscall__generic.inc
index be8e60d51a..9852a2ac43 100644
--- a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__syscall__generic.inc
+++ b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__syscall__generic.inc
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/sanitizer_common/sanitizer_syscall_generic.inc.orig	2017-07-03 15:33:06.561978756 +0000
+--- lib/sanitizer_common/sanitizer_syscall_generic.inc.orig	2017-07-03 15:33:06.000000000 +0000
 +++ lib/sanitizer_common/sanitizer_syscall_generic.inc
 @@ -11,13 +11,37 @@
  //
diff --git a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__unwind__linux__libcdep.cc b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__unwind__linux__libcdep.cc
index ac1a8ffc38..ab5771ab33 100644
--- a/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__unwind__linux__libcdep.cc
+++ b/compiler-rt-git/patches/patch-lib_sanitizer__common_sanitizer__unwind__linux__libcdep.cc
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc.orig	2017-07-03 15:33:06.562483709 +0000
+--- lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc.orig	2017-07-03 15:33:06.000000000 +0000
 +++ lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc
 @@ -8,11 +8,11 @@
  //===----------------------------------------------------------------------===//


Home | Main Index | Thread Index | Old Index