pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
compiler-rt-ubsan: Eliminate
Module Name: pkgsrc-wip
Committed By: Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By: kamil
Date: Mon Jul 17 00:43:46 2017 +0200
Changeset: 64b953be87eaff46167c6183614ade35d7959a7c
Removed Files:
compiler-rt-ubsan/DESCR
compiler-rt-ubsan/Makefile
compiler-rt-ubsan/PLIST
compiler-rt-ubsan/buildlink3.mk
compiler-rt-ubsan/distinfo
compiler-rt-ubsan/patches/patch-cmake_config-ix.cmake
compiler-rt-ubsan/patches/patch-lib_interception_interception.h
compiler-rt-ubsan/patches/patch-lib_interception_interception__linux.cc
compiler-rt-ubsan/patches/patch-lib_interception_interception__linux.h
compiler-rt-ubsan/patches/patch-lib_sanitizer__common_CMakeLists.txt
compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__internal__defs.h
compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__libignore.cc
compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__linux.cc
compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__linux.h
compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__linux__libcdep.cc
compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__netbsd.h
compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__platform.h
compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__platform__interceptors.h
compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.cc
compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.h
compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__procmaps.h
compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__procmaps__common.cc
compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc
compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__syscall__generic.inc
compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__unwind__linux__libcdep.cc
compiler-rt-ubsan/patches/patch-lib_ubsan_ubsan__platform.h
compiler-rt-ubsan/patches/patch-test_ubsan_TestCases_Float_cast-overflow.cpp
compiler-rt-ubsan/patches/patch-test_ubsan_lit.common.cfg
Log Message:
compiler-rt-ubsan: Eliminate
No longer needed, sent upstream and rejected as too large patch to review.
It will be partitioned into smaller chunks.
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=64b953be87eaff46167c6183614ade35d7959a7c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
compiler-rt-ubsan/DESCR | 29 -
compiler-rt-ubsan/Makefile | 46 --
compiler-rt-ubsan/PLIST | 41 --
compiler-rt-ubsan/buildlink3.mk | 14 -
compiler-rt-ubsan/distinfo | 37 --
.../patches/patch-cmake_config-ix.cmake | 22 -
.../patches/patch-lib_interception_interception.h | 33 -
.../patch-lib_interception_interception__linux.cc | 39 --
.../patch-lib_interception_interception__linux.h | 19 -
.../patch-lib_sanitizer__common_CMakeLists.txt | 12 -
...b_sanitizer__common_sanitizer__internal__defs.h | 15 -
...h-lib_sanitizer__common_sanitizer__libignore.cc | 19 -
...patch-lib_sanitizer__common_sanitizer__linux.cc | 347 ----------
.../patch-lib_sanitizer__common_sanitizer__linux.h | 20 -
..._sanitizer__common_sanitizer__linux__libcdep.cc | 70 ---
...patch-lib_sanitizer__common_sanitizer__netbsd.h | 25 -
...tch-lib_sanitizer__common_sanitizer__platform.h | 38 --
...zer__common_sanitizer__platform__interceptors.h | 251 --------
...r__common_sanitizer__platform__limits__posix.cc | 253 --------
...er__common_sanitizer__platform__limits__posix.h | 700 ---------------------
...tch-lib_sanitizer__common_sanitizer__procmaps.h | 31 -
...anitizer__common_sanitizer__procmaps__common.cc | 19 -
...anitizer__common_sanitizer__procmaps__netbsd.cc | 83 ---
...nitizer__common_sanitizer__syscall__generic.inc | 44 --
...er__common_sanitizer__unwind__linux__libcdep.cc | 43 --
.../patches/patch-lib_ubsan_ubsan__platform.h | 18 -
...ch-test_ubsan_TestCases_Float_cast-overflow.cpp | 13 -
.../patches/patch-test_ubsan_lit.common.cfg | 13 -
28 files changed, 2294 deletions(-)
diffs:
diff --git a/compiler-rt-ubsan/DESCR b/compiler-rt-ubsan/DESCR
deleted file mode 100644
index ec4b69e9ef..0000000000
--- a/compiler-rt-ubsan/DESCR
+++ /dev/null
@@ -1,29 +0,0 @@
-The compiler-rt project consists of:
-
- - builtins - a simple library that provides an implementation of the low-level
- target-specific hooks required by code generation and other runtime
- components. For example, when compiling for a 32-bit target, converting a
- double to a 64-bit unsigned integer is compiling into a runtime call to the
- "__fixunsdfdi" function. The builtins library provides optimized
- implementations of this and other low-level routines, either in
- target-independent C form, or as a heavily-optimized assembly.
-
- builtins provides full support for the libgcc interfaces on supported
- targets and high performance hand tuned implementations of commonly used
- functions like __floatundidf in assembly that are dramatically faster than
- the libgcc implementations. It should be very easy to bring builtins to
- support a new target by adding the new routines needed by that target.
-
- - sanitizer runtimes - runtime libraries that are required to run the code
- with sanitizer instrumentation. This includes runtimes for:
- * AddressSanitizer
- * ThreadSanitizer
- * UndefinedBehaviorSanitizer
- * MemorySanitizer
- * LeakSanitizer
- * DataFlowSanitizer
-
- - profile - library which is used to collect coverage information.
-
- - BlocksRuntime - a target-independent implementation of Apple "Blocks"
- runtime interfaces.
diff --git a/compiler-rt-ubsan/Makefile b/compiler-rt-ubsan/Makefile
deleted file mode 100644
index b1b5e62ce0..0000000000
--- a/compiler-rt-ubsan/Makefile
+++ /dev/null
@@ -1,46 +0,0 @@
-# $NetBSD: Makefile.common,v 1.7 2015/07/20 05:49:53 adam Exp $
-
-PKGNAME= compiler-rt-5.0.0
-CATEGORIES= lang devel
-
-GIT_REPOSITORIES= compiler-rt
-GIT_REPO.compiler-rt= https://github.com/llvm-mirror/compiler-rt.git
-GIT_REVISION.compiler-rt= 9e2c69ffc25e56881e2a4805ac765110dec265dc
-
-MAINTAINER= pkgsrc-users%NetBSD.org@localhost
-HOMEPAGE= http://compiler-rt.llvm.org/
-COMMENT= LLVM runtime libraries
-LICENSE= modified-bsd OR mit
-
-WRKSRC= ${WRKDIR}/build
-
-USE_LANGUAGES= c c++11
-USE_CMAKE= yes
-GCC_REQD+= 4.8
-
-WRKSRC= ${WRKDIR}/${PKGBASE}
-CONFIGURE_DIRS= ${WRKDIR}/build
-CMAKE_ARG_PATH= ${WRKSRC}
-
-CMAKE_ARGS+= -DCMAKE_BUILD_TYPE=Release
-CMAKE_ARGS+= -DCMAKE_C_COMPILER=${CC:Q}
-CMAKE_ARGS+= -DCMAKE_CXX_COMPILER=${CXX:Q}
-CMAKE_ARGS+= -DCOMPILER_RT_OS_DIR:STRING=${LOWER_OPSYS}${OS_VERSION:R}
-CMAKE_ARGS+= -DCOMPILER_RT_INSTALL_PATH:STRING=lib/clang/${PKGVERSION_NOREV}
-#CMAKE_ARGS+= -DCOMPILER_RT_INCLUDE_TESTS:BOOL=ON
-# Not supported in standalone build
-CMAKE_ARGS+= -DCOMPILER_RT_INCLUDE_TESTS:BOOL=OFF
-
-PLIST_SUBST+= COMPILER_RT_OS_DIR=${LOWER_OPSYS}${OS_VERSION:R}
-
-#TEST_TARGET= check-compiler-rt
-#TEST_ENV+= LD_LIBRARY_PATH=${WRKDIR}/build/lib
-
-post-extract:
- ${RUN} mkdir -p ${WRKDIR}/build
-
-.include "../../wip/mk/git-package.mk"
-.include "../../devel/googletest/buildlink3.mk"
-DEPENDS+= llvm-${PKGVERSION_NOREV}{,nb*}:../../wip/llvm-git
-.include "../../wip/llvm-git/buildlink3.mk"
-.include "../../mk/bsd.pkg.mk"
diff --git a/compiler-rt-ubsan/PLIST b/compiler-rt-ubsan/PLIST
deleted file mode 100644
index 5f654a8e56..0000000000
--- a/compiler-rt-ubsan/PLIST
+++ /dev/null
@@ -1,41 +0,0 @@
-@comment $NetBSD$
-lib/clang/${PKGVERSION}/asan_blacklist.txt
-lib/clang/${PKGVERSION}/include/sanitizer/allocator_interface.h
-lib/clang/${PKGVERSION}/include/sanitizer/asan_interface.h
-lib/clang/${PKGVERSION}/include/sanitizer/common_interface_defs.h
-lib/clang/${PKGVERSION}/include/sanitizer/coverage_interface.h
-lib/clang/${PKGVERSION}/include/sanitizer/dfsan_interface.h
-lib/clang/${PKGVERSION}/include/sanitizer/esan_interface.h
-lib/clang/${PKGVERSION}/include/sanitizer/linux_syscall_hooks.h
-lib/clang/${PKGVERSION}/include/sanitizer/lsan_interface.h
-lib/clang/${PKGVERSION}/include/sanitizer/msan_interface.h
-lib/clang/${PKGVERSION}/include/sanitizer/tsan_interface.h
-lib/clang/${PKGVERSION}/include/sanitizer/tsan_interface_atomic.h
-lib/clang/${PKGVERSION}/include/xray/xray_interface.h
-lib/clang/${PKGVERSION}/include/xray/xray_log_interface.h
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.asan-i386.a
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.asan-i386.so
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.asan-preinit-i386.a
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.asan-preinit-x86_64.a
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.asan-x86_64.a
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.asan-x86_64.a.syms
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.asan-x86_64.so
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.asan_cxx-i386.a
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.asan_cxx-x86_64.a
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.asan_cxx-x86_64.a.syms
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.builtins-i386.a
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.builtins-x86_64.a
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.stats-i386.a
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.stats-x86_64.a
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.stats_client-i386.a
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.stats_client-x86_64.a
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.ubsan_standalone-i386.a
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.ubsan_standalone-i386.so
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.ubsan_standalone-x86_64.a
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.ubsan_standalone-x86_64.a.syms
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.ubsan_standalone-x86_64.so
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.ubsan_standalone_cxx-i386.a
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.ubsan_standalone_cxx-i386.so
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.ubsan_standalone_cxx-x86_64.a
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.ubsan_standalone_cxx-x86_64.a.syms
-lib/clang/${PKGVERSION}/lib/${COMPILER_RT_OS_DIR}/libclang_rt.ubsan_standalone_cxx-x86_64.so
diff --git a/compiler-rt-ubsan/buildlink3.mk b/compiler-rt-ubsan/buildlink3.mk
deleted file mode 100644
index 904e0e5031..0000000000
--- a/compiler-rt-ubsan/buildlink3.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-# $NetBSD$
-
-BUILDLINK_TREE+= compiler-rt
-
-.if !defined(COMPILER_RT_BUILDLINK3_MK)
-COMPILER_RT_BUILDLINK3_MK:=
-
-BUILDLINK_API_DEPENDS.compiler-rt+= compiler-rt>=4.0.0nb20160924
-BUILDLINK_PKGSRCDIR.compiler-rt?= ../../wip/compiler-rt-git
-
-.include "../../wip/llvm-git/buildlink3.mk"
-.endif # COMPILER_RT_BUILDLINK3_MK
-
-BUILDLINK_TREE+= -compiler-rt
diff --git a/compiler-rt-ubsan/distinfo b/compiler-rt-ubsan/distinfo
deleted file mode 100644
index fc88f6d5a8..0000000000
--- a/compiler-rt-ubsan/distinfo
+++ /dev/null
@@ -1,37 +0,0 @@
-$NetBSD: distinfo,v 1.35 2015/09/11 01:21:57 tnn Exp $
-
-SHA1 (cfe-3.6.2.src.tar.xz) = 7ba809c9c17819a16b668640a642ed134d7052f0
-RMD160 (cfe-3.6.2.src.tar.xz) = 10d913b4d5317f8c2520e5fc6117df30937317a8
-Size (cfe-3.6.2.src.tar.xz) = 8617576 bytes
-SHA1 (compiler-rt-3.6.2.src.tar.xz) = c6c52d2923a60f1a2ca2f22fea1770fd2e25728d
-RMD160 (compiler-rt-3.6.2.src.tar.xz) = 9b68a32d49d4bef4603d550934192f39fea42895
-Size (compiler-rt-3.6.2.src.tar.xz) = 1128080 bytes
-SHA1 (libcxx-3.6.2.src.tar.xz) = 6c5aee9f05ecf17d1e3ecb1add34a33a5a904469
-RMD160 (libcxx-3.6.2.src.tar.xz) = 42b8832d01d4e6b553babc93cb5dbd4ce2bb1931
-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) = d0b0de34e0e4ff5feb262dac19a78082e0afc921
-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) = 2ffbb5737ae8cfb230e12eed87e38c209311168e
-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) = 1a158f3d3d20f3f59a8cbb62790dec58c24ed902
-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) = 851d900d3edad48af9e325945830022f7f346438
-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) = 9093a94b1ebc727c83cc169edc1bf6996e05dc17
-SHA1 (patch-lib_sanitizer__common_sanitizer__platform__limits__posix.h) = 78f0ee62291b5f43ca68da577017e3aef7d83f7a
-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) = 67e12a7c98a520f9fca9c6970a1e009d726aa5d6
-SHA1 (patch-lib_sanitizer__common_sanitizer__syscall__generic.inc) = b9ab90fafcb14d589e02a2062fe7e978d6b7edbb
-SHA1 (patch-lib_sanitizer__common_sanitizer__unwind__linux__libcdep.cc) = cf7e016fff0f57e7bcae93696ec05e5cff7b7093
-SHA1 (patch-lib_ubsan_ubsan__platform.h) = 5714b6b7cde91828375ad25fee1c8b9a8e9a200d
-SHA1 (patch-test_ubsan_TestCases_Float_cast-overflow.cpp) = f5cce8ef94b37a27610aa952d5ddc97b5638f7f4
-SHA1 (patch-test_ubsan_lit.common.cfg) = 65e809e0683c4197edbc8ea8d869bbfca6e46f57
diff --git a/compiler-rt-ubsan/patches/patch-cmake_config-ix.cmake b/compiler-rt-ubsan/patches/patch-cmake_config-ix.cmake
deleted file mode 100644
index 5b3911a1ec..0000000000
--- a/compiler-rt-ubsan/patches/patch-cmake_config-ix.cmake
+++ /dev/null
@@ -1,22 +0,0 @@
-$NetBSD$
-
---- 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}")
-
- if (SANITIZER_COMMON_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND
-- (OS_NAME MATCHES "Android|Darwin|Linux|FreeBSD" OR
-+ (OS_NAME MATCHES "Android|Darwin|Linux|FreeBSD|NetBSD" OR
- (OS_NAME MATCHES "Windows" AND (NOT MINGW AND NOT CYGWIN))))
- set(COMPILER_RT_HAS_SANITIZER_COMMON TRUE)
- else()
-@@ -504,7 +504,7 @@ else()
- endif()
-
- if (COMPILER_RT_HAS_SANITIZER_COMMON AND UBSAN_SUPPORTED_ARCH AND
-- OS_NAME MATCHES "Darwin|Linux|FreeBSD|Windows|Android")
-+ OS_NAME MATCHES "Darwin|Linux|FreeBSD|NetBSD|Windows|Android")
- set(COMPILER_RT_HAS_UBSAN TRUE)
- else()
- set(COMPILER_RT_HAS_UBSAN FALSE)
diff --git a/compiler-rt-ubsan/patches/patch-lib_interception_interception.h b/compiler-rt-ubsan/patches/patch-lib_interception_interception.h
deleted file mode 100644
index 7faa04119b..0000000000
--- a/compiler-rt-ubsan/patches/patch-lib_interception_interception.h
+++ /dev/null
@@ -1,33 +0,0 @@
-$NetBSD$
-
---- lib/interception/interception.h.orig 2017-07-03 15:33:06.000000000 +0000
-+++ lib/interception/interception.h
-@@ -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)
- # 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, ...) \
- extern "C" __declspec(dllimport) ret_type __stdcall func(__VA_ARGS__);
--#elif defined(__FreeBSD__)
-+#elif defined(__FreeBSD__) || defined(__NetBSD__)
- # define WRAP(x) __interceptor_ ## x
- # define WRAPPER_NAME(x) "__interceptor_" #x
- # define INTERCEPTOR_ATTRIBUTE __attribute__((visibility("default")))
-@@ -241,7 +241,7 @@ typedef unsigned long uptr; // NOLINT
-
- #define INCLUDED_FROM_INTERCEPTION_LIB
-
--#if defined(__linux__) || defined(__FreeBSD__)
-+#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
- # include "interception_linux.h"
- # define INTERCEPT_FUNCTION(func) INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)
- # define INTERCEPT_FUNCTION_VER(func, symver) \
diff --git a/compiler-rt-ubsan/patches/patch-lib_interception_interception__linux.cc b/compiler-rt-ubsan/patches/patch-lib_interception_interception__linux.cc
deleted file mode 100644
index 06d8d980c3..0000000000
--- a/compiler-rt-ubsan/patches/patch-lib_interception_interception__linux.cc
+++ /dev/null
@@ -1,39 +0,0 @@
-$NetBSD$
-
---- lib/interception/interception_linux.cc.orig 2017-07-03 15:33:06.000000000 +0000
-+++ lib/interception/interception_linux.cc
-@@ -12,14 +12,26 @@
- // Linux-specific interception methods.
- //===----------------------------------------------------------------------===//
-
--#if defined(__linux__) || defined(__FreeBSD__)
-+#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
- #include "interception.h"
-
- #include <dlfcn.h> // for dlsym() and dlvsym()
-
-+#ifdef __NetBSD__
-+static int mystrcmp(const char *s1, const char *s2) {
-+ while (*s1 == *s2++)
-+ if (*s1++ == 0) return (0);
-+ return (*(const unsigned char *)s1 - *(const unsigned char *)--s2);
-+}
-+#endif
-+
- namespace __interception {
- bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
- 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";
-+#endif
- *func_addr = (uptr)dlsym(RTLD_NEXT, func_name);
- return real == wrapper;
- }
-@@ -32,5 +44,4 @@ void *GetFuncAddrVer(const char *func_na
-
- } // namespace __interception
-
--
--#endif // __linux__ || __FreeBSD__
-+#endif // __linux__ || __FreeBSD__ || __NetBSD__
diff --git a/compiler-rt-ubsan/patches/patch-lib_interception_interception__linux.h b/compiler-rt-ubsan/patches/patch-lib_interception_interception__linux.h
deleted file mode 100644
index 0535469d53..0000000000
--- a/compiler-rt-ubsan/patches/patch-lib_interception_interception__linux.h
+++ /dev/null
@@ -1,19 +0,0 @@
-$NetBSD$
-
---- 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.
- //===----------------------------------------------------------------------===//
-
--#if defined(__linux__) || defined(__FreeBSD__)
-+#if defined(__linux__) || defined(__FreeBSD__) | defined(__NetBSD__)
-
- #if !defined(INCLUDED_FROM_INTERCEPTION_LIB)
- # error "interception_linux.h should be included from interception library only"
-@@ -44,4 +44,4 @@ void *GetFuncAddrVer(const char *func_na
- #endif // !defined(__ANDROID__)
-
- #endif // INTERCEPTION_LINUX_H
--#endif // __linux__ || __FreeBSD__
-+#endif // __linux__ || __FreeBSD__ || __NetBSD__
diff --git a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_CMakeLists.txt b/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_CMakeLists.txt
deleted file mode 100644
index 7fc326b105..0000000000
--- a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-$NetBSD$
-
---- lib/sanitizer_common/CMakeLists.txt.orig 2017-07-07 07:44:02.472208766 +0000
-+++ lib/sanitizer_common/CMakeLists.txt
-@@ -23,6 +23,7 @@ set(SANITIZER_SOURCES_NOTERMINATION
- sanitizer_procmaps_freebsd.cc
- sanitizer_procmaps_linux.cc
- sanitizer_procmaps_mac.cc
-+ sanitizer_procmaps_netbsd.cc
- sanitizer_stackdepot.cc
- sanitizer_stacktrace.cc
- sanitizer_stacktrace_printer.cc
diff --git a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__internal__defs.h b/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__internal__defs.h
deleted file mode 100644
index 35fdb035cb..0000000000
--- a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__internal__defs.h
+++ /dev/null
@@ -1,15 +0,0 @@
-$NetBSD$
-
---- lib/sanitizer_common/sanitizer_internal_defs.h.orig 2017-07-03 15:33:06.000000000 +0000
-+++ lib/sanitizer_common/sanitizer_internal_defs.h
-@@ -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__))
- typedef u64 OFF_T;
- #else
- typedef uptr OFF_T;
diff --git a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__libignore.cc b/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__libignore.cc
deleted file mode 100644
index 464bd0d300..0000000000
--- a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__libignore.cc
+++ /dev/null
@@ -1,19 +0,0 @@
-$NetBSD$
-
---- 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 @@
-
- #include "sanitizer_platform.h"
-
--#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_MAC
-+#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_MAC || SANITIZER_NETBSD
-
- #include "sanitizer_libignore.h"
- #include "sanitizer_flags.h"
-@@ -125,4 +125,4 @@ void LibIgnore::OnLibraryUnloaded() {
-
- } // namespace __sanitizer
-
--#endif // #if SANITIZER_FREEBSD || SANITIZER_LINUX
-+#endif // #if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
diff --git a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__linux.cc b/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__linux.cc
deleted file mode 100644
index 7f63b47a97..0000000000
--- a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__linux.cc
+++ /dev/null
@@ -1,347 +0,0 @@
-$NetBSD$
-
---- lib/sanitizer_common/sanitizer_linux.cc.orig 2017-07-07 07:44:02.473579496 +0000
-+++ lib/sanitizer_common/sanitizer_linux.cc
-@@ -14,7 +14,7 @@
-
- #include "sanitizer_platform.h"
-
--#if SANITIZER_FREEBSD || SANITIZER_LINUX
-+#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
-
- #include "sanitizer_common.h"
- #include "sanitizer_flags.h"
-@@ -27,10 +27,14 @@
- #include "sanitizer_stacktrace.h"
- #include "sanitizer_symbolizer.h"
-
--#if !SANITIZER_FREEBSD
-+#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
- #include <asm/param.h>
- #endif
-
-+#if SANITIZER_NETBSD
-+#include <lwp.h>
-+#endif
-+
- // For mips64, syscall(__NR_stat) fills the buffer in the 'struct kernel_stat'
- // format. Struct kernel_stat is defined as 'struct stat' in asm/stat.h. To
- // access stat from asm/stat.h, without conflicting with definition in
-@@ -79,6 +83,12 @@ extern "C" {
- extern char **environ; // provided by crt1
- #endif // SANITIZER_FREEBSD
-
-+#if SANITIZER_NETBSD
-+#include <limits.h> // For NAME_MAX
-+#include <sys/sysctl.h>
-+extern char **environ; // provided by crt1
-+#endif // SANITIZER_NETBSD
-+
- #if !SANITIZER_ANDROID
- #include <sys/signal.h>
- #endif
-@@ -139,7 +149,10 @@ namespace __sanitizer {
- #if !SANITIZER_S390
- 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
-+ 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
-@@ -182,26 +195,39 @@ uptr internal_open(const char *filename,
-
- uptr internal_read(fd_t fd, void *buf, uptr count) {
- sptr res;
-+#if 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,
- count));
-+#endif
- return res;
- }
-
- uptr internal_write(fd_t fd, const void *buf, uptr count) {
- sptr res;
-+#if SANITIZER_NETBSD
-+ HANDLE_EINTR(res, internal_syscall_ptr(SYSCALL(write), fd, buf, count));
-+#else
- HANDLE_EINTR(res, (sptr)internal_syscall(SYSCALL(write), fd, (uptr)buf,
- count));
-+#endif
- return res;
- }
-
- uptr internal_ftruncate(fd_t fd, uptr size) {
- sptr res;
-+#if SANITIZER_NETBSD
-+ HANDLE_EINTR(res, internal_syscall(SYSCALL(ftruncate), fd, 0, (s64)size));
-+#else
- HANDLE_EINTR(res, (sptr)internal_syscall(SYSCALL(ftruncate), fd,
- (OFF_T)size));
-+#endif
- return res;
- }
-
--#if !SANITIZER_LINUX_USES_64BIT_SYSCALLS && !SANITIZER_FREEBSD
-+#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;
-@@ -242,7 +268,7 @@ static void kernel_stat_to_stat(struct k
- #endif
-
- uptr internal_stat(const char *path, void *buf) {
--#if SANITIZER_FREEBSD
-+#if SANITIZER_FREEBSD || SANITIZER_NETBSD
- return internal_syscall(SYSCALL(fstatat), AT_FDCWD, (uptr)path,
- (uptr)buf, 0);
- #elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
-@@ -267,7 +293,9 @@ uptr internal_stat(const char *path, voi
- }
-
- uptr internal_lstat(const char *path, void *buf) {
--#if SANITIZER_FREEBSD
-+#if SANITIZER_NETBSD
-+ return internal_syscall(SYSCALL(lstat), path, buf);
-+#elif SANITIZER_FREEBSD
- return internal_syscall(SYSCALL(fstatat), AT_FDCWD, (uptr)path,
- (uptr)buf, AT_SYMLINK_NOFOLLOW);
- #elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
-@@ -292,7 +320,7 @@ uptr internal_lstat(const char *path, vo
- }
-
- uptr internal_fstat(fd_t fd, void *buf) {
--#if SANITIZER_FREEBSD || SANITIZER_LINUX_USES_64BIT_SYSCALLS
-+#if SANITIZER_FREEBSD || SANITIZER_LINUX_USES_64BIT_SYSCALLS || SANITIZER_NETBSD
- # if SANITIZER_MIPS64
- // For mips64, fstat syscall fills buffer in the format of kernel_stat
- struct kernel_stat kbuf;
-@@ -326,7 +354,9 @@ uptr internal_dup2(int oldfd, int newfd)
- }
-
- uptr internal_readlink(const char *path, char *buf, uptr bufsize) {
--#if SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
-+#if SANITIZER_NETBSD
-+ return internal_syscall_ptr(SYSCALL(readlink), path, buf, bufsize);
-+#elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
- return internal_syscall(SYSCALL(readlinkat), AT_FDCWD,
- (uptr)path, (uptr)buf, bufsize);
- #else
-@@ -356,7 +386,7 @@ uptr internal_sched_yield() {
- }
-
- void internal__exit(int exitcode) {
--#if SANITIZER_FREEBSD
-+#if SANITIZER_FREEBSD || SANITIZER_NETBSD
- internal_syscall(SYSCALL(exit), exitcode);
- #else
- internal_syscall(SYSCALL(exit_group), exitcode);
-@@ -395,19 +425,25 @@ bool FileExists(const char *filename) {
- tid_t GetTid() {
- #if SANITIZER_FREEBSD
- return (uptr)pthread_self();
-+#elif SANITIZER_NETBSD
-+ return _lwp_self();
- #else
- return internal_syscall(SYSCALL(gettid));
- #endif
- }
-
- u64 NanoTime() {
--#if SANITIZER_FREEBSD
-+#if SANITIZER_FREEBSD || SANITIZER_NETBSD
- timeval tv;
- #else
- kernel_timeval tv;
- #endif
- internal_memset(&tv, 0, sizeof(tv));
-+#if SANITIZER_NETBSD
-+ internal_syscall(SYSCALL(gettimeofday), &tv, NULL);
-+#else
- internal_syscall(SYSCALL(gettimeofday), (uptr)&tv, 0);
-+#endif
- return (u64)tv.tv_sec * 1000*1000*1000 + tv.tv_usec * 1000;
- }
-
-@@ -415,7 +451,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) {
--#if SANITIZER_FREEBSD
-+#if SANITIZER_FREEBSD || SANITIZER_NETBSD
- if (::environ != 0) {
- uptr NameLen = internal_strlen(name);
- for (char **Env = ::environ; *Env != 0; Env++) {
-@@ -549,6 +585,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);
-+#elif SANITIZER_NETBSD
-+ sched_yield(); /* No userspace futex-like synchromization */
- #else
- internal_syscall(SYSCALL(futex), (uptr)m, FUTEX_WAIT, MtxSleeping, 0, 0, 0);
- #endif
-@@ -562,6 +600,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 */
- #else
- internal_syscall(SYSCALL(futex), (uptr)m, FUTEX_WAKE, 1, 0, 0, 0);
- #endif
-@@ -577,6 +617,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.
-+#if SANITIZER_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
-+ char d_name[NAME_MAX + 1];
-+};
-+#else
- struct linux_dirent {
- #if SANITIZER_X32 || defined(__aarch64__)
- u64 d_ino;
-@@ -591,16 +642,34 @@ struct linux_dirent {
- #endif
- char d_name[256];
- };
-+#endif
-
- // 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.
-+ return internal_syscall_ptr(SYSCALL(ptrace), request, pid, (uptr)addr,
-+ (uptr)data);
-+#else
- return internal_syscall(SYSCALL(ptrace), request, pid, (uptr)addr,
- (uptr)data);
-+#endif
- }
-
- uptr internal_waitpid(int pid, int *status, int options) {
-+#if SANITIZER_NETBSD
-+ return internal_syscall(SYSCALL(wait4), pid, status, options,
-+ NULL /* rusage */);
-+#else
- return internal_syscall(SYSCALL(wait4), pid, (uptr)status, options,
- 0 /* rusage */);
-+#endif
- }
-
- uptr internal_getpid() {
-@@ -612,7 +681,9 @@ uptr internal_getppid() {
- }
-
- uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count) {
--#if SANITIZER_FREEBSD
-+#if SANITIZER_NETBSD
-+ return internal_syscall(SYSCALL(getdents), fd, dirp, (uptr)count);
-+#elif SANITIZER_FREEBSD
- 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);
-@@ -622,7 +693,11 @@ uptr internal_getdents(fd_t fd, struct l
- }
-
- uptr internal_lseek(fd_t fd, OFF_T offset, int whence) {
-+#if SANITIZER_NETBSD
-+ return internal_syscall64(SYSCALL(lseek), fd, 0, offset, whence);
-+#else
- return internal_syscall(SYSCALL(lseek), fd, offset, whence);
-+#endif
- }
-
- #if SANITIZER_LINUX
-@@ -714,7 +789,7 @@ int internal_sigaction_syscall(int signu
-
- uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set,
- __sanitizer_sigset_t *oldset) {
--#if SANITIZER_FREEBSD
-+#if SANITIZER_FREEBSD || SANITIZER_NETBSD
- return internal_syscall(SYSCALL(sigprocmask), how, set, oldset);
- #else
- __sanitizer_kernel_sigset_t *k_set = (__sanitizer_kernel_sigset_t *)set;
-@@ -863,7 +938,9 @@ static uptr GetKernelAreaSize() {
- #endif // SANITIZER_WORDSIZE == 32
-
- uptr GetMaxVirtualAddress() {
--#if SANITIZER_WORDSIZE == 64
-+#if SANITIZER_NETBSD && defined(__x86_64__)
-+ return 0x7f7ffffff000ULL; // (0x00007f8000000000 - PAGE_SIZE)
-+#elif SANITIZER_WORDSIZE == 64
- # if defined(__powerpc64__) || defined(__aarch64__)
- // On PowerPC64 we have two different address space layouts: 44- and 46-bit.
- // We somehow need to figure out which one we are using now and choose
-@@ -907,8 +984,12 @@ uptr GetPageSize() {
- }
-
- uptr ReadBinaryName(/*out*/char *buf, uptr buf_len) {
-+#if SANITIZER_FREEBSD || SANITIZER_NETBSD
- #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);
-@@ -1552,6 +1633,8 @@ SignalContext::WriteFlag SignalContext::
- static const uptr PF_WRITE = 1U << 1;
- #if SANITIZER_FREEBSD
- uptr err = ucontext->uc_mcontext.mc_err;
-+#elif SANITIZER_NETBSD
-+ uptr err = ucontext->uc_mcontext.__gregs[_REG_ERR];
- #else
- uptr err = ucontext->uc_mcontext.gregs[REG_ERR];
- #endif
-@@ -1598,6 +1681,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;
-+ *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];
-@@ -1610,6 +1698,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;
-+ *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];
-@@ -1710,4 +1803,4 @@ bool GetRandom(void *buffer, uptr length
-
- } // namespace __sanitizer
-
--#endif // SANITIZER_FREEBSD || SANITIZER_LINUX
-+#endif // SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
diff --git a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__linux.h b/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__linux.h
deleted file mode 100644
index 2f3913ce2e..0000000000
--- a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__linux.h
+++ /dev/null
@@ -1,20 +0,0 @@
-$NetBSD$
-
---- 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
-
- #include "sanitizer_platform.h"
--#if SANITIZER_FREEBSD || SANITIZER_LINUX
-+#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
- #include "sanitizer_common.h"
- #include "sanitizer_internal_defs.h"
- #include "sanitizer_posix.h"
-@@ -130,5 +130,5 @@ ALWAYS_INLINE uptr *get_android_tls_ptr(
-
- } // namespace __sanitizer
-
--#endif // SANITIZER_FREEBSD || SANITIZER_LINUX
-+#endif // SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
- #endif // SANITIZER_LINUX_H
diff --git a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__linux__libcdep.cc b/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__linux__libcdep.cc
deleted file mode 100644
index 09c4cbe10e..0000000000
--- a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__linux__libcdep.cc
+++ /dev/null
@@ -1,70 +0,0 @@
-$NetBSD$
-
---- lib/sanitizer_common/sanitizer_linux_libcdep.cc.orig 2017-07-03 15:33:06.000000000 +0000
-+++ lib/sanitizer_common/sanitizer_linux_libcdep.cc
-@@ -14,7 +14,7 @@
-
- #include "sanitizer_platform.h"
-
--#if SANITIZER_FREEBSD || SANITIZER_LINUX
-+#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
-
- #include "sanitizer_allocator_internal.h"
- #include "sanitizer_atomic.h"
-@@ -22,6 +22,7 @@
- #include "sanitizer_flags.h"
- #include "sanitizer_freebsd.h"
- #include "sanitizer_linux.h"
-+#include "sanitizer_netbsd.h"
- #include "sanitizer_placement_new.h"
- #include "sanitizer_procmaps.h"
- #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
- static uptr g_tls_size;
-
- #ifdef __i386__
-@@ -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
-
- #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) \
- || defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) \
-@@ -336,6 +339,10 @@ uptr ThreadSelf() {
- }
- #endif // SANITIZER_FREEBSD
-
-+#if SANITIZER_NETBSD
-+uptr ThreadSelf() { return (uptr)pthread_self(); }
-+#endif // SANITIZER_NETBSD
-+
- #if !SANITIZER_GO
- static void GetTls(uptr *addr, uptr *size) {
- #if SANITIZER_LINUX && !SANITIZER_ANDROID
-@@ -365,7 +372,7 @@ static void GetTls(uptr *addr, uptr *siz
- *addr = (uptr) dtv[2];
- *size = (*addr == 0) ? 0 : ((uptr) segbase[0] - (uptr) dtv[2]);
- }
--#elif SANITIZER_ANDROID
-+#elif SANITIZER_ANDROID || SANITIZER_NETBSD
- *addr = 0;
- *size = 0;
- #else
-@@ -376,7 +383,7 @@ static void GetTls(uptr *addr, uptr *siz
-
- #if !SANITIZER_GO
- uptr GetTlsSize() {
--#if SANITIZER_FREEBSD || SANITIZER_ANDROID
-+#if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NETBSD
- uptr addr, size;
- GetTls(&addr, &size);
- return size;
diff --git a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__netbsd.h b/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__netbsd.h
deleted file mode 100644
index 37bfd9ea09..0000000000
--- a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__netbsd.h
+++ /dev/null
@@ -1,25 +0,0 @@
-$NetBSD$
-
---- lib/sanitizer_common/sanitizer_netbsd.h.orig 2017-07-07 07:50:25.380441934 +0000
-+++ lib/sanitizer_common/sanitizer_netbsd.h
-@@ -0,0 +1,20 @@
-+//===-- sanitizer_freebsd.h -------------------------------------*- C++ -*-===//
-+//
-+// The LLVM Compiler Infrastructure
-+//
-+// This file is distributed under the University of Illinois Open Source
-+// License. See LICENSE.TXT for details.
-+//
-+//===----------------------------------------------------------------------===//
-+//
-+// This file is a part of Sanitizer runtime. It contains NetBSD-specific
-+// definitions.
-+//
-+//===----------------------------------------------------------------------===//
-+
-+#ifndef SANITIZER_NETBSD_H
-+#define SANITIZER_NETBSD_H
-+
-+#include "sanitizer_internal_defs.h"
-+
-+#endif // SANITIZER_NETBSD_H
diff --git a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__platform.h b/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__platform.h
deleted file mode 100644
index 41e30222d2..0000000000
--- a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__platform.h
+++ /dev/null
@@ -1,38 +0,0 @@
-$NetBSD$
-
---- lib/sanitizer_common/sanitizer_platform.h.orig 2017-07-03 15:33:06.000000000 +0000
-+++ lib/sanitizer_common/sanitizer_platform.h
-@@ -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)
- # error "This operating system is not supported"
- #endif
-
-@@ -30,6 +30,12 @@
- # define SANITIZER_FREEBSD 0
- #endif
-
-+#if defined(__NetBSD__)
-+#define SANITIZER_NETBSD 1
-+#else
-+#define SANITIZER_NETBSD 0
-+#endif
-+
- #if defined(__APPLE__)
- # define SANITIZER_MAC 1
- # include <TargetConditionals.h>
-@@ -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)
-
- #if __LP64__ || defined(_WIN64)
- # define SANITIZER_WORDSIZE 64
diff --git a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__platform__interceptors.h b/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__platform__interceptors.h
deleted file mode 100644
index 453404f73d..0000000000
--- a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__platform__interceptors.h
+++ /dev/null
@@ -1,251 +0,0 @@
-$NetBSD$
-
---- 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
-+#else
-+#define SI_NETBSD 0
-+#endif
-+
- #if SANITIZER_LINUX
- # define SI_LINUX 1
- #else
-@@ -111,7 +117,7 @@
- #define SANITIZER_INTERCEPT_MEMMEM \
- SI_NOT_WINDOWS && !SI_MAC_DEPLOYMENT_BELOW_10_7
- #define SANITIZER_INTERCEPT_MEMCHR 1
--#define SANITIZER_INTERCEPT_MEMRCHR SI_FREEBSD || SI_LINUX
-+#define SANITIZER_INTERCEPT_MEMRCHR SI_FREEBSD || SI_LINUX || SI_NETBSD
-
- #define SANITIZER_INTERCEPT_READ SI_NOT_WINDOWS
- #define SANITIZER_INTERCEPT_PREAD SI_NOT_WINDOWS
-@@ -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_PWRITEV SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_PREADV64 SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_PWRITEV64 SI_LINUX_NOT_ANDROID
-@@ -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_ISOC99_PRINTF SI_LINUX_NOT_ANDROID
- #endif
-
-@@ -151,13 +158,14 @@
-
- #define SANITIZER_INTERCEPT_GETPWNAM_AND_FRIENDS SI_NOT_WINDOWS
- #define SANITIZER_INTERCEPT_GETPWNAM_R_AND_FRIENDS \
-- SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID
-+ SI_FREEBSD || SI_NETBSD || SI_MAC || SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_GETPWENT \
-- SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID
-+ 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_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 +208,43 @@
- #define SANITIZER_INTERCEPT_MBSNRTOWCS SI_MAC || SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_WCSTOMBS SI_NOT_WINDOWS
- #define SANITIZER_INTERCEPT_WCSNRTOMBS \
-- SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID
-+ SI_FREEBSD || SI_NETBSD || SI_MAC || SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_WCRTOMB \
-- SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID
-+ SI_FREEBSD || SI_NETBSD || SI_MAC || SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_TCGETATTR SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_REALPATH SI_NOT_WINDOWS
- #define SANITIZER_INTERCEPT_CANONICALIZE_FILE_NAME SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_CONFSTR \
-- SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID
-+ SI_FREEBSD || SI_NETBSD || SI_MAC || SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_SCHED_GETAFFINITY SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_SCHED_GETPARAM SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_STRERROR SI_NOT_WINDOWS
- #define SANITIZER_INTERCEPT_STRERROR_R SI_NOT_WINDOWS
- #define SANITIZER_INTERCEPT_XPG_STRERROR_R SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_SCANDIR \
-- SI_FREEBSD || SI_LINUX_NOT_ANDROID
-+ SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_SCANDIR64 SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_GETGROUPS SI_NOT_WINDOWS
- #define SANITIZER_INTERCEPT_POLL SI_NOT_WINDOWS
- #define SANITIZER_INTERCEPT_PPOLL SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_WORDEXP \
-- SI_FREEBSD || (SI_MAC && !SI_IOS) || SI_LINUX_NOT_ANDROID
-+ SI_FREEBSD || SI_NETBSD || (SI_MAC && !SI_IOS) || SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_SIGWAIT SI_NOT_WINDOWS
- #define SANITIZER_INTERCEPT_SIGWAITINFO SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_SIGTIMEDWAIT SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_SIGSETOPS \
-- SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID
-+ SI_FREEBSD || SI_NETBSD || SI_MAC || SI_LINUX_NOT_ANDROID
- #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_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_STATVFS64 SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_INITGROUPS SI_NOT_WINDOWS
- #define SANITIZER_INTERCEPT_ETHER_NTOA_ATON SI_NOT_WINDOWS
-@@ -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)
- #define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_NOT_WINDOWS
- #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GETINHERITSCHED \
-- SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID
-+ SI_FREEBSD || SI_NETBSD || SI_MAC || SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_PTHREAD_ATTR_GETAFFINITY_NP SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETPSHARED SI_NOT_WINDOWS
- #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETTYPE SI_NOT_WINDOWS
- #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETPROTOCOL \
-- SI_MAC || SI_LINUX_NOT_ANDROID
-+ SI_MAC || SI_NETBSD || SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_PTHREAD_MUTEXATTR_GETPRIOCEILING \
-- SI_MAC || SI_LINUX_NOT_ANDROID
-+ SI_MAC || SI_NETBSD || SI_LINUX_NOT_ANDROID
- #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 +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_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__EXIT SI_LINUX || SI_FREEBSD || SI_MAC
-+#define SANITIZER_INTERCEPT__EXIT SI_LINUX || SI_FREEBSD || SI_NETBSD || SI_MAC
-
- #define SANITIZER_INTERCEPT_PHTREAD_MUTEX SI_NOT_WINDOWS
- #define SANITIZER_INTERCEPT_PTHREAD_SETNAME_NP \
-- SI_FREEBSD || SI_LINUX_NOT_ANDROID
-+ SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID
-
- #define SANITIZER_INTERCEPT_TLS_GET_ADDR \
-- SI_FREEBSD || SI_LINUX_NOT_ANDROID
-+ SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID
-
- #define SANITIZER_INTERCEPT_LISTXATTR SI_LINUX
- #define SANITIZER_INTERCEPT_GETXATTR SI_LINUX
- #define SANITIZER_INTERCEPT_GETRESID SI_LINUX
- #define SANITIZER_INTERCEPT_GETIFADDRS \
-- SI_FREEBSD || SI_LINUX_NOT_ANDROID || SI_MAC
-+ SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID || SI_MAC
- #define SANITIZER_INTERCEPT_IF_INDEXTONAME \
-- SI_FREEBSD || SI_LINUX_NOT_ANDROID || SI_MAC
-+ SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID || SI_MAC
- #define SANITIZER_INTERCEPT_CAPGET SI_LINUX_NOT_ANDROID
- #if SI_LINUX && defined(__arm__)
- #define SANITIZER_INTERCEPT_AEABI_MEM 1
-@@ -302,32 +315,33 @@
- #define SANITIZER_INTERCEPT_AEABI_MEM 0
- #endif
- #define SANITIZER_INTERCEPT___BZERO SI_MAC
--#define SANITIZER_INTERCEPT_FTIME !SI_FREEBSD && SI_NOT_WINDOWS
-+#define SANITIZER_INTERCEPT_FTIME !SI_FREEBSD && !SI_NETBSD && SI_NOT_WINDOWS
- #define SANITIZER_INTERCEPT_XDR SI_LINUX_NOT_ANDROID
--#define SANITIZER_INTERCEPT_TSEARCH SI_LINUX_NOT_ANDROID || SI_MAC
-+#define SANITIZER_INTERCEPT_TSEARCH SI_LINUX_NOT_ANDROID || SI_MAC || SI_NETBSD
- #define SANITIZER_INTERCEPT_LIBIO_INTERNALS SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_FOPEN SI_NOT_WINDOWS
- #define SANITIZER_INTERCEPT_FOPEN64 SI_LINUX_NOT_ANDROID
--#define SANITIZER_INTERCEPT_OPEN_MEMSTREAM SI_LINUX_NOT_ANDROID
-+#define SANITIZER_INTERCEPT_OPEN_MEMSTREAM SI_LINUX_NOT_ANDROID || SI_NETBSD
- #define SANITIZER_INTERCEPT_OBSTACK SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT_FFLUSH SI_NOT_WINDOWS
- #define SANITIZER_INTERCEPT_FCLOSE SI_NOT_WINDOWS
-
- #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
- #endif
-
--#define SANITIZER_INTERCEPT_GETPASS SI_LINUX_NOT_ANDROID || SI_MAC
-+#define SANITIZER_INTERCEPT_GETPASS SI_LINUX_NOT_ANDROID || SI_MAC || SI_NETBSD
- #define SANITIZER_INTERCEPT_TIMERFD SI_LINUX_NOT_ANDROID
-
- #define SANITIZER_INTERCEPT_MLOCKX SI_NOT_WINDOWS
- #define SANITIZER_INTERCEPT_FOPENCOOKIE SI_LINUX_NOT_ANDROID
--#define SANITIZER_INTERCEPT_SEM SI_LINUX || SI_FREEBSD
-+#define SANITIZER_INTERCEPT_SEM SI_LINUX || SI_FREEBSD || SI_NETBSD
- #define SANITIZER_INTERCEPT_PTHREAD_SETCANCEL SI_NOT_WINDOWS
--#define SANITIZER_INTERCEPT_MINCORE SI_LINUX
-+#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_R SI_MAC || SI_FREEBSD
-
- #define SANITIZER_INTERCEPTOR_HOOKS SI_LINUX || SI_MAC || SI_WINDOWS
-@@ -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___XSTAT !SANITIZER_INTERCEPT_STAT && SI_NOT_WINDOWS
- #define SANITIZER_INTERCEPT___XSTAT64 SI_LINUX_NOT_ANDROID
- #define SANITIZER_INTERCEPT___LXSTAT SANITIZER_INTERCEPT___XSTAT
-@@ -345,12 +360,13 @@
- #define SANITIZER_INTERCEPT_UTMPX SI_LINUX_NOT_ANDROID || SI_MAC || SI_FREEBSD
-
- #define SANITIZER_INTERCEPT_GETLOADAVG \
-- SI_LINUX_NOT_ANDROID || SI_MAC || SI_FREEBSD
-+ SI_LINUX_NOT_ANDROID || SI_MAC || SI_FREEBSD || SI_NETBSD
-
--#define SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO (!SI_FREEBSD && !SI_MAC)
--#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_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)
- #define SANITIZER_INTERCEPT_ALIGNED_ALLOC (!SI_MAC)
- #define SANITIZER_INTERCEPT_MALLOC_USABLE_SIZE (!SI_MAC)
- #define SANITIZER_INTERCEPT_MCHECK_MPROBE SI_LINUX_NOT_ANDROID
diff --git a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.cc b/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.cc
deleted file mode 100644
index 5534e22434..0000000000
--- a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.cc
+++ /dev/null
@@ -1,253 +0,0 @@
-$NetBSD$
-
---- lib/sanitizer_common/sanitizer_platform_limits_posix.cc.orig 2017-07-07 07:44:02.474052842 +0000
-+++ lib/sanitizer_common/sanitizer_platform_limits_posix.cc
-@@ -14,7 +14,7 @@
-
- #include "sanitizer_platform.h"
-
--#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC
-+#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC || SANITIZER_NETBSD
- // Tests in this file assume that off_t-dependent data structures match the
- // libc ABI. For example, struct dirent here is what readdir() function (as
- // exported from libc) returns, and not the user-facing "dirent", which
-@@ -78,7 +78,7 @@
- #include <net/if_arp.h>
- #endif
-
--#if SANITIZER_FREEBSD
-+#if SANITIZER_FREEBSD || SANITIZER_NETBSD
- # include <sys/mount.h>
- # include <sys/sockio.h>
- # include <sys/socket.h>
-@@ -93,16 +93,18 @@
- # include <sys/statvfs.h>
- # include <sys/soundcard.h>
- # include <sys/mtio.h>
--# include <sys/consio.h>
--# include <sys/kbio.h>
--# include <sys/link_elf.h>
- # include <netinet/ip_mroute.h>
- # include <netinet/in.h>
--# include <net/ethernet.h>
- # include <net/ppp_defs.h>
- # include <glob.h>
- # include <term.h>
-+#endif
-
-+#if SANITIZER_FREEBSD
-+#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
-@@ -110,11 +112,19 @@
- #undef INLINE // to avoid clashes with sanitizers' definitions
- #endif
-
--#if SANITIZER_FREEBSD || SANITIZER_IOS
-+#if SANITIZER_NETBSD
-+#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
- #undef IOC_DIRMASK
- #endif
-
--#if SANITIZER_LINUX || SANITIZER_FREEBSD
-+#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
- # include <utime.h>
- # include <sys/ptrace.h>
- # if defined(__mips64) || defined(__aarch64__) || defined(__arm__)
-@@ -199,9 +209,9 @@ typedef struct user_fpregs elf_fpregset_
- namespace __sanitizer {
- 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
- unsigned struct_stat64_sz = sizeof(struct stat64);
--#endif // !SANITIZER_IOS && !SANITIZER_FREEBSD
-+#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);
-@@ -244,12 +254,12 @@ namespace __sanitizer {
- unsigned struct_oldold_utsname_sz = sizeof(struct oldold_utsname);
- #endif // SANITIZER_LINUX
-
--#if SANITIZER_LINUX || SANITIZER_FREEBSD
-+#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
- unsigned struct_rlimit_sz = sizeof(struct rlimit);
- unsigned struct_timespec_sz = sizeof(struct timespec);
- 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
-
- #if SANITIZER_LINUX && !SANITIZER_ANDROID
- unsigned struct_ustat_sz = sizeof(struct ustat);
-@@ -257,12 +267,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
- 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
-
- uptr sig_ign = (uptr)SIG_IGN;
- uptr sig_dfl = (uptr)SIG_DFL;
-@@ -272,10 +284,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
- unsigned struct_shminfo_sz = sizeof(struct shminfo);
-+#if !SANITIZER_NETBSD
- unsigned struct_shm_info_sz = sizeof(struct shm_info);
-+#else
-+#define IPC_INFO -1
-+#define SHM_INFO -1
-+#define SHM_STAT -1
-+ unsigned struct_shm_info_sz = -1;
-+#endif
- int shmctl_ipc_stat = (int)IPC_STAT;
- int shmctl_ipc_info = (int)IPC_INFO;
- int shmctl_shm_info = (int)SHM_INFO;
-@@ -309,9 +328,10 @@ unsigned struct_ElfW_Phdr_sz = sizeof(El
- unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
- #endif
-
--#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
-- 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
-
- #if SANITIZER_LINUX && !SANITIZER_ANDROID && \
-@@ -451,7 +471,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
-
- #if SANITIZER_LINUX && !SANITIZER_ANDROID
- unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct);
-@@ -478,7 +498,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
- 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
-@@ -534,7 +555,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)
- unsigned IOCTL_SIOCGETSGCNT = SIOCGETSGCNT;
- unsigned IOCTL_SIOCGETVIFCNT = SIOCGETVIFCNT;
- #endif
-@@ -966,7 +988,7 @@ COMPILER_CHECK(IOC_NR(0x12345678) == _IO
- COMPILER_CHECK(IOC_TYPE(0x12345678) == _IOC_TYPE(0x12345678));
- #endif // SANITIZER_LINUX
-
--#if SANITIZER_LINUX || SANITIZER_FREEBSD
-+#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_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));
-@@ -974,9 +996,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
-
--#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !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);
-@@ -1028,7 +1051,7 @@ COMPILER_CHECK(sizeof(__sanitizer_dirent
- CHECK_SIZE_AND_OFFSET(dirent, d_ino);
- #if SANITIZER_MAC
- CHECK_SIZE_AND_OFFSET(dirent, d_seekoff);
--#elif SANITIZER_FREEBSD
-+#elif SANITIZER_FREEBSD || SANITIZER_NETBSD
- // There is no 'd_off' field on FreeBSD.
- #else
- CHECK_SIZE_AND_OFFSET(dirent, d_off);
-@@ -1125,11 +1148,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
- 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
-+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);
-@@ -1166,20 +1193,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);
--#if SANITIZER_LINUX || SANITIZER_FREEBSD
-+#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
- // Compare against the union, because we can't reach into the union in a
- // compliant way.
- #ifdef ifa_dstaddr
- #undef ifa_dstaddr
- #endif
--# if SANITIZER_FREEBSD
-+#if SANITIZER_FREEBSD || SANITIZER_NETBSD
- CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr);
- # else
- COMPILER_CHECK(sizeof(((__sanitizer_ifaddrs *)nullptr)->ifa_dstaddr) ==
- sizeof(((ifaddrs *)nullptr)->ifa_ifu));
- COMPILER_CHECK(offsetof(__sanitizer_ifaddrs, ifa_dstaddr) ==
- offsetof(ifaddrs, ifa_ifu));
--# endif // SANITIZER_FREEBSD
-+#endif // SANITIZER_FREEBSD || SANITIZER_NETBSD
- #else
- CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr);
- #endif // SANITIZER_LINUX
-@@ -1280,4 +1307,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
diff --git a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.h b/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.h
deleted file mode 100644
index 8f6bc9a3a0..0000000000
--- a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.h
+++ /dev/null
@@ -1,700 +0,0 @@
-$NetBSD$
-
---- lib/sanitizer_common/sanitizer_platform_limits_posix.h.orig 2017-07-07 07:44:02.474288555 +0000
-+++ lib/sanitizer_common/sanitizer_platform_limits_posix.h
-@@ -18,18 +18,31 @@
- #include "sanitizer_internal_defs.h"
- #include "sanitizer_platform.h"
-
-+// FreeBSD's and NetBSD's dlopen() returns a pointer to an Obj_Entry structure
-+// that incorporates the map structure.
- #if SANITIZER_FREEBSD
--// FreeBSD's dlopen() returns a pointer to an Obj_Entry structure that
--// incorporates the map structure.
- # define GET_LINK_MAP_BY_DLOPEN_HANDLE(handle) \
- ((link_map*)((handle) == nullptr ? nullptr : ((char*)(handle) + 544)))
--// Get sys/_types.h, because that tells us whether 64-bit inodes are
--// used in struct dirent below.
--#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)))
-+#elif defined(__i386__)
-+#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
- #else
- # define GET_LINK_MAP_BY_DLOPEN_HANDLE(handle) ((link_map*)(handle))
- #endif // !SANITIZER_FREEBSD
-
-+#if SANITIZER_FREEBSD
-+// Get sys/_types.h, because that tells us whether 64-bit inodes are
-+// used in struct dirent below.
-+#include <sys/_types.h>
-+#endif
-+
- #ifndef __GLIBC_PREREQ
- #define __GLIBC_PREREQ(x, y) 0
- #endif
-@@ -37,7 +50,7 @@
- namespace __sanitizer {
- extern unsigned struct_utsname_sz;
- extern unsigned struct_stat_sz;
--#if !SANITIZER_FREEBSD && !SANITIZER_IOS
-+#if !SANITIZER_FREEBSD && !SANITIZER_IOS && !SANITIZER_NETBSD
- extern unsigned struct_stat64_sz;
- #endif
- extern unsigned struct_rusage_sz;
-@@ -55,10 +68,14 @@ namespace __sanitizer {
- extern unsigned struct_itimerspec_sz;
- extern unsigned struct_sigevent_sz;
- extern unsigned struct_sched_param_sz;
-+#if !SANITIZER_NETBSD
- extern unsigned struct_statfs64_sz;
-+#endif
-
- #if !SANITIZER_ANDROID
-+#if !SANITIZER_NETBSD
- extern unsigned struct_statfs_sz;
-+#endif
- extern unsigned struct_sockaddr_sz;
- extern unsigned ucontext_t_sz;
- #endif // !SANITIZER_ANDROID
-@@ -121,18 +138,21 @@ namespace __sanitizer {
- #endif // SANITIZER_LINUX
-
- #if SANITIZER_LINUX || SANITIZER_FREEBSD
--
- #if defined(__powerpc64__) || defined(__s390__)
- const unsigned struct___old_kernel_stat_sz = 0;
- #elif !defined(__sparc__)
- const unsigned struct___old_kernel_stat_sz = 32;
- #endif
-+#endif // SANITIZER_LINUX || SANITIZER_FREEBSD
-+
-+#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
-
- extern unsigned struct_rlimit_sz;
- extern unsigned struct_utimbuf_sz;
- extern unsigned struct_timespec_sz;
-
- struct __sanitizer_iocb {
-+#if SANITIZER_LINUX || SANITIZER_FREEBSD
- u64 aio_data;
- u32 aio_key_or_aio_reserved1; // Simply crazy.
- u32 aio_reserved1_or_aio_key; // Luckily, we don't need these.
-@@ -144,21 +164,54 @@ namespace __sanitizer {
- s64 aio_offset;
- u64 aio_reserved2;
- 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;
-+#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;
-+#else
-+#error port this to your platform
-+#endif
-+#endif
- };
-+#endif
-
-+#if SANITIZER_LINUX || SANITIZER_FREEBSD
- struct __sanitizer_io_event {
- u64 data;
- u64 obj;
- u64 res;
- u64 res2;
- };
-+#endif
-
-+#if SANITIZER_LINUX || SANITIZER_FREEBSD
- const unsigned iocb_cmd_pread = 0;
- const unsigned iocb_cmd_pwrite = 1;
- const unsigned iocb_cmd_preadv = 7;
- const unsigned iocb_cmd_pwritev = 8;
-+#endif
-
- struct __sanitizer___sysctl_args {
-+#if SANITIZER_LINUX || SANITIZER_FREEBSD
- int *name;
- int nlen;
- void *oldval;
-@@ -166,10 +219,32 @@ namespace __sanitizer {
- void *newval;
- uptr newlen;
- unsigned long ___unused[4];
-+#else
-+#if defined(__x86_64__)
-+ 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;
-+#else
-+#error port this
-+#endif
-+#endif
- };
-
-+#if SANITIZER_LINUX || SANITIZER_FREEBSD
- const unsigned old_sigset_t_sz = sizeof(unsigned long);
-+#endif
-
-+#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
- struct __sanitizer_sem_t {
- #if SANITIZER_ANDROID && defined(_LP64)
- int data[4];
-@@ -179,9 +254,17 @@ namespace __sanitizer {
- uptr data[4];
- #elif SANITIZER_FREEBSD
- u32 data[4];
-+#elif SANITIZER_NETBSD
-+#if defined(__x86_64__)
-+ u8 data[40];
-+#elif defined(__i386__)
-+ u8 data[20];
-+#else
-+#error port this to your platform
-+#endif
- #endif
- };
--#endif // SANITIZER_LINUX || SANITIZER_FREEBSD
-+#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
-
- #if SANITIZER_ANDROID
- struct __sanitizer_mallinfo {
-@@ -324,14 +407,39 @@ namespace __sanitizer {
- unsigned long shm_dtime;
- unsigned long shm_ctime;
- };
-+
-+#elif SANITIZER_NETBSD
-+ struct __sanitizer_ipc_perm {
-+ u32 uid;
-+ u32 gid;
-+ u32 cuid;
-+ u32 cgid;
-+ u32 mode;
-+ unsigned short _seq;
-+ long _key;
-+ };
-+
-+ struct __sanitizer_shmid_ds {
-+ __sanitizer_ipc_perm shm_perm;
-+ unsigned long shm_segsz;
-+ u32 shm_lpid;
-+ u32 shm_cpid;
-+ unsigned int shm_nattch;
-+ u64 shm_atime;
-+ u64 shm_dtime;
-+ u64 shm_ctime;
-+ void *_shm_internal;
-+ };
- #endif
-
--#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !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
-
- struct __sanitizer_iovec {
- void *iov_base;
-@@ -351,6 +459,9 @@ namespace __sanitizer {
- # endif
- void *ifa_dstaddr; // (struct sockaddr *)
- void *ifa_data;
-+#if SANITIZER_NETBSD
-+ unsigned int ifa_addrflags;
-+#endif
- };
- #endif // !SANITIZER_ANDROID
-
-@@ -376,13 +487,24 @@ namespace __sanitizer {
- const int __sanitizer_XDR_FREE = 2;
- #endif
-
-+#if SANITIZER_NETBSD || (defined(__x86_64__) && !defined(_LP64))
-+ typedef long long __sanitizer_time_t;
-+#else
-+ typedef long __sanitizer_time_t;
-+#endif
-+
- struct __sanitizer_passwd {
- char *pw_name;
- char *pw_passwd;
-+#if SANITIZER_NETBSD
- int pw_uid;
- int pw_gid;
--#if SANITIZER_MAC || SANITIZER_FREEBSD
-- long pw_change;
-+#else
-+ u32 pw_uid;
-+ u32 pw_gid;
-+#endif
-+#if SANITIZER_MAC || SANITIZER_FREEBSD || SANITIZER_NETBSD
-+ __sanitizer_time_t pw_change;
- char *pw_class;
- #endif
- #if !(SANITIZER_ANDROID && (SANITIZER_WORDSIZE == 32))
-@@ -390,8 +512,8 @@ namespace __sanitizer {
- #endif
- char *pw_dir;
- char *pw_shell;
--#if SANITIZER_MAC || SANITIZER_FREEBSD
-- long pw_expire;
-+#if SANITIZER_MAC || SANITIZER_FREEBSD || SANITIZER_NETBSD
-+ __sanitizer_time_t pw_expire;
- #endif
- #if SANITIZER_FREEBSD
- int pw_fields;
-@@ -405,12 +527,6 @@ namespace __sanitizer {
- char **gr_mem;
- };
-
--#if defined(__x86_64__) && !defined(_LP64)
-- typedef long long __sanitizer_time_t;
--#else
-- typedef long __sanitizer_time_t;
--#endif
--
- struct __sanitizer_timeb {
- __sanitizer_time_t time;
- unsigned short millitm;
-@@ -447,7 +563,7 @@ namespace __sanitizer {
- };
- #endif
-
--#if SANITIZER_MAC || SANITIZER_FREEBSD
-+#if SANITIZER_MAC || SANITIZER_FREEBSD || SANITIZER_NETBSD
- struct __sanitizer_msghdr {
- void *msg_name;
- unsigned msg_namelen;
-@@ -497,6 +613,16 @@ namespace __sanitizer {
- unsigned short d_reclen;
- // more fields that we don't care about
- };
-+#elif SANITIZER_NETBSD
-+ struct __sanitizer_dirent {
-+ u64 d_fileno;
-+ u16 d_reclen;
-+#if 0 // not needed here?
-+ u16 d_namlen;
-+ u8 d_type;
-+ u8 d_name[512];
-+#endif
-+ };
- #elif SANITIZER_ANDROID || defined(__x86_64__)
- struct __sanitizer_dirent {
- unsigned long long d_ino;
-@@ -523,7 +649,7 @@ namespace __sanitizer {
- #endif
-
- // 'clock_t' is 32 bits wide on x64 FreeBSD
--#if SANITIZER_FREEBSD
-+#if SANITIZER_FREEBSD || SANITIZER_NETBSD
- typedef int __sanitizer_clock_t;
- #elif defined(__x86_64__) && !defined(_LP64)
- typedef long long __sanitizer_clock_t;
-@@ -531,7 +657,7 @@ namespace __sanitizer {
- typedef long __sanitizer_clock_t;
- #endif
-
--#if SANITIZER_LINUX
-+#if SANITIZER_LINUX || SANITIZER_NETBSD
- typedef int __sanitizer_clockid_t;
- #endif
-
-@@ -562,8 +688,22 @@ namespace __sanitizer {
- typedef struct {
- unsigned long fds_bits[1024 / (8 * sizeof(long))];
- } __sanitizer___kernel_fd_set;
-+#elif SANITIZER_NETBSD
-+ typedef u32 __sanitizer___kernel_uid_t;
-+ typedef u32 __sanitizer___kernel_gid_t;
-+ typedef u64 __sanitizer___kernel_off_t;
-+ typedef struct {
-+ u32 fds_bits[8];
-+ } __sanitizer___kernel_fd_set;
- #endif
-
-+#if SANITIZER_NETBSD
-+ typedef struct {
-+ unsigned int pta_magic;
-+ int pta_flags;
-+ void *pta_private;
-+ } __sanitizer_pthread_attr_t;
-+#else
- // 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 +711,7 @@ namespace __sanitizer {
- char size[pthread_attr_t_max_sz]; // NOLINT
- void *align;
- };
-+#endif
-
- #if SANITIZER_ANDROID
- # if SANITIZER_MIPS
-@@ -590,6 +731,10 @@ namespace __sanitizer {
- // uint32_t * 4
- unsigned int __bits[4];
- };
-+#elif SANITIZER_NETBSD
-+ struct __sanitizer_sigset_t {
-+ u32 __bits[4];
-+ };
- #endif
-
- // Linux system headers define the 'sa_handler' and 'sa_sigaction' macros.
-@@ -622,6 +767,15 @@ namespace __sanitizer {
- uptr sa_flags;
- void (*sa_restorer)();
- };
-+#elif SANITIZER_NETBSD
-+ struct __sanitizer_sigaction {
-+ union {
-+ void (*handler)(int sig);
-+ void (*sigaction)(int sig, void *siginfo, void *uctx);
-+ };
-+ __sanitizer_sigset_t sa_mask;
-+ int sa_flags;
-+ };
- #else // !SANITIZER_ANDROID
- struct __sanitizer_sigaction {
- #if defined(__mips__) && !SANITIZER_FREEBSD
-@@ -640,6 +794,7 @@ namespace __sanitizer {
- #else
- __sanitizer_sigset_t sa_mask;
- #endif
-+
- #ifndef __mips__
- #if defined(__sparc__)
- #if __GLIBC_PREREQ (2, 20)
-@@ -670,7 +825,7 @@ namespace __sanitizer {
- };
- #endif // !SANITIZER_ANDROID
-
--#if SANITIZER_FREEBSD
-+#if SANITIZER_FREEBSD || SANITIZER_NETBSD
- typedef __sanitizer_sigset_t __sanitizer_kernel_sigset_t;
- #elif defined(__mips__)
- struct __sanitizer_kernel_sigset_t {
-@@ -717,7 +872,7 @@ namespace __sanitizer {
- extern int af_inet6;
- uptr __sanitizer_in_addr_sz(int af);
-
--#if SANITIZER_LINUX || SANITIZER_FREEBSD
-+#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
- struct __sanitizer_dl_phdr_info {
- uptr dlpi_addr;
- const char *dlpi_name;
-@@ -733,7 +888,7 @@ namespace __sanitizer {
- int ai_family;
- int ai_socktype;
- int ai_protocol;
--#if SANITIZER_ANDROID || SANITIZER_MAC || SANITIZER_FREEBSD
-+#if SANITIZER_ANDROID || SANITIZER_MAC || SANITIZER_FREEBSD || SANITIZER_NETBSD
- unsigned ai_addrlen;
- char *ai_canonname;
- void *ai_addr;
-@@ -759,7 +914,7 @@ namespace __sanitizer {
- short revents;
- };
-
--#if SANITIZER_ANDROID || SANITIZER_MAC || SANITIZER_FREEBSD
-+#if SANITIZER_ANDROID || SANITIZER_MAC || SANITIZER_FREEBSD || SANITIZER_NETBSD
- typedef unsigned __sanitizer_nfds_t;
- #else
- typedef unsigned long __sanitizer_nfds_t;
-@@ -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
- struct __sanitizer_glob_t {
- uptr gl_pathc;
- uptr gl_matchc;
-@@ -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
-
--# if SANITIZER_LINUX || SANITIZER_FREEBSD
-+#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
- extern int glob_nomatch;
- extern int glob_altdirfunc;
- # endif
-@@ -807,7 +962,7 @@ namespace __sanitizer {
- uptr we_wordc;
- char **we_wordv;
- uptr we_offs;
--#if SANITIZER_FREEBSD
-+#if SANITIZER_FREEBSD || SANITIZER_NETBSD
- char *we_strings;
- uptr we_nbytes;
- #endif
-@@ -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;
-+ unsigned short _flags;
-+ short _file;
-+ struct {
-+ unsigned char *_base;
-+ int _size;
-+ } _bf;
-+ int _lbfsize;
-+ void *_cookie;
-+ int (*_close)(void *ptr);
-+ u64 (*_read)(void *, void *, uptr);
-+ u64 (*_seek)(void *, u64, int);
-+ uptr (*_write)(void *, const void *, uptr);
-+ struct {
-+ unsigned char *_base;
-+ int _size;
-+ } _ext;
-+ unsigned char *_up;
-+ int _ur;
-+ unsigned char _ubuf[3];
-+ unsigned char _nbuf[1];
-+ int (*_flush)(void *ptr);
-+ char _lb_unused[sizeof(uptr)];
-+ int _blksize;
-+ u64 _offset;
-+ };
-+#define SANITIZER_HAS_STRUCT_FILE 0 // not ported
- #else
- typedef void __sanitizer_FILE;
- # define SANITIZER_HAS_STRUCT_FILE 0
-@@ -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
- extern unsigned struct_shminfo_sz;
- extern unsigned struct_shm_info_sz;
- extern int shmctl_ipc_stat;
-@@ -923,6 +1110,7 @@ struct __sanitizer_cookie_io_functions_t
- };
- #endif
-
-+#if 1 // !SANITIZER_NETBSD
- #define IOC_NRBITS 8
- #define IOC_TYPEBITS 8
- #if defined(__powerpc__) || defined(__powerpc64__) || defined(__mips__) || \
-@@ -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;
-+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;
-+#endif
-
- #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;
-+#endif
-+
-+#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
- extern unsigned struct_mtget_sz;
- extern unsigned struct_mtop_sz;
- extern unsigned struct_rtentry_sz;
-@@ -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
-
- #if SANITIZER_LINUX && !SANITIZER_ANDROID
- extern unsigned struct_ax25_parms_struct_sz;
-@@ -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
- 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
-
- #if !SANITIZER_ANDROID && !SANITIZER_MAC
- extern unsigned struct_sioc_sg_req_sz;
-@@ -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
- extern unsigned IOCTL_SIOCGETSGCNT;
- extern unsigned IOCTL_SIOCGETVIFCNT;
- #endif
-@@ -1258,10 +1456,10 @@ struct __sanitizer_cookie_io_functions_t
- extern unsigned IOCTL_VT_RESIZEX;
- extern unsigned IOCTL_VT_SENDSIG;
- #endif // SANITIZER_LINUX
--#if SANITIZER_LINUX || SANITIZER_FREEBSD
-+#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
- extern unsigned IOCTL_MTIOCGET;
- extern unsigned IOCTL_MTIOCTOP;
-- 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 +1557,7 @@ struct __sanitizer_cookie_io_functions_t
- extern unsigned IOCTL_VT_RELDISP;
- extern unsigned IOCTL_VT_SETMODE;
- extern unsigned IOCTL_VT_WAITACTIVE;
--#endif // SANITIZER_LINUX || SANITIZER_FREEBSD
-+#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
-
- #if SANITIZER_LINUX && !SANITIZER_ANDROID
- extern unsigned IOCTL_CYGETDEFTHRESH;
-@@ -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_NETBSD
- extern unsigned IOCTL_GIO_SCRNMAP;
-+#endif
- extern unsigned IOCTL_KDDISABIO;
- extern unsigned IOCTL_KDENABIO;
- extern unsigned IOCTL_KDGETLED;
-+#if !SANITIZER_NETBSD
- extern unsigned IOCTL_KDGETMODE;
-+#endif
- extern unsigned IOCTL_KDGKBMODE;
- extern unsigned IOCTL_KDGKBTYPE;
- extern unsigned IOCTL_KDMKTONE;
- extern unsigned IOCTL_KDSETLED;
- extern unsigned IOCTL_KDSETMODE;
- extern unsigned IOCTL_KDSKBMODE;
-+#if !SANITIZER_NETBSD
- extern unsigned IOCTL_KIOCSOUND;
- extern unsigned IOCTL_PIO_SCRNMAP;
- #endif
-+#endif
-
- extern const int si_SEGV_MAPERR;
- extern const int si_SEGV_ACCERR;
diff --git a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__procmaps.h b/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__procmaps.h
deleted file mode 100644
index 7df23a6c7d..0000000000
--- a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__procmaps.h
+++ /dev/null
@@ -1,31 +0,0 @@
-$NetBSD$
-
---- 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 @@
-
- namespace __sanitizer {
-
--#if SANITIZER_FREEBSD || SANITIZER_LINUX
-+#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
- struct ProcSelfMapsBuff {
- char *data;
- uptr mmaped_size;
-@@ -29,7 +29,7 @@ struct ProcSelfMapsBuff {
-
- // Reads process memory map in an OS-specific way.
- void ReadProcMaps(ProcSelfMapsBuff *proc_maps);
--#endif // SANITIZER_FREEBSD || SANITIZER_LINUX
-+#endif // SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
-
- class MemoryMappingLayout {
- public:
-@@ -58,7 +58,7 @@ class MemoryMappingLayout {
-
- // FIXME: Hide implementation details for different platforms in
- // platform-specific files.
--# if SANITIZER_FREEBSD || SANITIZER_LINUX
-+#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
- ProcSelfMapsBuff proc_self_maps_;
- const char *current_;
-
diff --git a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__procmaps__common.cc b/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__procmaps__common.cc
deleted file mode 100644
index 2d1aa6d5df..0000000000
--- a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__procmaps__common.cc
+++ /dev/null
@@ -1,19 +0,0 @@
-$NetBSD$
-
---- 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 @@
-
- #include "sanitizer_platform.h"
-
--#if SANITIZER_FREEBSD || SANITIZER_LINUX
-+#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
-
- #include "sanitizer_common.h"
- #include "sanitizer_placement_new.h"
-@@ -173,4 +173,4 @@ void GetMemoryProfile(fill_profile_f cb,
-
- } // namespace __sanitizer
-
--#endif // SANITIZER_FREEBSD || SANITIZER_LINUX
-+#endif // SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
diff --git a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc b/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc
deleted file mode 100644
index 70cddb2dba..0000000000
--- a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc
+++ /dev/null
@@ -1,83 +0,0 @@
-$NetBSD$
-
---- lib/sanitizer_common/sanitizer_procmaps_netbsd.cc.orig 2017-07-07 07:50:25.382444345 +0000
-+++ lib/sanitizer_common/sanitizer_procmaps_netbsd.cc
-@@ -0,0 +1,78 @@
-+//===-- sanitizer_procmaps_freebsd.cc -------------------------------------===//
-+//
-+// This file is distributed under the University of Illinois Open Source
-+// License. See LICENSE.TXT for details.
-+//
-+//===----------------------------------------------------------------------===//
-+//
-+// Information about the process mappings (NetBSD-specific parts).
-+//===----------------------------------------------------------------------===//
-+
-+#include "sanitizer_platform.h"
-+#if SANITIZER_NETBSD
-+#include "sanitizer_common.h"
-+#include "sanitizer_procmaps.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)};
-+ size_t Size = 0;
-+ int Err = sysctl(Mib, __arraycount(Mib), NULL, &Size, NULL, 0);
-+ CHECK_EQ(Err, 0);
-+ CHECK_GT(Size, 0);
-+
-+ size_t MmapedSize = Size * 4 / 3;
-+ void *VmMap = MmapOrDie(MmapedSize, "ReadProcMaps()");
-+ Size = MmapedSize;
-+ Err = sysctl(Mib, __arraycount(Mib), VmMap, &Size, NULL, 0);
-+ CHECK_EQ(Err, 0);
-+
-+ proc_maps->data = (char *)VmMap;
-+ proc_maps->mmaped_size = MmapedSize;
-+ proc_maps->len = Size;
-+}
-+
-+bool MemoryMappingLayout::Next(uptr *start, uptr *end, uptr *offset,
-+ char filename[], uptr filename_size,
-+ uptr *protection, ModuleArch *arch, u8 *uuid) {
-+ CHECK(!arch && "not implemented");
-+ CHECK(!uuid && "not implemented");
-+ char *last = proc_self_maps_.data + proc_self_maps_.len;
-+ if (current_ >= last) return false;
-+ uptr dummy;
-+ if (!start) start = &dummy;
-+ if (!end) end = &dummy;
-+ if (!offset) offset = &dummy;
-+ if (!protection) protection = &dummy;
-+ struct kinfo_vmentry *VmEntry = (struct kinfo_vmentry *)current_;
-+
-+ *start = (uptr)VmEntry->kve_start;
-+ *end = (uptr)VmEntry->kve_end;
-+ *offset = (uptr)VmEntry->kve_offset;
-+
-+ *protection = 0;
-+ if ((VmEntry->kve_protection & KVME_PROT_READ) != 0)
-+ *protection |= kProtectionRead;
-+ if ((VmEntry->kve_protection & KVME_PROT_WRITE) != 0)
-+ *protection |= kProtectionWrite;
-+ if ((VmEntry->kve_protection & KVME_PROT_EXEC) != 0)
-+ *protection |= kProtectionExecute;
-+
-+ if (filename != NULL && filename_size > 0) {
-+ internal_snprintf(filename, Min(filename_size, (uptr)PATH_MAX), "%s",
-+ VmEntry->kve_path);
-+ }
-+
-+ current_ += sizeof(*VmEntry);
-+
-+ return true;
-+}
-+
-+} // namespace __sanitizer
-+
-+#endif // SANITIZER_NETBSD
diff --git a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__syscall__generic.inc b/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__syscall__generic.inc
deleted file mode 100644
index 5a3029f57f..0000000000
--- a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__syscall__generic.inc
+++ /dev/null
@@ -1,44 +0,0 @@
-$NetBSD$
-
---- 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 @@
- //
- //===----------------------------------------------------------------------===//
-
--#if SANITIZER_FREEBSD || SANITIZER_MAC
-+#ifdef SANITIZER_NETBSD
-+# define SYS_stat SYS___stat50
-+# define SYS_lstat SYS___lstat50
-+# define SYS_fstat SYS___fstat50
-+# define SYS_gettimeofday SYS___gettimeofday50
-+# define SYS_wait4 SYS___wait450
-+# define SYS_getdents SYS___getdents30
-+# define SYS_sigaltstack SYS___sigaltstack14
-+# define SYS_sigprocmask SYS___sigprocmask14
-+# define SYS_nanosleep SYS___nanosleep50
-+#endif
-+#if SANITIZER_FREEBSD || SANITIZER_MAC || SANITIZER_NETBSD
- # define SYSCALL(name) SYS_ ## name
- #else
- # define SYSCALL(name) __NR_ ## name
- #endif
-
--#if (SANITIZER_FREEBSD || SANITIZER_MAC) && defined(__x86_64__)
-+#if SANITIZER_NETBSD
-+// We use 3 kinds of internal_syscall's for different types of retval in order
-+// to address problems related to the byte order.
-+// - internal_syscall for 32-bit length (int, pid_t)
-+// - internal_syscall64 for 64-bit length (off_t)
-+// - internal_syscall_ptr for pointer and (s)size_t
-+# define internal_syscall syscall
-+# define internal_syscall64 __syscall
-+# if SANITIZER_WORDSIZE == 64
-+# define internal_syscall_ptr __syscall
-+# else
-+# define internal_syscall_ptr syscall
-+# endif
-+#elif defined(__x86_64__) && (SANITIZER_FREEBSD || SANITIZER_MAC)
- # define internal_syscall __syscall
- # else
- # define internal_syscall syscall
diff --git a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__unwind__linux__libcdep.cc b/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__unwind__linux__libcdep.cc
deleted file mode 100644
index ab5771ab33..0000000000
--- a/compiler-rt-ubsan/patches/patch-lib_sanitizer__common_sanitizer__unwind__linux__libcdep.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-$NetBSD$
-
---- 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 @@
- //===----------------------------------------------------------------------===//
- //
- // This file contains the unwind.h-based (aka "slow") stack unwinding routines
--// available to the tools on Linux, Android, and FreeBSD.
-+// available to the tools on Linux, Android, NetBSD and FreeBSD.
- //===----------------------------------------------------------------------===//
-
- #include "sanitizer_platform.h"
--#if SANITIZER_FREEBSD || SANITIZER_LINUX
-+#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
- #include "sanitizer_common.h"
- #include "sanitizer_stacktrace.h"
-
-@@ -78,7 +78,8 @@ void SanitizerInitializeUnwinder() {
- }
- #endif
-
--#ifdef __arm__
-+#if defined(__arm__) && !SANITIZER_NETBSD
-+// NetBSD uses dwarf EH
- #define UNWIND_STOP _URC_END_OF_STACK
- #define UNWIND_CONTINUE _URC_NO_REASON
- #else
-@@ -95,7 +96,7 @@ uptr Unwind_GetIP(struct _Unwind_Context
- // Clear the Thumb bit.
- return val & ~(uptr)1;
- #else
-- return _Unwind_GetIP(ctx);
-+ return (uptr)_Unwind_GetIP(ctx);
- #endif
- }
-
-@@ -165,4 +166,4 @@ void BufferedStackTrace::SlowUnwindStack
-
- } // namespace __sanitizer
-
--#endif // SANITIZER_FREEBSD || SANITIZER_LINUX
-+#endif // SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
diff --git a/compiler-rt-ubsan/patches/patch-lib_ubsan_ubsan__platform.h b/compiler-rt-ubsan/patches/patch-lib_ubsan_ubsan__platform.h
deleted file mode 100644
index b849ff199f..0000000000
--- a/compiler-rt-ubsan/patches/patch-lib_ubsan_ubsan__platform.h
+++ /dev/null
@@ -1,18 +0,0 @@
-$NetBSD$
-
---- lib/ubsan/ubsan_platform.h.orig 2017-07-03 15:33:06.000000000 +0000
-+++ lib/ubsan/ubsan_platform.h
-@@ -14,9 +14,10 @@
- #define UBSAN_PLATFORM_H
-
- // Other platforms should be easy to add, and probably work as-is.
--#if (defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__)) && \
-- (defined(__x86_64__) || defined(__i386__) || defined(__arm__) || \
-- defined(__aarch64__) || defined(__mips__) || defined(__powerpc64__) || \
-+#if (defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
-+ defined(__APPLE__)) && \
-+ (defined(__x86_64__) || defined(__i386__) || defined(__arm__) || \
-+ defined(__aarch64__) || defined(__mips__) || defined(__powerpc64__) || \
- defined(__s390__))
- # define CAN_SANITIZE_UB 1
- #elif defined(_WIN32)
diff --git a/compiler-rt-ubsan/patches/patch-test_ubsan_TestCases_Float_cast-overflow.cpp b/compiler-rt-ubsan/patches/patch-test_ubsan_TestCases_Float_cast-overflow.cpp
deleted file mode 100644
index 444c4b53e9..0000000000
--- a/compiler-rt-ubsan/patches/patch-test_ubsan_TestCases_Float_cast-overflow.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-$NetBSD$
-
---- test/ubsan/TestCases/Float/cast-overflow.cpp.orig 2017-07-03 15:33:06.000000000 +0000
-+++ test/ubsan/TestCases/Float/cast-overflow.cpp
-@@ -18,7 +18,7 @@
- # define BYTE_ORDER __DARWIN_BYTE_ORDER
- # define BIG_ENDIAN __DARWIN_BIG_ENDIAN
- # define LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN
--#elif defined(__FreeBSD__)
-+#elif defined(__FreeBSD__) || defined(__NetBSD__)
- # include <sys/endian.h>
- # define BYTE_ORDER _BYTE_ORDER
- # define BIG_ENDIAN _BIG_ENDIAN
diff --git a/compiler-rt-ubsan/patches/patch-test_ubsan_lit.common.cfg b/compiler-rt-ubsan/patches/patch-test_ubsan_lit.common.cfg
deleted file mode 100644
index 9df4bb1bfb..0000000000
--- a/compiler-rt-ubsan/patches/patch-test_ubsan_lit.common.cfg
+++ /dev/null
@@ -1,13 +0,0 @@
-$NetBSD$
-
---- test/ubsan/lit.common.cfg.orig 2017-07-03 15:33:06.000000000 +0000
-+++ test/ubsan/lit.common.cfg
-@@ -70,7 +70,7 @@ config.substitutions.append( ("%gmlt ",
- config.suffixes = ['.c', '.cc', '.cpp']
-
- # Check that the host supports UndefinedBehaviorSanitizer tests
--if config.host_os not in ['Linux', 'Darwin', 'FreeBSD', 'Windows']:
-+if config.host_os not in ['Linux', 'Darwin', 'FreeBSD', 'NetBSD', 'Windows']:
- config.unsupported = True
-
- # Allow tests to use REQUIRES=stable-runtime. For use when you cannot use XFAIL
Home |
Main Index |
Thread Index |
Old Index