pkgsrc-WIP-changes archive

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

ldc: Import ldc-0.17.0 as wip/ldc



Module Name:	pkgsrc-wip
Committed By:	Mateusz Poszwa <old4%o2.pl@localhost>
Pushed By:	f8l
Date:		Wed Mar 2 20:57:09 2016 +0100
Changeset:	5a2d1aa043671b440f0d53f76baf25e097fea002

Modified Files:
	Makefile
Added Files:
	ldc/DESCR
	ldc/Makefile
	ldc/PLIST
	ldc/distinfo
	ldc/patches/patch-runtime_druntime_osmodel.mak
	ldc/patches/patch-runtime_druntime_src_core_runtime.d
	ldc/patches/patch-runtime_druntime_src_core_stdc_config.d
	ldc/patches/patch-runtime_druntime_src_core_stdc_errno.d
	ldc/patches/patch-runtime_druntime_src_core_stdc_fenv.d
	ldc/patches/patch-runtime_druntime_src_core_stdc_locale.d
	ldc/patches/patch-runtime_druntime_src_core_stdc_math.d
	ldc/patches/patch-runtime_druntime_src_core_stdc_stdio.d
	ldc/patches/patch-runtime_druntime_src_core_stdc_stdlib.d
	ldc/patches/patch-runtime_druntime_src_core_stdc_string.d
	ldc/patches/patch-runtime_druntime_src_core_stdc_tgmath.d
	ldc/patches/patch-runtime_druntime_src_core_stdc_time.d
	ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_dlfcn.d
	ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_execinfo.d
	ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_cdefs.d
	ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_elf.d
	ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_elf32.d
	ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_elf64.d
	ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_elf__common.d
	ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_event.d
	ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_link__elf.d
	ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_mman.d
	ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_time.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_arpa_inet.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_dirent.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_dlfcn.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_fcntl.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_grp.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_net_if__.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_netdb.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_netinet_in__.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_netinet_tcp.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_poll.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_pthread.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_pwd.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_sched.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_semaphore.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_setjmp.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_signal.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_stdio.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_stdlib.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_ioctl.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_ipc.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_mman.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_resource.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_select.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_shm.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_socket.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_stat.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_time.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_types.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_uio.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_un.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_utsname.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_wait.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_syslog.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_termios.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_time.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_ucontext.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_unistd.d
	ldc/patches/patch-runtime_druntime_src_core_sys_posix_utime.d
	ldc/patches/patch-runtime_druntime_src_core_thread.d
	ldc/patches/patch-runtime_druntime_src_core_threadasm.S
	ldc/patches/patch-runtime_druntime_src_core_time.d
	ldc/patches/patch-runtime_druntime_src_gc_os.d
	ldc/patches/patch-runtime_druntime_src_rt_bss__section.c
	ldc/patches/patch-runtime_druntime_src_rt_dmain2.d
	ldc/patches/patch-runtime_druntime_src_rt_sections.d
	ldc/patches/patch-runtime_druntime_src_rt_sections__elf__shared.d
	ldc/patches/patch-runtime_druntime_src_rt_sections__ldc.d
	ldc/patches/patch-runtime_druntime_test_shared_src_load.d
	ldc/patches/patch-runtime_phobos_osmodel.mak
	ldc/patches/patch-runtime_phobos_std_complex.d
	ldc/patches/patch-runtime_phobos_std_conv.d
	ldc/patches/patch-runtime_phobos_std_datetime.d
	ldc/patches/patch-runtime_phobos_std_file.d
	ldc/patches/patch-runtime_phobos_std_internal_math_gammafunction.d
	ldc/patches/patch-runtime_phobos_std_math.d
	ldc/patches/patch-runtime_phobos_std_numeric.d
	ldc/patches/patch-runtime_phobos_std_parallelism.d
	ldc/patches/patch-runtime_phobos_std_socket.d
	ldc/patches/patch-runtime_phobos_std_stdio.d
	ldc/patches/patch-runtime_phobos_std_system.d

Log Message:
ldc: Import ldc-0.17.0 as wip/ldc

The LDC project aims to provide a portable D programming language
compiler with modern optimization and code generation capabilities.
The compiler uses the official DMD frontend to support the latest D2
version and relies on the LLVM Core libraries for code generation.

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

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

diffstat:
 Makefile                                           |   1 +
 ldc/DESCR                                          |   4 +
 ldc/Makefile                                       |  99 +++
 ldc/PLIST                                          | 332 ++++++++
 ldc/distinfo                                       |  89 +++
 ldc/patches/patch-runtime_druntime_osmodel.mak     |  16 +
 .../patch-runtime_druntime_src_core_runtime.d      |  43 +
 .../patch-runtime_druntime_src_core_stdc_config.d  |  15 +
 .../patch-runtime_druntime_src_core_stdc_errno.d   | 145 ++++
 .../patch-runtime_druntime_src_core_stdc_fenv.d    |  66 ++
 .../patch-runtime_druntime_src_core_stdc_locale.d  |  30 +
 .../patch-runtime_druntime_src_core_stdc_math.d    | 580 ++++++++++++++
 .../patch-runtime_druntime_src_core_stdc_stdio.d   | 165 ++++
 .../patch-runtime_druntime_src_core_stdc_stdlib.d  |  14 +
 .../patch-runtime_druntime_src_core_stdc_string.d  |  17 +
 .../patch-runtime_druntime_src_core_stdc_tgmath.d  | 561 +++++++++++++
 .../patch-runtime_druntime_src_core_stdc_time.d    |  31 +
 ...ch-runtime_druntime_src_core_sys_netbsd_dlfcn.d | 120 +++
 ...runtime_druntime_src_core_sys_netbsd_execinfo.d | 140 ++++
 ...untime_druntime_src_core_sys_netbsd_sys_cdefs.d |  23 +
 ...-runtime_druntime_src_core_sys_netbsd_sys_elf.d |  18 +
 ...untime_druntime_src_core_sys_netbsd_sys_elf32.d | 194 +++++
 ...untime_druntime_src_core_sys_netbsd_sys_elf64.d | 200 +++++
 ..._druntime_src_core_sys_netbsd_sys_elf__common.d | 866 +++++++++++++++++++++
 ...untime_druntime_src_core_sys_netbsd_sys_event.d | 115 +++
 ...me_druntime_src_core_sys_netbsd_sys_link__elf.d |  85 ++
 ...runtime_druntime_src_core_sys_netbsd_sys_mman.d | 153 ++++
 ...tch-runtime_druntime_src_core_sys_netbsd_time.d |  26 +
 ...runtime_druntime_src_core_sys_posix_arpa_inet.d |  50 ++
 ...ch-runtime_druntime_src_core_sys_posix_dirent.d |  90 +++
 ...tch-runtime_druntime_src_core_sys_posix_dlfcn.d |  36 +
 ...tch-runtime_druntime_src_core_sys_posix_fcntl.d |  66 ++
 ...patch-runtime_druntime_src_core_sys_posix_grp.d |  48 ++
 ...-runtime_druntime_src_core_sys_posix_net_if__.d |  28 +
 ...tch-runtime_druntime_src_core_sys_posix_netdb.d | 120 +++
 ...time_druntime_src_core_sys_posix_netinet_in__.d | 206 +++++
 ...ntime_druntime_src_core_sys_posix_netinet_tcp.d |  17 +
 ...atch-runtime_druntime_src_core_sys_posix_poll.d |  48 ++
 ...h-runtime_druntime_src_core_sys_posix_pthread.d | 266 +++++++
 ...patch-runtime_druntime_src_core_sys_posix_pwd.d |  56 ++
 ...tch-runtime_druntime_src_core_sys_posix_sched.d |  48 ++
 ...runtime_druntime_src_core_sys_posix_semaphore.d |  30 +
 ...ch-runtime_druntime_src_core_sys_posix_setjmp.d |  71 ++
 ...ch-runtime_druntime_src_core_sys_posix_signal.d | 339 ++++++++
 ...tch-runtime_druntime_src_core_sys_posix_stdio.d |  17 +
 ...ch-runtime_druntime_src_core_sys_posix_stdlib.d |  90 +++
 ...runtime_druntime_src_core_sys_posix_sys_ioctl.d |  25 +
 ...h-runtime_druntime_src_core_sys_posix_sys_ipc.d |  39 +
 ...-runtime_druntime_src_core_sys_posix_sys_mman.d | 121 +++
 ...time_druntime_src_core_sys_posix_sys_resource.d |  84 ++
 ...untime_druntime_src_core_sys_posix_sys_select.d |  62 ++
 ...h-runtime_druntime_src_core_sys_posix_sys_shm.d |  39 +
 ...untime_druntime_src_core_sys_posix_sys_socket.d | 240 ++++++
 ...-runtime_druntime_src_core_sys_posix_sys_stat.d | 113 +++
 ...-runtime_druntime_src_core_sys_posix_sys_time.d |  34 +
 ...runtime_druntime_src_core_sys_posix_sys_types.d | 102 +++
 ...h-runtime_druntime_src_core_sys_posix_sys_uio.d |  24 +
 ...ch-runtime_druntime_src_core_sys_posix_sys_un.d |  22 +
 ...ntime_druntime_src_core_sys_posix_sys_utsname.d |  29 +
 ...-runtime_druntime_src_core_sys_posix_sys_wait.d |  48 ++
 ...ch-runtime_druntime_src_core_sys_posix_syslog.d |  78 ++
 ...h-runtime_druntime_src_core_sys_posix_termios.d | 161 ++++
 ...atch-runtime_druntime_src_core_sys_posix_time.d |  87 +++
 ...-runtime_druntime_src_core_sys_posix_ucontext.d |  69 ++
 ...ch-runtime_druntime_src_core_sys_posix_unistd.d | 205 +++++
 ...tch-runtime_druntime_src_core_sys_posix_utime.d |  23 +
 .../patch-runtime_druntime_src_core_thread.d       | 113 +++
 .../patch-runtime_druntime_src_core_threadasm.S    |  15 +
 ldc/patches/patch-runtime_druntime_src_core_time.d |  38 +
 ldc/patches/patch-runtime_druntime_src_gc_os.d     |  14 +
 .../patch-runtime_druntime_src_rt_bss__section.c   |  15 +
 ldc/patches/patch-runtime_druntime_src_rt_dmain2.d |  50 ++
 .../patch-runtime_druntime_src_rt_sections.d       |  15 +
 ...runtime_druntime_src_rt_sections__elf__shared.d |  99 +++
 .../patch-runtime_druntime_src_rt_sections__ldc.d  |  23 +
 .../patch-runtime_druntime_test_shared_src_load.d  |  14 +
 ldc/patches/patch-runtime_phobos_osmodel.mak       |  16 +
 ldc/patches/patch-runtime_phobos_std_complex.d     |  36 +
 ldc/patches/patch-runtime_phobos_std_conv.d        |  25 +
 ldc/patches/patch-runtime_phobos_std_datetime.d    |  64 ++
 ldc/patches/patch-runtime_phobos_std_file.d        |  27 +
 ...untime_phobos_std_internal_math_gammafunction.d | 116 +++
 ldc/patches/patch-runtime_phobos_std_math.d        |  93 +++
 ldc/patches/patch-runtime_phobos_std_numeric.d     |  16 +
 ldc/patches/patch-runtime_phobos_std_parallelism.d |  29 +
 ldc/patches/patch-runtime_phobos_std_socket.d      |  21 +
 ldc/patches/patch-runtime_phobos_std_stdio.d       |  19 +
 ldc/patches/patch-runtime_phobos_std_system.d      |  22 +
 88 files changed, 8259 insertions(+)

diffs:
diff --git a/Makefile b/Makefile
index 7e99277..307b6d2 100644
--- a/Makefile
+++ b/Makefile
@@ -1496,6 +1496,7 @@ SUBDIR+=	lcrack
 SUBDIR+=	ldapbrowser
 SUBDIR+=	ldapdns
 SUBDIR+=	ldapuseradd
+SUBDIR+=	ldc
 SUBDIR+=	ldc-git
 SUBDIR+=	lde
 SUBDIR+=	ldtp
diff --git a/ldc/DESCR b/ldc/DESCR
new file mode 100644
index 0000000..79a999a
--- /dev/null
+++ b/ldc/DESCR
@@ -0,0 +1,4 @@
+The LDC project aims to provide a portable D programming language
+compiler with modern optimization and code generation capabilities.
+The compiler uses the official DMD frontend to support the latest D2
+version and relies on the LLVM Core libraries for code generation.
diff --git a/ldc/Makefile b/ldc/Makefile
new file mode 100644
index 0000000..f601189
--- /dev/null
+++ b/ldc/Makefile
@@ -0,0 +1,99 @@
+# $NetBSD$
+
+PKGNAME=	ldc-0.17.0
+DISTNAME=	${PKGNAME}-src
+GITHUB_RELEASE=	v${PKGVERSION_NOREV}
+CATEGORIES=	wip
+MASTER_SITES=	${MASTER_SITE_GITHUB:=ldc-developers/}
+
+MAINTAINER=	pkgsrc-users%NetBSD.org@localhost
+HOMEPAGE=	${MASTER_SITE_GITHUB:=ldc-developers/ldc/}
+COMMENT=	D compiler based on LLVM
+LICENSE=	modified-bsd					\
+		AND (artistic OR gnu-gpl-v1)			\
+		AND (artistic OR gnu-gpl-v2 OR gnu-gpl-v3)	\
+		AND gnu-lgpl-v2.1				\
+		AND modified-bsd				\
+		AND boost-license
+#TODO: The modified-bsd two lines above should be
+# University of Illinois Open Source License.
+# They are similar, but I am not sure if they are equivalent.
+
+USE_CMAKE=	yes
+USE_LANGUAGES=	c c++
+
+EGDIR=	${PREFIX}/share/examples/${PKGBASE}
+
+CONF_FILES=	${EGDIR}/ldc2.conf ${PKG_SYSCONFDIR}/ldc2.conf
+
+post-install:
+	${MKDIR} -p ${DESTDIR}${EGDIR}	\
+		&& ${MV} ${DESTDIR}${PREFIX}/etc/ldc2.conf	\
+			${DESTDIR}${EGDIR}
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/runtime.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/stdc/config.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/stdc/errno.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/stdc/fenv.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/stdc/locale.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/stdc/math.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/stdc/stdio.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/stdc/stdlib.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/stdc/string.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/stdc/tgmath.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/stdc/time.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/netbsd/dlfcn.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/netbsd/execinfo.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/netbsd/sys/cdefs.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/netbsd/sys/elf.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/netbsd/sys/elf32.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/netbsd/sys/elf64.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/netbsd/sys/elf_common.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/netbsd/sys/event.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/netbsd/sys/link_elf.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/netbsd/sys/mman.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/netbsd/time.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/arpa/inet.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/dirent.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/dlfcn.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/fcntl.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/grp.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/net/if_.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/netdb.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/netinet/in_.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/netinet/tcp.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/poll.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/pthread.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/pwd.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/sched.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/semaphore.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/setjmp.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/signal.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/stdio.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/stdlib.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/sys/ioctl.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/sys/ipc.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/sys/mman.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/sys/resource.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/sys/select.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/sys/shm.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/sys/socket.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/sys/stat.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/sys/time.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/sys/types.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/sys/uio.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/sys/un.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/sys/utsname.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/sys/wait.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/syslog.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/termios.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/time.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/ucontext.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/unistd.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/sys/posix/utime.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/thread.d.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/threadasm.S.orig
+	${RM} ${DESTDIR}${PREFIX}/include/d/core/time.d.orig
+
+.include "../../wip/llvm/buildlink3.mk"
+.include "../../devel/libconfig/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/ldc/PLIST b/ldc/PLIST
new file mode 100644
index 0000000..bac9ceb
--- /dev/null
+++ b/ldc/PLIST
@@ -0,0 +1,332 @@
+@comment $NetBSD$
+bin/ldc2
+bin/ldmd2
+include/d/core/atomic.d
+include/d/core/bitop.d
+include/d/core/checkedint.d
+include/d/core/cpuid.d
+include/d/core/demangle.d
+include/d/core/exception.d
+include/d/core/internal/convert.d
+include/d/core/internal/hash.d
+include/d/core/internal/traits.d
+include/d/core/math.d
+include/d/core/memory.d
+include/d/core/runtime.d
+include/d/core/simd.d
+include/d/core/stdc/complex.d
+include/d/core/stdc/config.d
+include/d/core/stdc/ctype.d
+include/d/core/stdc/errno.c
+include/d/core/stdc/errno.d
+include/d/core/stdc/fenv.d
+include/d/core/stdc/float_.d
+include/d/core/stdc/inttypes.d
+include/d/core/stdc/limits.d
+include/d/core/stdc/locale.d
+include/d/core/stdc/math.d
+include/d/core/stdc/signal.d
+include/d/core/stdc/stdarg.d
+include/d/core/stdc/stddef.d
+include/d/core/stdc/stdint.d
+include/d/core/stdc/stdio.d
+include/d/core/stdc/stdlib.d
+include/d/core/stdc/string.d
+include/d/core/stdc/tgmath.d
+include/d/core/stdc/time.d
+include/d/core/stdc/wchar_.d
+include/d/core/stdc/wctype.d
+include/d/core/sync/barrier.d
+include/d/core/sync/condition.d
+include/d/core/sync/config.d
+include/d/core/sync/exception.d
+include/d/core/sync/mutex.d
+include/d/core/sync/rwmutex.d
+include/d/core/sync/semaphore.d
+include/d/core/sys/freebsd/dlfcn.d
+include/d/core/sys/freebsd/execinfo.d
+include/d/core/sys/freebsd/sys/cdefs.d
+include/d/core/sys/freebsd/sys/elf.d
+include/d/core/sys/freebsd/sys/elf32.d
+include/d/core/sys/freebsd/sys/elf64.d
+include/d/core/sys/freebsd/sys/elf_common.d
+include/d/core/sys/freebsd/sys/event.d
+include/d/core/sys/freebsd/sys/link_elf.d
+include/d/core/sys/freebsd/sys/mman.d
+include/d/core/sys/freebsd/time.d
+include/d/core/sys/linux/config.d
+include/d/core/sys/linux/dlfcn.d
+include/d/core/sys/linux/elf.d
+include/d/core/sys/linux/epoll.d
+include/d/core/sys/linux/errno.d
+include/d/core/sys/linux/execinfo.d
+include/d/core/sys/linux/link.d
+include/d/core/sys/linux/stdio.d
+include/d/core/sys/linux/sys/inotify.d
+include/d/core/sys/linux/sys/mman.d
+include/d/core/sys/linux/sys/signalfd.d
+include/d/core/sys/linux/sys/sysinfo.d
+include/d/core/sys/linux/sys/xattr.d
+include/d/core/sys/linux/termios.d
+include/d/core/sys/linux/time.d
+include/d/core/sys/linux/tipc.d
+include/d/core/sys/netbsd/dlfcn.d
+include/d/core/sys/netbsd/execinfo.d
+include/d/core/sys/netbsd/sys/cdefs.d
+include/d/core/sys/netbsd/sys/elf.d
+include/d/core/sys/netbsd/sys/elf32.d
+include/d/core/sys/netbsd/sys/elf64.d
+include/d/core/sys/netbsd/sys/elf_common.d
+include/d/core/sys/netbsd/sys/event.d
+include/d/core/sys/netbsd/sys/link_elf.d
+include/d/core/sys/netbsd/sys/mman.d
+include/d/core/sys/netbsd/time.d
+include/d/core/sys/osx/execinfo.d
+include/d/core/sys/osx/mach/dyld.d
+include/d/core/sys/osx/mach/getsect.d
+include/d/core/sys/osx/mach/kern_return.d
+include/d/core/sys/osx/mach/loader.d
+include/d/core/sys/osx/mach/port.d
+include/d/core/sys/osx/mach/semaphore.d
+include/d/core/sys/osx/mach/thread_act.d
+include/d/core/sys/osx/pthread.d
+include/d/core/sys/osx/sys/cdefs.d
+include/d/core/sys/osx/sys/event.d
+include/d/core/sys/osx/sys/mman.d
+include/d/core/sys/posix/arpa/inet.d
+include/d/core/sys/posix/config.d
+include/d/core/sys/posix/dirent.d
+include/d/core/sys/posix/dlfcn.d
+include/d/core/sys/posix/fcntl.d
+include/d/core/sys/posix/grp.d
+include/d/core/sys/posix/inttypes.d
+include/d/core/sys/posix/net/if_.d
+include/d/core/sys/posix/netdb.d
+include/d/core/sys/posix/netinet/in_.d
+include/d/core/sys/posix/netinet/tcp.d
+include/d/core/sys/posix/poll.d
+include/d/core/sys/posix/pthread.d
+include/d/core/sys/posix/pwd.d
+include/d/core/sys/posix/sched.d
+include/d/core/sys/posix/semaphore.d
+include/d/core/sys/posix/setjmp.d
+include/d/core/sys/posix/signal.d
+include/d/core/sys/posix/stdio.d
+include/d/core/sys/posix/stdlib.d
+include/d/core/sys/posix/sys/ioctl.d
+include/d/core/sys/posix/sys/ipc.d
+include/d/core/sys/posix/sys/mman.d
+include/d/core/sys/posix/sys/msg.d
+include/d/core/sys/posix/sys/resource.d
+include/d/core/sys/posix/sys/select.d
+include/d/core/sys/posix/sys/shm.d
+include/d/core/sys/posix/sys/socket.d
+include/d/core/sys/posix/sys/stat.d
+include/d/core/sys/posix/sys/statvfs.d
+include/d/core/sys/posix/sys/time.d
+include/d/core/sys/posix/sys/types.d
+include/d/core/sys/posix/sys/uio.d
+include/d/core/sys/posix/sys/un.d
+include/d/core/sys/posix/sys/utsname.d
+include/d/core/sys/posix/sys/wait.d
+include/d/core/sys/posix/syslog.d
+include/d/core/sys/posix/termios.d
+include/d/core/sys/posix/time.d
+include/d/core/sys/posix/ucontext.d
+include/d/core/sys/posix/unistd.d
+include/d/core/sys/posix/utime.d
+include/d/core/sys/solaris/dlfcn.d
+include/d/core/sys/solaris/elf.d
+include/d/core/sys/solaris/execinfo.d
+include/d/core/sys/solaris/libelf.d
+include/d/core/sys/solaris/link.d
+include/d/core/sys/solaris/sys/elf.d
+include/d/core/sys/solaris/sys/elf_386.d
+include/d/core/sys/solaris/sys/elf_SPARC.d
+include/d/core/sys/solaris/sys/elf_amd64.d
+include/d/core/sys/solaris/sys/elf_notes.d
+include/d/core/sys/solaris/sys/elftypes.d
+include/d/core/sys/solaris/sys/link.d
+include/d/core/sys/solaris/sys/priocntl.d
+include/d/core/sys/solaris/sys/procset.d
+include/d/core/sys/solaris/sys/types.d
+include/d/core/sys/solaris/time.d
+include/d/core/sys/windows/com.d
+include/d/core/sys/windows/dbghelp.d
+include/d/core/sys/windows/dll.d
+include/d/core/sys/windows/stacktrace.d
+include/d/core/sys/windows/stat.d
+include/d/core/sys/windows/threadaux.d
+include/d/core/sys/windows/windows.d
+include/d/core/sys/windows/winsock2.d
+include/d/core/thread.d
+include/d/core/threadasm.S
+include/d/core/time.d
+include/d/core/vararg.d
+include/d/etc/c/curl.d
+include/d/etc/c/odbc/sql.d
+include/d/etc/c/odbc/sqlext.d
+include/d/etc/c/odbc/sqltypes.d
+include/d/etc/c/odbc/sqlucode.d
+include/d/etc/c/sqlite3.d
+include/d/etc/c/zlib.d
+include/d/etc/linux/memoryerror.d
+include/d/ldc/arm_unwind.c
+include/d/ldc/arrayinit.d
+include/d/ldc/attributes.d
+include/d/ldc/eh/common.d
+include/d/ldc/eh/fixedpool.d
+include/d/ldc/eh/libunwind.d
+include/d/ldc/eh/win32.d
+include/d/ldc/eh/win64.d
+include/d/ldc/gccbuiltins_aarch64.di
+include/d/ldc/gccbuiltins_arm.di
+include/d/ldc/gccbuiltins_mips.di
+include/d/ldc/gccbuiltins_ppc.di
+include/d/ldc/gccbuiltins_s390.di
+include/d/ldc/gccbuiltins_x86.di
+include/d/ldc/intrinsics.di
+include/d/ldc/llvmasm.di
+include/d/ldc/msvc.c
+include/d/ldc/object.d
+include/d/ldc/osx_tls.c
+include/d/ldc/simd.di
+include/d/std/algorithm/comparison.d
+include/d/std/algorithm/internal.d
+include/d/std/algorithm/iteration.d
+include/d/std/algorithm/mutation.d
+include/d/std/algorithm/package.d
+include/d/std/algorithm/searching.d
+include/d/std/algorithm/setops.d
+include/d/std/algorithm/sorting.d
+include/d/std/array.d
+include/d/std/ascii.d
+include/d/std/base64.d
+include/d/std/bigint.d
+include/d/std/bitmanip.d
+include/d/std/c/fenv.d
+include/d/std/c/freebsd/socket.d
+include/d/std/c/linux/linux.d
+include/d/std/c/linux/linuxextern.d
+include/d/std/c/linux/pthread.d
+include/d/std/c/linux/socket.d
+include/d/std/c/linux/termios.d
+include/d/std/c/linux/tipc.d
+include/d/std/c/locale.d
+include/d/std/c/math.d
+include/d/std/c/osx/socket.d
+include/d/std/c/process.d
+include/d/std/c/stdarg.d
+include/d/std/c/stddef.d
+include/d/std/c/stdio.d
+include/d/std/c/stdlib.d
+include/d/std/c/string.d
+include/d/std/c/time.d
+include/d/std/c/wcharh.d
+include/d/std/c/windows/com.d
+include/d/std/c/windows/stat.d
+include/d/std/c/windows/windows.d
+include/d/std/c/windows/winsock.d
+include/d/std/compiler.d
+include/d/std/complex.d
+include/d/std/concurrency.d
+include/d/std/container/array.d
+include/d/std/container/binaryheap.d
+include/d/std/container/dlist.d
+include/d/std/container/package.d
+include/d/std/container/rbtree.d
+include/d/std/container/slist.d
+include/d/std/container/util.d
+include/d/std/conv.d
+include/d/std/cstream.d
+include/d/std/csv.d
+include/d/std/datetime.d
+include/d/std/demangle.d
+include/d/std/digest/crc.d
+include/d/std/digest/digest.d
+include/d/std/digest/md.d
+include/d/std/digest/ripemd.d
+include/d/std/digest/sha.d
+include/d/std/encoding.d
+include/d/std/exception.d
+include/d/std/experimental/logger/core.d
+include/d/std/experimental/logger/filelogger.d
+include/d/std/experimental/logger/multilogger.d
+include/d/std/experimental/logger/nulllogger.d
+include/d/std/experimental/logger/package.d
+include/d/std/file.d
+include/d/std/format.d
+include/d/std/functional.d
+include/d/std/getopt.d
+include/d/std/internal/cstring.d
+include/d/std/internal/digest/sha_SSSE3.d
+include/d/std/internal/math/biguintcore.d
+include/d/std/internal/math/biguintnoasm.d
+include/d/std/internal/math/biguintx86.d
+include/d/std/internal/math/errorfunction.d
+include/d/std/internal/math/gammafunction.d
+include/d/std/internal/processinit.d
+include/d/std/internal/scopebuffer.d
+include/d/std/internal/test/dummyrange.d
+include/d/std/internal/unicode_comp.d
+include/d/std/internal/unicode_decomp.d
+include/d/std/internal/unicode_grapheme.d
+include/d/std/internal/unicode_norm.d
+include/d/std/internal/unicode_tables.d
+include/d/std/internal/windows/advapi32.d
+include/d/std/json.d
+include/d/std/math.d
+include/d/std/mathspecial.d
+include/d/std/meta.d
+include/d/std/metastrings.d
+include/d/std/mmfile.d
+include/d/std/net/curl.d
+include/d/std/net/isemail.d
+include/d/std/numeric.d
+include/d/std/outbuffer.d
+include/d/std/parallelism.d
+include/d/std/path.d
+include/d/std/process.d
+include/d/std/random.d
+include/d/std/range/interfaces.d
+include/d/std/range/package.d
+include/d/std/range/primitives.d
+include/d/std/regex/internal/backtracking.d
+include/d/std/regex/internal/generator.d
+include/d/std/regex/internal/ir.d
+include/d/std/regex/internal/kickstart.d
+include/d/std/regex/internal/parser.d
+include/d/std/regex/internal/tests.d
+include/d/std/regex/internal/thompson.d
+include/d/std/regex/package.d
+include/d/std/signals.d
+include/d/std/socket.d
+include/d/std/socketstream.d
+include/d/std/stdint.d
+include/d/std/stdio.d
+include/d/std/stdiobase.d
+include/d/std/stream.d
+include/d/std/string.d
+include/d/std/syserror.d
+include/d/std/system.d
+include/d/std/traits.d
+include/d/std/typecons.d
+include/d/std/typelist.d
+include/d/std/typetuple.d
+include/d/std/uni.d
+include/d/std/uri.d
+include/d/std/utf.d
+include/d/std/uuid.d
+include/d/std/variant.d
+include/d/std/windows/charset.d
+include/d/std/windows/iunknown.d
+include/d/std/windows/registry.d
+include/d/std/windows/syserror.d
+include/d/std/xml.d
+include/d/std/zip.d
+include/d/std/zlib.d
+lib/libdruntime-ldc-debug.a
+lib/libdruntime-ldc.a
+lib/libphobos2-ldc-debug.a
+lib/libphobos2-ldc.a
+share/examples/ldc/ldc2.conf
diff --git a/ldc/distinfo b/ldc/distinfo
new file mode 100644
index 0000000..38e5a59
--- /dev/null
+++ b/ldc/distinfo
@@ -0,0 +1,89 @@
+$NetBSD$
+
+SHA1 (ldc-0.17.0-src.tar.gz) = 5cf60c835cde891b996ea69f0d934dac10002b82
+RMD160 (ldc-0.17.0-src.tar.gz) = 08ecc79943527b21887c78941445fa27fe1e308c
+SHA512 (ldc-0.17.0-src.tar.gz) = 89ebac16bbe2b2b2baa421b6e96371926fd3c78a38b0be6c322cc1f1eda880598027464c18bce8d3b206742038d0d35b1df061f878da43233184bcd3c2778d8a
+Size (ldc-0.17.0-src.tar.gz) = 4947638 bytes
+SHA1 (patch-runtime_druntime_osmodel.mak) = 79ec151a5c4548da9b398dd24509df9f051fa3c3
+SHA1 (patch-runtime_druntime_src_core_runtime.d) = abb900a58d9e9405207e4046ab2b3c115afa9565
+SHA1 (patch-runtime_druntime_src_core_stdc_config.d) = 30cf376ceddf9e161c7d9587e77df391e7b9c382
+SHA1 (patch-runtime_druntime_src_core_stdc_errno.d) = 904f511a8659a4dce3a135c97730258b55d11f96
+SHA1 (patch-runtime_druntime_src_core_stdc_fenv.d) = 42493a06ed3b62ec36f1014dd6ba8053499f975e
+SHA1 (patch-runtime_druntime_src_core_stdc_locale.d) = cb0d3424dfbe61570e446ea04d1298bba5123f83
+SHA1 (patch-runtime_druntime_src_core_stdc_math.d) = f020416b74539c5c47460a27a777258af400188b
+SHA1 (patch-runtime_druntime_src_core_stdc_stdio.d) = 9db34e143a47055276f800dd08fb0d4e857e1889
+SHA1 (patch-runtime_druntime_src_core_stdc_stdlib.d) = 316a55df93f5cd0631af0501dd02d7994b6d18c2
+SHA1 (patch-runtime_druntime_src_core_stdc_string.d) = 7b32050fbc38700ec9b258f4c7ed497ed8d6cde2
+SHA1 (patch-runtime_druntime_src_core_stdc_tgmath.d) = 4d8945b639362035b9bc45d325e50291e77a0eaa
+SHA1 (patch-runtime_druntime_src_core_stdc_time.d) = 8c06a57314f9426c5cc3823e8c2ad6661049e155
+SHA1 (patch-runtime_druntime_src_core_sys_netbsd_dlfcn.d) = 70ec062cbf25e5b36df5bca96fd0dcb41d9576ea
+SHA1 (patch-runtime_druntime_src_core_sys_netbsd_execinfo.d) = db9625cbb38824b79ce70a9cda8f8952c0014f14
+SHA1 (patch-runtime_druntime_src_core_sys_netbsd_sys_cdefs.d) = 5593bd0e2fc1149cee85bbe0f79377e802a814e2
+SHA1 (patch-runtime_druntime_src_core_sys_netbsd_sys_elf.d) = a0793194daab3282b9ef1335a0024b68b4d26b2f
+SHA1 (patch-runtime_druntime_src_core_sys_netbsd_sys_elf32.d) = 4e835863c3d0c6a09a8a78edad07206ee59b0c0d
+SHA1 (patch-runtime_druntime_src_core_sys_netbsd_sys_elf64.d) = 22551af51967749286e8e22940317b8f64a34872
+SHA1 (patch-runtime_druntime_src_core_sys_netbsd_sys_elf__common.d) = 819c3454fe15003416eb5fa64fdc5548066e9384
+SHA1 (patch-runtime_druntime_src_core_sys_netbsd_sys_event.d) = d0e2895914178bd79a6fa30dce519e08e7bd3cec
+SHA1 (patch-runtime_druntime_src_core_sys_netbsd_sys_link__elf.d) = 35b380d001f1f911a9cbac349c95fffc17e5a0a3
+SHA1 (patch-runtime_druntime_src_core_sys_netbsd_sys_mman.d) = 794923731548e0c9397bb15b30de965652b9de7f
+SHA1 (patch-runtime_druntime_src_core_sys_netbsd_time.d) = 970f4204ce08c7c6019e9491009afeba93bfc2dc
+SHA1 (patch-runtime_druntime_src_core_sys_posix_arpa_inet.d) = b0a0ee39475d5801a982b6387fb5b2c3c96a4745
+SHA1 (patch-runtime_druntime_src_core_sys_posix_dirent.d) = 2973149c750af149f0210d83805dc22540a15466
+SHA1 (patch-runtime_druntime_src_core_sys_posix_dlfcn.d) = 10e243b140b50fddd2304f343a28d778fca4ee75
+SHA1 (patch-runtime_druntime_src_core_sys_posix_fcntl.d) = 7f3302aade6031b3359219a2b1b618b2fb14878a
+SHA1 (patch-runtime_druntime_src_core_sys_posix_grp.d) = 2ce33f0732166dffcfe8d6a3670b789a5d192bfc
+SHA1 (patch-runtime_druntime_src_core_sys_posix_net_if__.d) = 56ccad60f480a0052224b07978050057174724c1
+SHA1 (patch-runtime_druntime_src_core_sys_posix_netdb.d) = eb2c65470961bd845eb03322282cb09186d9fad6
+SHA1 (patch-runtime_druntime_src_core_sys_posix_netinet_in__.d) = f06cc34b5d032272092d356d04899662ec77fe13
+SHA1 (patch-runtime_druntime_src_core_sys_posix_netinet_tcp.d) = cef34601e8c65692a828ced8b0ccdc381611d4c8
+SHA1 (patch-runtime_druntime_src_core_sys_posix_poll.d) = cb8a51a0751a98283b185999f0f7fc2720939a68
+SHA1 (patch-runtime_druntime_src_core_sys_posix_pthread.d) = ca30b198f735d9f20c030aeff22d7a8b54a762e5
+SHA1 (patch-runtime_druntime_src_core_sys_posix_pwd.d) = fe19b7934973d5eed2bc07b6a93ec7b266a4bd12
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sched.d) = 374f5037aed80a818b79aa99be58780747e8981a
+SHA1 (patch-runtime_druntime_src_core_sys_posix_semaphore.d) = 9ba232716f64ff27bae870c78b34a1f93d4bd691
+SHA1 (patch-runtime_druntime_src_core_sys_posix_setjmp.d) = 27df98df8b40901b0e0487d4aa16c63234ddc49b
+SHA1 (patch-runtime_druntime_src_core_sys_posix_signal.d) = 247024ca1036b5dbb10b11e8fd27f6d8e3426997
+SHA1 (patch-runtime_druntime_src_core_sys_posix_stdio.d) = 4ed539032bcf8fb4626e9b1933e01c82afbe4476
+SHA1 (patch-runtime_druntime_src_core_sys_posix_stdlib.d) = 4b71a243b566ad3a0fefe21c96a154b2d9b41292
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_ioctl.d) = 5cbe309208ce02b0e2b39fc8794452c16fc905d6
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_ipc.d) = b3f63a86b25104cf281927993f119c42e0729cc3
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_mman.d) = 695acba21ad3fb402768942e8d4c17be0c61e124
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_resource.d) = 0760417ca4d3fbf104cf19293ce83f46bece9556
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_select.d) = 5a8c8a580f6fd79ad81d98ce2a7e0eaefce67c8b
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_shm.d) = 0e3c3c2bd97d9d1053aba468db1580566d93733e
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_socket.d) = 1a2b2c8108021b1849302f3a139294032a259eda
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_stat.d) = a56a9adf7afa7cd7dd34ac716bd068f87d1b7cd1
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_time.d) = 48a48542a268643ff480e4e1ffbba97b8a8a56e2
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_types.d) = b2bbeeb6fccf683f2f48a8addd31181b9b809180
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_uio.d) = 313aa166c0905d5230a9d54322b79bd47d2b7181
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_un.d) = 267e89401dfe63c64d81292d87e9d2a01aab4d11
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_utsname.d) = 30092b5586b66f3b5da4623ae51829af66fd837d
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_wait.d) = 52985253102d703f94e44408985a833fdce03461
+SHA1 (patch-runtime_druntime_src_core_sys_posix_syslog.d) = 04da01b67b6248fdbad4d7e3a8f05c11fabfdcab
+SHA1 (patch-runtime_druntime_src_core_sys_posix_termios.d) = 6ca3b89f97e8dbc7c719a58fac77bb66d30d7b62
+SHA1 (patch-runtime_druntime_src_core_sys_posix_time.d) = 53ce8206fcfa68bec46033ead9ce9204a6f3d96e
+SHA1 (patch-runtime_druntime_src_core_sys_posix_ucontext.d) = 01721508a88174d5bcd948849d4918ac0ab78b31
+SHA1 (patch-runtime_druntime_src_core_sys_posix_unistd.d) = 318b9a5318ebee88b001adc6aed05d600648533b
+SHA1 (patch-runtime_druntime_src_core_sys_posix_utime.d) = 2099425c3687f79d945103029432499368ea209b
+SHA1 (patch-runtime_druntime_src_core_thread.d) = 7e3c354a9396d22501c64d630b035efe7c51da65
+SHA1 (patch-runtime_druntime_src_core_threadasm.S) = 61da1b6fff6d1cebb5e8c2f88e4fe04249d15cbf
+SHA1 (patch-runtime_druntime_src_core_time.d) = bf3555fcc057b0e3b76a3a9cd265137cdeec90d0
+SHA1 (patch-runtime_druntime_src_gc_os.d) = 5cbc3818655f23f6d755f2d4960d543db8765a4d
+SHA1 (patch-runtime_druntime_src_rt_bss__section.c) = b2748c8076ddb6e98be95e7ed26749d3f309d301
+SHA1 (patch-runtime_druntime_src_rt_dmain2.d) = 888b170bad46c9c7ce4a7e381644083e956db1a0
+SHA1 (patch-runtime_druntime_src_rt_sections.d) = f6ff734d28dfb2bcbde015b1e64b35ba9464d708
+SHA1 (patch-runtime_druntime_src_rt_sections__elf__shared.d) = 5034f0264ccfd35846a12b3f6e8adaa7add346ca
+SHA1 (patch-runtime_druntime_src_rt_sections__ldc.d) = 595f1fe0f21c7ce3f6299ab645ad2c46a9979350
+SHA1 (patch-runtime_druntime_test_shared_src_load.d) = 38db7d5220931446093e96e7cc6e7a395e447752
+SHA1 (patch-runtime_phobos_osmodel.mak) = 77596eb1c6a3bb8dc94321d2e84a0d498ab42304
+SHA1 (patch-runtime_phobos_std_complex.d) = d559b11fe05bdceaf1306591f76f6a737a23ac65
+SHA1 (patch-runtime_phobos_std_conv.d) = c89cabeda3ff7cc165e6941141a994e70dfe06fd
+SHA1 (patch-runtime_phobos_std_datetime.d) = 34dca75b528e8d446b46b29410348923ecd603e6
+SHA1 (patch-runtime_phobos_std_file.d) = 1c215ff469025b9752ed952a43b0cfef3fd3543e
+SHA1 (patch-runtime_phobos_std_internal_math_gammafunction.d) = 9b438f81d9eaaad734f8ccc05ae3cedb258f1403
+SHA1 (patch-runtime_phobos_std_math.d) = d78e28331a01f044509d84b0ddc41d3f2491715a
+SHA1 (patch-runtime_phobos_std_numeric.d) = cae1a1ea5576f7a035c7a4823cf5b190a79b3c9e
+SHA1 (patch-runtime_phobos_std_parallelism.d) = f5a6a8613178fd8531a15941a85b38085c29145b
+SHA1 (patch-runtime_phobos_std_socket.d) = 9dd63f526c89b81e80c4bc839a2ed7563602af9d
+SHA1 (patch-runtime_phobos_std_stdio.d) = dc0602eaa116c9da6706b7d89902f5783e75aefc
+SHA1 (patch-runtime_phobos_std_system.d) = c125ed02b8215bea8887266867dda93e587499f1
diff --git a/ldc/patches/patch-runtime_druntime_osmodel.mak b/ldc/patches/patch-runtime_druntime_osmodel.mak
new file mode 100644
index 0000000..ae2f6d2
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_osmodel.mak
@@ -0,0 +1,16 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/osmodel.mak.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/osmodel.mak
+@@ -15,6 +15,9 @@ ifeq (,$(OS))
+   ifeq (OpenBSD,$(uname_S))
+     OS:=openbsd
+   endif
++  ifeq (NetBSD,$(uname_S))
++    OS:=netbsd
++  endif
+   ifeq (Solaris,$(uname_S))
+     OS:=solaris
+   endif
diff --git a/ldc/patches/patch-runtime_druntime_src_core_runtime.d b/ldc/patches/patch-runtime_druntime_src_core_runtime.d
new file mode 100644
index 0000000..68a85b6
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_runtime.d
@@ -0,0 +1,43 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/runtime.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/runtime.d
+@@ -407,6 +407,8 @@ extern (C) bool runModuleUnitTests()
+         import core.sys.osx.execinfo;
+     else version( FreeBSD )
+         import core.sys.freebsd.execinfo;
++    else version( NetBSD )
++        import core.sys.netbsd.execinfo;
+     else version( Windows )
+         import core.sys.windows.stacktrace;
+     else version( Solaris )
+@@ -489,6 +491,8 @@ Throwable.TraceInfo defaultTraceHandler(
+         import core.sys.osx.execinfo;
+     else version( FreeBSD )
+         import core.sys.freebsd.execinfo;
++    else version( NetBSD )
++        import core.sys.netbsd.execinfo;
+     else version( Windows )
+         import core.sys.windows.stacktrace;
+     else version( Solaris )
+@@ -650,6 +654,18 @@ Throwable.TraceInfo defaultTraceHandler(
+                         symEnd = eptr - buf.ptr;
+                     }
+                 }
++                else version( NetBSD )
++                {
++                    // format is: 0x00000000 <_D6module4funcAFZv+0x78> at module
++                    auto bptr = cast(char*) memchr( buf.ptr, '<', buf.length );
++                    auto eptr = cast(char*) memchr( buf.ptr, '+', buf.length );
++
++                    if( bptr++ && eptr )
++                    {
++                        symBeg = bptr - buf.ptr;
++                        symEnd = eptr - buf.ptr;
++                    }
++                }
+                 else version( Solaris )
+                 {
+                     // format is object'symbol+offset [pc]
diff --git a/ldc/patches/patch-runtime_druntime_src_core_stdc_config.d b/ldc/patches/patch-runtime_druntime_src_core_stdc_config.d
new file mode 100644
index 0000000..b9695ee
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_stdc_config.d
@@ -0,0 +1,15 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/stdc/config.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/stdc/config.d
+@@ -116,6 +116,8 @@ else version( DigitalMars )
+             alias real c_long_double;
+         else version( FreeBSD )
+             alias real c_long_double;
++        else version( NetBSD )
++            alias real c_long_double;
+         else version( Solaris )
+             alias real c_long_double;
+         else version( OSX )
diff --git a/ldc/patches/patch-runtime_druntime_src_core_stdc_errno.d b/ldc/patches/patch-runtime_druntime_src_core_stdc_errno.d
new file mode 100644
index 0000000..8d45aef
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_stdc_errno.d
@@ -0,0 +1,145 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/stdc/errno.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/stdc/errno.d
+@@ -1000,6 +1000,138 @@ else version( FreeBSD )
+     enum EPROTO             = 92;       /// Protocol error
+     enum ELAST              = 92;       /// Must be equal largest errno
+ }
++else version (NetBSD)
++{
++    enum EPERM           = 1               /** Operation not permitted */;
++    enum ENOENT          = 2               /** No such file or directory */;
++    enum ESRCH           = 3               /** No such process */;
++    enum EINTR           = 4               /** Interrupted system call */;
++    enum EIO             = 5               /** Input/output error */;
++    enum ENXIO           = 6               /** Device not configured */;
++    enum E2BIG           = 7               /** Argument list too long */;
++    enum ENOEXEC         = 8               /** Exec format error */;
++    enum EBADF           = 9               /** Bad file descriptor */;
++    enum ECHILD          = 10              /** No child processes */;
++    enum EDEADLK         = 11              /** Resource deadlock avoided */;
++    /* 11 was EAGAIN */
++    enum ENOMEM          = 12              /** Cannot allocate memory */;
++    enum EACCES          = 13              /** Permission denied */;
++    enum EFAULT          = 14              /** Bad address */;
++    enum ENOTBLK         = 15              /** Block device required */;
++    enum EBUSY           = 16              /** Device busy */;
++    enum EEXIST          = 17              /** File exists */;
++    enum EXDEV           = 18              /** Cross-device link */;
++    enum ENODEV          = 19              /** Operation not supported by device */;
++    enum ENOTDIR         = 20              /** Not a directory */;
++    enum EISDIR          = 21              /** Is a directory */;
++    enum EINVAL          = 22              /** Invalid argument */;
++    enum ENFILE          = 23              /** Too many open files in system */;
++    enum EMFILE          = 24              /** Too many open files */;
++    enum ENOTTY          = 25              /** Inappropriate ioctl for device */;
++    enum ETXTBSY         = 26              /** Text file busy */;
++    enum EFBIG           = 27              /** File too large */;
++    enum ENOSPC          = 28              /** No space left on device */;
++    enum ESPIPE          = 29              /** Illegal seek */;
++    enum EROFS           = 30              /** Read-only file system */;
++    enum EMLINK          = 31              /** Too many links */;
++    enum EPIPE           = 32              /** Broken pipe */;
++    /* math software */
++    enum EDOM            = 33              /** Numerical argument out of domain */;
++    enum ERANGE          = 34              /** Result too large or too small */;
++
++    /* non-blocking and interrupt i/o */
++    enum EAGAIN          = 35              /** Resource temporarily unavailable */;
++    enum EWOULDBLOCK     = EAGAIN          /** Operation would block */;
++    enum EINPROGRESS     = 36              /** Operation now in progress */;
++    enum EALREADY        = 37              /** Operation already in progress */;
++
++    /* ipc/network software -- argument errors */
++    enum ENOTSOCK        = 38              /** Socket operation on non-socket */;
++    enum EDESTADDRREQ    = 39              /** Destination address required */;
++    enum EMSGSIZE        = 40              /** Message too long */;
++    enum EPROTOTYPE      = 41              /** Protocol wrong type for socket */;
++    enum ENOPROTOOPT     = 42              /** Protocol option not available */;
++    enum EPROTONOSUPPORT = 43              /** Protocol not supported */;
++    enum ESOCKTNOSUPPORT = 44              /** Socket type not supported */;
++    enum EOPNOTSUPP      = 45              /** Operation not supported */;
++    enum EPFNOSUPPORT    = 46              /** Protocol family not supported */;
++    enum EAFNOSUPPORT    = 47              /** Address family not supported by protocol family */;
++    enum EADDRINUSE      = 48              /** Address already in use */;
++    enum EADDRNOTAVAIL   = 49              /** Can't assign requested address */;
++
++    /* ipc/network software -- operational errors */
++    enum ENETDOWN        = 50              /** Network is down */;
++    enum ENETUNREACH     = 51              /** Network is unreachable */;
++    enum ENETRESET       = 52              /** Network dropped connection on reset */;
++    enum ECONNABORTED    = 53              /** Software caused connection abort */;
++    enum ECONNRESET      = 54              /** Connection reset by peer */;
++    enum ENOBUFS         = 55              /** No buffer space available */;
++    enum EISCONN         = 56              /** Socket is already connected */;
++    enum ENOTCONN        = 57              /** Socket is not connected */;
++    enum ESHUTDOWN       = 58              /** Can't send after socket shutdown */;
++    enum ETOOMANYREFS    = 59              /** Too many references: can't splice */;
++    enum ETIMEDOUT       = 60              /** Operation timed out */;
++    enum ECONNREFUSED    = 61              /** Connection refused */;
++    enum ELOOP           = 62              /** Too many levels of symbolic links */;
++    enum ENAMETOOLONG    = 63              /** File name too long */;
++
++    /* should be rearranged */
++    enum EHOSTDOWN       = 64              /** Host is down */;
++    enum EHOSTUNREACH    = 65              /** No route to host */;
++    enum ENOTEMPTY       = 66              /** Directory not empty */;
++
++    /* quotas & mush */
++    enum EPROCLIM        = 67              /** Too many processes */;
++    enum EUSERS          = 68              /** Too many users */;
++    enum EDQUOT          = 69              /** Disc quota exceeded */;
++
++    /* Network File System */
++    enum ESTALE          = 70              /** Stale NFS file handle */;
++    enum EREMOTE         = 71              /** Too many levels of remote in path */;
++    enum EBADRPC         = 72              /** RPC struct is bad */;
++    enum ERPCMISMATCH    = 73              /** RPC version wrong */;
++    enum EPROGUNAVAIL    = 74              /** RPC prog. not avail */;
++    enum EPROGMISMATCH   = 75              /** Program version wrong */;
++    enum EPROCUNAVAIL    = 76              /** Bad procedure for program */;
++
++    enum ENOLCK          = 77              /** No locks available */;
++    enum ENOSYS          = 78              /** Function not implemented */;
++
++    enum EFTYPE          = 79              /** Inappropriate file type or format */;
++    enum EAUTH           = 80              /** Authentication error */;
++    enum ENEEDAUTH       = 81              /** Need authenticator */;
++
++    /* SystemV IPC */
++    enum EIDRM           = 82              /** Identifier removed */;
++    enum ENOMSG          = 83              /** No message of desired type */;
++    enum EOVERFLOW       = 84              /** Value too large to be stored in data type */;
++    /* Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995 */
++    enum EILSEQ          = 85              /** Illegal byte sequence */;
++
++    /* From IEEE Std 1003.1-2001 */
++    /* Base, Realtime, Threads or Thread Priority Scheduling option errors */
++    enum ENOTSUP         = 86              /** Not supported */;
++
++    /* Realtime option errors */
++    enum ECANCELED       = 87              /** Operation canceled */;
++
++    /* Realtime, XSI STREAMS option errors */
++    enum EBADMSG         = 88              /** Bad or Corrupt message */;
++
++    /* XSI STREAMS option errors  */
++    enum ENODATA         = 89              /** No message available */;
++    enum ENOSR           = 90              /** No STREAM resources */;
++    enum ENOSTR          = 91              /** Not a STREAM */;
++    enum ETIME           = 92              /** STREAM ioctl timeout */;
++
++    /* File system extended attribute errors */
++    enum ENOATTR         = 93              /** Attribute not found */;
++
++    /* Realtime, XSI STREAMS option errors */
++    enum EMULTIHOP       = 94              /** Multihop attempted */;
++    enum ENOLINK         = 95              /** Link has been severed */;
++    enum EPROTO          = 96              /** Protocol error */;
++}
+ else version (Solaris)
+ {
+     enum EPERM =  1       /** Not super-user                       */;
diff --git a/ldc/patches/patch-runtime_druntime_src_core_stdc_fenv.d b/ldc/patches/patch-runtime_druntime_src_core_stdc_fenv.d
new file mode 100644
index 0000000..cc7ed58
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_stdc_fenv.d
@@ -0,0 +1,66 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/stdc/fenv.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/stdc/fenv.d
+@@ -190,6 +190,46 @@ else version ( FreeBSD )
+ 
+     alias ushort fexcept_t;
+ }
++else version ( NetBSD )
++{
++    version(X86_64)
++    {
++        struct fenv_t
++        {
++            struct _x87
++            {
++                    uint control;       /* Control word register */
++                    uint status;        /* Status word register */
++                    uint tag;           /* Tag word register */
++                    uint[4] others;     /* EIP, Pointer Selector, etc */
++            };
++            _x87 x87;
++
++            uint mxcsr;                 /* Control and status register */
++        }
++   }
++   version(X86)
++   {
++        struct fenv_t
++        {
++            struct _x87
++            {
++                    ushort control;       /* Control word register */
++                    ushort unused1;
++                    ushort status;        /* Status word register */
++                    ushort unused2;
++                    ushort tag;           /* Tag word register */
++                    ushort unused3;
++                    uint[4] others;     /* EIP, Pointer Selector, etc */
++            };
++            _x87 x87;
++            uint32_t mxcsr;                 /* Control and status register */
++        };
++
++    }
++
++    alias uint fexcept_t;
++}
+ else version( CRuntime_Bionic )
+ {
+     version(X86)
+@@ -304,6 +344,12 @@ else version( FreeBSD )
+     ///
+     enum FE_DFL_ENV = &__fe_dfl_env;
+ }
++else version( NetBSD )
++{
++    private extern const fenv_t __fe_dfl_env;
++    ///
++    enum FE_DFL_ENV = &__fe_dfl_env;
++}
+ else version( CRuntime_Bionic )
+ {
+     private extern const fenv_t __fe_dfl_env;
diff --git a/ldc/patches/patch-runtime_druntime_src_core_stdc_locale.d b/ldc/patches/patch-runtime_druntime_src_core_stdc_locale.d
new file mode 100644
index 0000000..7dc7e13
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_stdc_locale.d
@@ -0,0 +1,30 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/stdc/locale.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/stdc/locale.d
+@@ -126,6 +126,23 @@ else version(FreeBSD)
+     ///
+     enum LC_MESSAGES       = 6;
+ }
++else version(NetBSD)
++{
++    ///
++    enum LC_ALL            = 0;
++    ///
++    enum LC_COLLATE        = 1;
++    ///
++    enum LC_CTYPE          = 2;
++    ///
++    enum LC_MONETARY       = 3;
++    ///
++    enum LC_NUMERIC        = 4;
++    ///
++    enum LC_TIME           = 5;
++    ///
++    enum LC_MESSAGES       = 6;
++}
+ else version(Solaris)
+ {
+     enum LC_CTYPE          = 0;
diff --git a/ldc/patches/patch-runtime_druntime_src_core_stdc_math.d b/ldc/patches/patch-runtime_druntime_src_core_stdc_math.d
new file mode 100644
index 0000000..0517947
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_stdc_math.d
@@ -0,0 +1,580 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/stdc/math.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/stdc/math.d
+@@ -45,6 +45,13 @@ version (FreeBSD)
+     ///
+     enum int FP_ILOGBNAN      = int.max;
+ }
++version ( NetBSD )
++{
++    ///
++    enum int FP_ILOGB0        = -int.max;
++    ///
++    enum int FP_ILOGBNAN      = int.max;
++}
+ else version (CRuntime_Bionic)
+ {
+     ///
+@@ -813,6 +820,97 @@ else version( FreeBSD )
+     int signbit(real x)         { return __signbit(x); }
+   }
+ }
++else version( NetBSD )
++{
++    enum
++    {
++        ///
++        FP_INFINITE    = 0,
++        ///
++        FP_NAN         = 1,
++        ///
++        FP_NORMAL      = 2,
++        ///
++        FP_SUBNORMAL   = 3,
++        ///
++        FP_ZERO        = 4,
++    }
++
++    enum
++    {
++        ///
++        FP_FAST_FMA  = 0,
++        ///
++        FP_FAST_FMAF = 0,
++        ///
++        FP_FAST_FMAL = 0,
++    }
++
++    uint __fpclassifyf(float x);
++    uint __fpclassifyd(double x);
++    uint __fpclassifyl(real x);
++
++  extern (D)
++  {
++    //int fpclassify(real-floating x);
++    ///
++    int fpclassify(float x)     { return __fpclassifyf(x); }
++    ///
++    int fpclassify(double x)    { return __fpclassifyd(x); }
++    ///
++    int fpclassify(real x)
++    {
++        return (real.sizeof == double.sizeof)
++            ? __fpclassifyd(x)
++            : __fpclassifyl(x);
++    }
++
++    //int isfinite(real-floating x);
++    ///
++    int isfinite(float x)       { return fpclassify(x) >= FP_NORMAL; }
++    ///
++    int isfinite(double x)      { return fpclassify(x) >= FP_NORMAL; }
++    ///
++    int isfinite(real x)        { return fpclassify(x) >= FP_NORMAL; }
++
++    //int isinf(real-floating x);
++    ///
++    int isinf(float x)          { return fpclassify(x) == FP_INFINITE; }
++    ///
++    int isinf(double x)         { return fpclassify(x) == FP_INFINITE; }
++    ///
++    int isinf(real x)           { return fpclassify(x) == FP_INFINITE; }
++
++    //int isnan(real-floating x);
++    ///
++    int isnan(float x)          { return fpclassify(x) == FP_NAN;   }
++    ///
++    int isnan(double x)         { return fpclassify(x) == FP_NAN;   }
++    ///
++    int isnan(real x)           { return fpclassify(x) == FP_NAN;   }
++
++    //int isnormal(real-floating x);
++    ///
++    int isnormal(float x)       { return fpclassify(x) == FP_NORMAL; }
++    ///
++    int isnormal(double x)      { return fpclassify(x) == FP_NORMAL; }
++    ///
++    int isnormal(real x)        { return fpclassify(x) == FP_NORMAL; }
++
++    //int signbit(real-floating x);
++    ///
++    int signbit(float x)     { return (cast(short*)&(x))[1] & 0x8000; }
++    ///
++    int signbit(double x)    { return (cast(short*)&(x))[3] & 0x8000; }
++    ///
++    int signbit(real x)
++    {
++        return (real.sizeof == double.sizeof)
++            ? (cast(short*)&(x))[3] & 0x8000
++            : (cast(short*)&(x))[4] & 0x8000;
++    }
++  }
++}
+ else version( Solaris )
+ {
+     int __isnanf(float x);
+@@ -1450,7 +1548,7 @@ else version( FreeBSD )
+   }
+   else
+   {
+-      ///
++    ///
+     real    acosl(real x);
+     ///
+     real    asinl(real x);
+@@ -1850,6 +1948,452 @@ else version( FreeBSD )
+     ///
+     float   fmaf(float x, float y, float z);
+ }
++else version( NetBSD )
++{
++
++    ///
++    real    acosl(real x) ;
++    ///
++    real    asinl(real x) ;
++    ///
++    real    atanl(real x) ;
++    ///
++    real    atan2l(real y, real x) ;
++    ///
++    real    cosl(real x) ;
++    ///
++    real    sinl(real x) ;
++    ///
++    real    tanl(real x) ;
++    ///
++    real    exp2l(real x) ;
++    ///
++    real    frexpl(real value, int* exp) ;
++    ///
++    int     ilogbl(real x) ;
++    ///
++    real    ldexpl(real x, int exp) ;
++    ///
++    real    logbl(real x) ;
++    ///
++    real    modfl(real value, real *iptr) ;
++    ///
++    real    scalbnl(real x, int n) ;
++    ///
++    real    scalblnl(real x, c_long n) ;
++    ///
++    real    fabsl(real x) ;
++    ///
++    real    hypotl(real x, real y) ;
++    ///
++    real    sqrtl(real x) ;
++    ///
++    real    ceill(real x) ;
++    ///
++    real    floorl(real x) ;
++    ///
++    real    nearbyintl(real x) ;
++    ///
++    real    rintl(real x) ;
++    ///
++    c_long  lrintl(real x) { return cast(c_long)rintl(x); }
++    ///
++    real    roundl(real x) ;
++    ///
++    c_long  lroundl(real x) { return cast(c_long)roundl(x);}
++    ///
++    long    llroundl(real x) { return cast(long)roundl(x);}
++    ///
++    real    truncl(real x) ;
++    ///
++    real    fmodl(real x, real y) ;
++    ///
++    real    remainderl(real x, real y)  { return remainder(x,y); }
++    ///
++    real    remquol(real x, real y, int* quo){ return remquo(x,y,quo); }
++    ///
++    real    copysignl(real x, real y)  ;
++    ///
++    double  nan(char* tagp);
++    ///
++    float   nanf(char* tagp);
++    ///
++    real    nanl(char* tagp);
++    ///
++    real    nextafterl(real x, real y) ;
++    ///
++    real    nexttowardl(real x, real y) { return nexttoward(cast(double) x, cast(double) y); }
++    ///
++    real    fdiml(real x, real y) ;
++    ///
++    real    fmaxl(real x, real y) ;
++    ///
++    real    fminl(real x, real y) ;
++    ///
++    real    fmal(real x, real y, real z) ;
++
++    ///
++    double  acos(double x);
++    ///
++    float   acosf(float x);
++
++    ///
++    double  asin(double x);
++    ///
++    float   asinf(float x);
++
++    ///
++    double  atan(double x);
++    ///
++    float   atanf(float x);
++
++    ///
++    double  atan2(double y, double x);
++    ///
++    float   atan2f(float y, float x);
++
++    ///
++    double  cos(double x);
++    ///
++    float   cosf(float x);
++
++    ///
++    double  sin(double x);
++    ///
++    float   sinf(float x);
++
++    ///
++    double  tan(double x);
++    ///
++    float   tanf(float x);
++
++    ///
++    double  acosh(double x);
++    ///
++    float   acoshf(float x);
++    ///
++    real    acoshl(real x) ;
++
++    ///
++    double  asinh(double x);
++    ///
++    float   asinhf(float x);
++    ///
++    real    asinhl(real x) ;
++
++    ///
++    double  atanh(double x);
++    ///
++    float   atanhf(float x);
++    ///
++    real    atanhl(real x) ;
++
++    ///
++    double  cosh(double x);
++    ///
++    float   coshf(float x);
++    ///
++    real    coshl(real x) ;
++
++    ///
++    double  sinh(double x);
++    ///
++    float   sinhf(float x);
++    ///
++    real    sinhl(real x);
++
++    ///
++    double  tanh(double x);
++    ///
++    float   tanhf(float x);
++    ///
++    real    tanhl(real x) ;
++
++    ///
++    double  exp(double x);
++    ///
++    float   expf(float x);
++    ///
++    real    expl(real x) ;
++
++    ///
++    double  exp2(double x);
++    ///
++    float   exp2f(float x);
++
++    ///
++    double  expm1(double x);
++    ///
++    float   expm1f(float x);
++    ///
++    real    expm1l(real x)  { return expm1(cast(double) x); }
++
++    ///
++    double  frexp(double value, int* exp);
++    ///
++    float   frexpf(float value, int* exp);
++
++    ///
++    int     ilogb(double x);
++    ///
++    int     ilogbf(float x);
++
++    ///
++    double  ldexp(double x, int exp);
++    ///
++    float   ldexpf(float x, int exp);
++
++    ///
++    double  log(double x);
++    ///
++    float   logf(float x);
++    /// NetBSD has no logl. It is just alias log(double)
++    real    logl(real x)
++    {
++        if(x<0) return real.nan;
++        if(x==0) return -real.infinity;
++        if(isnan(x) || isinf(x)) return x;
++        real rs = 0;
++        if(x>double.max)
++        {
++            immutable MAX = log(double.max);
++            for(; x>double.max; x /= double.max)
++                rs += MAX;
++        }
++        else if(x<double.min_normal)
++        {
++            immutable MIN = log(double.min_normal);
++            for(; x<double.min_normal; x /= double.min_normal)
++                rs += MIN;
++        }
++        rs += log(x);
++        return rs;
++    }
++
++    ///
++    double  log10(double x);
++    ///
++    float   log10f(float x);
++    ///NetBSD has no log10l. It is just alias log(double)
++    real    log10l(real x)
++    {
++        if(x<0) return real.nan;
++        if(x==0) return -real.infinity;
++        if(isnan(x) || isinf(x)) return x;
++
++        real rs = 0;
++        if(x>double.max)
++        {
++            immutable MAX = log10(double.max);
++            for(; x>double.max; x /= double.max)
++                rs += MAX;
++        }
++        else if(x<double.min_normal)
++        {
++            immutable MIN = log10(double.min_normal);
++            for(; x<double.min_normal; x /= double.min_normal)
++                rs += MIN;
++        }
++        rs += log10(x);
++
++        return rs;
++    }
++
++
++    ///
++    double  log1p(double x);
++    ///
++    float   log1pf(float x);
++    ///
++    real    log1pl(real x) { return log1p(cast(double) x); }
++
++    private enum real ONE_LN2 = 1 / 0x1.62e42fefa39ef358p-1L;
++    ///
++    double  log2(double x) { return log(x) * ONE_LN2; }
++    ///
++    float   log2f(float x) { return logf(x) * ONE_LN2; }
++    ///
++    real    log2l(real x)  { return logl(x) * ONE_LN2; }
++
++    ///
++    double  logb(double x);
++    ///
++    float   logbf(float x);
++
++    ///
++    double  modf(double value, double* iptr);
++    ///
++    float   modff(float value, float* iptr);
++
++    ///
++    double  scalbn(double x, int n);
++    ///
++    float   scalbnf(float x, int n);
++
++    ///
++    double  scalbln(double x, c_long n);
++    ///
++    float   scalblnf(float x, c_long n);
++
++    ///
++    double  cbrt(double x);
++    ///
++    float   cbrtf(float x);
++    ///
++    real    cbrtl(real x);
++
++    ///
++    double  fabs(double x);
++    ///
++    float   fabsf(float x);
++
++    ///
++    double  hypot(double x, double y);
++    ///
++    float   hypotf(float x, float y);
++
++    ///
++    double  pow(double x, double y);
++    ///
++    float   powf(float x, float y);
++    ///
++    real    powl(real x, real y);
++
++    ///
++    double  sqrt(double x);
++    ///
++    float   sqrtf(float x);
++
++    ///
++    double  erf(double x);
++    ///
++    float   erff(float x);
++    ///
++    real    erfl(real x) { return erf(cast(double) x); }
++
++    ///
++    double  erfc(double x);
++    ///
++    float   erfcf(float x);
++    ///
++    real    erfcl(real x)  { return erfc(cast(double) x); }
++
++    ///
++    double  lgamma(double x);
++    ///
++    float   lgammaf(float x);
++    ///
++    real    lgammal(real x){ return lgamma(x); }
++
++    ///
++    double  tgamma(double x);
++    ///
++    float   tgammaf(float x);
++    ///
++    real    tgammal(real x){ return tgamma(cast(double) x); }
++
++    ///
++    double  ceil(double x);
++    ///
++    float   ceilf(float x);
++
++    ///
++    double  floor(double x);
++    ///
++    float   floorf(float x);
++
++    ///
++    double  nearbyint(double x);
++    ///
++    float   nearbyintf(float x);
++
++    ///
++    double  rint(double x);
++    ///
++    float   rintf(float x);
++
++    ///
++    c_long  lrint(double x);
++    ///
++    c_long  lrintf(float x);
++
++    ///
++    long    llrint(double x);
++    ///
++    long    llrintf(float x);
++    ///
++    long    llrintl(real x) { return cast(long)rintl(x); }
++
++    ///
++    double  round(double x);
++    ///
++    float   roundf(float x);
++
++    ///
++    c_long  lround(double x);
++    ///
++    c_long  lroundf(float x);
++
++    ///
++    long    llround(double x);
++    ///
++    long    llroundf(float x);
++
++    ///
++    double  trunc(double x);
++    ///
++    float   truncf(float x);
++
++    ///
++    double  fmod(double x, double y);
++    ///
++    float   fmodf(float x, float y);
++
++    ///
++    double  remainder(double x, double y);
++    ///
++    float   remainderf(float x, float y);
++
++    ///
++    double  remquo(double x, double y, int* quo);
++    ///
++    float   remquof(float x, float y, int* quo);
++
++    ///
++    double  copysign(double x, double y);
++    ///
++    float   copysignf(float x, float y);
++
++    ///
++    double  nextafter(double x, double y);
++    ///
++    float   nextafterf(float x, float y);
++
++    ///
++    double  nexttoward(double x, real y);
++    ///
++    float   nexttowardf(float x, real y);
++
++    ///
++    double  fdim(double x, double y);
++    ///
++    float   fdimf(float x, float y);
++
++    ///
++    double  fmax(double x, double y);
++    ///
++    float   fmaxf(float x, float y);
++
++    ///
++    double  fmin(double x, double y);
++    ///
++    float   fminf(float x, float y);
++
++    ///
++    double  fma(double x, double y, double z);
++    ///
++    float   fmaf(float x, float y, float z);
++}
+ else version(CRuntime_Bionic)
+ {
+     // Bionic defines long double as 64 bits, same as double, so several long
diff --git a/ldc/patches/patch-runtime_druntime_src_core_stdc_stdio.d b/ldc/patches/patch-runtime_druntime_src_core_stdc_stdio.d
new file mode 100644
index 0000000..0a951fd
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_stdc_stdio.d
@@ -0,0 +1,165 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/stdc/stdio.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/stdc/stdio.d
+@@ -25,6 +25,10 @@ private
+   {
+     import core.sys.posix.sys.types;
+   }
++  version (NetBSD)
++  {
++    import core.sys.posix.sys.types;
++  }
+ }
+ 
+ extern (C):
+@@ -166,6 +170,37 @@ else version ( FreeBSD )
+         long        _mbstateL;
+     }
+ }
++else version ( NetBSD )
++{
++    enum
++    {
++        ///
++        BUFSIZ       = 1024,
++        ///
++        EOF          = -1,
++        ///
++        FOPEN_MAX    = 20,
++        ///
++        FILENAME_MAX = 1024,
++        ///
++        TMP_MAX      = 308915776,
++        ///
++        L_tmpnam     = 1024
++    }
++
++    struct __sbuf
++    {
++        ubyte *_base;
++        int _size;
++    }
++
++    union __mbstate_t // <sys/_types.h>
++    {
++        char[128]   _mbstate8;
++        long        _mbstateL;
++    }
++}
++
+ else version (Solaris)
+ {
+     enum
+@@ -392,6 +427,50 @@ else version( FreeBSD )
+     ///
+     alias shared(__sFILE) FILE;
+ }
++else version( NetBSD )
++{
++    ///
++    alias off_t fpos_t;
++
++    ///
++    struct __sFILE
++    {
++        ubyte*          _p;
++        int             _r;
++        int             _w;
++        ushort           _flags;
++        short           _file;
++        __sbuf          _bf;
++        int             _lbfsize;
++
++        void*           _cookie;
++        int     function(void*)                 _close;
++        ssize_t     function(void*, char*, size_t)     _read;
++        fpos_t  function(void*, fpos_t, int)    _seek;
++        ssize_t     function(void*, in char*, size_t)  _write;
++
++        __sbuf          _ub;
++        ubyte*          _up;
++        int             _ur;
++
++        ubyte[3]        _ubuf;
++        ubyte[1]        _nbuf;
++
++        int     function(void *)    _flush;
++        /* Formerly used by fgetln/fgetwln; kept for binary compatibility */
++        char[__sbuf.sizeof - _flush.sizeof]    _lb_unused;
++
++
++        int             _blksize;
++        off_t          _offset;
++        static assert(off_t.sizeof==8);
++    }
++
++    ///
++    alias __sFILE _iobuf;
++    ///
++    alias shared(__sFILE) FILE;
++}
+ else version (Solaris)
+ {
+     ///
+@@ -637,6 +716,29 @@ else version( FreeBSD )
+     ///
+     alias __stderrp stderr;
+ }
++else version( NetBSD )
++{
++    enum
++    {
++        ///
++        _IOFBF = 0,
++        ///
++        _IOLBF = 1,
++        ///
++        _IONBF = 2,
++    }
++
++    private extern __gshared FILE[3] __sF;
++    @property auto __stdin() { return &__sF[0]; }
++    @property auto __stdout() { return &__sF[1]; }
++    @property auto __stderr() { return &__sF[2]; }
++    ///
++    alias __stdin stdin;
++    ///
++    alias __stdout stdout;
++    ///
++    alias __stderr stderr;
++}
+ else version (Solaris)
+ {
+     enum
+@@ -1039,6 +1141,28 @@ else version( FreeBSD )
+     ///
+     int  vsnprintf(char* s, size_t n, in char* format, va_list arg);
+ }
++else version( NetBSD )
++{
++  // No unsafe pointer manipulation.
++  @trusted
++  {
++      ///
++    void rewind(FILE*);
++    ///
++    pure void clearerr(FILE*);
++    ///
++    pure int  feof(FILE*);
++    ///
++    pure int  ferror(FILE*);
++    ///
++    int  fileno(FILE*);
++  }
++
++  ///
++    int  snprintf(char* s, size_t n, in char* format, ...);
++    ///
++    int  vsnprintf(char* s, size_t n, in char* format, va_list arg);
++}
+ else version (Solaris)
+ {
+   // No unsafe pointer manipulation.
diff --git a/ldc/patches/patch-runtime_druntime_src_core_stdc_stdlib.d b/ldc/patches/patch-runtime_druntime_src_core_stdc_stdlib.d
new file mode 100644
index 0000000..9cc17ea
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_stdc_stdlib.d
@@ -0,0 +1,14 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/stdc/stdlib.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/stdc/stdlib.d
+@@ -66,6 +66,7 @@ version(Windows)      enum RAND_MAX = 0x
+ else version(CRuntime_Glibc)  enum RAND_MAX = 0x7fffffff;
+ else version(OSX)     enum RAND_MAX = 0x7fffffff;
+ else version(FreeBSD) enum RAND_MAX = 0x7fffffff;
++else version(NetBSD)  enum RAND_MAX = 0x7fffffff;
+ else version(Solaris) enum RAND_MAX = 0x7fff;
+ else version(CRuntime_Bionic) enum RAND_MAX = 0x7fffffff;
+ else static assert( false, "Unsupported platform" );
diff --git a/ldc/patches/patch-runtime_druntime_src_core_stdc_string.d b/ldc/patches/patch-runtime_druntime_src_core_stdc_string.d
new file mode 100644
index 0000000..d0ccf84
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_stdc_string.d
@@ -0,0 +1,17 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/stdc/string.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/stdc/string.d
+@@ -80,6 +80,10 @@ else version (FreeBSD)
+ {
+     int strerror_r(int errnum, char* buf, size_t buflen);
+ }
++else version (NetBSD)
++{
++    int strerror_r(int errnum, char* buf, size_t buflen);
++}
+ else version (Solaris)
+ {
+     int strerror_r(int errnum, char* buf, size_t buflen);
diff --git a/ldc/patches/patch-runtime_druntime_src_core_stdc_tgmath.d b/ldc/patches/patch-runtime_druntime_src_core_stdc_tgmath.d
new file mode 100644
index 0000000..9c1aff8
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_stdc_tgmath.d
@@ -0,0 +1,561 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/stdc/tgmath.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/stdc/tgmath.d
+@@ -571,6 +571,554 @@ version( FreeBSD )
+ //  alias core.stdc.complex.crealf     creal;
+ //  alias core.stdc.complex.creall     creal;
+ }
++version( NetBSD )
++{
++    ///
++    alias core.stdc.math.acos          acos;
++    ///
++    alias core.stdc.math.acosf         acos;
++    ///
++    alias core.stdc.math.acosl         acos;
++
++    ///
++    alias core.stdc.complex.cacos      acos;
++    ///
++    alias core.stdc.complex.cacosf     acos;
++    ///
++    alias core.stdc.complex.cacosl     acos;
++
++    ///
++    alias core.stdc.math.asin          asin;
++    ///
++    alias core.stdc.math.asinf         asin;
++    ///
++    alias core.stdc.math.asinl         asin;
++
++    ///
++    alias core.stdc.complex.casin      asin;
++    ///
++    alias core.stdc.complex.casinf     asin;
++    ///
++    alias core.stdc.complex.casinl     asin;
++
++    ///
++    alias core.stdc.math.atan          atan;
++    ///
++    alias core.stdc.math.atanf         atan;
++    ///
++    alias core.stdc.math.atanl         atan;
++
++    ///
++    alias core.stdc.complex.catan      atan;
++    ///
++    alias core.stdc.complex.catanf     atan;
++    ///
++    alias core.stdc.complex.catanl     atan;
++
++    ///
++    alias core.stdc.math.atan2         atan2;
++    ///
++    alias core.stdc.math.atan2f        atan2;
++    ///
++    alias core.stdc.math.atan2l        atan2;
++
++    ///
++    alias core.stdc.math.cos           cos;
++    ///
++    alias core.stdc.math.cosf          cos;
++    ///
++    alias core.stdc.math.cosl          cos;
++
++    ///
++    alias core.stdc.complex.ccos       cos;
++    ///
++    alias core.stdc.complex.ccosf      cos;
++    ///
++    alias core.stdc.complex.ccosl      cos;
++
++    ///
++    alias core.stdc.math.sin           sin;
++    ///
++    alias core.stdc.math.sinf          sin;
++    ///
++    alias core.stdc.math.sinl          sin;
++
++    ///
++    alias core.stdc.complex.csin       csin;
++    ///
++    alias core.stdc.complex.csinf      csin;
++    ///
++    alias core.stdc.complex.csinl      csin;
++
++    ///
++    alias core.stdc.math.tan           tan;
++    ///
++    alias core.stdc.math.tanf          tan;
++    ///
++    alias core.stdc.math.tanl          tan;
++
++    ///
++    alias core.stdc.complex.ctan       tan;
++    ///
++    alias core.stdc.complex.ctanf      tan;
++    ///
++    alias core.stdc.complex.ctanl      tan;
++
++    ///
++    alias core.stdc.math.acosh         acosh;
++    ///
++    alias core.stdc.math.acoshf        acosh;
++    ///
++    alias core.stdc.math.acoshl        acosh;
++
++    ///
++    alias core.stdc.complex.cacosh     acosh;
++    ///
++    alias core.stdc.complex.cacoshf    acosh;
++    ///
++    alias core.stdc.complex.cacoshl    acosh;
++
++    ///
++    alias core.stdc.math.asinh         asinh;
++    ///
++    alias core.stdc.math.asinhf        asinh;
++    ///
++    alias core.stdc.math.asinhl        asinh;
++
++    ///
++    alias core.stdc.complex.casinh     asinh;
++    ///
++    alias core.stdc.complex.casinhf    asinh;
++    ///
++    alias core.stdc.complex.casinhl    asinh;
++
++    ///
++    alias core.stdc.math.atanh         atanh;
++    ///
++    alias core.stdc.math.atanhf        atanh;
++    ///
++    alias core.stdc.math.atanhl        atanh;
++
++    ///
++    alias core.stdc.complex.catanh     atanh;
++    ///
++    alias core.stdc.complex.catanhf    atanh;
++    ///
++    alias core.stdc.complex.catanhl    atanh;
++
++    ///
++    alias core.stdc.math.cosh          cosh;
++    ///
++    alias core.stdc.math.coshf         cosh;
++    ///
++    alias core.stdc.math.coshl         cosh;
++
++    ///
++    alias core.stdc.complex.ccosh      cosh;
++    ///
++    alias core.stdc.complex.ccoshf     cosh;
++    ///
++    alias core.stdc.complex.ccoshl     cosh;
++
++    ///
++    alias core.stdc.math.sinh          sinh;
++    ///
++    alias core.stdc.math.sinhf         sinh;
++    ///
++    alias core.stdc.math.sinhl         sinh;
++
++    ///
++    alias core.stdc.complex.csinh      sinh;
++    ///
++    alias core.stdc.complex.csinhf     sinh;
++    ///
++    alias core.stdc.complex.csinhl     sinh;
++
++    ///
++    alias core.stdc.math.tanh          tanh;
++    ///
++    alias core.stdc.math.tanhf         tanh;
++    ///
++    alias core.stdc.math.tanhl         tanh;
++
++    ///
++    alias core.stdc.complex.ctanh      tanh;
++    ///
++    alias core.stdc.complex.ctanhf     tanh;
++    ///
++    alias core.stdc.complex.ctanhl     tanh;
++
++    ///
++    alias core.stdc.math.exp           exp;
++    ///
++    alias core.stdc.math.expf          exp;
++    ///
++    alias core.stdc.math.expl          exp;
++
++    ///
++    alias core.stdc.complex.cexp       exp;
++    ///
++    alias core.stdc.complex.cexpf      exp;
++    ///
++    alias core.stdc.complex.cexpl      exp;
++
++    ///
++    alias core.stdc.math.exp2          exp2;
++    ///
++    alias core.stdc.math.exp2f         exp2;
++    ///
++    alias core.stdc.math.exp2l         exp2;
++
++    ///
++    alias core.stdc.math.expm1         expm1;
++    ///
++    alias core.stdc.math.expm1f        expm1;
++    ///
++    alias core.stdc.math.expm1l        expm1;
++
++    ///
++    alias core.stdc.math.frexp         frexp;
++    ///
++    alias core.stdc.math.frexpf        frexp;
++    ///
++    alias core.stdc.math.frexpl        frexp;
++
++    ///
++    alias core.stdc.math.ilogb         ilogb;
++    ///
++    alias core.stdc.math.ilogbf        ilogb;
++    ///
++    alias core.stdc.math.ilogbl        ilogb;
++
++    ///
++    alias core.stdc.math.ldexp         ldexp;
++    ///
++    alias core.stdc.math.ldexpf        ldexp;
++    ///
++    alias core.stdc.math.ldexpl        ldexp;
++
++    ///
++    alias core.stdc.math.log           log;
++    ///
++    alias core.stdc.math.logf          log;
++    ///
++    alias core.stdc.math.logl          log;
++
++    ///
++    alias core.stdc.complex.clog       log;
++    ///
++    alias core.stdc.complex.clogf      log;
++    ///
++    alias core.stdc.complex.clogl      log;
++
++    ///
++    alias core.stdc.math.log10         log10;
++    ///
++    alias core.stdc.math.log10f        log10;
++    ///
++    alias core.stdc.math.log10l        log10;
++
++    ///
++    alias core.stdc.math.log1p         log1p;
++    ///
++    alias core.stdc.math.log1pf        log1p;
++    ///
++    alias core.stdc.math.log1pl        log1p;
++
++    ///
++    alias core.stdc.math.log2          log2;
++    ///
++    alias core.stdc.math.log2f         log2;
++    ///
++    alias core.stdc.math.log2l         log2;
++
++    ///
++    alias core.stdc.math.logb          logb;
++    ///
++    alias core.stdc.math.logbf         logb;
++    ///
++    alias core.stdc.math.logbl         logb;
++
++    ///
++    alias core.stdc.math.modf          modf;
++    ///
++    alias core.stdc.math.modff         modf;
++//  alias core.stdc.math.modfl         modf;
++
++    ///
++    alias core.stdc.math.scalbn        scalbn;
++    ///
++    alias core.stdc.math.scalbnf       scalbn;
++    ///
++    alias core.stdc.math.scalbnl       scalbn;
++
++    ///
++    alias core.stdc.math.scalbln       scalbln;
++    ///
++    alias core.stdc.math.scalblnf      scalbln;
++    ///
++    alias core.stdc.math.scalblnl      scalbln;
++
++    ///
++    alias core.stdc.math.cbrt          cbrt;
++    ///
++    alias core.stdc.math.cbrtf         cbrt;
++    ///
++    alias core.stdc.math.cbrtl         cbrt;
++
++    ///
++    alias core.stdc.math.fabs          fabs;
++    ///
++    alias core.stdc.math.fabsf         fabs;
++    ///
++    alias core.stdc.math.fabsl         fabs;
++
++    ///
++    alias core.stdc.complex.cabs       fabs;
++    ///
++    alias core.stdc.complex.cabsf      fabs;
++    ///
++    alias core.stdc.complex.cabsl      fabs;
++
++    ///
++    alias core.stdc.math.hypot         hypot;
++    ///
++    alias core.stdc.math.hypotf        hypot;
++    ///
++    alias core.stdc.math.hypotl        hypot;
++
++    ///
++    alias core.stdc.math.pow           pow;
++    ///
++    alias core.stdc.math.powf          pow;
++    ///
++    alias core.stdc.math.powl          pow;
++
++    ///
++    alias core.stdc.complex.cpow       pow;
++    ///
++    alias core.stdc.complex.cpowf      pow;
++    ///
++    alias core.stdc.complex.cpowl      pow;
++
++    ///
++    alias core.stdc.math.sqrt          sqrt;
++    ///
++    alias core.stdc.math.sqrtf         sqrt;
++    ///
++    alias core.stdc.math.sqrtl         sqrt;
++
++    ///
++    alias core.stdc.complex.csqrt      sqrt;
++    ///
++    alias core.stdc.complex.csqrtf     sqrt;
++    ///
++    alias core.stdc.complex.csqrtl     sqrt;
++
++    ///
++    alias core.stdc.math.erf           erf;
++    ///
++    alias core.stdc.math.erff          erf;
++    ///
++    alias core.stdc.math.erfl          erf;
++
++    ///
++    alias core.stdc.math.erfc          erfc;
++    ///
++    alias core.stdc.math.erfcf         erfc;
++    ///
++    alias core.stdc.math.erfcl         erfc;
++
++    ///
++    alias core.stdc.math.lgamma        lgamma;
++    ///
++    alias core.stdc.math.lgammaf       lgamma;
++    ///
++    alias core.stdc.math.lgammal       lgamma;
++
++    ///
++    alias core.stdc.math.tgamma        tgamma;
++    ///
++    alias core.stdc.math.tgammaf       tgamma;
++    ///
++    alias core.stdc.math.tgammal       tgamma;
++
++    ///
++    alias core.stdc.math.ceil          ceil;
++    ///
++    alias core.stdc.math.ceilf         ceil;
++    ///
++    alias core.stdc.math.ceill         ceil;
++
++    ///
++    alias core.stdc.math.floor         floor;
++    ///
++    alias core.stdc.math.floorf        floor;
++    ///
++    alias core.stdc.math.floorl        floor;
++
++    ///
++    alias core.stdc.math.nearbyint     nearbyint;
++    ///
++    alias core.stdc.math.nearbyintf    nearbyint;
++    ///
++    alias core.stdc.math.nearbyintl    nearbyint;
++
++    ///
++    alias core.stdc.math.rint          rint;
++    ///
++    alias core.stdc.math.rintf         rint;
++    ///
++    alias core.stdc.math.rintl         rint;
++
++    ///
++    alias core.stdc.math.lrint         lrint;
++    ///
++    alias core.stdc.math.lrintf        lrint;
++    ///
++    alias core.stdc.math.lrintl        lrint;
++
++    ///
++    alias core.stdc.math.llrint        llrint;
++    ///
++    alias core.stdc.math.llrintf       llrint;
++    ///
++    alias core.stdc.math.llrintl       llrint;
++
++    ///
++    alias core.stdc.math.round         round;
++    ///
++    alias core.stdc.math.roundf        round;
++    ///
++    alias core.stdc.math.roundl        round;
++
++    ///
++    alias core.stdc.math.lround        lround;
++    ///
++    alias core.stdc.math.lroundf       lround;
++    ///
++    alias core.stdc.math.lroundl       lround;
++
++    ///
++    alias core.stdc.math.llround       llroundl;
++    ///
++    alias core.stdc.math.llroundf      llroundl;
++    ///
++    alias core.stdc.math.llroundl      llroundl;
++
++    ///
++    alias core.stdc.math.trunc         trunc;
++    ///
++    alias core.stdc.math.truncf        trunc;
++    ///
++    alias core.stdc.math.truncl        trunc;
++
++    ///
++    alias core.stdc.math.fmod          fmod;
++    ///
++    alias core.stdc.math.fmodf         fmod;
++    ///
++    alias core.stdc.math.fmodl         fmod;
++
++    ///
++    alias core.stdc.math.remainder     remainder;
++    ///
++    alias core.stdc.math.remainderf    remainder;
++    ///
++    alias core.stdc.math.remainderl    remainder;
++
++    ///
++    alias core.stdc.math.remquo        remquo;
++    ///
++    alias core.stdc.math.remquof       remquo;
++    ///
++    alias core.stdc.math.remquol       remquo;
++
++    ///
++    alias core.stdc.math.copysign      copysign;
++    ///
++    alias core.stdc.math.copysignf     copysign;
++    ///
++    alias core.stdc.math.copysignl     copysign;
++
++//  alias core.stdc.math.nan           nan;
++//  alias core.stdc.math.nanf          nan;
++//  alias core.stdc.math.nanl          nan;
++
++    ///
++    alias core.stdc.math.nextafter     nextafter;
++    ///
++    alias core.stdc.math.nextafterf    nextafter;
++    ///
++    alias core.stdc.math.nextafterl    nextafter;
++
++    ///
++    alias core.stdc.math.nexttoward    nexttoward;
++    ///
++    alias core.stdc.math.nexttowardf   nexttoward;
++    ///
++    alias core.stdc.math.nexttowardl   nexttoward;
++
++    ///
++    alias core.stdc.math.fdim          fdim;
++    ///
++    alias core.stdc.math.fdimf         fdim;
++    ///
++    alias core.stdc.math.fdiml         fdim;
++
++    ///
++    alias core.stdc.math.fmax          fmax;
++    ///
++    alias core.stdc.math.fmaxf         fmax;
++    ///
++    alias core.stdc.math.fmaxl         fmax;
++
++    ///
++    alias core.stdc.math.fmin          fmin;
++    ///
++    alias core.stdc.math.fmin          fmin;
++    ///
++    alias core.stdc.math.fminl         fmin;
++
++    ///
++    alias core.stdc.math.fma           fma;
++    ///
++    alias core.stdc.math.fmaf          fma;
++    ///
++    alias core.stdc.math.fmal          fma;
++
++    ///
++    alias core.stdc.complex.carg       carg;
++    ///
++    alias core.stdc.complex.cargf      carg;
++    ///
++    alias core.stdc.complex.cargl      carg;
++
++    ///
++    alias core.stdc.complex.cimag      cimag;
++    ///
++    alias core.stdc.complex.cimagf     cimag;
++    ///
++    alias core.stdc.complex.cimagl     cimag;
++
++    ///
++    alias core.stdc.complex.conj       conj;
++    ///
++    alias core.stdc.complex.conjf      conj;
++    ///
++    alias core.stdc.complex.conjl      conj;
++
++    ///
++    alias core.stdc.complex.cproj      cproj;
++    ///
++    alias core.stdc.complex.cprojf     cproj;
++    ///
++    alias core.stdc.complex.cprojl     cproj;
++
++//  alias core.stdc.complex.creal      creal;
++//  alias core.stdc.complex.crealf     creal;
++//  alias core.stdc.complex.creall     creal;
++}
+ else
+ {
+     ///
diff --git a/ldc/patches/patch-runtime_druntime_src_core_stdc_time.d b/ldc/patches/patch-runtime_druntime_src_core_stdc_time.d
new file mode 100644
index 0000000..86c3c47
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_stdc_time.d
@@ -0,0 +1,31 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/stdc/time.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/stdc/time.d
+@@ -82,6 +82,10 @@ else version( FreeBSD )
+ {
+     enum clock_t CLOCKS_PER_SEC = 128;
+ }
++else version( NetBSD )
++{
++    enum clock_t CLOCKS_PER_SEC = 100;
++}
+ else version (CRuntime_Glibc)
+ {
+     enum clock_t CLOCKS_PER_SEC = 1_000_000;
+@@ -145,6 +149,13 @@ else version( FreeBSD )
+     ///
+     extern __gshared const(char)*[2] tzname; // non-standard
+ }
++else version( NetBSD )
++{
++    ///
++    void tzset();                            // non-standard
++    ///
++    extern __gshared const(char)*[2] tzname; // non-standard
++}
+ else version (Solaris)
+ {
+     ///
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_dlfcn.d b/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_dlfcn.d
new file mode 100644
index 0000000..a8f3997
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_dlfcn.d
@@ -0,0 +1,120 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/netbsd/dlfcn.d.orig	2016-03-02 01:38:47.233139170 +0000
++++ runtime/druntime/src/core/sys/netbsd/dlfcn.d
+@@ -0,0 +1,113 @@
++/**
++ * D header file for NetBSD.
++ *
++ * Copyright: Copyright Martin Nowak 2012.
++ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
++ * Authors:   Martin Nowak
++ */
++module core.sys.netbsd.dlfcn;
++
++public import core.sys.posix.dlfcn;
++
++version (NetBSD):
++extern (C):
++nothrow:
++
++enum __BSD_VISIBLE = true;
++
++/*
++ * Modes and flags for dlopen().
++ */
++static assert(RTLD_LAZY   == 1);
++static assert(RTLD_NOW    == 2);
++enum RTLD_MODEMASK        =  0x3;
++static assert(RTLD_GLOBAL == 0x100);
++static assert(RTLD_LOCAL  == 0x200);
++//enum RTLD_TRACE           =  0x200;
++enum RTLD_NODELETE        =  0x01000;
++enum RTLD_NOLOAD          =  0x02000;
++
++/*
++ * Request arguments for dlinfo().
++ */
++enum RTLD_DI_LINKMAP     = 2;    /* Obtain link map. */
++enum RTLD_DI_SERINFO     = 4;    /* Obtain search path info. */
++enum RTLD_DI_SERINFOSIZE = 5;    /*  ... query for required space. */
++enum RTLD_DI_ORIGIN      = 6;    /* Obtain object origin */
++enum RTLD_DI_MAX         = RTLD_DI_ORIGIN;
++
++/*
++ * Special handle arguments for dlsym()/dlinfo().
++ */
++enum RTLD_NEXT    = cast(void *)-1;    /* Search subsequent objects. */
++enum RTLD_DEFAULT = cast(void *)-2;    /* Use default search algorithm. */
++enum RTLD_SELF    = cast(void *)-3;    /* Search the caller itself. */
++
++static if (__BSD_VISIBLE)
++{
++    /*
++     * Structure filled in by dladdr().
++     */
++    struct Dl_info {
++        const(char)     *dli_fname;     /* Pathname of shared object. */
++        void            *dli_fbase;     /* Base address of shared object. */
++        const(char)     *dli_sname;     /* Name of nearest symbol. */
++        void            *dli_saddr;     /* Address of nearest symbol. */
++    };
++
++    /*-
++     * The actual type declared by this typedef is immaterial, provided that
++     * it is a function pointer.  Its purpose is to provide a return type for
++     * dlfunc() which can be cast to a function pointer type without depending
++     * on behavior undefined by the C standard, which might trigger a compiler
++     * diagnostic.  We intentionally declare a unique type signature to force
++     * a diagnostic should the application not cast the return value of dlfunc()
++     * appropriately.
++     */
++    struct __dlfunc_arg {
++        int     __dlfunc_dummy;
++    };
++
++    alias void function(__dlfunc_arg) dlfunc_t;
++
++    /*
++     * Structures, returned by the RTLD_DI_SERINFO dlinfo() request.
++     */
++    struct Dl_serpath {
++        char *          dls_name;       /* single search path entry */
++        uint            dls_flags;      /* path information */
++    };
++
++    struct Dl_serinfo {
++        size_t          dls_size;       /* total buffer size */
++        uint            dls_cnt;        /* number of path entries */
++        Dl_serpath[1]   dls_serpath;    /* there may be more than one */
++    };
++}
++
++private template __externC(RT, P...)
++{
++    alias extern(C) RT function(P) nothrow @nogc __externC;
++}
++
++/* XSI functions first. */
++static assert(is(typeof(&dlclose) == __externC!(int, void*)));
++static assert(is(typeof(&dlerror) == __externC!(char*)));
++static assert(is(typeof(&dlopen)  == __externC!(void*, const char*, int)));
++static assert(is(typeof(&dlsym)   == __externC!(void*, void*, const char*)));
++
++static if (__BSD_VISIBLE)
++{
++    void*    fdlopen(int, int);
++    int      dladdr(const(void)*, Dl_info*);
++    dlfunc_t dlfunc(void*, const(char)*);
++    int      dlinfo(void*, int, void*);
++    void     dllockinit(void* _context,
++        void* function(void* _context) _lock_create,
++        void  function(void* _lock)    _rlock_acquire,
++        void  function(void* _lock)    _wlock_acquire,
++        void  function(void* _lock)    _lock_release,
++        void  function(void* _lock)    _lock_destroy,
++        void  function(void* _context) _context_destroy);
++    void*    dlvsym(void*, const(char)*, const(char)*);
++}
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_execinfo.d b/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_execinfo.d
new file mode 100644
index 0000000..725c903
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_execinfo.d
@@ -0,0 +1,140 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/netbsd/execinfo.d.orig	2016-03-02 01:38:47.234934858 +0000
++++ runtime/druntime/src/core/sys/netbsd/execinfo.d
+@@ -0,0 +1,133 @@
++/**
++ * NetBSD implementation of glibc's $(LINK2 http://www.gnu.org/software/libc/manual/html_node/Backtraces.html backtrace) facility.
++ *
++ * Copyright: Copyright Martin Nowak 2012.
++ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
++ * Authors:   Martin Nowak
++ * Source:    $(DRUNTIMESRC core/sys/netbsd/_execinfo.d)
++ */
++module core.sys.netbsd.execinfo;
++
++version (NetBSD):
++extern (C):
++nothrow:
++
++import core.sys.netbsd.dlfcn;
++
++// Use extern (D) so that these functions don't collide with libexecinfo.
++
++extern (D) int backtrace(void** buffer, int size)
++{
++    import core.thread : thread_stackBottom;
++
++    void** p, pend=cast(void**)thread_stackBottom();
++    version (D_InlineAsm_X86)
++        asm nothrow @trusted { mov p[EBP], EBP; }
++    else version (D_InlineAsm_X86_64)
++        asm nothrow @trusted { mov p[RBP], RBP; }
++    else
++        static assert(false, "Architecture not supported.");
++
++    int i;
++    for (; i < size && p < pend; ++i)
++    {
++        buffer[i] = *(p + 1);
++        auto pnext = cast(void**)*p;
++        if (pnext <= p) break;
++        p = pnext;
++    }
++    return i;
++}
++
++
++extern (D) char** backtrace_symbols(const(void*)* buffer, int size)
++{
++    static void* realloc(void* p, size_t len) nothrow
++    {
++        static import cstdlib=core.stdc.stdlib;
++        auto res = cstdlib.realloc(p, len);
++        if (res is null) cstdlib.free(p);
++        return res;
++    }
++
++    if (size <= 0) return null;
++
++    size_t pos = size * (char*).sizeof;
++    char** p = cast(char**)realloc(null, pos);
++    if (p is null) return null;
++
++    Dl_info info;
++    foreach (i, addr; buffer[0 .. size])
++    {
++        if (dladdr(addr, &info) == 0)
++            (cast(ubyte*)&info)[0 .. info.sizeof] = 0;
++        fixupDLInfo(addr, info);
++
++        immutable len = formatStackFrame(null, 0, addr, info);
++        assert(len > 0);
++
++        p = cast(char**)realloc(p, pos + len);
++        if (p is null) return null;
++
++        formatStackFrame(cast(char*)p + pos, len, addr, info) == len || assert(0);
++
++        p[i] = cast(char*)pos;
++        pos += len;
++    }
++    foreach (i; 0 .. size)
++    {
++        pos = cast(size_t)p[i];
++        p[i] = cast(char*)p + pos;
++    }
++    return p;
++}
++
++
++extern (D) void backtrace_symbols_fd(const(void*)* buffer, int size, int fd)
++{
++    import core.sys.posix.unistd : write;
++    import core.stdc.stdlib : alloca;
++
++    if (size <= 0) return;
++
++    Dl_info info;
++    foreach (i, addr; buffer[0 .. size])
++    {
++        if (dladdr(addr, &info) == 0)
++            (cast(ubyte*)&info)[0 .. info.sizeof] = 0;
++        fixupDLInfo(addr, info);
++
++        enum maxAlloca = 1024;
++        enum min = (size_t a, size_t b) => a <= b ? a : b;
++        immutable len = min(formatStackFrame(null, 0, addr, info), maxAlloca);
++        assert(len > 0);
++
++        auto p = cast(char*)alloca(len);
++        if (p is null) return;
++
++        formatStackFrame(p, len, addr, info) >= len || assert(0);
++        p[len - 1] = '\n';
++        write(fd, p, len);
++    }
++}
++
++
++private void fixupDLInfo(const(void)* addr, ref Dl_info info)
++{
++    if (info.dli_fname is null) info.dli_fname = "???";
++    if (info.dli_fbase is null) info.dli_fbase = null;
++    if (info.dli_sname is null) info.dli_sname = "???";
++    if (info.dli_saddr is null) info.dli_saddr = cast(void*)addr;
++}
++
++
++private size_t formatStackFrame(char* p, size_t plen, const(void)* addr, const ref Dl_info info)
++{
++    import core.stdc.stdio : snprintf;
++
++    immutable off = addr - info.dli_saddr;
++    immutable len = snprintf(p, plen, "%p <%s+%zd> at %s",
++                             addr, info.dli_sname, off, info.dli_fname);
++    assert(len > 0);
++    return cast(size_t)len + 1; // + '\0'
++}
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_cdefs.d b/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_cdefs.d
new file mode 100644
index 0000000..75dd2eb
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_cdefs.d
@@ -0,0 +1,23 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/netbsd/sys/cdefs.d.orig	2016-03-02 01:38:47.237364846 +0000
++++ runtime/druntime/src/core/sys/netbsd/sys/cdefs.d
+@@ -0,0 +1,16 @@
++/**
++ * D header file for FreeBSD
++ *
++ * Authors: Martin Nowak
++ */
++module core.sys.netbsd.sys.cdefs;
++
++version (NetBSD):
++
++public import core.sys.posix.config;
++
++
++enum __POSIX_VISIBLE = 200112;
++enum __XSI_VISIBLE = 700;
++enum __BSD_VISIBLE = true;
++enum __ISO_C_VISIBLE = 1999;
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_elf.d b/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_elf.d
new file mode 100644
index 0000000..b1dc9d7
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_elf.d
@@ -0,0 +1,18 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/netbsd/sys/elf.d.orig	2016-03-02 01:38:47.238980833 +0000
++++ runtime/druntime/src/core/sys/netbsd/sys/elf.d
+@@ -0,0 +1,11 @@
++/**
++ * D header file for NetBSD.
++ *
++ * $(LINK2 http://svnweb.freebsd.org/base/head/sys/sys/elf.h?view=markup, sys/elf.h)
++ */
++module core.sys.netbsd.sys.elf;
++
++version (NetBSD):
++
++public import core.sys.netbsd.sys.elf32;
++public import core.sys.netbsd.sys.elf64;
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_elf32.d b/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_elf32.d
new file mode 100644
index 0000000..522830f
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_elf32.d
@@ -0,0 +1,194 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/netbsd/sys/elf32.d.orig	2016-03-02 01:38:47.240511265 +0000
++++ runtime/druntime/src/core/sys/netbsd/sys/elf32.d
+@@ -0,0 +1,187 @@
++/**
++ * D header file for NetBSD.
++ *
++ * $(LINK2 http://svnweb.freebsd.org/base/head/sys/sys/elf32.h?view=markup, sys/elf32.h)
++ */
++module core.sys.netbsd.sys.elf32;
++
++version (NetBSD):
++extern (C):
++pure:
++nothrow:
++
++import core.stdc.stdint;
++public import core.sys.netbsd.sys.elf_common;
++
++alias uint16_t Elf32_Half;
++alias uint32_t Elf32_Word;
++alias int32_t  Elf32_Sword;
++alias uint64_t Elf32_Lword;
++alias uint32_t Elf32_Addr;
++alias uint32_t Elf32_Off;
++alias Elf32_Word Elf32_Hashelt;
++alias Elf32_Word Elf32_Size;
++alias Elf32_Sword Elf32_Ssize;
++
++struct Elf32_Ehdr
++{
++    char[EI_NIDENT] e_ident;
++    Elf32_Half    e_type;
++    Elf32_Half    e_machine;
++    Elf32_Word    e_version;
++    Elf32_Addr    e_entry;
++    Elf32_Off     e_phoff;
++    Elf32_Off     e_shoff;
++    Elf32_Word    e_flags;
++    Elf32_Half    e_ehsize;
++    Elf32_Half    e_phentsize;
++    Elf32_Half    e_phnum;
++    Elf32_Half    e_shentsize;
++    Elf32_Half    e_shnum;
++    Elf32_Half    e_shstrndx;
++}
++
++struct Elf32_Shdr
++{
++    Elf32_Word    sh_name;
++    Elf32_Word    sh_type;
++    Elf32_Word    sh_flags;
++    Elf32_Addr    sh_addr;
++    Elf32_Off     sh_offset;
++    Elf32_Word    sh_size;
++    Elf32_Word    sh_link;
++    Elf32_Word    sh_info;
++    Elf32_Word    sh_addralign;
++    Elf32_Word    sh_entsize;
++}
++
++struct Elf32_Phdr
++{
++    Elf32_Word    p_type;
++    Elf32_Off     p_offset;
++    Elf32_Addr    p_vaddr;
++    Elf32_Addr    p_paddr;
++    Elf32_Word    p_filesz;
++    Elf32_Word    p_memsz;
++    Elf32_Word    p_flags;
++    Elf32_Word    p_align;
++}
++
++struct Elf32_Dyn
++{
++  Elf32_Sword   d_tag;
++  union _d_un
++  {
++      Elf32_Word d_val;
++      Elf32_Addr d_ptr;
++  } _d_un d_un;
++}
++
++struct Elf32_Rel
++{
++    Elf32_Addr    r_offset;
++    Elf32_Word    r_info;
++}
++
++struct Elf32_Rela
++{
++    Elf32_Addr    r_offset;
++    Elf32_Word    r_info;
++    Elf32_Sword   r_addend;
++}
++
++extern (D)
++{
++    auto ELF32_R_SYM(V)(V val) { return val >> 8; }
++    auto ELF32_R_TYPE(V)(V val) { return val & 0xff; }
++    auto ELF32_R_INFO(S, T)(S sym, T type) { return (sym << 8) + (type & 0xff); }
++}
++
++alias Elf_Note Elf32_Nhdr;
++
++struct Elf32_Move
++{
++    Elf32_Lword   m_value;
++    Elf32_Word    m_info;
++    Elf32_Word    m_poffset;
++    Elf32_Half    m_repeat;
++    Elf32_Half    m_stride;
++}
++
++extern (D)
++{
++    auto ELF32_M_SYM(I)(I info) { return info >> 8; }
++    auto ELF32_M_SIZE(I)(I info) { return cast(ubyte)info; }
++    auto ELF32_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubye)size; }
++}
++
++struct Elf32_Cap
++{
++    Elf32_Word    c_tag;
++    union _c_un
++    {
++        Elf32_Word      c_val;
++        Elf32_Addr      c_ptr;
++    } _c_un c_un;
++}
++
++struct Elf32_Sym
++{
++    Elf32_Word    st_name;
++    Elf32_Addr    st_value;
++    Elf32_Word    st_size;
++    ubyte st_info;
++    ubyte st_other;
++    Elf32_Half st_shndx;
++}
++
++extern (D)
++{
++    auto ELF32_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; }
++    auto ELF32_ST_TYPE(T)(T val) { return val & 0xf; }
++    auto ELF32_ST_INFO(B, T)(B bind, T type) { return (bind << 4) + (type & 0xf); }
++    auto ELF32_ST_VISIBILITY(O)(O o) { return o & 0x03; }
++}
++
++struct Elf32_Verdef
++{
++    Elf32_Half    vd_version;
++    Elf32_Half    vd_flags;
++    Elf32_Half    vd_ndx;
++    Elf32_Half    vd_cnt;
++    Elf32_Word    vd_hash;
++    Elf32_Word    vd_aux;
++    Elf32_Word    vd_next;
++}
++
++struct Elf32_Verdaux
++{
++    Elf32_Word    vda_name;
++    Elf32_Word    vda_next;
++}
++
++struct Elf32_Verneed
++{
++    Elf32_Half    vn_version;
++    Elf32_Half    vn_cnt;
++    Elf32_Word    vn_file;
++    Elf32_Word    vn_aux;
++    Elf32_Word    vn_next;
++}
++
++struct Elf32_Vernaux
++{
++    Elf32_Word    vna_hash;
++    Elf32_Half    vna_flags;
++    Elf32_Half    vna_other;
++    Elf32_Word    vna_name;
++    Elf32_Word    vna_next;
++}
++
++alias Elf32_Half Elf32_Versym;
++
++struct Elf32_Syminfo
++{
++    Elf32_Half si_boundto;
++    Elf32_Half si_flags;
++}
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_elf64.d b/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_elf64.d
new file mode 100644
index 0000000..f06153e
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_elf64.d
@@ -0,0 +1,200 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/netbsd/sys/elf64.d.orig	2016-03-02 01:38:47.242446986 +0000
++++ runtime/druntime/src/core/sys/netbsd/sys/elf64.d
+@@ -0,0 +1,193 @@
++/**
++ * D header file for NetBSD.
++ *
++ * $(LINK2 http://svnweb.freebsd.org/base/head/sys/sys/elf64.h?view=markup, sys/elf64.h)
++ */
++module core.sys.netbsd.sys.elf64;
++
++version (NetBSD):
++extern (C):
++pure:
++nothrow:
++
++import core.stdc.stdint;
++public import core.sys.netbsd.sys.elf_common;
++
++alias uint16_t Elf64_Half;
++alias uint32_t Elf64_Word;
++alias int32_t  Elf64_Sword;
++alias uint64_t Elf64_Lword;
++alias uint64_t Elf64_Xword;
++alias int64_t  Elf64_Sxword;
++alias uint64_t Elf64_Addr;
++alias uint64_t Elf64_Off;
++alias Elf64_Word Elf64_Hashelt;
++alias Elf64_Xword Elf64_Size;
++alias Elf64_Sxword Elf64_Ssize;
++
++struct Elf64_Ehdr
++{
++    char[EI_NIDENT] e_ident;
++    Elf64_Half    e_type;
++    Elf64_Half    e_machine;
++    Elf64_Word    e_version;
++    Elf64_Addr    e_entry;
++    Elf64_Off     e_phoff;
++    Elf64_Off     e_shoff;
++    Elf64_Word    e_flags;
++    Elf64_Half    e_ehsize;
++    Elf64_Half    e_phentsize;
++    Elf64_Half    e_phnum;
++    Elf64_Half    e_shentsize;
++    Elf64_Half    e_shnum;
++    Elf64_Half    e_shstrndx;
++}
++
++struct Elf64_Shdr
++{
++    Elf64_Word    sh_name;
++    Elf64_Word    sh_type;
++    Elf64_Xword   sh_flags;
++    Elf64_Addr    sh_addr;
++    Elf64_Off     sh_offset;
++    Elf64_Xword   sh_size;
++    Elf64_Word    sh_link;
++    Elf64_Word    sh_info;
++    Elf64_Xword   sh_addralign;
++    Elf64_Xword   sh_entsize;
++}
++
++struct Elf64_Phdr
++{
++    Elf64_Word    p_type;
++    Elf64_Word    p_flags;
++    Elf64_Off     p_offset;
++    Elf64_Addr    p_vaddr;
++    Elf64_Addr    p_paddr;
++    Elf64_Xword   p_filesz;
++    Elf64_Xword   p_memsz;
++    Elf64_Xword   p_align;
++}
++
++struct Elf64_Dyn
++{
++  Elf64_Sxword  d_tag;
++  union _d_un
++  {
++      Elf64_Xword d_val;
++      Elf64_Addr d_ptr;
++  } _d_un d_un;
++}
++
++struct Elf64_Rel
++{
++    Elf64_Addr    r_offset;
++    Elf64_Xword   r_info;
++}
++
++struct Elf64_Rela
++{
++    Elf64_Addr    r_offset;
++    Elf64_Xword   r_info;
++    Elf64_Sxword  r_addend;
++}
++
++extern (D)
++{
++    auto ELF64_R_SYM(I)(I i) { return i >> 32; }
++    auto ELF64_R_TYPE(I)(I i) { return i & 0xffffffff; }
++    auto ELF64_R_INFO(S, T)(S sym, T type) { return (sym << 32) + (type & 0xffffffff); }
++
++    auto ELF64_R_TYPE_DATA(I)(I i) { return (cast(Elf64_Xword) i << 32) >> 40; }
++    auto ELF64_R_TYPE_ID(I)(I i) { return (cast(Elf64_Xword) i << 56 ) >> 56; }
++    auto ELF64_R_TYPE_INFO(D, T)(D d, T t) { return cast(Elf64_Xword) d << 8 + cast(Elf64_Xword) t; }
++}
++
++alias Elf_Note Elf64_Nhdr;
++
++struct Elf64_Move
++{
++    Elf64_Lword   m_value;
++    Elf64_Xword   m_info;
++    Elf64_Xword   m_poffset;
++    Elf64_Half    m_repeat;
++    Elf64_Half    m_stride;
++}
++
++extern (D)
++{
++    auto ELF64_M_SYM(I)(I info) { return info >> 8; }
++    auto ELF64_M_SIZE(I)(I info) { return cast(ubyte)info; }
++    auto ELF64_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubye)size; }
++}
++
++struct Elf64_Cap
++{
++    Elf64_Xword   c_tag;
++    union _c_un
++    {
++        Elf64_Xword     c_val;
++        Elf64_Addr      c_ptr;
++    } _c_un c_un;
++}
++
++struct Elf64_Sym
++{
++    Elf64_Word    st_name;
++    ubyte st_info;
++    ubyte st_other;
++    Elf64_Half st_shndx;
++    Elf64_Addr    st_value;
++    Elf64_Xword   st_size;
++}
++
++extern (D)
++{
++    auto ELF64_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; }
++    auto ELF64_ST_TYPE(T)(T val) { return val & 0xf; }
++    auto ELF64_ST_INFO(B, T)(B bind, T type) { return (bind << 4) + (type & 0xf); }
++    auto ELF64_ST_VISIBILITY(O)(O o) { return o & 0x03; }
++}
++
++struct Elf64_Verdef
++{
++    Elf64_Half    vd_version;
++    Elf64_Half    vd_flags;
++    Elf64_Half    vd_ndx;
++    Elf64_Half    vd_cnt;
++    Elf64_Word    vd_hash;
++    Elf64_Word    vd_aux;
++    Elf64_Word    vd_next;
++}
++
++struct Elf64_Verdaux
++{
++    Elf64_Word    vda_name;
++    Elf64_Word    vda_next;
++}
++
++struct Elf64_Verneed
++{
++    Elf64_Half    vn_version;
++    Elf64_Half    vn_cnt;
++    Elf64_Word    vn_file;
++    Elf64_Word    vn_aux;
++    Elf64_Word    vn_next;
++}
++
++struct Elf64_Vernaux
++{
++    Elf64_Word    vna_hash;
++    Elf64_Half    vna_flags;
++    Elf64_Half    vna_other;
++    Elf64_Word    vna_name;
++    Elf64_Word    vna_next;
++}
++
++alias Elf64_Half Elf64_Versym;
++
++struct Elf64_Syminfo
++{
++    Elf64_Half si_boundto;
++    Elf64_Half si_flags;
++}
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_elf__common.d b/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_elf__common.d
new file mode 100644
index 0000000..55c1056
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_elf__common.d
@@ -0,0 +1,866 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/netbsd/sys/elf_common.d.orig	2016-03-02 01:38:47.244219558 +0000
++++ runtime/druntime/src/core/sys/netbsd/sys/elf_common.d
+@@ -0,0 +1,859 @@
++/**
++ * D header file for NetBSD.
++ * TODO - check
++ *
++ * $(LINK2 http://svnweb.freebsd.org/base/head/sys/sys/elf_common.h?view=markup, sys/elf_common.h)
++ */
++module core.sys.netbsd.sys.elf_common;
++
++version (NetBSD):
++extern (C):
++pure:
++nothrow:
++
++import core.stdc.stdint;
++
++struct Elf_Note
++{
++    uint32_t      n_namesz;
++    uint32_t      n_descsz;
++    uint32_t      n_type;
++}
++
++struct Elf_GNU_Hash_Header
++{
++    uint32_t      gh_nbuckets;
++    uint32_t      gh_symndx;
++    uint32_t      gh_maskwords;
++    uint32_t      gh_shift2;
++}
++
++enum EI_MAG0 =         0;
++enum EI_MAG1 =         1;
++enum EI_MAG2 =         2;
++enum EI_MAG3 =         3;
++enum EI_CLASS =        4;
++enum EI_DATA =         5;
++enum EI_VERSION =      6;
++enum EI_OSABI =        7;
++enum EI_ABIVERSION =   8;
++enum OLD_EI_BRAND =    8;
++enum EI_PAD =          9;
++enum EI_NIDENT =       16;
++
++enum ELFMAG0 =         0x7f;
++enum ELFMAG1 =         'E';
++enum ELFMAG2 =         'L';
++enum ELFMAG3 =         'F';
++enum ELFMAG =          "\177ELF";
++enum SELFMAG =         4;
++
++enum EV_NONE =         0;
++enum EV_CURRENT =      1;
++
++enum ELFCLASSNONE =    0;
++enum ELFCLASS32 =      1;
++enum ELFCLASS64 =      2;
++
++enum ELFDATANONE =     0;
++enum ELFDATA2LSB =     1;
++enum ELFDATA2MSB =     2;
++
++enum ELFOSABI_NONE =           0;
++enum ELFOSABI_SYSV =           0;
++enum ELFOSABI_HPUX =           1;
++enum ELFOSABI_NETBSD =         2;
++enum ELFOSABI_LINUX =          3;
++enum ELFOSABI_HURD  =          4;
++enum ELFOSABI_86OPEN =         5;
++enum ELFOSABI_SOLARIS =        6;
++enum ELFOSABI_AIX =            7;
++enum ELFOSABI_MONTEREY =       7;
++enum ELFOSABI_IRIX =           8;
++enum ELFOSABI_FREEBSD =        9;
++enum ELFOSABI_TRU64 =          10;
++enum ELFOSABI_MODESTO =        11;
++enum ELFOSABI_OPENBSD =        12;
++enum ELFOSABI_OPENVMS =        13;
++enum ELFOSABI_NSK =            14;
++enum ELFOSABI_AROS =           15;
++enum ELFOSABI_ARM =            97;
++enum ELFOSABI_STANDALONE =     255;
++
++extern (D)
++{
++    auto IS_ELF(T)(T ehdr) { return ehdr.e_ident[EI_MAG0] == ELFMAG0 &&
++                                    ehdr.e_ident[EI_MAG1] == ELFMAG1 &&
++                                    ehdr.e_ident[EI_MAG2] == ELFMAG2 &&
++                                    ehdr.e_ident[EI_MAG3] == ELFMAG3; }
++}
++
++enum ET_NONE =         0;
++enum ET_REL =          1;
++enum ET_EXEC =         2;
++enum ET_DYN =          3;
++enum ET_CORE =         4;
++enum ET_LOOS =         0xfe00;
++enum ET_HIOS =         0xfeff;
++enum ET_LOPROC =       0xff00;
++enum ET_HIPROC =       0xffff;
++
++enum EM_NONE =          0;
++enum EM_M32 =           1;
++enum EM_SPARC =         2;
++enum EM_386 =           3;
++enum EM_68K =           4;
++enum EM_88K =           5;
++enum EM_860 =           7;
++enum EM_MIPS =          8;
++enum EM_S370 =          9;
++enum EM_MIPS_RS3_LE =  10;
++enum EM_PARISC =       15;
++enum EM_VPP500 =       17;
++enum EM_SPARC32PLUS =  18;
++enum EM_960 =          19;
++enum EM_PPC =          20;
++enum EM_PPC64 =        21;
++enum EM_S390 =         22;
++enum EM_V800 =         36;
++enum EM_FR20 =         37;
++enum EM_RH32 =         38;
++enum EM_RCE =          39;
++enum EM_ARM =          40;
++enum EM_SH =           42;
++enum EM_SPARCV9 =      43;
++enum EM_TRICORE =      44;
++enum EM_ARC =          45;
++enum EM_H8_300 =       46;
++enum EM_H8_300H =      47;
++enum EM_H8S =          48;
++enum EM_H8_500 =       49;
++enum EM_IA_64 =        50;
++enum EM_MIPS_X =       51;
++enum EM_COLDFIRE =     52;
++enum EM_68HC12 =       53;
++enum EM_MMA =          54;
++enum EM_PCP =          55;
++enum EM_NCPU =         56;
++enum EM_NDR1 =         57;
++enum EM_STARCORE =     58;
++enum EM_ME16 =         59;
++enum EM_ST100 =        60;
++enum EM_TINYJ =        61;
++enum EM_X86_64 =       62;
++enum EM_AMD64 =        62;
++enum EM_PDSP =         63;
++enum EM_FX66 =         66;
++enum EM_ST9PLUS =      67;
++enum EM_ST7 =          68;
++enum EM_68HC16 =       69;
++enum EM_68HC11 =       70;
++enum EM_68HC08 =       71;
++enum EM_68HC05 =       72;
++enum EM_SVX =          73;
++enum EM_ST19 =         74;
++enum EM_VAX =          75;
++enum EM_CRIS =         76;
++enum EM_JAVELIN =      77;
++enum EM_FIREPATH =     78;
++enum EM_ZSP =          79;
++enum EM_MMIX =         80;
++enum EM_HUANY =        81;
++enum EM_PRISM =        82;
++enum EM_AVR =          83;
++enum EM_FR30 =         84;
++enum EM_D10V =         85;
++enum EM_D30V =         86;
++enum EM_V850 =         87;
++enum EM_M32R =         88;
++enum EM_MN10300 =      89;
++enum EM_MN10200 =      90;
++enum EM_PJ =           91;
++enum EM_OPENRISC =     92;
++enum EM_ARC_A5 =       93;
++enum EM_XTENSA =       94;
++enum EM_VIDEOCORE =    95;
++enum EM_TMM_GPP =      96;
++enum EM_NS32K =        97;
++enum EM_TPC =          98;
++enum EM_SNP1K =        99;
++enum EM_ST200 =       100;
++enum EM_IP2K =        101;
++enum EM_MAX =         102;
++enum EM_CR =          103;
++enum EM_F2MC16 =      104;
++enum EM_MSP430 =      105;
++enum EM_BLACKFIN =    106;
++enum EM_SE_C33 =      107;
++enum EM_SEP =         108;
++enum EM_ARCA =        109;
++enum EM_UNICORE =     110;
++enum EM_AARCH64 =     183;     /* AArch64 64-bit ARM microprocessor */
++
++/* Unofficial machine types follow */
++enum EM_AVR32  =       6317;    /* used by NetBSD/avr32 */
++enum EM_ALPHA_EXP  =  36902;   /* used by NetBSD/alpha; obsolete */
++
++enum EM_486 =           6;
++enum EM_MIPS_RS4_BE =  10;
++enum EM_ALPHA_STD =    41;
++enum EM_ALPHA =    0x9026;
++
++enum SHN_UNDEF =       0;
++enum SHN_LORESERVE =   0xff00;
++enum SHN_LOPROC =      0xff00;
++enum SHN_HIPROC =      0xff1f;
++enum SHN_LOOS =        0xff20;
++enum SHN_HIOS =        0xff3f;
++enum SHN_ABS =         0xfff1;
++enum SHN_COMMON =      0xfff2;
++enum SHN_XINDEX =      0xffff;
++enum SHN_HIRESERVE =   0xffff;
++
++enum SHT_NULL =          0;
++enum SHT_PROGBITS =      1;
++enum SHT_SYMTAB =        2;
++enum SHT_STRTAB =        3;
++enum SHT_RELA =          4;
++enum SHT_HASH =          5;
++enum SHT_DYNAMIC =       6;
++enum SHT_NOTE =          7;
++enum SHT_NOBITS =        8;
++enum SHT_REL =           9;
++enum SHT_SHLIB =         10;
++enum SHT_DYNSYM =        11;
++enum SHT_INIT_ARRAY =    14;
++enum SHT_FINI_ARRAY =    15;
++enum SHT_PREINIT_ARRAY = 16;
++enum SHT_GROUP =         17;
++enum SHT_SYMTAB_SHNDX =  18;
++enum SHT_LOOS =          0x60000000;
++enum SHT_LOSUNW =        0x6ffffff4;
++enum SHT_SUNW_dof =      0x6ffffff4;
++enum SHT_SUNW_cap =      0x6ffffff5;
++enum SHT_SUNW_SIGNATURE = 0x6ffffff6;
++enum SHT_GNU_HASH =      0x6ffffff6;
++enum SHT_SUNW_ANNOTATE = 0x6ffffff7;
++enum SHT_SUNW_DEBUGSTR = 0x6ffffff8;
++enum SHT_SUNW_DEBUG =    0x6ffffff9;
++enum SHT_SUNW_move =     0x6ffffffa;
++enum SHT_SUNW_COMDAT =   0x6ffffffb;
++enum SHT_SUNW_syminfo =  0x6ffffffc;
++enum SHT_SUNW_verdef =   0x6ffffffd;
++enum SHT_GNU_verdef =    0x6ffffffd;
++enum SHT_SUNW_verneed =  0x6ffffffe;
++enum SHT_GNU_verneed =   0x6ffffffe;
++enum SHT_SUNW_versym =   0x6fffffff;
++enum SHT_GNU_versym =    0x6fffffff;
++enum SHT_HISUNW =        0x6fffffff;
++enum SHT_HIOS =          0x6fffffff;
++enum SHT_LOPROC =        0x70000000;
++enum SHT_AMD64_UNWIND =  0x70000001;
++enum SHT_ARM_EXIDX =     0x70000001;
++enum SHT_ARM_PREEMPTMAP = 0x70000002;
++enum SHT_ARM_ATTRIBUTES = 0x70000003;
++enum SHT_ARM_DEBUGOVERLAY = 0x70000004;
++enum SHT_ARM_OVERLAYSECTION = 0x70000005;
++enum SHT_MIPS_REGINFO =  0x70000006;
++enum SHT_MIPS_OPTIONS =  0x7000000d;
++enum SHT_MIPS_DWARF =    0x7000001e;
++enum SHT_HIPROC =        0x7fffffff;
++enum SHT_LOUSER =        0x80000000;
++enum SHT_HIUSER =        0x8fffffff;
++
++enum SHF_WRITE =            (1 << 0);
++enum SHF_ALLOC =            (1 << 1);
++enum SHF_EXECINSTR =        (1 << 2);
++enum SHF_MERGE =            (1 << 4);
++enum SHF_STRINGS =          (1 << 5);
++enum SHF_INFO_LINK =        (1 << 6);
++enum SHF_LINK_ORDER =       (1 << 7);
++enum SHF_OS_NONCONFORMING = (1 << 8);
++enum SHF_GROUP =            (1 << 9);
++enum SHF_TLS =              (1 << 10);
++enum SHF_MASKOS =           0x0ff00000;
++enum SHF_MASKPROC =         0xf0000000;
++
++enum PT_NULL =         0;
++enum PT_LOAD =         1;
++enum PT_DYNAMIC =      2;
++enum PT_INTERP =       3;
++enum PT_NOTE =         4;
++enum PT_SHLIB =        5;
++enum PT_PHDR =         6;
++enum PT_TLS =          7;
++enum PT_LOOS =         0x60000000;
++enum PT_SUNW_UNWIND =  0x6464e550;
++enum PT_GNU_EH_FRAME = 0x6474e550;
++enum PT_GNU_STACK =    0x6474e551;
++enum PT_GNU_RELRO =    0x6474e552;
++enum PT_LOSUNW =       0x6ffffffa;
++enum PT_SUNWBSS =      0x6ffffffa;
++enum PT_SUNWSTACK =    0x6ffffffb;
++enum PT_SUNWDTRACE =   0x6ffffffc;
++enum PT_SUNWCAP =      0x6ffffffd;
++enum PT_HISUNW =       0x6fffffff;
++enum PT_HIOS =         0x6fffffff;
++enum PT_LOPROC =       0x70000000;
++enum PT_HIPROC =       0x7fffffff;
++
++enum PF_X =            (1 << 0);
++enum PF_W =            (1 << 1);
++enum PF_R =            (1 << 2);
++enum PF_MASKOS =       0x0ff00000;
++enum PF_MASKPROC =     0xf0000000;
++
++enum PN_XNUM =         0xffff;
++
++enum DT_NULL =         0;
++enum DT_NEEDED =       1;
++enum DT_PLTRELSZ =     2;
++enum DT_PLTGOT =       3;
++enum DT_HASH =         4;
++enum DT_STRTAB =       5;
++enum DT_SYMTAB =       6;
++enum DT_RELA =         7;
++enum DT_RELASZ =       8;
++enum DT_RELAENT =      9;
++enum DT_STRSZ =        10;
++enum DT_SYMENT =       11;
++enum DT_INIT =         12;
++enum DT_FINI =         13;
++enum DT_SONAME =       14;
++enum DT_RPATH =        15;
++enum DT_SYMBOLIC =     16;
++enum DT_REL =          17;
++enum DT_RELSZ =        18;
++enum DT_RELENT =       19;
++enum DT_PLTREL =       20;
++enum DT_DEBUG =        21;
++enum DT_TEXTREL =      22;
++enum DT_JMPREL =       23;
++enum DT_BIND_NOW =     24;
++enum DT_INIT_ARRAY =   25;
++enum DT_FINI_ARRAY =   26;
++enum DT_INIT_ARRAYSZ = 27;
++enum DT_FINI_ARRAYSZ = 28;
++enum DT_RUNPATH =      29;
++enum DT_FLAGS =        30;
++enum DT_ENCODING =     32;
++enum DT_PREINIT_ARRAY = 32;
++enum DT_PREINIT_ARRAYSZ = 33;
++enum DT_MAXPOSTAGS =   34;
++enum DT_LOOS =         0x6000000d;
++enum DT_SUNW_AUXILIARY = 0x6000000d;
++enum DT_SUNW_RTLDINF = 0x6000000e;
++enum DT_SUNW_FILTER =  0x6000000f;
++enum DT_SUNW_CAP =     0x60000010;
++enum DT_HIOS =         0x6ffff000;
++enum DT_VALRNGLO =     0x6ffffd00;
++enum DT_CHECKSUM =     0x6ffffdf8;
++enum DT_PLTPADSZ =     0x6ffffdf9;
++enum DT_MOVEENT =      0x6ffffdfa;
++enum DT_MOVESZ =       0x6ffffdfb;
++enum DT_FEATURE_1 =    0x6ffffdfc;
++enum DT_POSFLAG_1 =    0x6ffffdfd;
++enum DT_SYMINSZ =      0x6ffffdfe;
++enum DT_SYMINENT =     0x6ffffdff;
++enum DT_VALRNGHI =     0x6ffffdff;
++enum DT_ADDRRNGLO =    0x6ffffe00;
++enum DT_GNU_HASH =     0x6ffffef5;
++enum DT_CONFIG =       0x6ffffefa;
++enum DT_DEPAUDIT =     0x6ffffefb;
++enum DT_AUDIT =        0x6ffffefc;
++enum DT_PLTPAD =       0x6ffffefd;
++enum DT_MOVETAB =      0x6ffffefe;
++enum DT_SYMINFO =      0x6ffffeff;
++enum DT_ADDRRNGHI =    0x6ffffeff;
++enum DT_VERSYM =       0x6ffffff0;
++enum DT_RELACOUNT =    0x6ffffff9;
++enum DT_RELCOUNT =     0x6ffffffa;
++enum DT_FLAGS_1 =      0x6ffffffb;
++enum DT_VERDEF =       0x6ffffffc;
++enum DT_VERDEFNUM =    0x6ffffffd;
++enum DT_VERNEED =      0x6ffffffe;
++enum DT_VERNEEDNUM =   0x6fffffff;
++enum DT_LOPROC =       0x70000000;
++enum DT_DEPRECATED_SPARC_REGISTER = 0x7000001;
++enum DT_AUXILIARY =    0x7ffffffd;
++enum DT_USED =         0x7ffffffe;
++enum DT_FILTER =       0x7fffffff;
++enum DT_HIPROC =       0x7fffffff;
++
++enum DF_ORIGIN =       0x00000001;
++enum DF_SYMBOLIC =     0x00000002;
++enum DF_TEXTREL =      0x00000004;
++enum DF_BIND_NOW =     0x00000008;
++enum DF_STATIC_TLS =   0x00000010;
++
++enum DF_1_BIND_NOW =   0x00000001;
++enum DF_1_GLOBAL =     0x00000002;
++enum DF_1_NODELETE =   0x00000008;
++enum DF_1_LOADFLTR =   0x00000010;
++enum DF_1_NOOPEN =     0x00000040;
++enum DF_1_NODEFLIB =   0x00000800;
++
++enum NT_PRSTATUS =     1;
++enum NT_FPREGSET =     2;
++enum NT_PRPSINFO =     3;
++enum NT_THRMISC =      7;
++enum NT_PROCSTAT_PROC = 8;
++enum NT_PROCSTAT_FILES = 9;
++enum NT_PROCSTAT_VMMAP = 10;
++enum NT_PROCSTAT_GROUPS = 11;
++enum NT_PROCSTAT_UMASK = 12;
++enum NT_PROCSTAT_RLIMIT = 13;
++enum NT_PROCSTAT_OSREL = 14;
++enum NT_PROCSTAT_PSSTRINGS = 15;
++enum NT_PROCSTAT_AUXV = 16;
++
++enum STB_LOCAL =       0;
++enum STB_GLOBAL =      1;
++enum STB_WEAK =        2;
++enum STB_NUM =         3;
++enum STB_LOOS =        10;
++enum STB_HIOS =        12;
++enum STB_LOPROC =      13;
++enum STB_HIPROC =      15;
++
++enum STT_NOTYPE =      0;
++enum STT_OBJECT =      1;
++enum STT_FUNC =        2;
++enum STT_SECTION =     3;
++enum STT_FILE =        4;
++enum STT_COMMON =      5;
++enum STT_TLS =         6;
++enum STT_NUM =         7;
++enum STT_LOOS =        10;
++enum STT_GNU_IFUNC =   10;
++enum STT_HIOS =        12;
++enum STT_LOPROC =      13;
++enum STT_HIPROC =      15;
++
++enum STV_DEFAULT =     0;
++enum STV_INTERNAL =    1;
++enum STV_HIDDEN =      2;
++enum STV_PROTECTED =   3;
++enum STV_EXPORTED =    4;
++enum STV_SINGLETON =   5;
++enum STV_ELIMINATE =   6;
++
++enum STN_UNDEF =       0;
++
++enum VER_DEF_CURRENT = 1;
++alias VER_NDX VER_DEF_IDX;
++
++enum VER_FLG_BASE =    0x1;
++enum VER_FLG_WEAK =    0x2;
++
++enum VER_NEED_CURRENT = 1;
++enum VER_NEED_WEAK =    32768;
++enum VER_NEED_HIDDEN = VER_NDX_HIDDEN;
++alias VER_NDX VER_NEED_IDX;
++
++enum VER_NDX_LOCAL =           0;
++enum VER_NDX_GLOBAL =          1;
++enum VER_NDX_GIVEN =           2;
++
++enum VER_NDX_HIDDEN =      32768;
++extern (D)
++{
++    auto VER_NDX(V)(V v) { return v & ~(1u << 15); }
++}
++
++enum CA_SUNW_NULL =    0;
++enum CA_SUNW_HW_1 =    1;
++enum CA_SUNW_SF_1 =    2;
++
++enum SYMINFO_FLG_DIRECT =      0x0001;
++enum SYMINFO_FLG_PASSTHRU =    0x0002;
++enum SYMINFO_FLG_COPY =        0x0004;
++enum SYMINFO_FLG_LAZYLOAD =    0x0008;
++enum SYMINFO_FLG_DIRECTBIND =  0x0010;
++enum SYMINFO_FLG_NOEXTDIRECT = 0x0020;
++enum SYMINFO_FLG_FILTER =      0x0002;
++enum SYMINFO_FLG_AUXILIARY =   0x0040;
++
++enum SYMINFO_BT_SELF =         0xffff;
++enum SYMINFO_BT_PARENT =       0xfffe;
++enum SYMINFO_BT_NONE =         0xfffd;
++enum SYMINFO_BT_EXTERN =       0xfffc;
++enum SYMINFO_BT_LOWRESERVE =   0xff00;
++
++enum SYMINFO_NONE =            0;
++enum SYMINFO_CURRENT =         1;
++enum SYMINFO_NUM =             2;
++
++enum R_386_NONE =               0;
++enum R_386_32 =                 1;
++enum R_386_PC32 =               2;
++enum R_386_GOT32 =              3;
++enum R_386_PLT32 =              4;
++enum R_386_COPY =               5;
++enum R_386_GLOB_DAT =           6;
++enum R_386_JMP_SLOT =           7;
++enum R_386_RELATIVE =           8;
++enum R_386_GOTOFF =             9;
++enum R_386_GOTPC =              10;
++enum R_386_TLS_TPOFF =          14;
++enum R_386_TLS_IE =             15;
++enum R_386_TLS_GOTIE =          16;
++enum R_386_TLS_LE =             17;
++enum R_386_TLS_GD =             18;
++enum R_386_TLS_LDM =            19;
++enum R_386_TLS_GD_32 =          24;
++enum R_386_TLS_GD_PUSH =        25;
++enum R_386_TLS_GD_CALL =        26;
++enum R_386_TLS_GD_POP =         27;
++enum R_386_TLS_LDM_32 =         28;
++enum R_386_TLS_LDM_PUSH =       29;
++enum R_386_TLS_LDM_CALL =       30;
++enum R_386_TLS_LDM_POP =        31;
++enum R_386_TLS_LDO_32 =         32;
++enum R_386_TLS_IE_32 =          33;
++enum R_386_TLS_LE_32 =          34;
++enum R_386_TLS_DTPMOD32 =       35;
++enum R_386_TLS_DTPOFF32 =       36;
++enum R_386_TLS_TPOFF32 =        37;
++enum R_386_IRELATIVE =          42;
++
++enum R_ARM_NONE =               0;
++enum R_ARM_PC24 =               1;
++enum R_ARM_ABS32 =              2;
++enum R_ARM_REL32 =              3;
++enum R_ARM_PC13 =               4;
++enum R_ARM_ABS16 =              5;
++enum R_ARM_ABS12 =              6;
++enum R_ARM_THM_ABS5 =           7;
++enum R_ARM_ABS8 =               8;
++enum R_ARM_SBREL32 =            9;
++enum R_ARM_THM_PC22 =           10;
++enum R_ARM_THM_PC8 =            11;
++enum R_ARM_AMP_VCALL9 =         12;
++enum R_ARM_SWI24 =              13;
++enum R_ARM_THM_SWI8 =           14;
++enum R_ARM_XPC25 =              15;
++enum R_ARM_THM_XPC22 =          16;
++enum R_ARM_TLS_DTPMOD32 =       17;
++enum R_ARM_TLS_DTPOFF32 =       18;
++enum R_ARM_TLS_TPOFF32 =        19;
++enum R_ARM_COPY =               20;
++enum R_ARM_GLOB_DAT =           21;
++enum R_ARM_JUMP_SLOT =          22;
++enum R_ARM_RELATIVE =           23;
++enum R_ARM_GOTOFF =             24;
++enum R_ARM_GOTPC =              25;
++enum R_ARM_GOT32 =              26;
++enum R_ARM_PLT32 =              27;
++enum R_ARM_GNU_VTENTRY =        100;
++enum R_ARM_GNU_VTINHERIT =      101;
++enum R_ARM_RSBREL32 =           250;
++enum R_ARM_THM_RPC22 =          251;
++enum R_ARM_RREL32 =             252;
++enum R_ARM_RABS32 =             253;
++enum R_ARM_RPC24 =              254;
++enum R_ARM_RBASE =              255;
++
++enum R_IA_64_NONE =             0;
++enum R_IA_64_IMM14 =            0x21;
++enum R_IA_64_IMM22 =            0x22;
++enum R_IA_64_IMM64 =            0x23;
++enum R_IA_64_DIR32MSB =         0x24;
++enum R_IA_64_DIR32LSB =         0x25;
++enum R_IA_64_DIR64MSB =         0x26;
++enum R_IA_64_DIR64LSB =         0x27;
++enum R_IA_64_GPREL22 =          0x2a;
++enum R_IA_64_GPREL64I =         0x2b;
++enum R_IA_64_GPREL32MSB =       0x2c;
++enum R_IA_64_GPREL32LSB =       0x2d;
++enum R_IA_64_GPREL64MSB =       0x2e;
++enum R_IA_64_GPREL64LSB =       0x2f;
++enum R_IA_64_LTOFF22 =          0x32;
++enum R_IA_64_LTOFF64I =         0x33;
++enum R_IA_64_PLTOFF22 =         0x3a;
++enum R_IA_64_PLTOFF64I =        0x3b;
++enum R_IA_64_PLTOFF64MSB =      0x3e;
++enum R_IA_64_PLTOFF64LSB =      0x3f;
++enum R_IA_64_FPTR64I =          0x43;
++enum R_IA_64_FPTR32MSB =        0x44;
++enum R_IA_64_FPTR32LSB =        0x45;
++enum R_IA_64_FPTR64MSB =        0x46;
++enum R_IA_64_FPTR64LSB =        0x47;
++enum R_IA_64_PCREL60B =         0x48;
++enum R_IA_64_PCREL21B =         0x49;
++enum R_IA_64_PCREL21M =         0x4a;
++enum R_IA_64_PCREL21F =         0x4b;
++enum R_IA_64_PCREL32MSB =       0x4c;
++enum R_IA_64_PCREL32LSB =       0x4d;
++enum R_IA_64_PCREL64MSB =       0x4e;
++enum R_IA_64_PCREL64LSB =       0x4f;
++enum R_IA_64_LTOFF_FPTR22 =     0x52;
++enum R_IA_64_LTOFF_FPTR64I =    0x53;
++enum R_IA_64_LTOFF_FPTR32MSB =  0x54;
++enum R_IA_64_LTOFF_FPTR32LSB =  0x55;
++enum R_IA_64_LTOFF_FPTR64MSB =  0x56;
++enum R_IA_64_LTOFF_FPTR64LSB =  0x57;
++enum R_IA_64_SEGREL32MSB =      0x5c;
++enum R_IA_64_SEGREL32LSB =      0x5d;
++enum R_IA_64_SEGREL64MSB =      0x5e;
++enum R_IA_64_SEGREL64LSB =      0x5f;
++enum R_IA_64_SECREL32MSB =      0x64;
++enum R_IA_64_SECREL32LSB =      0x65;
++enum R_IA_64_SECREL64MSB =      0x66;
++enum R_IA_64_SECREL64LSB =      0x67;
++enum R_IA_64_REL32MSB =         0x6c;
++enum R_IA_64_REL32LSB =         0x6d;
++enum R_IA_64_REL64MSB =         0x6e;
++enum R_IA_64_REL64LSB =         0x6f;
++enum R_IA_64_LTV32MSB =         0x74;
++enum R_IA_64_LTV32LSB =         0x75;
++enum R_IA_64_LTV64MSB =         0x76;
++enum R_IA_64_LTV64LSB =         0x77;
++enum R_IA_64_PCREL21BI =        0x79;
++enum R_IA_64_PCREL22 =          0x7a;
++enum R_IA_64_PCREL64I =         0x7b;
++enum R_IA_64_IPLTMSB =          0x80;
++enum R_IA_64_IPLTLSB =          0x81;
++enum R_IA_64_SUB =              0x85;
++enum R_IA_64_LTOFF22X =         0x86;
++enum R_IA_64_LDXMOV =           0x87;
++enum R_IA_64_TPREL14 =          0x91;
++enum R_IA_64_TPREL22 =          0x92;
++enum R_IA_64_TPREL64I =         0x93;
++enum R_IA_64_TPREL64MSB =       0x96;
++enum R_IA_64_TPREL64LSB =       0x97;
++enum R_IA_64_LTOFF_TPREL22 =    0x9a;
++enum R_IA_64_DTPMOD64MSB =      0xa6;
++enum R_IA_64_DTPMOD64LSB =      0xa7;
++enum R_IA_64_LTOFF_DTPMOD22 =   0xaa;
++enum R_IA_64_DTPREL14 =         0xb1;
++enum R_IA_64_DTPREL22 =         0xb2;
++enum R_IA_64_DTPREL64I =        0xb3;
++enum R_IA_64_DTPREL32MSB =      0xb4;
++enum R_IA_64_DTPREL32LSB =      0xb5;
++enum R_IA_64_DTPREL64MSB =      0xb6;
++enum R_IA_64_DTPREL64LSB =      0xb7;
++enum R_IA_64_LTOFF_DTPREL22 =   0xba;
++
++enum R_MIPS_NONE =              0;
++enum R_MIPS_16 =                1;
++enum R_MIPS_32 =                2;
++enum R_MIPS_REL32 =             3;
++enum R_MIPS_26 =                4;
++enum R_MIPS_HI16 =              5;
++enum R_MIPS_LO16 =              6;
++enum R_MIPS_GPREL16 =           7;
++enum R_MIPS_LITERAL =           8;
++enum R_MIPS_GOT16 =             9;
++enum R_MIPS_PC16 =              10;
++enum R_MIPS_CALL16 =            11;
++enum R_MIPS_GPREL32 =           12;
++enum R_MIPS_GOTHI16 =           21;
++enum R_MIPS_GOTLO16 =           22;
++enum R_MIPS_CALLHI16 =          30;
++enum R_MIPS_CALLLO16 =          31;
++
++enum R_PPC_NONE =               0;
++enum R_PPC_ADDR32 =             1;
++enum R_PPC_ADDR24 =             2;
++enum R_PPC_ADDR16 =             3;
++enum R_PPC_ADDR16_LO =          4;
++enum R_PPC_ADDR16_HI =          5;
++enum R_PPC_ADDR16_HA =          6;
++enum R_PPC_ADDR14 =             7;
++enum R_PPC_ADDR14_BRTAKEN =     8;
++enum R_PPC_ADDR14_BRNTAKEN =    9;
++enum R_PPC_REL24 =              10;
++enum R_PPC_REL14 =              11;
++enum R_PPC_REL14_BRTAKEN =      12;
++enum R_PPC_REL14_BRNTAKEN =     13;
++enum R_PPC_GOT16 =              14;
++enum R_PPC_GOT16_LO =           15;
++enum R_PPC_GOT16_HI =           16;
++enum R_PPC_GOT16_HA =           17;
++enum R_PPC_PLTREL24 =           18;
++enum R_PPC_COPY =               19;
++enum R_PPC_GLOB_DAT =           20;
++enum R_PPC_JMP_SLOT =           21;
++enum R_PPC_RELATIVE =           22;
++enum R_PPC_LOCAL24PC =          23;
++enum R_PPC_UADDR32 =            24;
++enum R_PPC_UADDR16 =            25;
++enum R_PPC_REL32 =              26;
++enum R_PPC_PLT32 =              27;
++enum R_PPC_PLTREL32 =           28;
++enum R_PPC_PLT16_LO =           29;
++enum R_PPC_PLT16_HI =           30;
++enum R_PPC_PLT16_HA =           31;
++enum R_PPC_SDAREL16 =           32;
++enum R_PPC_SECTOFF =            33;
++enum R_PPC_SECTOFF_LO =         34;
++enum R_PPC_SECTOFF_HI =         35;
++enum R_PPC_SECTOFF_HA =         36;
++
++enum R_PPC64_ADDR64 =           38;
++enum R_PPC64_ADDR16_HIGHER =    39;
++enum R_PPC64_ADDR16_HIGHERA =   40;
++enum R_PPC64_ADDR16_HIGHEST =   41;
++enum R_PPC64_ADDR16_HIGHESTA =  42;
++enum R_PPC64_UADDR64 =          43;
++enum R_PPC64_REL64 =            44;
++enum R_PPC64_PLT64 =            45;
++enum R_PPC64_PLTREL64 =         46;
++enum R_PPC64_TOC16 =            47;
++enum R_PPC64_TOC16_LO =         48;
++enum R_PPC64_TOC16_HI =         49;
++enum R_PPC64_TOC16_HA =         50;
++enum R_PPC64_TOC =              51;
++enum R_PPC64_DTPMOD64 =         68;
++enum R_PPC64_TPREL64 =          73;
++enum R_PPC64_DTPREL64 =         78;
++
++enum R_PPC_TLS =                67;
++enum R_PPC_DTPMOD32 =           68;
++enum R_PPC_TPREL16 =            69;
++enum R_PPC_TPREL16_LO =         70;
++enum R_PPC_TPREL16_HI =         71;
++enum R_PPC_TPREL16_HA =         72;
++enum R_PPC_TPREL32 =            73;
++enum R_PPC_DTPREL16 =           74;
++enum R_PPC_DTPREL16_LO =        75;
++enum R_PPC_DTPREL16_HI =        76;
++enum R_PPC_DTPREL16_HA =        77;
++enum R_PPC_DTPREL32 =           78;
++enum R_PPC_GOT_TLSGD16 =        79;
++enum R_PPC_GOT_TLSGD16_LO =     80;
++enum R_PPC_GOT_TLSGD16_HI =     81;
++enum R_PPC_GOT_TLSGD16_HA =     82;
++enum R_PPC_GOT_TLSLD16 =        83;
++enum R_PPC_GOT_TLSLD16_LO =     84;
++enum R_PPC_GOT_TLSLD16_HI =     85;
++enum R_PPC_GOT_TLSLD16_HA =     86;
++enum R_PPC_GOT_TPREL16 =        87;
++enum R_PPC_GOT_TPREL16_LO =     88;
++enum R_PPC_GOT_TPREL16_HI =     89;
++enum R_PPC_GOT_TPREL16_HA =     90;
++
++enum R_PPC_EMB_NADDR32 =        101;
++enum R_PPC_EMB_NADDR16 =        102;
++enum R_PPC_EMB_NADDR16_LO =     103;
++enum R_PPC_EMB_NADDR16_HI =     104;
++enum R_PPC_EMB_NADDR16_HA =     105;
++enum R_PPC_EMB_SDAI16 =         106;
++enum R_PPC_EMB_SDA2I16 =        107;
++enum R_PPC_EMB_SDA2REL =        108;
++enum R_PPC_EMB_SDA21 =          109;
++enum R_PPC_EMB_MRKREF =         110;
++enum R_PPC_EMB_RELSEC16 =       111;
++enum R_PPC_EMB_RELST_LO =       112;
++enum R_PPC_EMB_RELST_HI =       113;
++enum R_PPC_EMB_RELST_HA =       114;
++enum R_PPC_EMB_BIT_FLD =        115;
++enum R_PPC_EMB_RELSDA =         116;
++
++enum R_SPARC_NONE =             0;
++enum R_SPARC_8 =                1;
++enum R_SPARC_16 =               2;
++enum R_SPARC_32 =               3;
++enum R_SPARC_DISP8 =            4;
++enum R_SPARC_DISP16 =           5;
++enum R_SPARC_DISP32 =           6;
++enum R_SPARC_WDISP30 =          7;
++enum R_SPARC_WDISP22 =          8;
++enum R_SPARC_HI22 =             9;
++enum R_SPARC_22 =               10;
++enum R_SPARC_13 =               11;
++enum R_SPARC_LO10 =             12;
++enum R_SPARC_GOT10 =            13;
++enum R_SPARC_GOT13 =            14;
++enum R_SPARC_GOT22 =            15;
++enum R_SPARC_PC10 =             16;
++enum R_SPARC_PC22 =             17;
++enum R_SPARC_WPLT30 =           18;
++enum R_SPARC_COPY =             19;
++enum R_SPARC_GLOB_DAT =         20;
++enum R_SPARC_JMP_SLOT =         21;
++enum R_SPARC_RELATIVE =         22;
++enum R_SPARC_UA32 =             23;
++enum R_SPARC_PLT32 =            24;
++enum R_SPARC_HIPLT22 =          25;
++enum R_SPARC_LOPLT10 =          26;
++enum R_SPARC_PCPLT32 =          27;
++enum R_SPARC_PCPLT22 =          28;
++enum R_SPARC_PCPLT10 =          29;
++enum R_SPARC_10 =               30;
++enum R_SPARC_11 =               31;
++enum R_SPARC_64 =               32;
++enum R_SPARC_OLO10 =            33;
++enum R_SPARC_HH22 =             34;
++enum R_SPARC_HM10 =             35;
++enum R_SPARC_LM22 =             36;
++enum R_SPARC_PC_HH22 =          37;
++enum R_SPARC_PC_HM10 =          38;
++enum R_SPARC_PC_LM22 =          39;
++enum R_SPARC_WDISP16 =          40;
++enum R_SPARC_WDISP19 =          41;
++enum R_SPARC_GLOB_JMP =         42;
++enum R_SPARC_7 =                43;
++enum R_SPARC_5 =                44;
++enum R_SPARC_6 =                45;
++enum R_SPARC_DISP64 =           46;
++enum R_SPARC_PLT64 =            47;
++enum R_SPARC_HIX22 =            48;
++enum R_SPARC_LOX10 =            49;
++enum R_SPARC_H44 =              50;
++enum R_SPARC_M44 =              51;
++enum R_SPARC_L44 =              52;
++enum R_SPARC_REGISTER =         53;
++enum R_SPARC_UA64 =             54;
++enum R_SPARC_UA16 =             55;
++enum R_SPARC_TLS_GD_HI22 =      56;
++enum R_SPARC_TLS_GD_LO10 =      57;
++enum R_SPARC_TLS_GD_ADD =       58;
++enum R_SPARC_TLS_GD_CALL =      59;
++enum R_SPARC_TLS_LDM_HI22 =     60;
++enum R_SPARC_TLS_LDM_LO10 =     61;
++enum R_SPARC_TLS_LDM_ADD =      62;
++enum R_SPARC_TLS_LDM_CALL =     63;
++enum R_SPARC_TLS_LDO_HIX22 =    64;
++enum R_SPARC_TLS_LDO_LOX10 =    65;
++enum R_SPARC_TLS_LDO_ADD =      66;
++enum R_SPARC_TLS_IE_HI22 =      67;
++enum R_SPARC_TLS_IE_LO10 =      68;
++enum R_SPARC_TLS_IE_LD =        69;
++enum R_SPARC_TLS_IE_LDX =       70;
++enum R_SPARC_TLS_IE_ADD =       71;
++enum R_SPARC_TLS_LE_HIX22 =     72;
++enum R_SPARC_TLS_LE_LOX10 =     73;
++enum R_SPARC_TLS_DTPMOD32 =     74;
++enum R_SPARC_TLS_DTPMOD64 =     75;
++enum R_SPARC_TLS_DTPOFF32 =     76;
++enum R_SPARC_TLS_DTPOFF64 =     77;
++enum R_SPARC_TLS_TPOFF32 =      78;
++enum R_SPARC_TLS_TPOFF64 =      79;
++
++enum R_X86_64_NONE =            0;
++enum R_X86_64_64 =              1;
++enum R_X86_64_PC32 =            2;
++enum R_X86_64_GOT32 =           3;
++enum R_X86_64_PLT32 =           4;
++enum R_X86_64_COPY =            5;
++enum R_X86_64_GLOB_DAT =        6;
++enum R_X86_64_JMP_SLOT =        7;
++enum R_X86_64_RELATIVE =        8;
++enum R_X86_64_GOTPCREL =        9;
++enum R_X86_64_32 =              10;
++enum R_X86_64_32S =             11;
++enum R_X86_64_16 =              12;
++enum R_X86_64_PC16 =            13;
++enum R_X86_64_8 =               14;
++enum R_X86_64_PC8 =             15;
++enum R_X86_64_DTPMOD64 =        16;
++enum R_X86_64_DTPOFF64 =        17;
++enum R_X86_64_TPOFF64 =         18;
++enum R_X86_64_TLSGD =           19;
++enum R_X86_64_TLSLD =           20;
++enum R_X86_64_DTPOFF32 =        21;
++enum R_X86_64_GOTTPOFF =        22;
++enum R_X86_64_TPOFF32 =         23;
++enum R_X86_64_IRELATIVE =       37;
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_event.d b/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_event.d
new file mode 100644
index 0000000..a1348ad
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_event.d
@@ -0,0 +1,115 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/netbsd/sys/event.d.orig	2016-03-02 01:38:47.246440929 +0000
++++ runtime/druntime/src/core/sys/netbsd/sys/event.d
+@@ -0,0 +1,108 @@
++/**
++ * D header file for NetBSD.
++ *
++ * Copyright: Copyright Martin Nowak 2012.
++ * License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
++ * Authors:   Martin Nowak
++ */
++
++/*          Copyright Martin Nowak 2012.
++ * Distributed under the Boost Software License, Version 1.0.
++ *    (See accompanying file LICENSE or copy at
++ *          http://www.boost.org/LICENSE_1_0.txt)
++ */
++module core.sys.netbsd.sys.event;
++
++version (NetBSD):
++extern (C):
++
++import core.stdc.stdint;    // intptr_t, uintptr_t
++import core.sys.posix.time; // timespec
++
++enum
++{
++    EVFILT_READ     =  0,
++    EVFILT_WRITE    =  1,
++    EVFILT_AIO      =  2, /* attached to aio requests */
++    EVFILT_VNODE    =  3, /* attached to vnodes */
++    EVFILT_PROC     =  4, /* attached to struct proc */
++    EVFILT_SIGNAL   =  5, /* attached to struct proc */
++    EVFILT_TIMER    =  6, /* timers */
++    EVFILT_SYSCOUNT =  7,
++}
++
++extern(D) void EV_SET(kevent_t* kevp, typeof(kevent_t.tupleof) args)
++{
++    *kevp = kevent_t(args);
++}
++
++struct kevent_t
++{
++    uintptr_t    ident; /* identifier for this event */
++    uint        filter; /* filter for event */
++    uint        flags;
++    uint        fflags;
++    ulong       data;
++    void        *udata; /* opaque user data identifier */
++}
++
++enum
++{
++    /* actions */
++    EV_ADD      = 0x0001, /* add event to kq (implies enable) */
++    EV_DELETE   = 0x0002, /* delete event from kq */
++    EV_ENABLE   = 0x0004, /* enable event */
++    EV_DISABLE  = 0x0008, /* disable event (not reported) */
++
++    /* flags */
++    EV_ONESHOT  = 0x0010, /* only report one occurrence */
++    EV_CLEAR    = 0x0020, /* clear event state after reporting */
++    EV_RECEIPT  = 0x0040, /* force EV_ERROR on success, data=0 */
++    EV_DISPATCH = 0x0080, /* disable event after reporting */
++
++    EV_SYSFLAGS = 0xF000, /* reserved by system */
++    EV_FLAG1    = 0x2000, /* filter-specific flag */
++
++    /* returned values */
++    EV_EOF      = 0x8000, /* EOF detected */
++    EV_ERROR    = 0x4000, /* error, data contains errno */
++}
++
++enum
++{
++    /*
++     * data/hint flags for EVFILT_{READ|WRITE}, shared with userspace
++     */
++    NOTE_LOWAT      = 0x0001,                  /* low water mark */
++
++    /*
++     * data/hint flags for EVFILT_VNODE, shared with userspace
++     */
++    NOTE_DELETE     = 0x0001,                  /* vnode was removed */
++    NOTE_WRITE      = 0x0002,                  /* data contents changed */
++    NOTE_EXTEND     = 0x0004,                  /* size increased */
++    NOTE_ATTRIB     = 0x0008,                  /* attributes changed */
++    NOTE_LINK       = 0x0010,                  /* link count changed */
++    NOTE_RENAME     = 0x0020,                  /* vnode was renamed */
++    NOTE_REVOKE     = 0x0040,                  /* vnode access was revoked */
++
++    /*
++     * data/hint flags for EVFILT_PROC, shared with userspace
++     */
++    NOTE_EXIT       = 0x80000000,              /* process exited */
++    NOTE_FORK       = 0x40000000,              /* process forked */
++    NOTE_EXEC       = 0x20000000,              /* process exec'd */
++    NOTE_PCTRLMASK  = 0xf0000000,              /* mask for hint bits */
++    NOTE_PDATAMASK  = 0x000fffff,              /* mask for pid */
++
++    /* additional flags for EVFILT_PROC */
++    NOTE_TRACK      = 0x00000001,              /* follow across forks */
++    NOTE_TRACKERR   = 0x00000002,              /* could not track child */
++    NOTE_CHILD      = 0x00000004               /* am a child process */
++
++}
++
++int kqueue();
++int kevent(int kq, const kevent_t *changelist, int nchanges,
++           kevent_t *eventlist, int nevents,
++           const timespec *timeout);
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_link__elf.d b/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_link__elf.d
new file mode 100644
index 0000000..ca8461b
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_link__elf.d
@@ -0,0 +1,85 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/netbsd/sys/link_elf.d.orig	2016-03-02 01:38:47.248298358 +0000
++++ runtime/druntime/src/core/sys/netbsd/sys/link_elf.d
+@@ -0,0 +1,78 @@
++/**
++ * D header file for NetBSD.
++ *
++ * $(LINK2 http://svnweb.freebsd.org/base/head/sys/sys/link_elf.h?view=markup, sys/link_elf.h)
++ */
++module core.sys.netbsd.sys.link_elf;
++
++version (NetBSD):
++extern (C):
++nothrow:
++
++import core.stdc.stdint : uint64_t;
++import core.sys.netbsd.sys.elf;
++
++version(D_LP64)
++    enum __ELF_NATIVE_CLASS = 64;
++else
++    enum __ELF_NATIVE_CLASS = 32;
++
++template ElfW(string type)
++{
++    mixin("alias Elf"~__ELF_NATIVE_CLASS.stringof~"_"~type~" ElfW;");
++}
++
++enum LA_SER_ORIG =      0x01;
++enum LA_SER_LIBPATH =   0x02;
++enum LA_SER_RUNPATH =   0x04;
++enum LA_SER_CONFIG =    0x08;
++enum LA_SER_DEFAULT =   0x40;
++enum LA_SER_SECURE =    0x80;
++
++struct link_map
++{
++    char*           l_addr;
++
++    version (MIPS32)
++        char*       l_offs;
++    version (MIPS64)
++        char*       l_offs;
++
++    char*           l_name;
++    void*           l_ld;
++    link_map*       l_next, l_prev;
++}
++alias link_map Link_map;
++
++enum
++{
++    RT_CONSISTENT,
++    RT_ADD,
++    RT_DELETE,
++}
++
++struct r_debug
++{
++    int             r_version;
++    link_map*       r_map;
++    void function(r_debug*, link_map*) r_brk;
++};
++
++struct dl_phdr_info
++{
++    ElfW!"Addr"     dlpi_addr;
++    char*           dlpi_name;
++    ElfW!"Phdr"*    dlpi_phdr;
++    ElfW!"Half"     dlpi_phnum;
++    uint64_t        dlpi_adds;
++    uint64_t        dlpi_subs;
++    size_t          dlpi_tls_modid;
++    void*           dlpi_tls_data;
++};
++
++
++private alias extern(C) int function(dl_phdr_info*, size_t, void *) dl_iterate_phdr_cb;
++private alias extern(C) int function(dl_phdr_info*, size_t, void *) @nogc dl_iterate_phdr_cb_ngc;
++extern int dl_iterate_phdr(dl_iterate_phdr_cb __callback, void*__data);
++extern int dl_iterate_phdr(dl_iterate_phdr_cb_ngc __callback, void*__data) @nogc;
++
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_mman.d b/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_mman.d
new file mode 100644
index 0000000..cc41e2e
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_sys_mman.d
@@ -0,0 +1,153 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/netbsd/sys/mman.d.orig	2016-03-02 01:38:47.249900098 +0000
++++ runtime/druntime/src/core/sys/netbsd/sys/mman.d
+@@ -0,0 +1,146 @@
++/**
++ * D header file for NetBSD
++ *
++ * TODO check
++ * Authors: Martin Nowak
++ */
++module core.sys.netbsd.sys.mman;
++
++version (NetBSD):
++extern (C):
++nothrow:
++
++public import core.sys.posix.sys.mman;
++import core.sys.netbsd.sys.cdefs;
++import core.sys.posix.sys.types;
++
++
++static if (__BSD_VISIBLE)
++{
++    enum INHERIT_SHARE = 0;
++    enum INHERIT_COPY = 1;
++    enum INHERIT_NONE = 2;
++    enum INHERIT_DONATE_COPY = 3;
++    enum INHERIT_ZERO = 4;
++}
++
++// already in core.sys.posix.sys.mman
++// enum PROT_NONE = 0x00;
++// enum PROT_READ = 0x01;
++// enum PROT_WRITE = 0x02;
++// enum PROT_EXEC = 0x04;
++// enum MAP_SHARED = 0x0001;
++// enum MAP_PRIVATE = 0x0002;
++static if (__BSD_VISIBLE)
++    alias MAP_COPY = MAP_PRIVATE;
++// enum MAP_FIXED = 0x0010;
++
++static if (__BSD_VISIBLE)
++{
++    enum MAP_RENAME = 0x0020;
++    enum MAP_NORESERVE = 0x0040;
++    enum MAP_RESERVED0080 = 0x0080;
++    enum MAP_RESERVED0100 = 0x0100;
++    enum MAP_HASSEMAPHORE = 0x0200;
++    enum MAP_STACK = 0x0400;
++    enum MAP_NOSYNC = 0x0800;
++
++    enum MAP_FILE = 0x0000;
++
++    // already in core.sys.posix.sys.mman
++    // enum MAP_ANON = 0x1000;
++    //#ifndef _KERNEL
++    alias MAP_ANONYMOUS = MAP_ANON;
++    //#endif /* !_KERNEL */
++
++    enum MAP_EXCL = 0x00004000;
++    enum MAP_NOCORE = 0x00020000;
++    enum MAP_PREFAULT_READ = 0x00040000;
++    version (LP64)
++        enum MAP_32BIT = 0x00080000;
++
++
++    extern(D) int MAP_ALIGNED(int n) { return n << MAP_ALIGNMENT_SHIFT; }
++    enum MAP_ALIGNMENT_SHIFT = 24;
++    enum MAP_ALIGNMENT_MASK = MAP_ALIGNED(0xff);
++    enum MAP_ALIGNED_SUPER = MAP_ALIGNED(1);
++}
++
++static if (__POSIX_VISIBLE >= 199309)
++{
++    // already in core.sys.posix.sys.mman
++    // enum MCL_CURRENT = 0x0001;
++    // enum MCL_FUTURE = 0x0002;
++}
++
++// already in core.sys.posix.sys.mman
++enum MAP_FAILED = cast(void*)-1;
++
++// already in core.sys.posix.sys.mman
++// enum MS_SYNC = 0x0000;
++// enum MS_ASYNC = 0x0001;
++// enum MS_INVALIDATE = 0x0002;
++
++enum _MADV_NORMAL = 0;
++enum _MADV_RANDOM = 1;
++enum _MADV_SEQUENTIAL = 2;
++enum _MADV_WILLNEED = 3;
++enum _MADV_DONTNEED = 4;
++
++static if (__BSD_VISIBLE)
++{
++    alias MADV_NORMAL = _MADV_NORMAL;
++    alias MADV_RANDOM = _MADV_RANDOM;
++    alias MADV_SEQUENTIAL = _MADV_SEQUENTIAL;
++    alias MADV_WILLNEED = _MADV_WILLNEED;
++    alias MADV_DONTNEED = _MADV_DONTNEED;
++    enum MADV_FREE = 5;
++    enum MADV_NOSYNC = 6;
++    enum MADV_AUTOSYNC = 7;
++    enum MADV_NOCORE = 8;
++    enum MADV_CORE = 9;
++    enum MADV_PROTECT = 10;
++
++    enum MINCORE_INCORE = 0x1;
++    enum MINCORE_REFERENCED = 0x2;
++    enum MINCORE_MODIFIED = 0x4;
++    enum MINCORE_REFERENCED_OTHER = 0x8;
++    enum MINCORE_MODIFIED_OTHER = 0x10;
++    enum MINCORE_SUPER = 0x20;
++
++    enum SHM_ANON = cast(const(char) *)1;
++}
++
++static if (__POSIX_VISIBLE >= 200112)
++{
++    // already in core.sys.posix.sys.mman
++    // alias POSIX_MADV_NORMAL = _MADV_NORMAL;
++    // alias POSIX_MADV_RANDOM = _MADV_RANDOM;
++    // alias POSIX_MADV_SEQUENTIAL = _MADV_SEQUENTIAL;
++    // alias POSIX_MADV_WILLNEED = _MADV_WILLNEED;
++    // alias POSIX_MADV_DONTNEED = _MADV_DONTNEED;
++}
++
++static if (__BSD_VISIBLE)
++{
++    int getpagesizes(size_t *, int);
++    int madvise(void *, size_t, int);
++    int mincore(const(void) *, size_t, char *);
++    int minherit(void *, size_t, int);
++}
++// already in core.sys.posix.sys.mman
++// int mlock(const void *, size_t);
++// void *  mmap(void *, size_t, int, int, int, off_t);
++// int mprotect(const void *, size_t, int);
++// int msync(void *, size_t, int);
++// int munlock(const void *, size_t);
++// int munmap(void *, size_t);
++static if (__POSIX_VISIBLE >= 200112)
++    // int posix_madvise(void *, size_t, int);
++static if (__POSIX_VISIBLE >= 199309)
++{
++    // int mlockall(int);
++    // int munlockall();
++    // int shm_open(const(char) *, int, mode_t);
++    // int shm_unlink(const(char) *);
++}
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_time.d b/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_time.d
new file mode 100644
index 0000000..369fde4
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_netbsd_time.d
@@ -0,0 +1,26 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/netbsd/time.d.orig	2016-03-02 01:38:47.251518739 +0000
++++ runtime/druntime/src/core/sys/netbsd/time.d
+@@ -0,0 +1,19 @@
++//Written in the D programming language
++
++/++
++    D header file for NetBSD's extensions to POSIX's time.h.
++
++    Copyright: Copyright 2014
++    License:   $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
++    Authors:   Jonathan M Davis
++ +/
++module core.sys.netbsd.time;
++
++public import core.sys.posix.time;
++
++version(NetBSD):
++
++enum CLOCK_REALTIME          = 0;
++enum CLOCK_VIRTUAL           = 1;
++enum CLOCK_PROF              = 2;
++enum CLOCK_MONOTONIC         = 3;
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_arpa_inet.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_arpa_inet.d
new file mode 100644
index 0000000..98dc4f4
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_arpa_inet.d
@@ -0,0 +1,50 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/arpa/inet.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/arpa/inet.d
+@@ -124,6 +124,32 @@ else version( FreeBSD )
+     const(char)*    inet_ntop(int, in void*, char*, socklen_t);
+     int             inet_pton(int, in char*, void*);
+ }
++else version( NetBSD )
++{
++    alias uint16_t in_port_t;
++    alias uint32_t in_addr_t;
++
++    struct in_addr
++    {
++        in_addr_t s_addr;
++    }
++
++    enum INET_ADDRSTRLEN = 16;
++
++    @trusted pure
++    {
++    uint32_t htonl(uint32_t);
++    uint16_t htons(uint16_t);
++    uint32_t ntohl(uint32_t);
++    uint16_t ntohs(uint16_t);
++    }
++
++    in_addr_t       inet_addr(in char*);
++    char*           inet_ntoa(in_addr);
++    const(char)*    inet_ntop(int, in void*, char*, socklen_t);
++    int             inet_pton(int, in char*, void*);
++}
++
+ else version( Solaris )
+ {
+     alias uint16_t in_port_t;
+@@ -235,6 +261,10 @@ else version( FreeBSD )
+ {
+     enum INET6_ADDRSTRLEN = 46;
+ }
++else version( NetBSD )
++{
++    enum INET6_ADDRSTRLEN = 46;
++}
+ else version( Solaris )
+ {
+     enum INET6_ADDRSTRLEN = 46;
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_dirent.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_dirent.d
new file mode 100644
index 0000000..ce326ba
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_dirent.d
@@ -0,0 +1,90 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/dirent.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/dirent.d
+@@ -142,6 +142,36 @@ else version( FreeBSD )
+ 
+     dirent* readdir(DIR*);
+ }
++else version( NetBSD )
++{
++    enum
++    {
++        DT_UNKNOWN  = 0,
++        DT_FIFO     = 1,
++        DT_CHR      = 2,
++        DT_DIR      = 4,
++        DT_BLK      = 6,
++        DT_REG      = 8,
++        DT_LNK      = 10,
++        DT_SOCK     = 12,
++        DT_WHT      = 14
++    }
++
++
++    struct dirent
++    {
++        ulong      d_fileno;
++        ushort    d_reclen;
++        ushort    d_namlen;
++        ubyte     d_type;
++        char[512] d_name;
++    }
++
++    alias void* DIR;
++
++    dirent* __readdir30(DIR*);
++    alias __readdir30 readdir;
++}
+ else version (Solaris)
+ {
+     struct dirent
+@@ -205,11 +235,20 @@ else
+     static assert(false, "Unsupported platform");
+ }
+ 
++version( NetBSD )
++{
++    DIR*    __opendir30(in char*);
++    alias __opendir30 opendir;
++}
++else
++{
++    DIR*    opendir(in char*);
++}
+ int     closedir(DIR*);
+-DIR*    opendir(in char*);
+ //dirent* readdir(DIR*);
+ void    rewinddir(DIR*);
+ 
++
+ //
+ // Thread-Safe Functions (TSF)
+ //
+@@ -237,6 +276,12 @@ else version( FreeBSD )
+ {
+     int readdir_r(DIR*, dirent*, dirent**);
+ }
++else version( NetBSD )
++{
++    int __readdir_r30(DIR*, dirent*, dirent**);
++    alias __readdir_r30 readdir_r;
++}
++
+ else version (Solaris)
+ {
+     static if (__USE_LARGEFILE64)
+@@ -276,6 +321,11 @@ else version( FreeBSD )
+     void   seekdir(DIR*, c_long);
+     c_long telldir(DIR*);
+ }
++else version( NetBSD )
++{
++    void   seekdir(DIR*, c_long);
++    c_long telldir(DIR*);
++}
+ else version (OSX)
+ {
+ }
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_dlfcn.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_dlfcn.d
new file mode 100644
index 0000000..381d458
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_dlfcn.d
@@ -0,0 +1,36 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/dlfcn.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/dlfcn.d
+@@ -165,6 +165,29 @@ else version( FreeBSD )
+         void*        dli_saddr;
+     }
+ }
++else version( NetBSD )
++{
++    enum RTLD_LAZY      = 1;
++    enum RTLD_NOW       = 2;
++    enum RTLD_GLOBAL    = 0x100;
++    enum RTLD_LOCAL     = 0x200;
++    enum RTLD_NODELETE  = 0x01000;         /* Do not remove members. */
++    enum RTLD_NOLOAD    = 0x02000;
++
++    int   dlclose(void*);
++    char* dlerror();
++    void* dlopen(in char*, int);
++    void* dlsym(void*, in char*);
++    int   dladdr(const(void)* addr, Dl_info* info);
++
++    struct Dl_info
++    {
++        const(char)* dli_fname;
++        void*        dli_fbase;
++        const(char)* dli_sname;
++        void*        dli_saddr;
++    }
++}
+ else version( Solaris )
+ {
+     enum RTLD_LAZY      = 1;
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_fcntl.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_fcntl.d
new file mode 100644
index 0000000..1e513a8
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_fcntl.d
@@ -0,0 +1,66 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/fcntl.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/fcntl.d
+@@ -367,6 +367,59 @@ else version( FreeBSD )
+     int creat(in char*, mode_t);
+     int open(in char*, int, ...);
+ }
++else version( NetBSD )
++{
++    enum F_DUPFD        = 0;
++    enum F_GETFD        = 1;
++    enum F_SETFD        = 2;
++    enum F_GETFL        = 3;
++    enum F_SETFL        = 4;
++    enum F_GETOWN       = 5;
++    enum F_SETOWN       = 6;
++    enum F_GETLK        = 7;
++    enum F_SETLK        = 8;
++    enum F_SETLKW       = 9;
++    enum F_CLOSEM       = 10;
++    enum F_MAXFD        = 11;
++    enum F_DUPFD_CLOEXEC= 12;
++    enum F_GETNOSIGPIPE = 13;
++    enum F_SETNOSIGPIPE = 14;
++
++    enum FD_CLOEXEC     = 1;
++
++    enum F_RDLCK        = 1;
++    enum F_UNLCK        = 2;
++    enum F_WRLCK        = 3;
++
++    enum O_CREAT        = 0x0200;
++    enum O_EXCL         = 0x0800;
++    enum O_NOCTTY       = 0x8000;
++    enum O_TRUNC        = 0x0400;
++
++    enum O_RDONLY       = 0x0000;
++    enum O_WRONLY       = 0x0001;
++    enum O_RDWR         = 0x0002;
++    enum O_ACCMODE      = 0x0003;
++
++    enum O_NONBLOCK     = 0x0004;
++    enum O_APPEND       = 0x0008;
++    enum O_SYNC         = 0x0080;
++    //enum O_DSYNC
++    //enum O_RSYNC
++
++    struct flock
++    {
++        off_t   l_start;
++        off_t   l_len;
++        pid_t   l_pid;
++        short   l_type;
++        short   l_whence;
++    }
++
++
++    int creat(in char*, mode_t);
++    int open(in char*, int, ...);
++}
+ else version (Solaris)
+ {
+     enum F_DUPFD = 0;
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_grp.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_grp.d
new file mode 100644
index 0000000..cc6b68e
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_grp.d
@@ -0,0 +1,48 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/grp.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/grp.d
+@@ -68,6 +68,16 @@ else version( FreeBSD )
+         char**  gr_mem;
+     }
+ }
++else version( NetBSD )
++{
++    struct group
++    {
++        char*   gr_name;
++        char*   gr_passwd;
++        gid_t   gr_gid;
++        char**  gr_mem;
++    }
++}
+ else version( Solaris )
+ {
+     struct group
+@@ -119,6 +129,11 @@ else version( FreeBSD )
+     int getgrnam_r(in char*, group*, char*, size_t, group**);
+     int getgrgid_r(gid_t, group*, char*, size_t, group**);
+ }
++else version( NetBSD )
++{
++    int getgrnam_r(in char*, group*, char*, size_t, group**);
++    int getgrgid_r(gid_t, group*, char*, size_t, group**);
++}
+ else version( Solaris )
+ {
+     int getgrnam_r(in char*, group*, char*, int, group**);
+@@ -159,6 +174,12 @@ else version( FreeBSD )
+     @trusted void endgrent();
+     @trusted void setgrent();
+ }
++else version( NetBSD )
++{
++    group* getgrent();
++    @trusted void endgrent();
++    @trusted void setgrent();
++}
+ else version( Solaris )
+ {
+     group* getgrent();
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_net_if__.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_net_if__.d
new file mode 100644
index 0000000..b2e51a2
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_net_if__.d
@@ -0,0 +1,28 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/net/if_.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/net/if_.d
+@@ -82,6 +82,21 @@ else version( FreeBSD )
+     if_nameindex_t* if_nameindex();
+     void            if_freenameindex(if_nameindex_t*);
+ }
++else version( NetBSD )
++{
++    struct if_nameindex_t
++    {
++        uint    if_index;
++        char*   if_name;
++    }
++
++    enum IF_NAMESIZE = 16;
++
++    uint            if_nametoindex(in char*);
++    char*           if_indextoname(uint, char*);
++    if_nameindex_t* if_nameindex();
++    void            if_freenameindex(if_nameindex_t*);
++}
+ else version( CRuntime_Bionic )
+ {
+     enum IF_NAMESIZE = 16;
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_netdb.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_netdb.d
new file mode 100644
index 0000000..95b7a81
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_netdb.d
@@ -0,0 +1,120 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/netdb.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/netdb.d
+@@ -387,6 +387,113 @@ else version( FreeBSD )
+     enum EAI_SYSTEM         = 11;
+     enum EAI_OVERFLOW       = 14;
+ }
++else version( NetBSD )
++{
++    struct hostent
++    {
++        char*   h_name;
++        char**  h_aliases;
++        int     h_addrtype;
++        int     h_length;
++        char**  h_addr_list;
++        extern (D) char* h_addr() @property { return h_addr_list[0]; } // non-standard
++    }
++
++    struct netent
++    {
++        char*   n_name;
++        char**  n_aliases;
++        int     n_addrtype;
++        uint32_t n_net;
++/+ todo
++#if (defined(__sparc__) && defined(_LP64)) || \
++    (defined(__sh__) && defined(_LP64) && (_BYTE_ORDER == _BIG_ENDIAN))
++        int             __n_pad0;       /* ABI compatibility */
++#endif
++        uint32_t        n_net;          /*%< network # */
++#if defined(__alpha__) || (defined(__i386__) && defined(_LP64)) || \
++    (defined(__sh__) && defined(_LP64) && (_BYTE_ORDER == _LITTLE_ENDIAN))
++        int             __n_pad0;       /* ABI compatibility */
++#endif
++
+++/
++    }
++
++    struct protoent
++    {
++        char*   p_name;
++        char**  p_aliases;
++        int     p_proto;
++    }
++
++    struct servent
++    {
++        char*   s_name;
++        char**  s_aliases;
++        int     s_port;
++        char*   s_proto;
++    }
++
++    enum IPPORT_RESERVED = 1024;
++
++    //h_errno
++
++    enum HOST_NOT_FOUND = 1;
++    enum NO_DATA        = 4;
++    enum NO_RECOVERY    = 3;
++    enum TRY_AGAIN      = 2;
++
++    struct addrinfo
++    {
++        int         ai_flags;
++        int         ai_family;
++        int         ai_socktype;
++        int         ai_protocol;
++/+todo
++#if defined(__sparc__) && defined(_LP64)
++        int             __ai_pad0;      /* ABI compatibility */
++#endif
+++/
++        socklen_t   ai_addrlen;
++/+todo
++#if defined(__alpha__) || (defined(__i386__) && defined(_LP64))
++        int             __ai_pad0;      /* ABI compatibility */
++#endif
+++/
++        char*       ai_canonname;
++        sockaddr*   ai_addr;
++        addrinfo*   ai_next;
++    }
++
++    enum AI_PASSIVE         = 0x1;
++    enum AI_CANONNAME       = 0x2;
++    enum AI_NUMERICHOST     = 0x4;
++    enum AI_NUMERICSERV     = 0x8;
++    enum AI_V4MAPPED        = 0x800;
++    enum AI_ALL             = 0x100;
++    enum AI_ADDRCONFIG      = 0x400;
++
++    enum NI_NOFQDN          = 0x1;
++    enum NI_NUMERICHOST     = 0x2;
++    enum NI_NAMEREQD        = 0x4;
++    enum NI_NUMERICSERV     = 0x8;
++    enum NI_DGRAM           = 0x10;
++    enum NI_WITHSCOPEID     = 0x00000020;
++    enum NI_NUMERICSCOPE    = 0x00000040;
++    enum NI_MAXHOST         = 1025; // non-standard
++    enum NI_MAXSERV         = 32;   // non-standard
++
++    enum EAI_AGAIN          = 2;
++    enum EAI_BADFLAGS       = 3;
++    enum EAI_FAIL           = 4;
++    enum EAI_FAMILY         = 5;
++    enum EAI_MEMORY         = 6;
++    enum EAI_NONAME         = 8;
++    enum EAI_SERVICE        = 9;
++    enum EAI_SOCKTYPE       = 10;
++    enum EAI_SYSTEM         = 11;
++    enum EAI_OVERFLOW       = 14;
++}
+ else version (Solaris)
+ {
+     struct hostent
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_netinet_in__.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_netinet_in__.d
new file mode 100644
index 0000000..3cc2a10
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_netinet_in__.d
@@ -0,0 +1,206 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/netinet/in_.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/netinet/in_.d
+@@ -202,6 +202,42 @@ else version( FreeBSD )
+ 
+     //enum INET_ADDRSTRLEN       = 16;
+ }
++else version( NetBSD )
++{
++
++    struct sockaddr_in
++    {
++        ubyte       sin_len;
++        sa_family_t sin_family;
++        in_port_t   sin_port;
++        in_addr     sin_addr;
++        ubyte[8]    sin_zero;
++    }
++
++    enum
++    {
++        IPPROTO_IP   = 0,
++        IPPROTO_ICMP = 1,
++        IPPROTO_IGMP = 2,
++        IPPROTO_GGP  = 3,
++        IPPROTO_TCP  = 6,
++        IPPROTO_PUP  = 12,
++        IPPROTO_UDP  = 17,
++        IPPROTO_IDP  = 22,
++        IPPROTO_ND   = 77,
++        IPPROTO_MAX  = 256
++    }
++
++    enum : uint
++    {
++        INADDR_ANY       = 0x00000000,
++        INADDR_BROADCAST = 0xffffffff,
++        INADDR_LOOPBACK  = 0x7f000001,
++        INADDR_NONE      = 0xffffffff
++    }
++
++    //enum INET_ADDRSTRLEN       = 16;
++}
+ else version( Solaris )
+ {
+     struct sockaddr_in
+@@ -712,6 +748,145 @@ else version( FreeBSD )
+                __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL;
+     }
+ }
++else version( NetBSD )
++{
++    struct in6_addr
++    {
++        union
++        {
++            uint8_t[16] s6_addr;
++            uint16_t[8] s6_addr16;
++            uint32_t[4] s6_addr32;
++        }
++    }
++
++    struct sockaddr_in6
++    {
++        uint8_t     sin6_len;
++        sa_family_t sin6_family;
++        in_port_t   sin6_port;
++        uint32_t    sin6_flowinfo;
++        in6_addr    sin6_addr;
++        uint32_t    sin6_scope_id;
++    }
++
++    extern __gshared immutable in6_addr in6addr_any;
++    extern __gshared immutable in6_addr in6addr_loopback;
++
++    struct ipv6_mreq
++    {
++        in6_addr    ipv6mr_multiaddr;
++        uint        ipv6mr_interface;
++    }
++
++    enum : uint
++    {
++        IPPROTO_IPV6        = 41,
++
++        //INET6_ADDRSTRLEN    = 46,
++
++        IPV6_JOIN_GROUP     = 12,
++        IPV6_LEAVE_GROUP    = 13,
++        IPV6_MULTICAST_HOPS = 10,
++        IPV6_MULTICAST_IF   = 9,
++        IPV6_MULTICAST_LOOP = 11,
++        IPV6_UNICAST_HOPS   = 4,
++        IPV6_V6ONLY         = 27,
++    }
++
++    private enum
++    {
++        __IPV6_ADDR_SCOPE_NODELOCAL     = 0x01,
++        __IPV6_ADDR_SCOPE_INTFACELOCAL  = 0x01,
++        __IPV6_ADDR_SCOPE_LINKLOCAL     = 0x02,
++        __IPV6_ADDR_SCOPE_SITELOCAL     = 0x05,
++        __IPV6_ADDR_SCOPE_ORGLOCAL      = 0x08,
++        __IPV6_ADDR_SCOPE_GLOBAL        = 0x0e,
++    }
++
++    // macros
++    extern (D) int IN6_IS_ADDR_UNSPECIFIED( in in6_addr* a ) pure
++    {
++        return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
++               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
++               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == 0) &&
++               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) == 0);
++    }
++
++    extern (D) int IN6_IS_ADDR_LOOPBACK( in in6_addr* a ) pure
++    {
++        return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
++               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
++               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == 0) &&
++               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) == ntohl(1));
++    }
++
++    extern (D) int IN6_IS_ADDR_V4COMPAT( in in6_addr* a ) pure
++    {
++        return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
++               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
++               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == 0) &&
++               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) != 0) &&
++               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) != ntohl(1));
++    }
++
++    extern (D) int IN6_IS_ADDR_V4MAPPED( in in6_addr* a ) pure
++    {
++        return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
++               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
++               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == ntohl(0x0000ffff));
++    }
++
++    extern (D) int IN6_IS_ADDR_LINKLOCAL( in in6_addr* a ) pure
++    {
++        return a.s6_addr[0] == 0xfe && (a.s6_addr[1] & 0xc0) == 0x80;
++    }
++
++    extern (D) int IN6_IS_ADDR_SITELOCAL( in in6_addr* a ) pure
++    {
++        return a.s6_addr[0] == 0xfe && (a.s6_addr[1] & 0xc0) == 0xc0;
++    }
++
++    extern (D) int IN6_IS_ADDR_MULTICAST( in in6_addr* a ) pure
++    {
++        return a.s6_addr[0] == 0xff;
++    }
++
++    extern (D) uint8_t __IPV6_ADDR_MC_SCOPE( in in6_addr* a ) pure
++    {
++        return a.s6_addr[1] & 0x0f;
++    }
++
++    extern (D) int IN6_IS_ADDR_MC_NODELOCAL( in in6_addr* a ) pure
++    {
++        return IN6_IS_ADDR_MULTICAST(a) &&
++               __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL;
++    }
++
++    extern (D) int IN6_IS_ADDR_MC_LINKLOCAL( in in6_addr* a ) pure
++    {
++        return IN6_IS_ADDR_MULTICAST(a) &&
++               __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL;
++    }
++
++    extern (D) int IN6_IS_ADDR_MC_SITELOCAL( in in6_addr* a ) pure
++    {
++        return IN6_IS_ADDR_MULTICAST(a) &&
++               __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL;
++    }
++
++    extern (D) int IN6_IS_ADDR_MC_ORGLOCAL( in in6_addr* a ) pure
++    {
++        return IN6_IS_ADDR_MULTICAST(a) &&
++               __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL;
++    }
++
++    extern (D) int IN6_IS_ADDR_MC_GLOBAL( in in6_addr* a ) pure
++    {
++        return IN6_IS_ADDR_MULTICAST(a) &&
++               __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL;
++    }
++}
+ else version( Solaris )
+ {
+     struct in6_addr
+@@ -988,6 +1163,10 @@ else version( FreeBSD )
+ {
+     enum uint IPPROTO_RAW = 255;
+ }
++else version( NetBSD )
++{
++    enum uint IPPROTO_RAW = 255;
++}
+ else version( Solaris )
+ {
+     enum uint IPPROTO_RAW = 255;
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_netinet_tcp.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_netinet_tcp.d
new file mode 100644
index 0000000..a32fe75
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_netinet_tcp.d
@@ -0,0 +1,17 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/netinet/tcp.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/netinet/tcp.d
+@@ -38,6 +38,10 @@ else version( FreeBSD )
+ {
+     enum TCP_NODELAY = 1;
+ }
++else version( NetBSD )
++{
++    enum TCP_NODELAY = 1;
++}
+ else version( Solaris )
+ {
+     enum TCP_NODELAY = 1;
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_poll.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_poll.d
new file mode 100644
index 0000000..9c8b8fe
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_poll.d
@@ -0,0 +1,48 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/poll.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/poll.d
+@@ -143,6 +143,41 @@ else version( FreeBSD )
+ 
+     int poll(pollfd*, nfds_t, int);
+ }
++else version( NetBSD )
++{
++    alias uint nfds_t;
++
++    struct pollfd
++    {
++        int     fd;
++        short   events;
++        short   revents;
++    };
++
++    enum
++    {
++        POLLIN      = 0x0001,
++        POLLPRI     = 0x0002,
++        POLLOUT     = 0x0004,
++        POLLRDNORM  = 0x0040,
++        POLLWRNORM  = POLLOUT,
++        POLLRDBAND  = 0x0080,
++        POLLWRBAND  = 0x0100,
++        //POLLEXTEND  = 0x0200,
++        //POLLATTRIB  = 0x0400,
++        //POLLNLINK   = 0x0800,
++        //POLLWRITE   = 0x1000,
++        POLLERR     = 0x0008,
++        POLLHUP     = 0x0010,
++        POLLNVAL    = 0x0020,
++
++        POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|
++        POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
++    }
++
++    int poll(pollfd*, nfds_t, int);
++}
++
+ else version( Solaris )
+ {
+     alias c_ulong nfds_t;
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_pthread.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_pthread.d
new file mode 100644
index 0000000..36b5c68
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_pthread.d
@@ -0,0 +1,266 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/pthread.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/pthread.d
+@@ -209,6 +209,85 @@ else version( FreeBSD )
+     enum PTHREAD_COND_INITIALIZER               = null;
+     enum PTHREAD_RWLOCK_INITIALIZER             = null;
+ }
++else version( NetBSD )
++{
++    enum PRI_NONE = -1;
++    enum
++    {
++        PTHREAD_INHERIT_SCHED       = 0x0,
++
++        PTHREAD_CREATE_DETACHED     = 1,
++        PTHREAD_CREATE_JOINABLE     = 0,
++        PTHREAD_EXPLICIT_SCHED      = 1,
++    }
++
++    enum
++    {
++        PTHREAD_PROCESS_PRIVATE     = 0,
++        PTHREAD_PROCESS_SHARED      = 1,
++    }
++
++    enum
++    {
++        PTHREAD_CANCEL_ENABLE       = 0,
++        PTHREAD_CANCEL_DISABLE      = 1,
++        PTHREAD_CANCEL_DEFERRED     = 0,
++        PTHREAD_CANCEL_ASYNCHRONOUS = 1,
++    }
++
++    enum PTHREAD_CANCELED = cast(void*) 1;
++
++    enum PTHREAD_DONE_INIT  = 1;
++
++    struct _PTHREAD_MUTEX_INITIALIZER{
++       enum f1 = 0x33330003;
++       enum f2 = 0;
++       enum f3 = [ 0, 0, 0 ];
++       enum f4 = 0;
++       enum f5 = [0, 0, 0 ];
++       enum f6 = null;
++       enum f7 = null;
++       enum f8 = 0;
++       enum f9 = null;
++    }
++    enum PTHREAD_MUTEX_INITIALIZER              = _PTHREAD_MUTEX_INITIALIZER();
++
++    struct _PTHREAD_ONCE_INIT{
++      enum f1 = PTHREAD_MUTEX_INITIALIZER;
++      enum f2 = 0;
++    }
++    enum PTHREAD_ONCE_INIT                      = _PTHREAD_ONCE_INIT();
++    struct _PTHREAD_COND_INITIALIZER{
++       enum f1 = 0x55550005;
++       enum f2 = 0;
++       struct __PTHREAD_COND_INITIALIZER_S
++       {
++          enum p1 = null;
++          enum p2 = null;
++          enum p3 = null;
++          enum p4 = null;
++       }
++       enum f3 = __PTHREAD_COND_INITIALIZER_S();
++    }
++    enum PTHREAD_COND_INITIALIZER               = _PTHREAD_COND_INITIALIZER();
++    struct _PTHREAD_RWLOCK_INITIALIZER
++    {
++        enum f1 = 0x99990009;
++        enum f2  = 0;
++        struct __PTHREAD_RWLOCK_INITIALIZER_S
++        {
++            enum p1 = null;
++            enum p2 = null;
++        }
++
++        enum f3 = __PTHREAD_RWLOCK_INITIALIZER_S();
++        enum f4 = __PTHREAD_RWLOCK_INITIALIZER_S();
++        enum f5 = 0;
++        enum f6 = null;
++        enum f7 = null;
++    }
++    enum PTHREAD_RWLOCK_INITIALIZER             = _PTHREAD_RWLOCK_INITIALIZER();
++}
+ else version (Solaris)
+ {
+     enum
+@@ -362,6 +441,33 @@ else version( FreeBSD )
+     void __pthread_cleanup_push_imp(_pthread_cleanup_routine, void*, _pthread_cleanup_info*);
+     void __pthread_cleanup_pop_imp(int);
+ }
++else version( NetBSD )
++{
++    alias void function(void*) _pthread_cleanup_routine;
++
++    struct _pthread_cleanup_store
++    {
++        void*[4]    pthread_cleanup_pad;
++    }
++
++    struct pthread_cleanup
++    {
++        _pthread_cleanup_store __cleanup_info__ = void;
++
++        extern (D) void push()( _pthread_cleanup_routine cleanup_routine, void* cleanup_arg )
++        {
++            pthread__cleanup_push( cleanup_routine, cleanup_arg, &__cleanup_info__ );
++        }
++
++        extern (D) void pop()( int execute )
++        {
++            pthread__cleanup_pop( execute, &__cleanup_info__ );
++        }
++    }
++
++    void pthread__cleanup_push(_pthread_cleanup_routine, void*, void*);
++    void pthread__cleanup_pop(int, void *);
++}
+ else version (Solaris)
+ {
+     alias void function(void*) _pthread_cleanup_routine;
+@@ -507,6 +613,18 @@ else version( FreeBSD )
+     int pthread_barrierattr_init(pthread_barrierattr_t*);
+     int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
+ }
++else version( NetBSD )
++{
++    enum PTHREAD_BARRIER_SERIAL_THREAD = 1234567;
++
++    int pthread_barrier_destroy(pthread_barrier_t*);
++    int pthread_barrier_init(pthread_barrier_t*, in pthread_barrierattr_t*, uint);
++    int pthread_barrier_wait(pthread_barrier_t*);
++    int pthread_barrierattr_destroy(pthread_barrierattr_t*);
++    int pthread_barrierattr_getpshared(in pthread_barrierattr_t*, int*);
++    int pthread_barrierattr_init(pthread_barrierattr_t*);
++    int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
++}
+ else version (OSX)
+ {
+ }
+@@ -565,6 +683,14 @@ else version( FreeBSD )
+     int pthread_spin_trylock(pthread_spinlock_t*);
+     int pthread_spin_unlock(pthread_spinlock_t*);
+ }
++else version( NetBSD )
++{
++    int pthread_spin_init(pthread_spinlock_t*, int);
++    int pthread_spin_destroy(pthread_spinlock_t*);
++    int pthread_spin_lock(pthread_spinlock_t*);
++    int pthread_spin_trylock(pthread_spinlock_t*);
++    int pthread_spin_unlock(pthread_spinlock_t*);
++}
+ else version (OSX)
+ {
+ }
+@@ -648,6 +774,24 @@ else version( FreeBSD )
+     int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted;
+     int pthread_setconcurrency(int);
+ }
++else version( NetBSD )
++{
++    enum
++    {
++        PTHREAD_MUTEX_NORMAL        = 0,
++        PTHREAD_MUTEX_ERRORCHECK    = 1,
++        PTHREAD_MUTEX_RECURSIVE     = 2,
++        PTHREAD_MUTEX_TYPE_MAX
++    }
++    enum PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_ERRORCHECK;
++
++    int pthread_attr_getguardsize(in pthread_attr_t*, size_t*);
++    int pthread_attr_setguardsize(pthread_attr_t*, size_t);
++    int pthread_getconcurrency();
++    int pthread_mutexattr_gettype(pthread_mutexattr_t*, int*);
++    int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted;
++    int pthread_setconcurrency(int);
++}
+ else version (Solaris)
+ {
+     enum
+@@ -698,6 +842,10 @@ else version( FreeBSD )
+ {
+     int pthread_getcpuclockid(pthread_t, clockid_t*);
+ }
++else version( NetBSD )
++{
++
++}
+ else version (OSX)
+ {
+ }
+@@ -740,6 +888,12 @@ else version( FreeBSD )
+     int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
+     int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
+ }
++else version( NetBSD )
++{
++    int pthread_mutex_timedlock(pthread_mutex_t*, in timespec*);
++    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
++    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
++}
+ else version (Solaris)
+ {
+     int pthread_mutex_timedlock(pthread_mutex_t*, in timespec*);
+@@ -876,6 +1030,24 @@ else version( FreeBSD )
+     int pthread_setschedparam(pthread_t, int, sched_param*);
+     // int pthread_setschedprio(pthread_t, int); // not implemented
+ }
++else version( NetBSD )
++{
++    enum
++    {
++        PTHREAD_SCOPE_PROCESS   = 0,
++        PTHREAD_SCOPE_SYSTEM    = 0x1
++    }
++
++    int pthread_attr_getinheritsched(in pthread_attr_t*, int*);
++    int pthread_attr_getschedpolicy(in pthread_attr_t*, int*);
++    int pthread_attr_getscope(in pthread_attr_t*, int*);
++    int pthread_attr_setinheritsched(pthread_attr_t*, int);
++    int pthread_attr_setschedpolicy(pthread_attr_t*, int);
++    int pthread_attr_setscope(in pthread_attr_t*, int);
++    int pthread_getschedparam(pthread_t, int*, sched_param*);
++    int pthread_setschedparam(pthread_t, int, sched_param*);
++    //int pthread_setschedprio(pthread_t, int);
++}
+ else version (Solaris)
+ {
+     enum
+@@ -953,6 +1125,15 @@ else version( FreeBSD )
+     int pthread_attr_setstackaddr(pthread_attr_t*, void*);
+     int pthread_attr_setstacksize(pthread_attr_t*, size_t);
+ }
++else version( NetBSD )
++{
++    int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*);
++    int pthread_attr_getstackaddr(in pthread_attr_t*, void**);
++    int pthread_attr_getstacksize(in pthread_attr_t*, size_t*);
++    int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
++    int pthread_attr_setstackaddr(pthread_attr_t*, void*);
++    int pthread_attr_setstacksize(pthread_attr_t*, size_t);
++}
+ else version (Solaris)
+ {
+     int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*);
+@@ -1006,6 +1187,15 @@ else version( FreeBSD )
+     int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
+     int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
+ }
++else version( NetBSD )
++{
++    int pthread_condattr_getpshared(in pthread_condattr_t*, int*);
++    int pthread_condattr_setpshared(pthread_condattr_t*, int);
++    int pthread_mutexattr_getpshared(in pthread_mutexattr_t*, int*);
++    int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
++    int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
++    int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
++}
+ else version( OSX )
+ {
+     int pthread_condattr_getpshared(in pthread_condattr_t*, int*);
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_pwd.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_pwd.d
new file mode 100644
index 0000000..dcab789
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_pwd.d
@@ -0,0 +1,56 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/pwd.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/pwd.d
+@@ -85,6 +85,22 @@ else version( FreeBSD )
+         int pw_fields;      /* internal: fields filled in */
+     }
+ }
++else version( NetBSD )
++{
++    struct passwd
++    {
++        char*   pw_name;        /* user name */
++        char*   pw_passwd;      /* encrypted password */
++        uid_t   pw_uid;         /* user uid */
++        gid_t   pw_gid;         /* user gid */
++        time_t  pw_change;      /* password change time */
++        char*   pw_class;       /* user access class */
++        char*   pw_gecos;       /* Honeywell login info */
++        char*   pw_dir;     /* home directory */
++        char*   pw_shell;       /* default shell */
++        time_t  pw_expire;      /* account expiration */
++    }
++}
+ else version (Solaris)
+ {
+     struct passwd
+@@ -143,6 +159,13 @@ else version( FreeBSD )
+     int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
+     int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
+ }
++else version( NetBSD )
++{
++    int __getpwnam_r50(in char*, passwd*, char*, size_t, passwd**);
++    alias __getpwnam_r50 getpwnam_r;
++    int __getpwuid_r50(uid_t, passwd*, char*, size_t, passwd**);
++    alias __getpwuid_r50 getpwuid_r;
++}
+ else version (Solaris)
+ {
+     int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
+@@ -183,6 +206,12 @@ else version ( FreeBSD )
+     passwd* getpwent();
+     void    setpwent();
+ }
++else version ( NetBSD )
++{
++    void    endpwent();
++    passwd* getpwent();
++    void    setpwent();
++}
+ else version (Solaris)
+ {
+     void endpwent();
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sched.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sched.d
new file mode 100644
index 0000000..fdd21fe
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sched.d
@@ -0,0 +1,48 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/sched.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sched.d
+@@ -86,6 +86,17 @@ else version( FreeBSD )
+     enum SCHED_OTHER    = 2;
+     enum SCHED_RR       = 3;
+ }
++else version( NetBSD )
++{
++    struct sched_param
++    {
++        int sched_priority;
++    }
++
++    enum SCHED_FIFO     = 1;
++    enum SCHED_OTHER    = 0;
++    enum SCHED_RR       = 2;
++}
+ else version (Solaris)
+ {
+     struct sched_param
+@@ -144,6 +155,10 @@ else version( FreeBSD )
+ {
+     int sched_yield();
+ }
++else version( NetBSD )
++{
++    int sched_yield();
++}
+ else version (Solaris)
+ {
+     int sched_yield();
+@@ -184,6 +199,12 @@ else version( FreeBSD )
+     int sched_get_priority_max(int);
+     int sched_rr_get_interval(pid_t, timespec*);
+ }
++else version( NetBSD )
++{
++    int sched_get_priority_min(int);
++    int sched_get_priority_max(int);
++    int sched_rr_get_interval(pid_t, timespec*);
++}
+ else version (Solaris)
+ {
+     int sched_get_priority_max(int);
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_semaphore.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_semaphore.d
new file mode 100644
index 0000000..fa1b541
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_semaphore.d
@@ -0,0 +1,30 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/semaphore.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/semaphore.d
+@@ -81,6 +81,12 @@ else version( FreeBSD )
+ 
+     enum SEM_FAILED = cast(sem_t*) null;
+ }
++else version( NetBSD )
++{
++    alias size_t sem_t;
++
++    enum SEM_FAILED = cast(sem_t*) null;
++}
+ else version (Solaris)
+ {
+     struct sem_t
+@@ -137,6 +143,10 @@ else version( FreeBSD )
+ {
+     int sem_timedwait(sem_t*, in timespec*);
+ }
++else version( NetBSD )
++{
++    int sem_timedwait(sem_t*, in timespec*);
++}
+ else version (Solaris)
+ {
+     int sem_timedwait(sem_t*, in timespec*);
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_setjmp.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_setjmp.d
new file mode 100644
index 0000000..72bd567
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_setjmp.d
@@ -0,0 +1,71 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/setjmp.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/setjmp.d
+@@ -170,6 +170,26 @@ else version( FreeBSD )
+     int  setjmp(ref jmp_buf);
+     void longjmp(ref jmp_buf, int);
+ }
++else version( NetBSD )
++{
++    // <machine/setjmp.h>
++    version( X86 )
++    {
++        enum _JBLEN = 13;
++        struct _jmp_buf { int[_JBLEN + 1] _jb; }
++    }
++    else version( X86_64)
++    {
++        enum _JBLEN = 11;
++        struct _jmp_buf { c_long[_JBLEN] _jb; }
++    }
++    else
++        static assert(0);
++    alias _jmp_buf[_JBLEN] jmp_buf;
++
++    int  setjmp(ref jmp_buf);
++    void longjmp(ref jmp_buf, int);
++}
+ else version( CRuntime_Bionic )
+ {
+     // <machine/setjmp.h>
+@@ -238,6 +258,24 @@ else version( FreeBSD )
+     int  sigsetjmp(ref sigjmp_buf);
+     void siglongjmp(ref sigjmp_buf, int);
+ }
++else version( NetBSD )
++{
++    // <machine/setjmp.h>
++    version( X86 )
++    {
++        struct _sigjmp_buf { int[_JBLEN + 1] _ssjb; }
++    }
++    else version( X86_64)
++    {
++        struct _sigjmp_buf { c_long[_JBLEN] _sjb; }
++    }
++    else
++        static assert(0);
++    alias _sigjmp_buf[_JBLEN + 1] sigjmp_buf;
++
++    int  sigsetjmp(ref sigjmp_buf);
++    void siglongjmp(ref sigjmp_buf, int);
++}
+ else version( CRuntime_Bionic )
+ {
+     alias c_long[_JBLEN + 1] sigjmp_buf;
+@@ -264,6 +302,12 @@ else version( FreeBSD )
+     int  _setjmp(ref jmp_buf);
+     void _longjmp(ref jmp_buf, int);
+ }
++else version( NetBSD )
++{
++    int  _setjmp(ref jmp_buf);
++    void _longjmp(ref jmp_buf, int);
++}
++
+ else version( CRuntime_Bionic )
+ {
+     int  _setjmp(ref jmp_buf);
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_signal.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_signal.d
new file mode 100644
index 0000000..79acb75
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_signal.d
@@ -0,0 +1,339 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/signal.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/signal.d
+@@ -395,6 +395,31 @@ else version( FreeBSD )
+     enum SIGUSR2    = 31;
+     enum SIGURG     = 16;
+ }
++else version( NetBSD )
++{
++    //SIGABRT (defined in core.stdc.signal)
++    enum SIGALRM    = 14;
++    enum SIGBUS     = 10;
++    enum SIGCHLD    = 20;
++    enum SIGCONT    = 19;
++    //SIGFPE (defined in core.stdc.signal)
++    enum SIGHUP     = 1;
++    //SIGILL (defined in core.stdc.signal)
++    //SIGINT (defined in core.stdc.signal)
++    enum SIGKILL    = 9;
++    enum SIGPIPE    = 13;
++    enum SIGQUIT    = 3;
++    //SIGSEGV (defined in core.stdc.signal)
++    enum SIGSTOP    = 17;
++    //SIGTERM (defined in core.stdc.signal)
++    enum SIGTSTP    = 18;
++    enum SIGTTIN    = 21;
++    enum SIGTTOU    = 22;
++    enum SIGUSR1    = 30;
++    enum SIGUSR2    = 31;
++    enum SIGURG     = 16;
++}
++
+ else version (Solaris)
+ {
+     enum SIGALRM = 14;
+@@ -453,6 +478,19 @@ else version( FreeBSD )
+         sigset_t sa_mask;
+     }
+ }
++else version( NetBSD )
++{
++    struct sigaction_t
++    {
++        union
++        {
++            sigfn_t     sa_handler;
++            sigactfn_t  sa_sigaction;
++        }
++        sigset_t sa_mask;
++        int      sa_flags;
++    }
++}
+ else version (Solaris)
+ {
+     struct sigaction_t
+@@ -855,6 +893,100 @@ else version( FreeBSD )
+     int sigsuspend(in sigset_t *);
+     int sigwait(in sigset_t*, int*);
+ }
++else version( NetBSD )
++{
++    enum SIG_HOLD = cast(sigfn_t2) 3;
++
++    struct sigset_t
++    {
++        uint[4] __bits;
++    }
++
++    enum SA_NOCLDSTOP = 8;
++
++    enum SIG_BLOCK = 1;
++    enum SIG_UNBLOCK = 2;
++    enum SIG_SETMASK = 3;
++
++    union sigval_t {
++        int     sival_int;
++        void    *sival_ptr;
++    };
++    struct _rt{
++        pid_t   _pid;
++        uid_t   _uid;
++        sigval_t        _value;
++    };
++    struct _child{
++        pid_t   _pid;
++        uid_t   _uid;
++        int     _status;
++        clock_t _utime;
++        clock_t _stime;
++    };
++   struct _fault{
++        void   *_addr;
++        int     _trap;
++        int     _trap2;
++        int     _trap3;
++    };
++    struct _poll{
++        long    _band;
++        int     _fd;
++    };
++    union _reason{
++        _rt rt;
++        _child child;
++        _fault fault;
++        _poll poll;
++    };
++    struct _ksiginfo {
++        int     _signo;
++        int     _code;
++        int     _errno;
++/+#ifdef _LP64
++        /* In _LP64 the union starts on an 8-byte boundary. */
++        int     _pad;
++#endif+/
++        _reason reason;
++    };
++
++
++    union siginfo_t
++    {
++        ubyte[128] si_pad;/* Total size; for future expansion */
++        _ksiginfo _info;
++        @property ref c_long si_band() return { return _info.reason.poll._band; }
++    }
++
++    enum SI_USER    = 0;
++    enum SI_QUEUE   = -1;
++    enum SI_TIMER   = -2;
++    enum SI_ASYNCIO = -3;
++    enum SI_MESGQ   = -4;
++
++    int kill(pid_t, int);
++    int __sigaction14(int, in sigaction_t*, sigaction_t*);
++    int __sigaddset14(sigset_t*, int);
++    int __sigdelset14(sigset_t*, int);
++    int __sigemptyset14(sigset_t *);
++    int __sigfillset14(sigset_t *);
++    int __sigismember14(in sigset_t *, int);
++    int __sigpending14(sigset_t *);
++    int __sigprocmask14(int, in sigset_t*, sigset_t*);
++    int __sigsuspend14(in sigset_t *);
++    int sigwait(in sigset_t*, int*);
++
++    alias __sigaction14 sigaction;
++    alias __sigaddset14 sigaddset;
++    alias __sigdelset14 sigdelset;
++    alias __sigemptyset14 sigemptyset;
++    alias __sigfillset14 sigfillset;
++    alias __sigismember14 sigismember;
++    alias __sigpending14 sigpending;
++    alias __sigprocmask14 sigprocmask;
++    alias __sigsuspend14 sigsuspend;
++}
+ else version (Solaris)
+ {
+     enum SIG_HOLD = cast(sigfn_t2)2;
+@@ -1626,6 +1758,130 @@ else version( FreeBSD )
+     int sigpause(int);
+     int sigrelse(int);
+ }
++else version( NetBSD )
++{
++    // No SIGPOLL on *BSD
++    enum SIGPROF        = 27;
++    enum SIGSYS         = 12;
++    enum SIGTRAP        = 5;
++    enum SIGVTALRM      = 26;
++    enum SIGXCPU        = 24;
++    enum SIGXFSZ        = 25;
++
++    enum
++    {
++        SA_ONSTACK      = 0x0001,
++        SA_RESTART      = 0x0002,
++        SA_RESETHAND    = 0x0004,
++        SA_NODEFER      = 0x0010,
++        SA_NOCLDWAIT    = 0x0020,
++        SA_SIGINFO      = 0x0040,
++    }
++
++    enum
++    {
++        SS_ONSTACK = 0x0001,
++        SS_DISABLE = 0x0004,
++    }
++
++    enum MINSIGSTKSZ = 8192;
++    enum SIGSTKSZ    = (MINSIGSTKSZ + 32768);
++;
++    //ucontext_t (defined in core.sys.posix.ucontext)
++    //mcontext_t (defined in core.sys.posix.ucontext)
++
++    struct stack_t
++    {
++        void*   ss_sp;
++        size_t  ss_size;
++        int     ss_flags;
++    }
++
++    struct sigstack
++    {
++        void*   ss_sp;
++        int     ss_onstack;
++    }
++
++    enum
++    {
++        ILL_ILLOPC = 1,
++        ILL_ILLOPN,
++        ILL_ILLADR,
++        ILL_ILLTRP,
++        ILL_PRVOPC,
++        ILL_PRVREG,
++        ILL_COPROC,
++        ILL_BADSTK,
++    }
++
++    enum
++    {
++        BUS_ADRALN = 1,
++        BUS_ADRERR,
++        BUS_OBJERR,
++    }
++
++    enum
++    {
++        SEGV_MAPERR = 1,
++        SEGV_ACCERR,
++    }
++
++    enum
++    {
++        FPE_INTOVF = 1,
++        FPE_INTDIV,
++        FPE_FLTDIV,
++        FPE_FLTOVF,
++        FPE_FLTUND,
++        FPE_FLTRES,
++        FPE_FLTINV,
++        FPE_FLTSUB,
++    }
++
++    enum
++    {
++        TRAP_BRKPT = 1,
++        TRAP_TRACE,
++    }
++
++    enum
++    {
++        CLD_EXITED = 1,
++        CLD_KILLED,
++        CLD_DUMPED,
++        CLD_TRAPPED,
++        CLD_STOPPED,
++        CLD_CONTINUED,
++    }
++
++    enum
++    {
++        POLL_IN = 1,
++        POLL_OUT,
++        POLL_MSG,
++        POLL_ERR,
++        POLL_PRI,
++        POLL_HUP,
++    }
++
++    //sigfn_t bsd_signal(int sig, sigfn_t func);
++    sigfn_t sigset(int sig, sigfn_t func);
++
++  nothrow:
++  @nogc:
++    //sigfn_t2 bsd_signal(int sig, sigfn_t2 func);
++    sigfn_t2 sigset(int sig, sigfn_t2 func);
++
++    int killpg(pid_t, int);
++    int sigaltstack(in stack_t*, stack_t*);
++    int sighold(int);
++    int sigignore(int);
++    int siginterrupt(int, int);
++    int sigpause(int);
++    int sigrelse(int);
++}
+ else version (Solaris)
+ {
+     enum SIGPOLL = 22;
+@@ -1929,6 +2185,14 @@ else version( FreeBSD )
+         c_long  tv_nsec;
+     }
+ }
++else version( NetBSD )
++{
++    struct timespec
++    {
++        time_t  tv_sec;
++        c_long  tv_nsec;
++    }
++}
+ else version (Solaris)
+ {
+     struct timespec
+@@ -2024,6 +2288,21 @@ else version( FreeBSD )
+     int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
+     int sigwaitinfo(in sigset_t*, siginfo_t*);
+ }
++else version( NetBSD )
++{
++    struct sigevent
++    {
++        int             sigev_notify;
++        int             sigev_signo;
++        sigval          sigev_value;
++        void function(sigval) sigev_notify_function;
++        void /* pthread_attr_t */*sigev_notify_attributes;
++    }
++
++    int sigqueue(pid_t, int, in sigval);
++    int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
++    int sigwaitinfo(in sigset_t*, siginfo_t*);
++}
+ else version (OSX)
+ {
+ }
+@@ -2097,6 +2376,11 @@ else version( FreeBSD )
+     int pthread_kill(pthread_t, int);
+     int pthread_sigmask(int, in sigset_t*, sigset_t*);
+ }
++else version( NetBSD )
++{
++    int pthread_kill(pthread_t, int);
++    int pthread_sigmask(int, in sigset_t*, sigset_t*);
++}
+ else version (Solaris)
+ {
+     int pthread_kill(pthread_t, int);
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_stdio.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_stdio.d
new file mode 100644
index 0000000..98990b7
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_stdio.d
@@ -0,0 +1,17 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/stdio.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/stdio.d
+@@ -272,6 +272,10 @@ version( FreeBSD )
+ {
+     enum P_tmpdir  = "/var/tmp/";
+ }
++version( NetBSD )
++{
++    enum P_tmpdir  = "/var/tmp/";
++}
+ version( Solaris )
+ {
+     enum P_tmpdir  = "/var/tmp/";
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_stdlib.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_stdlib.d
new file mode 100644
index 0000000..c192478
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_stdlib.d
@@ -0,0 +1,90 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/stdlib.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/stdlib.d
+@@ -91,6 +91,10 @@ else version( FreeBSD )
+ {
+     int posix_memalign(void**, size_t, size_t);
+ }
++else version( NetBSD )
++{
++    int posix_memalign(void**, size_t, size_t);
++}
+ else version( Solaris )
+ {
+     int posix_memalign(void**, size_t, size_t);
+@@ -125,6 +129,13 @@ else version( FreeBSD )
+ 
+     void* valloc(size_t); // LEGACY non-standard
+ }
++else version( NetBSD )
++{
++    int setenv(in char*, in char*, int);
++    int __unsetenv13(in char*);
++    alias __unsetenv13 unsetenv;
++    void* valloc(size_t); // LEGACY non-standard
++}
+ else version( Android )
+ {
+     int setenv(in char*, in char*, int);
+@@ -159,6 +170,10 @@ else version( FreeBSD )
+ {
+     int rand_r(uint*);
+ }
++else version( NetBSD )
++{
++    int rand_r(uint*);
++}
+ else version( Solaris )
+ {
+     int rand_r(uint*);
+@@ -342,6 +357,47 @@ else version( FreeBSD )
+     void   srandom(uint);
+     int    unlockpt(int);
+ }
++else version( NetBSD )
++{
++    //WNOHANG     (defined in core.sys.posix.sys.wait)
++    //WUNTRACED   (defined in core.sys.posix.sys.wait)
++    //WEXITSTATUS (defined in core.sys.posix.sys.wait)
++    //WIFEXITED   (defined in core.sys.posix.sys.wait)
++    //WIFSIGNALED (defined in core.sys.posix.sys.wait)
++    //WIFSTOPPED  (defined in core.sys.posix.sys.wait)
++    //WSTOPSIG    (defined in core.sys.posix.sys.wait)
++    //WTERMSIG    (defined in core.sys.posix.sys.wait)
++
++    c_long a64l(in char*);
++    double drand48();
++    //char*  ecvt(double, int, int *, int *); // LEGACY
++    double erand48(ref ushort[3]);
++    //char*  fcvt(double, int, int *, int *); // LEGACY
++    //char*  gcvt(double, int, char*); // LEGACY
++    int    getsubopt(char**, in char**, char**);
++    int    grantpt(int);
++    char*  initstate(uint, char*, size_t);
++    c_long jrand48(ref ushort[3]);
++    char*  l64a(c_long);
++    void   lcong48(ref ushort[7]);
++    c_long lrand48();
++    char*  mktemp(char*); // LEGACY
++    int    mkstemp(char*);
++    char*  mkdtemp(char*); // Defined in IEEE 1003.1, 2008 Edition
++    c_long mrand48();
++    c_long nrand48(ref ushort[3]);
++    int    posix_openpt(int);
++    char*  ptsname(int);
++    int    putenv(char*);
++    c_long random();
++    char*  realpath(in char*, char*);
++    ushort *seed48(ref ushort[3]);
++    void   setkey(in char*);
++    char*  setstate(in char*);
++    void   srand48(c_long);
++    void   srandom(uint);
++    int    unlockpt(int);
++}
+ else version( CRuntime_Bionic )
+ {
+     double  drand48();
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_ioctl.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_ioctl.d
new file mode 100644
index 0000000..8155ad2
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_ioctl.d
@@ -0,0 +1,25 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/sys/ioctl.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sys/ioctl.d
+@@ -359,6 +359,18 @@ else version (FreeBSD)
+ 
+     int ioctl(int, c_ulong, ...);
+ }
++else version (NetBSD)
++{
++    struct winsize
++    {
++        ushort ws_row;
++        ushort ws_col;
++        ushort ws_xpixel;
++        ushort ws_ypixel;
++    }
++
++    int ioctl(int, c_ulong, ...);
++}
+ else version (Solaris)
+ {
+     int ioctl(int fildes, int request, ...);
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_ipc.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_ipc.d
new file mode 100644
index 0000000..6dbf372
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_ipc.d
@@ -0,0 +1,39 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/sys/ipc.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sys/ipc.d
+@@ -115,6 +115,32 @@ else version( FreeBSD )
+ 
+     key_t ftok(in char*, int);
+ }
++else version( NetBSD )
++{
++
++    struct ipc_perm
++    {
++        uid_t   cuid;
++        gid_t   cgid;
++        uid_t   uid;
++        gid_t   gid;
++        mode_t  mode;
++        ushort  seq;
++        key_t   key;
++    }
++
++    enum IPC_CREAT      = 0x0100; // 01000
++    enum IPC_EXCL       = 0x0200; // 02000
++    enum IPC_NOWAIT     = 0x0400; // 04000
++
++    enum key_t IPC_PRIVATE = 0;
++
++    enum IPC_RMID       = 0;
++    enum IPC_SET        = 1;
++    enum IPC_STAT       = 2;
++
++    key_t ftok(in char*, int);
++}
+ else version( CRuntime_Bionic )
+ {
+     // All except ftok are from the linux kernel headers.
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_mman.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_mman.d
new file mode 100644
index 0000000..f2fc71a
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_mman.d
@@ -0,0 +1,121 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/sys/mman.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sys/mman.d
+@@ -76,6 +76,16 @@ else version( FreeBSD )
+     enum POSIX_MADV_DONTNEED    = 4;
+     int posix_madvise(void *addr, size_t len, int advice);
+ }
++else version( NetBSD )
++{
++    enum POSIX_MADV_NORMAL      = 0;
++    enum POSIX_MADV_RANDOM      = 1;
++    enum POSIX_MADV_SEQUENTIAL  = 2;
++    enum POSIX_MADV_WILLNEED    = 3;
++    enum POSIX_MADV_DONTNEED    = 4;
++    int posix_madvise(void *addr, size_t len, int advice);
++}
++
+ else version (Solaris)
+ {
+ }
+@@ -118,6 +128,13 @@ else version( FreeBSD )
+     enum PROT_WRITE     = 0x02;
+     enum PROT_EXEC      = 0x04;
+ }
++else version( NetBSD )
++{
++    enum PROT_NONE      = 0x00;
++    enum PROT_READ      = 0x01;
++    enum PROT_WRITE     = 0x02;
++    enum PROT_EXEC      = 0x04;
++}
+ else version (Solaris)
+ {
+     enum PROT_NONE = 0x00;
+@@ -164,6 +181,11 @@ else version( FreeBSD )
+     void* mmap(void*, size_t, int, int, int, off_t);
+     int   munmap(void*, size_t);
+ }
++else version( NetBSD )
++{
++    void* mmap(void*, size_t, int, int, int, off_t);
++    int   munmap(void*, size_t);
++}
+ else version (Solaris)
+ {
+     void* mmap(void*, size_t, int, int, int, off_t);
+@@ -318,6 +340,21 @@ else version( FreeBSD )
+ 
+     int msync(void*, size_t, int);
+ }
++else version( NetBSD )
++{
++    enum MAP_SHARED     = 0x0001;
++    enum MAP_PRIVATE    = 0x0002;
++    enum MAP_FIXED      = 0x0010;
++    enum MAP_ANON       = 0x1000;
++
++    enum MAP_FAILED     = cast(void*)-1;
++
++    enum MS_SYNC        = 0x0000;
++    enum MS_ASYNC       = 0x0001;
++    enum MS_INVALIDATE  = 0x0002;
++
++    int msync(void*, size_t, int);
++}
+ else version (Solaris)
+ {
+     enum MAP_SHARED = 0x0001;
+@@ -429,6 +466,14 @@ else version( FreeBSD )
+     int mlockall(int);
+     int munlockall();
+ }
++else version( NetBSD )
++{
++    enum MCL_CURRENT    = 0x0001;
++    enum MCL_FUTURE     = 0x0002;
++
++    int mlockall(int);
++    int munlockall();
++}
+ else version (Solaris)
+ {
+     enum MCL_CURRENT = 0x0001;
+@@ -473,6 +518,11 @@ else version( FreeBSD )
+     int mlock(in void*, size_t);
+     int munlock(in void*, size_t);
+ }
++else version( NetBSD )
++{
++    int mlock(in void*, size_t);
++    int munlock(in void*, size_t);
++}
+ else version (Solaris)
+ {
+     int mlock(in void*, size_t);
+@@ -507,6 +557,10 @@ else version( FreeBSD )
+ {
+     int mprotect(void*, size_t, int);
+ }
++else version( NetBSD )
++{
++    int mprotect(void*, size_t, int);
++}
+ else version (Solaris)
+ {
+     int mprotect(void*, size_t, int);
+@@ -543,6 +597,11 @@ else version( FreeBSD )
+     int shm_open(in char*, int, mode_t);
+     int shm_unlink(in char*);
+ }
++else version( NetBSD )
++{
++    int shm_open(in char*, int, mode_t);
++    int shm_unlink(in char*);
++}
+ else version (Solaris)
+ {
+     int shm_open(in char*, int, mode_t);
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_resource.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_resource.d
new file mode 100644
index 0000000..76f2293
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_resource.d
@@ -0,0 +1,84 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/sys/resource.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sys/resource.d
+@@ -234,6 +234,64 @@ else version (FreeBSD)
+         RLIMIT_AS     = 10,
+     }
+ }
++else version (NetBSD)
++{
++    enum
++    {
++        PRIO_PROCESS = 0,
++        PRIO_PGRP    = 1,
++        PRIO_USER    = 2,
++    }
++
++    alias long rlim_t;
++
++    enum
++    {
++        RLIM_INFINITY   = (cast(rlim_t)((cast(ulong) 1 << 63) - 1)),
++        // FreeBSD explicitly does not define the following:
++        //RLIM_SAVED_MAX,
++        //RLIM_SAVED_CUR,
++    }
++
++    enum
++    {
++        RUSAGE_SELF     =  0,
++        RUSAGE_CHILDREN = -1,
++    }
++
++    struct rusage
++    {
++        timeval ru_utime;
++        timeval ru_stime;
++        c_long ru_maxrss;
++        alias ru_ixrss ru_first;
++        c_long ru_ixrss;
++        c_long ru_idrss;
++        c_long ru_isrss;
++        c_long ru_minflt;
++        c_long ru_majflt;
++        c_long ru_nswap;
++        c_long ru_inblock;
++        c_long ru_oublock;
++        c_long ru_msgsnd;
++        c_long ru_msgrcv;
++        c_long ru_nsignals;
++        c_long ru_nvcsw;
++        c_long ru_nivcsw;
++        alias ru_nivcsw ru_last;
++    }
++
++    enum
++    {
++        RLIMIT_CORE   =  4,
++        RLIMIT_CPU    =  0,
++        RLIMIT_DATA   =  2,
++        RLIMIT_FSIZE  =  1,
++        RLIMIT_NOFILE =  8,
++        RLIMIT_STACK  =  3,
++        RLIMIT_AS     = 10,
++    }
++}
+ else version (Solaris)
+ {
+     enum
+@@ -406,6 +464,12 @@ else version (FreeBSD)
+     int getrusage(int, rusage*);
+     int setrlimit(int, in rlimit*);
+ }
++else version (NetBSD)
++{
++    int getrlimit(int, rlimit*);
++    int getrusage(int, rusage*);
++    int setrlimit(int, in rlimit*);
++}
+ else version (Solaris)
+ {
+     int getrlimit(int, rlimit*);
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_select.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_select.d
new file mode 100644
index 0000000..832f675
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_select.d
@@ -0,0 +1,62 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/sys/select.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sys/select.d
+@@ -218,6 +218,55 @@ else version( FreeBSD )
+     int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
+     int select(int, fd_set*, fd_set*, fd_set*, timeval*);
+ }
++else version( NetBSD )
++{
++    private
++    {
++        alias c_ulong __fd_mask;
++        enum _NFDBITS = __fd_mask.sizeof * 8;
++    }
++
++    enum uint FD_SETSIZE = 256;
++
++    struct fd_set
++    {
++        __fd_mask[(FD_SETSIZE + (_NFDBITS - 1)) / _NFDBITS] __fds_bits;
++    }
++
++    extern (D) __fd_mask __fdset_mask(uint n)
++    {
++        return cast(__fd_mask) 1 << (n % _NFDBITS);
++    }
++
++    extern (D) void FD_CLR( int n, fd_set* p )
++    {
++        p.__fds_bits[n / _NFDBITS] &= ~__fdset_mask(n);
++    }
++
++    extern (D) bool FD_ISSET( int n, const(fd_set)* p )
++    {
++        return (p.__fds_bits[n / _NFDBITS] & __fdset_mask(n)) != 0;
++    }
++
++    extern (D) void FD_SET( int n, fd_set* p )
++    {
++        p.__fds_bits[n / _NFDBITS] |= __fdset_mask(n);
++    }
++
++    extern (D) void FD_ZERO( fd_set* p )
++    {
++        fd_set *_p;
++        size_t _n;
++
++        _p = p;
++        _n = (FD_SETSIZE + (_NFDBITS - 1)) / _NFDBITS;
++        while (_n > 0)
++            _p.__fds_bits[--_n] = 0;
++    }
++
++    int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
++    int select(int, fd_set*, fd_set*, fd_set*, timeval*);
++}
+ else version (Solaris)
+ {
+     private
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_shm.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_shm.d
new file mode 100644
index 0000000..3a39b4e
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_shm.d
@@ -0,0 +1,39 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/sys/shm.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sys/shm.d
+@@ -121,6 +121,32 @@ else version( FreeBSD )
+     int   shmdt(in void*);
+     int   shmget(key_t, size_t, int);
+ }
++else version( NetBSD )
++{
++    enum SHM_RDONLY     = 0x01000; // 010000
++    enum SHM_RND        = 0x02000; // 020000
++    enum SHMLBA         = 1 << 12; // PAGE_SIZE = (1<<PAGE_SHIFT)
++
++    alias c_ulong   shmatt_t;
++
++    struct shmid_ds
++    {
++        ipc_perm        shm_perm;
++        size_t             shm_segsz;
++        pid_t           shm_lpid;
++        pid_t           shm_cpid;
++        short           shm_nattch;
++        time_t          shm_atime;
++        time_t          shm_dtime;
++        time_t          shm_ctime;
++        void*           shm_internal;
++    }
++
++    void* shmat(int, in void*, int);
++    int   shmctl(int, int, shmid_ds*);
++    int   shmdt(in void*);
++    int   shmget(key_t, size_t, int);
++}
+ else version( OSX )
+ {
+ 
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_socket.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_socket.d
new file mode 100644
index 0000000..99c29f6
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_socket.d
@@ -0,0 +1,240 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/sys/socket.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sys/socket.d
+@@ -927,6 +927,205 @@ else version( FreeBSD )
+     int     sockatmark(int);
+     int     socketpair(int, int, int, ref int[2]);
+ }
++else version( NetBSD )
++{
++    alias uint   socklen_t;
++    alias ubyte  sa_family_t;
++
++    struct sockaddr
++    {
++        ubyte       sa_len;
++        sa_family_t sa_family;
++        byte[14]    sa_data;
++    }
++
++    private
++    {
++        enum _SS_ALIGNSIZE  = long.sizeof;
++        enum _SS_MAXSIZE    = 128;
++        enum _SS_PAD1SIZE   = _SS_ALIGNSIZE - ubyte.sizeof - sa_family_t.sizeof;
++        enum _SS_PAD2SIZE   = _SS_MAXSIZE - ubyte.sizeof - sa_family_t.sizeof - _SS_PAD1SIZE - _SS_ALIGNSIZE;
++    }
++
++    struct sockaddr_storage
++    {
++         ubyte              ss_len;
++         sa_family_t        ss_family;
++         byte[_SS_PAD1SIZE] __ss_pad1;
++         long               __ss_align;
++         byte[_SS_PAD2SIZE] __ss_pad2;
++    }
++
++    struct msghdr
++    {
++        void*     msg_name;
++        socklen_t msg_namelen;
++        iovec*    msg_iov;
++        int       msg_iovlen;
++        void*     msg_control;
++        socklen_t msg_controllen;
++        int       msg_flags;
++    }
++
++    struct cmsghdr
++    {
++         socklen_t cmsg_len;
++         int       cmsg_level;
++         int       cmsg_type;
++    }
++
++    enum : uint
++    {
++        SCM_RIGHTS = 0x01
++    }
++
++    private // <machine/param.h>
++    {
++        enum _ALIGNBYTES = /+c_int+/ int.sizeof - 1;
++        extern (D) size_t _ALIGN( size_t p ) { return (p + _ALIGNBYTES) & ~_ALIGNBYTES; }
++    }
++
++    extern (D) ubyte* CMSG_DATA( cmsghdr* cmsg )
++    {
++        return cast(ubyte*) cmsg + _ALIGN( cmsghdr.sizeof );
++    }
++
++    extern (D) cmsghdr* CMSG_NXTHDR( msghdr* mhdr, cmsghdr* cmsg )
++    {
++        if( cmsg == null )
++        {
++           return CMSG_FIRSTHDR( mhdr );
++        }
++        else
++        {
++            if( cast(ubyte*) cmsg + _ALIGN( cmsg.cmsg_len ) + _ALIGN( cmsghdr.sizeof ) >
++                    cast(ubyte*) mhdr.msg_control + mhdr.msg_controllen )
++                return null;
++            else
++                return cast(cmsghdr*) (cast(ubyte*) cmsg + _ALIGN( cmsg.cmsg_len ));
++        }
++    }
++
++    extern (D) cmsghdr* CMSG_FIRSTHDR( msghdr* mhdr )
++    {
++        return mhdr.msg_controllen >= cmsghdr.sizeof ? cast(cmsghdr*) mhdr.msg_control : null;
++    }
++
++    struct linger
++    {
++        int l_onoff;
++        int l_linger;
++    }
++
++    enum
++    {
++        SOCK_DGRAM      = 2,
++        SOCK_RDM        = 4,
++        SOCK_SEQPACKET  = 5,
++        SOCK_STREAM     = 1
++    }
++
++    enum : uint
++    {
++        SOL_SOCKET      = 0xffff
++    }
++
++    enum : uint
++    {
++         SO_DEBUG        = 0x0001,          /* turn on debugging info recording */
++         SO_ACCEPTCONN   = 0x0002,          /* socket has had listen() */
++         SO_REUSEADDR    = 0x0004,          /* allow local address reuse */
++         SO_KEEPALIVE    = 0x0008,          /* keep connections alive */
++         SO_DONTROUTE    = 0x0010,          /* just use interface addresses */
++         SO_BROADCAST    = 0x0020,          /* permit sending of broadcast msgs */
++         SO_USELOOPBACK  = 0x0040,          /* bypass hardware when possible */
++         SO_LINGER       = 0x0080,          /* linger on close if data present */
++         SO_OOBINLINE    = 0x0100,          /* leave received OOB data in line */
++         SO_REUSEPORT    = 0x0200,          /* allow local address & port reuse */
++        /*      SO_OTIMESTAMP   0x0400          */
++         SO_NOSIGPIPE    = 0x0800,          /* no SIGPIPE from EPIPE */
++         SO_ACCEPTFILTER = 0x1000,          /* there is an accept filter */
++         SO_TIMESTAMP    = 0x2000,          /* timestamp received dgram traffic */
++
++        /*
++         * Additional options, not kept in so_options.
++         */
++         SO_SNDBUF       = 0x1001,          /* send buffer size */
++         SO_RCVBUF       = 0x1002,          /* receive buffer size */
++         SO_SNDLOWAT     = 0x1003,          /* send low-water mark */
++         SO_RCVLOWAT     = 0x1004,          /* receive low-water mark */
++        /* SO_OSNDTIMEO         0x1005 */
++        /* SO_ORCVTIMEO         0x1006 */
++         SO_ERROR        = 0x1007,          /* get error status and clear */
++         SO_TYPE         = 0x1008,          /* get socket type */
++         SO_OVERFLOWED   = 0x1009,          /* datagrams: return packets dropped */
++
++         SO_NOHEADER     = 0x100a,          /* user supplies no header to kernel;
++                                                 * kernel removes header and supplies
++                                                 * payload
++                                                 */
++         SO_SNDTIMEO     = 0x100b,          /* send timeout */
++         SO_RCVTIMEO     = 0x100c          /* receive timeout */
++
++    }
++
++    enum
++    {
++        SOMAXCONN       = 128
++    }
++
++    enum : uint
++    {
++         MSG_OOB         = 0x0001,          /* process out-of-band data */
++         MSG_PEEK        = 0x0002,          /* peek at incoming message */
++         MSG_DONTROUTE   = 0x0004,          /* send without using routing tables */
++         MSG_EOR         = 0x0008,          /* data completes record */
++         MSG_TRUNC       = 0x0010,          /* data discarded before delivery */
++         MSG_CTRUNC      = 0x0020,          /* control data lost before delivery */
++         MSG_WAITALL     = 0x0040,          /* wait for full request or error */
++         MSG_DONTWAIT    = 0x0080,          /* this message should be nonblocking */
++         MSG_BCAST       = 0x0100,          /* this message was rcvd using link-level brdcst */
++         MSG_MCAST       = 0x0200,          /* this message was rcvd using link-level mcast */
++         MSG_NOSIGNAL    = 0x0400          /* do not generate SIGPIPE on EOF */
++
++
++    }
++
++    enum
++    {
++        AF_APPLETALK    = 16,
++        AF_INET         = 2,
++        AF_IPX          = 23,
++        AF_UNIX         = 1,
++        AF_UNSPEC       = 0
++    }
++
++    enum
++    {
++        SHUT_RD = 0,
++        SHUT_WR = 1,
++        SHUT_RDWR = 2
++    }
++
++    int     accept(int, sockaddr*, socklen_t*);
++    int     bind(int, in sockaddr*, socklen_t);
++    int     connect(int, in sockaddr*, socklen_t);
++    int     getpeername(int, sockaddr*, socklen_t*);
++    int     getsockname(int, sockaddr*, socklen_t*);
++    int     getsockopt(int, int, int, void*, socklen_t*);
++    int     listen(int, int);
++    ssize_t recv(int, void*, size_t, int);
++    ssize_t recvfrom(int, void*, size_t, int, sockaddr*, socklen_t*);
++    ssize_t recvmsg(int, msghdr*, int);
++    ssize_t send(int, in void*, size_t, int);
++    ssize_t sendmsg(int, in msghdr*, int);
++    ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t);
++    int     setsockopt(int, int, int, in void*, socklen_t);
++    int     shutdown(int, int);
++    int     socket(int, int, int);
++    int     sockatmark(int);
++    int     socketpair(int, int, int, ref int[2]);
++}
+ else version (Solaris)
+ {
+     alias uint socklen_t;
+@@ -1311,6 +1510,13 @@ else version( FreeBSD )
+         AF_INET6    = 28
+     }
+ }
++else version( NetBSD )
++{
++    enum
++    {
++        AF_INET6    = 24
++    }
++}
+ else version (Solaris)
+ {
+     enum
+@@ -1358,6 +1564,13 @@ else version( FreeBSD )
+         SOCK_RAW    = 3
+     }
+ }
++else version( NetBSD )
++{
++    enum
++    {
++        SOCK_RAW    = 3
++    }
++}
+ else version (Solaris)
+ {
+     enum
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_stat.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_stat.d
new file mode 100644
index 0000000..5947b76
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_stat.d
@@ -0,0 +1,113 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/sys/stat.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sys/stat.d
+@@ -777,6 +777,70 @@ else version( FreeBSD )
+     extern (D) bool S_ISLNK( mode_t mode )  { return S_ISTYPE( mode, S_IFLNK );  }
+     extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); }
+ }
++else version( NetBSD )
++{
++    struct stat_t
++    {
++        dev_t     st_dev;               /* inode's device */
++        mode_t    st_mode;              /* inode protection mode */
++        ino_t     st_ino;               /* inode's number */
++        nlink_t   st_nlink;             /* number of hard links */
++        uid_t     st_uid;               /* user ID of the file's owner */
++        gid_t     st_gid;               /* group ID of the file's group */
++        dev_t     st_rdev;              /* device type */
++
++        time_t    st_atime;             /* time of last access */
++        long      st_atimensec;         /* nsec of last access */
++        time_t    st_mtime;             /* time of last data modification */
++        long      st_mtimensec;         /* nsec of last data modification */
++        time_t    st_ctime;             /* time of last file status change */
++        long      st_ctimensec;         /* nsec of last file status change */
++        time_t    st_birthtime;         /* time of creation */
++        long      st_birthtimensec;     /* nsec of time of creation */
++
++        off_t     st_size;              /* file size, in bytes */
++        blkcnt_t  st_blocks;            /* blocks allocated for file */
++        blksize_t st_blksize;           /* optimal blocksize for I/O */
++        uint32_t  st_flags;             /* user defined flags for file */
++        uint32_t  st_gen;               /* file generation number */
++        uint32_t[2]  st_spare;
++    }
++
++    enum S_IRUSR    = 0x100; // octal 0000400
++    enum S_IWUSR    = 0x080; // octal 0000200
++    enum S_IXUSR    = 0x040; // octal 0000100
++    enum S_IRWXU    = 0x1C0; // octal 0000700
++
++    enum S_IRGRP    = 0x020;  // octal 0000040
++    enum S_IWGRP    = 0x010;  // octal 0000020
++    enum S_IXGRP    = 0x008;  // octal 0000010
++    enum S_IRWXG    = 0x038;  // octal 0000070
++
++    enum S_IROTH    = 0x4; // 0000004
++    enum S_IWOTH    = 0x2; // 0000002
++    enum S_IXOTH    = 0x1; // 0000001
++    enum S_IRWXO    = 0x7; // 0000007
++
++    enum S_ISUID    = 0x800; // octal 0004000
++    enum S_ISGID    = 0x400; // octal 0002000
++    enum S_ISVTX    = 0x200; // octal 0001000
++
++    private
++    {
++        extern (D) bool S_ISTYPE( mode_t mode, uint mask )
++        {
++            return ( mode & S_IFMT ) == mask;
++        }
++    }
++
++    extern (D) bool S_ISBLK( mode_t mode )  { return S_ISTYPE( mode, S_IFBLK );  }
++    extern (D) bool S_ISCHR( mode_t mode )  { return S_ISTYPE( mode, S_IFCHR );  }
++    extern (D) bool S_ISDIR( mode_t mode )  { return S_ISTYPE( mode, S_IFDIR );  }
++    extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO );  }
++    extern (D) bool S_ISREG( mode_t mode )  { return S_ISTYPE( mode, S_IFREG );  }
++    extern (D) bool S_ISLNK( mode_t mode )  { return S_ISTYPE( mode, S_IFLNK );  }
++    extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); }
++}
+ else version (Solaris)
+ {
+     private enum _ST_FSTYPSZ = 16;
+@@ -1105,6 +1169,15 @@ else version( FreeBSD )
+     int   lstat(in char*, stat_t*);
+     int   stat(in char*, stat_t*);
+ }
++else version( NetBSD )
++{
++    int   __fstat50(int, stat_t*);
++    int   __lstat50(in char*, stat_t*);
++    int   __stat50(in char*, stat_t*);
++    alias __fstat50 fstat;
++    alias __lstat50 lstat;
++    alias __stat50 stat;
++}
+ else version( CRuntime_Bionic )
+ {
+     int   fstat(int, stat_t*) @trusted;
+@@ -1174,6 +1247,19 @@ else version( FreeBSD )
+ 
+     int mknod(in char*, mode_t, dev_t);
+ }
++else version( NetBSD )
++{
++    enum S_IFMT     = 0xF000; // octal 0170000
++    enum S_IFBLK    = 0x6000; // octal 0060000
++    enum S_IFCHR    = 0x2000; // octal 0020000
++    enum S_IFIFO    = 0x1000; // octal 0010000
++    enum S_IFREG    = 0x8000; // octal 0100000
++    enum S_IFDIR    = 0x4000; // octal 0040000
++    enum S_IFLNK    = 0xA000; // octal 0120000
++    enum S_IFSOCK   = 0xC000; // octal 0140000
++
++    int mknod(in char*, mode_t, dev_t);
++}
+ else version (Solaris)
+ {
+     enum S_IFMT = 0xF000;
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_time.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_time.d
new file mode 100644
index 0000000..aed3386
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_time.d
@@ -0,0 +1,34 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/sys/time.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sys/time.d
+@@ -123,6 +123,27 @@ else version( FreeBSD )
+     int setitimer(int, in itimerval*, itimerval*);
+     int utimes(in char*, ref const(timeval)[2]);
+ }
++else version( NetBSD )
++{
++    struct timeval
++    {
++        time_t      tv_sec;
++        suseconds_t tv_usec;
++    }
++
++    struct itimerval
++    {
++        timeval it_interval;
++        timeval it_value;
++    }
++
++
++    int getitimer(int, itimerval*);
++    int gettimeofday(timeval*, void*); // timezone_t* is normally void*
++    int setitimer(int, in itimerval*, itimerval*);
++    int utimes(in char*, ref const(timeval)[2]);
++}
++
+ else version (Solaris)
+ {
+     struct timeval
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_types.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_types.d
new file mode 100644
index 0000000..218e8fe
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_types.d
@@ -0,0 +1,102 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/sys/types.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sys/types.d
+@@ -138,6 +138,23 @@ else version( FreeBSD )
+     alias uint      uid_t;
+     alias uint      fflags_t;
+ }
++else version( NetBSD )
++{
++    alias long      blkcnt_t;
++    alias int       blksize_t;
++    alias ulong     dev_t;
++    alias uint      gid_t;
++    alias ulong     ino_t;
++    alias uint      mode_t;
++    alias uint      nlink_t;
++    alias ulong     off_t;
++    alias int       pid_t;
++    //size_t (defined in core.stdc.stddef)
++    alias c_long      ssize_t;
++    alias c_long      time_t;
++    alias uint        uid_t;
++
++}
+ else version (Solaris)
+ {
+     alias char* caddr_t;
+@@ -269,6 +286,16 @@ else version( FreeBSD )
+     alias c_long    suseconds_t;
+     alias uint      useconds_t;
+ }
++else version( NetBSD )
++{
++    alias ulong     fsblkcnt_t;
++    alias ulong     fsfilcnt_t;
++    alias c_long    clock_t;
++    alias long      id_t;
++    alias c_long    key_t;
++    alias c_long    suseconds_t;
++    alias uint      useconds_t;
++}
+ else version (Solaris)
+ {
+     static if (__USE_FILE_OFFSET64)
+@@ -645,6 +672,31 @@ else version( FreeBSD )
+     alias void* pthread_rwlockattr_t;
+     alias void* pthread_t;
+ }
++else version( NetBSD )
++{
++    alias int lwpid_t;
++
++    struct pthread_attr_t_ {ubyte[16] a;};
++    struct pthread_cond_t_ {ubyte[40] a;};
++    struct pthread_condattr_t_ {ubyte[16] a;};
++    struct pthread_mutex_t_ {ubyte[48] a;};
++    struct pthread_mutexattr_t_{ubyte[16] a;};
++    struct pthread_once_t_{ubyte[56] a;};
++    struct pthread_rwlock_t_{ubyte[64] a;};
++    struct pthread_rwlockattr_t_{ubyte[16] a;};
++
++    alias pthread_attr_t_ pthread_attr_t;
++    alias pthread_cond_t_ pthread_cond_t;
++    alias pthread_condattr_t_ pthread_condattr_t;
++    alias uint pthread_key_t;
++    alias pthread_mutex_t_ pthread_mutex_t;
++    alias pthread_mutexattr_t_ pthread_mutexattr_t;
++    alias pthread_once_t_ pthread_once_t;
++    alias pthread_rwlock_t_ pthread_rwlock_t;
++    alias pthread_rwlockattr_t_ pthread_rwlockattr_t;
++
++    alias void* pthread_t;
++}
+ else version (Solaris)
+ {
+     alias uint pthread_t;
+@@ -809,6 +861,11 @@ else version( FreeBSD )
+     alias void* pthread_barrier_t;
+     alias void* pthread_barrierattr_t;
+ }
++else version( NetBSD )
++{
++    alias void* pthread_barrier_t;
++    alias void* pthread_barrierattr_t;
++}
+ else version( OSX )
+ {
+ }
+@@ -852,6 +909,10 @@ else version( FreeBSD )
+ {
+     alias void* pthread_spinlock_t;
+ }
++else version( NetBSD )
++{
++    alias void* pthread_spinlock_t;
++}
+ else version (Solaris)
+ {
+     alias pthread_mutex_t pthread_spinlock_t;
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_uio.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_uio.d
new file mode 100644
index 0000000..4a7d76c
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_uio.d
@@ -0,0 +1,24 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/sys/uio.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sys/uio.d
+@@ -70,6 +70,17 @@ else version( FreeBSD )
+     ssize_t readv(int, in iovec*, int);
+     ssize_t writev(int, in iovec*, int);
+ }
++else version( NetBSD )
++{
++    struct iovec
++    {
++        void*  iov_base;
++        size_t iov_len;
++    }
++
++    ssize_t readv(int, in iovec*, int);
++    ssize_t writev(int, in iovec*, int);
++}
+ else version (Solaris)
+ {
+     struct iovec
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_un.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_un.d
new file mode 100644
index 0000000..3abe868
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_un.d
@@ -0,0 +1,22 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/sys/un.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sys/un.d
+@@ -60,6 +60,15 @@ else version( FreeBSD )
+         byte[104]   sun_path;
+     }
+ }
++else version( NetBSD )
++{
++    struct sockaddr_un
++    {
++        ubyte       sun_len;
++        sa_family_t sun_family;
++        byte[104]   sun_path;
++    }
++}
+ else version( Solaris )
+ {
+     struct sockaddr_un
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_utsname.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_utsname.d
new file mode 100644
index 0000000..48d4014
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_utsname.d
@@ -0,0 +1,29 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/sys/utsname.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sys/utsname.d
+@@ -53,6 +53,22 @@ else version(FreeBSD)
+ 
+     int uname(utsname* __name);
+ }
++else version(NetBSD)
++{
++    private enum utsNameLength = 256;
++
++    struct utsname
++    {
++        char[utsNameLength] sysname;
++        char[utsNameLength] nodename;
++        char[utsNameLength] release;
++        // The field name is version but version is a keyword in D.
++        char[utsNameLength] update;
++        char[utsNameLength] machine;
++    }
++
++    int uname(utsname* __name);
++}
+ else version(CRuntime_Bionic)
+ {
+     private enum SYS_NMLN = 65;
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_wait.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_wait.d
new file mode 100644
index 0000000..9812432
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_sys_wait.d
@@ -0,0 +1,48 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/sys/wait.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sys/wait.d
+@@ -113,6 +113,28 @@ else version( FreeBSD )
+     extern (D) int  WSTOPSIG( int status )     { return status >> 8;                     }
+     extern (D) int  WTERMSIG( int status )     { return _WSTATUS( status );              }
+ }
++else version( NetBSD )
++{
++    enum WNOHANG        = 1;
++    enum WUNTRACED      = 2;
++
++    private
++    {
++        enum _WSTOPPED = 0x7F; // octal 0177
++    }
++
++    extern (D) int _WSTATUS(int status)         { return (status & 0x7F);           }
++    extern (D) int  WEXITSTATUS( int status )   { return (status >> 8);             }
++    extern (D) int  WIFCONTINUED( int status )  { return status == 0x13;            }
++    extern (D) bool WIFEXITED( int status )     { return _WSTATUS(status) == 0;     }
++    extern (D) bool WIFSIGNALED( int status )
++    {
++        return _WSTATUS( status ) != _WSTOPPED && _WSTATUS( status ) != 0;
++    }
++    extern (D) bool WIFSTOPPED( int status )   { return _WSTATUS( status ) == _WSTOPPED; }
++    extern (D) int  WSTOPSIG( int status )     { return status >> 8;                     }
++    extern (D) int  WTERMSIG( int status )     { return _WSTATUS( status );              }
++}
+ else version (Solaris)
+ {
+     enum WNOHANG        = 64;
+@@ -205,6 +227,12 @@ else version (FreeBSD)
+ 
+     // http://www.freebsd.org/projects/c99/
+ }
++else version (NetBSD)
++{
++    enum WSTOPPED       = WUNTRACED;
++    //enum WCONTINUED     = 4;
++    enum WNOWAIT        = 0x00010000;
++}
+ else version (Solaris)
+ {
+     enum WEXITED = 1;
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_syslog.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_syslog.d
new file mode 100644
index 0000000..e77f8c4
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_syslog.d
@@ -0,0 +1,78 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/syslog.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/syslog.d
+@@ -202,6 +202,71 @@ else version( FreeBSD )
+     void syslog (int __pri, const char *__fmt, ...);
+     void closelog();
+ }
++else version( NetBSD )
++{
++    //http://fxr.watson.org/fxr/source/sys/syslog.h
++
++    //PRIORITY
++    enum {
++        LOG_EMERG = 0,     /* system is unusable */
++        LOG_ALERT = 1,     /* action must be taken immediately */
++        LOG_CRIT  = 2,     /* critical conditions */
++        LOG_ERR   = 3,     /* error conditions */
++        LOG_WARNING = 4,   /* warning conditions */
++        LOG_NOTICE  = 5,   /* normal but significant condition */
++        LOG_INFO    = 6,   /* informational */
++        LOG_DEBUG   = 7,   /* debug-level messages */
++    };
++
++    //OPTIONS
++    enum {
++        LOG_PID    = 0x01,    /* log the pid with each message */
++        LOG_CONS   = 0x02,    /* log on the console if errors in sending */
++        LOG_ODELAY = 0x04,    /* delay open until first syslog() (default) */
++        LOG_NDELAY = 0x08,    /* don't delay open */
++        LOG_NOWAIT = 0x10,    /* don't wait for console forks: DEPRECATED */
++        LOG_PERROR = 0x20,    /* log to stderr as well */
++    };
++
++    //FACILITY
++    enum {
++        LOG_KERN   = (0<<3),  /* kernel messages */
++        LOG_USER   = (1<<3),  /* random user-level messages */
++        LOG_MAIL   = (2<<3),  /* mail system */
++        LOG_DAEMON = (3<<3),  /* system daemons */
++        LOG_AUTH   = (4<<3),  /* security/authorization messages */
++        LOG_SYSLOG = (5<<3),  /* messages generated internally by syslogd */
++        LOG_LPR    = (6<<3),  /* line printer subsystem */
++        LOG_NEWS   = (7<<3),  /* network news subsystem */
++        LOG_UUCP   = (8<<3),  /* UUCP subsystem */
++        LOG_CRON   = (9<<3),  /* clock daemon */
++        LOG_AUTHPRIV = (10<<3), /* security/authorization messages (private), */
++        LOG_FTP    =  (11<<3), /* ftp daemon */
++        LOG_NTP    = (12<<3), /* NTP subsystem */
++        LOG_SECURITY = (13<<3), /* security subsystems (firewalling, etc.) */
++        LOG_CONSOLE  = (14<<3), /* /dev/console output */
++
++        /* other codes through 15 reserved for system use */
++        LOG_LOCAL0 = (16<<3), /* reserved for local use */
++        LOG_LOCAL1 = (17<<3), /* reserved for local use */
++        LOG_LOCAL2 = (18<<3), /* reserved for local use */
++        LOG_LOCAL3 = (19<<3), /* reserved for local use */
++        LOG_LOCAL4 = (20<<3), /* reserved for local use */
++        LOG_LOCAL5 = (21<<3), /* reserved for local use */
++        LOG_LOCAL6 = (22<<3), /* reserved for local use */
++        LOG_LOCAL7 = (23<<3), /* reserved for local use */
++
++        LOG_NFACILITIES = 24,  /* current number of facilities */
++    };
++
++    int LOG_MASK(int pri) { return 1 << pri; }        /* mask for one priority */
++    int LOG_UPTO(int pri) { return (1 << (pri+1)) - 1; }  /* all priorities through pri */
++
++    void openlog (const char *, int __option, int __facility);
++    int  setlogmask (int __mask);
++    void syslog (int __pri, const char *__fmt, ...);
++    void closelog();
++}
+ else version( Solaris )
+ {
+     //http://pubs.opengroup.org/onlinepubs/007904875/basedefs/syslog.h.html
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_termios.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_termios.d
new file mode 100644
index 0000000..57a15ee
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_termios.d
@@ -0,0 +1,161 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/termios.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/termios.d
+@@ -459,6 +459,115 @@ else version ( FreeBSD )
+     int     tcsetattr(int, int, in termios*);
+ 
+ }
++else version ( NetBSD )
++{
++    alias ubyte cc_t;
++    alias uint  speed_t;
++    alias uint  tcflag_t;
++
++    enum NCCS   = 20;
++
++    struct termios
++    {
++        tcflag_t   c_iflag;
++        tcflag_t   c_oflag;
++        tcflag_t   c_cflag;
++        tcflag_t   c_lflag;
++        cc_t[NCCS] c_cc;
++        speed_t    c_ispeed;
++        speed_t    c_ospeed;
++    }
++
++    enum VEOF       = 0;
++    enum VEOL       = 1;
++    enum VERASE     = 3;
++    enum VINTR      = 8;
++    enum VKILL      = 5;
++    enum VMIN       = 16;
++    enum VQUIT      = 9;
++    enum VSTART     = 12;
++    enum VSTOP      = 13;
++    enum VSUSP      = 10;
++    enum VTIME      = 17;
++
++    enum BRKINT     = 0x0000002;
++    enum ICRNL      = 0x0000100;
++    enum IGNBRK     = 0x0000001;
++    enum IGNCR      = 0x0000080;
++    enum IGNPAR     = 0x0000004;
++    enum INLCR      = 0x0000040;
++    enum INPCK      = 0x0000010;
++    enum ISTRIP     = 0x0000020;
++    enum IXOFF      = 0x0000400;
++    enum IXON       = 0x0000200;
++    enum PARMRK     = 0x0000008;
++
++    enum OPOST      = 0x0000001;
++
++    enum B0         = 0;
++    enum B50        = 50;
++    enum B75        = 75;
++    enum B110       = 110;
++    enum B134       = 134;
++    enum B150       = 150;
++    enum B200       = 200;
++    enum B300       = 300;
++    enum B600       = 600;
++    enum B1200      = 1200;
++    enum B1800      = 1800;
++    enum B2400      = 2400;
++    enum B4800      = 4800;
++    enum B9600      = 9600;
++    enum B19200     = 19200;
++    enum B38400     = 38400;
++
++    enum CSIZE      = 0x0000300;
++    enum   CS5      = 0x0000000;
++    enum   CS6      = 0x0000100;
++    enum   CS7      = 0x0000200;
++    enum   CS8      = 0x0000300;
++    enum CSTOPB     = 0x0000400;
++    enum CREAD      = 0x0000800;
++    enum PARENB     = 0x0001000;
++    enum PARODD     = 0x0002000;
++    enum HUPCL      = 0x0004000;
++    enum CLOCAL     = 0x0008000;
++
++    enum ECHO       = 0x00000008;
++    enum ECHOE      = 0x00000002;
++    enum ECHOK      = 0x00000004;
++    enum ECHONL     = 0x00000010;
++    enum ICANON     = 0x00000100;
++    enum IEXTEN     = 0x00000400;
++    enum ISIG       = 0x00000080;
++    enum NOFLSH     = 0x80000000;
++    enum TOSTOP     = 0x00400000;
++
++    enum TCSANOW    = 0;
++    enum TCSADRAIN  = 1;
++    enum TCSAFLUSH  = 2;
++
++    enum TCIFLUSH   = 1;
++    enum TCOFLUSH   = 2;
++    enum TCIOFLUSH  = 3;
++
++    enum TCIOFF     = 3;
++    enum TCION      = 4;
++    enum TCOOFF     = 1;
++    enum TCOON      = 2;
++
++    speed_t cfgetispeed(in termios*);
++    speed_t cfgetospeed(in termios*);
++    int     cfsetispeed(termios*, speed_t);
++    int     cfsetospeed(termios*, speed_t);
++    int     tcdrain(int);
++    int     tcflow(int, int);
++    int     tcflush(int, int);
++    int     tcgetattr(int, termios*);
++    int     tcsendbreak(int, int);
++    int     tcsetattr(int, int, in termios*);
++
++}
+ 
+ //
+ // XOpen (XSI)
+@@ -601,4 +710,38 @@ else version( FreeBSD )
+ 
+     pid_t   tcgetsid(int);
+ }
++else version( NetBSD )
++{
++    enum IXANY      = 0x00000800;
++
++    enum ONLCR      = 0x00000002;
++    enum OCRNL      = 0x00000010;
++    enum ONOCR      = 0x00000020;
++    enum ONLRET     = 0x00000040;
++    //enum OFILL
++    //enum NLDLY
++    //enum     NL0
++    //enum     NL1
++    //enum CRDLY
++    //enum     CR0
++    //enum     CR1
++    //enum     CR2
++    //enum     CR3
++    enum TABDLY     = 0x00000004;
++    enum     TAB0   = 0x00000000;
++    //enum     TAB1
++    //enum     TAB2
++    enum     TAB3   = 0x00000004;
++    //enum BSDLY
++    //enum     BS0
++    //enum     BS1
++    //enum VTDLY
++    //enum     VT0
++    //enum     VT1
++    //enum FFDLY
++    //enum     FF0
++    //enum     FF1
++
++    pid_t   tcgetsid(int);
++}
+ 
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_time.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_time.d
new file mode 100644
index 0000000..731e11c
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_time.d
@@ -0,0 +1,87 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/time.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/time.d
+@@ -52,6 +52,10 @@ else version( FreeBSD )
+ {
+     time_t timegm(tm*); // non-standard
+ }
++else version( NetBSD )
++{
++    time_t timegm(tm*); // non-standard
++}
+ else version (Solaris)
+ {
+     time_t timegm(tm*); // non-standard
+@@ -115,6 +119,12 @@ else version (FreeBSD)
+     deprecated("Please import it from core.sys.freebsd.time instead.")
+         alias CLOCK_MONOTONIC_FAST = core.sys.freebsd.time.CLOCK_MONOTONIC_FAST;
+ }
++else version (NetBSD)
++{
++    // time.h
++    enum CLOCK_MONOTONIC         = 3;
++}
++
+ else version (OSX)
+ {
+     // No CLOCK_MONOTONIC defined
+@@ -245,6 +255,30 @@ else version( FreeBSD )
+     int timer_getoverrun(timer_t);
+     int timer_settime(timer_t, int, in itimerspec*, itimerspec*);
+ }
++else version( NetBSD )
++{
++    struct itimerspec
++    {
++        timespec it_interval;
++        timespec it_value;
++    }
++
++    enum CLOCK_REALTIME      = 0;
++    enum TIMER_ABSTIME       = 0x01;
++
++    alias int clockid_t; // <sys/_types.h>
++    alias int timer_t;
++
++    int clock_getres(clockid_t, timespec*);
++    int clock_gettime(clockid_t, timespec*);
++    int clock_settime(clockid_t, in timespec*);
++    int nanosleep(in timespec*, timespec*);
++    int timer_create(clockid_t, sigevent*, timer_t*);
++    int timer_delete(timer_t);
++    int timer_gettime(timer_t, itimerspec*);
++    int timer_getoverrun(timer_t);
++    int timer_settime(timer_t, int, in itimerspec*, itimerspec*);
++}
+ else version (Solaris)
+ {
+     enum CLOCK_PROCESS_CPUTIME_ID = 5; // <sys/time_impl.h>
+@@ -338,6 +372,13 @@ else version( FreeBSD )
+     tm*   gmtime_r(in time_t*, tm*);
+     tm*   localtime_r(in time_t*, tm*);
+ }
++else version( NetBSD )
++{
++    char* asctime_r(in tm*, char*);
++    char* ctime_r(in time_t*, char*);
++    tm*   gmtime_r(in time_t*, tm*);
++    tm*   localtime_r(in time_t*, tm*);
++}
+ else version (Solaris)
+ {
+     char* asctime_r(in tm*, char*);
+@@ -391,6 +432,11 @@ else version( FreeBSD )
+     //tm*   getdate(in char*);
+     char* strptime(in char*, in char*, tm*);
+ }
++else version( NetBSD )
++{
++    tm*   getdate(in char*);
++    char* strptime(in char*, in char*, tm*);
++}
+ else version (Solaris)
+ {
+     extern __gshared c_long timezone, altzone;
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_ucontext.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_ucontext.d
new file mode 100644
index 0000000..a3a539d
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_ucontext.d
@@ -0,0 +1,69 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/ucontext.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/ucontext.d
+@@ -701,6 +701,62 @@ else version( FreeBSD )
+         int[4]          __spare__;
+     }
+ }
++else version( NetBSD )
++{
++
++    version( X86_64 )
++    {
++      enum { NGREG = 26 };
++      alias __greg_t = ulong;
++      alias __gregset_t = __greg_t[NGREG];
++      alias __fpregset_t = align(8)ubyte[512];
++
++      struct mcontext_t {
++        __gregset_t     __gregs;
++        __greg_t        _mc_tlsbase;
++        __fpregset_t    __fpregs;
++      }
++    }
++    else version( X86 )
++    {
++      enum { NGREG = 19 };
++      alias __greg_t = ulong;
++      alias __gregset_t = __greg_t[_NGREG];
++      struct __fpregset_t{
++        union __fp_reg_set{
++                struct __fpchip_state{
++                        int[27]     __fp_state; /* Environment and registers */
++                } ;       /* x87 regs in fsave format */
++                struct __fp_xmm_state{
++                        ubyte[512]    __fp_xmm;
++                } ;       /* x87 and xmm regs in fxsave format */
++                int[128]     __fp_fpregs;
++        };
++        __fpregset_t __fp_reg_set;
++        int[33]     __fp_pad;                   /* Historic padding */
++      };
++
++      struct mcontext_t {
++        __gregset_t     __gregs;
++        __fpregset_t    __fpregs;
++        __greg_t        _mc_tlsbase;
++      }
++    }
++
++    struct ucontext_t
++    {
++        uint    uc_flags;       /* properties */
++        ucontext_t *    uc_link;        /* context to resume */
++        sigset_t        uc_sigmask;     /* signals blocked in this context */
++        stack_t         uc_stack;       /* the stack used by this context */
++        mcontext_t      uc_mcontext;    /* machine state */
++        /+ todo #if defined(_UC_MACHINE_PAD)
++                long            __uc_pad[_UC_MACHINE_PAD];
++        #endif
++        +/
++
++    }
++}
+ else version ( Solaris )
+ {
+     alias uint[4] upad128_t;
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_unistd.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_unistd.d
new file mode 100644
index 0000000..12bf854
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_unistd.d
@@ -0,0 +1,205 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/unistd.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/unistd.d
+@@ -116,6 +116,11 @@ else version( FreeBSD )
+     off_t lseek(int, off_t, int) @trusted;
+     int   ftruncate(int, off_t) @trusted;
+ }
++else version( NetBSD )
++{
++    off_t lseek(int, off_t, int) @trusted;
++    int   ftruncate(int, off_t) @trusted;
++}
+ else version( Solaris )
+ {
+     version ( D_LP64 )
+@@ -808,6 +813,143 @@ else version( FreeBSD )
+         _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS =  14,
+     }
+ }
++else version( NetBSD )
++{
++    enum F_OK       = 0;
++    enum R_OK       = 0x04;
++    enum W_OK       = 0x02;
++    enum X_OK       = 0x01;
++
++    enum F_ULOCK    = 0;
++    enum F_LOCK     = 1;
++    enum F_TLOCK    = 2;
++    enum F_TEST     = 3;
++
++    enum
++    {
++        _SC_ARG_MAX                        =   1,
++        _SC_CHILD_MAX                      =   2,
++        _O_SC_CLK_TCK                      =   3,
++        _SC_NGROUPS_MAX                    =   4,
++        _SC_OPEN_MAX                       =   5,
++        _SC_JOB_CONTROL                    =   6,
++        _SC_SAVED_IDS                      =   7,
++        _SC_VERSION                        =   8,
++        _SC_BC_BASE_MAX                    =   9,
++        _SC_BC_DIM_MAX                     =  10,
++        _SC_BC_SCALE_MAX                   =  11,
++        _SC_BC_STRING_MAX                  =  12,
++        _SC_COLL_WEIGHTS_MAX               =  13,
++        _SC_EXPR_NEST_MAX                  =  14,
++        _SC_LINE_MAX                       =  15,
++        _SC_RE_DUP_MAX                     =  16,
++        _SC_2_VERSION                      =  17,
++        _SC_2_C_BIND                       =  18,
++        _SC_2_C_DEV                        =  19,
++        _SC_2_CHAR_TERM                    =  20,
++        _SC_2_FORT_DEV                     =  21,
++        _SC_2_FORT_RUN                     =  22,
++        _SC_2_LOCALEDEF                    =  23,
++        _SC_2_SW_DEV                       =  24,
++        _SC_2_UPE                          =  25,
++        _SC_STREAM_MAX                     =  26,
++        _SC_TZNAME_MAX                     =  27,
++        _SC_PAGESIZE                       =  28,
++        _SC_FSYNC                          =  29,
++        _SC_XOPEN_SHM                      =  30,
++        _SC_SYNCHRONIZED_IO                =  31,
++        _SC_IOV_MAX                        =  32,
++        _SC_MAPPED_FILES                   =  33,
++        _SC_MEMLOCK                        =  34,
++        _SC_MEMLOCK_RANGE                  =  35,
++        _SC_MEMORY_PROTECTION              =  36,
++        _SC_LOGIN_NAME_MAX                 =  37,
++        _SC_MONOTONIC_CLOCK                =  38,
++        _SC_CLK_TCK                        =  39,
++        _SC_ATEXIT_MAX                     =  40,
++        _SC_THREADS                        =  41,
++        _SC_SEMAPHORES                     =  42,
++        _SC_BARRIERS                       =  43,
++        _SC_TIMERS                         =  44,
++        _SC_SPIN_LOCKS                     =  45,
++        _SC_READER_WRITER_LOCKS            =  46,
++        _SC_GETGR_R_SIZE_MAX               =  47,
++        _SC_GETPW_R_SIZE_MAX               =  48,
++        _SC_CLOCK_SELECTION                =  49,
++        _SC_ASYNCHRONOUS_IO                =  50,
++        _SC_AIO_LISTIO_MAX                 =  51,
++        _SC_AIO_MAX                        =  52,
++        _SC_MESSAGE_PASSING     = 53,
++        _SC_MQ_OPEN_MAX         = 54,
++        _SC_MQ_PRIO_MAX         = 55,
++        _SC_PRIORITY_SCHEDULING = 56,
++        _SC_THREAD_DESTRUCTOR_ITERATIONS = 57,
++        _SC_THREAD_KEYS_MAX             = 58,
++        _SC_THREAD_STACK_MIN            = 59,
++        _SC_THREAD_THREADS_MAX          = 60,
++        _SC_THREAD_ATTR_STACKADDR       = 61,
++        _SC_THREAD_ATTR_STACKSIZE       = 62,
++        _SC_THREAD_PRIORITY_SCHEDULING  = 63,
++        _SC_THREAD_PRIO_INHERIT         = 64,
++        _SC_THREAD_PRIO_PROTECT         = 65,
++        _SC_THREAD_PROCESS_SHARED       = 66,
++        _SC_THREAD_SAFE_FUNCTIONS       = 67,
++        _SC_TTY_NAME_MAX                = 68,
++        _SC_HOST_NAME_MAX               = 69,
++        _SC_PASS_MAX                    = 70,
++        _SC_REGEXP                      = 71,
++        _SC_SHELL                       = 72,
++        _SC_SYMLOOP_MAX                 = 73,
++
++        /* Actually, they are not supported or implemented yet */
++        _SC_V6_ILP32_OFF32              = 74,
++        _SC_V6_ILP32_OFFBIG             = 75,
++        _SC_V6_LP64_OFF64               = 76,
++        _SC_V6_LPBIG_OFFBIG             = 77,
++        _SC_2_PBS                       = 80,
++        _SC_2_PBS_ACCOUNTING            = 81,
++        _SC_2_PBS_CHECKPOINT            = 82,
++        _SC_2_PBS_LOCATE                = 83,
++        _SC_2_PBS_MESSAGE               = 84,
++        _SC_2_PBS_TRACK                 = 85,
++
++        /* These are implemented */
++        _SC_SPAWN                       = 86,
++        _SC_SHARED_MEMORY_OBJECTS       = 87,
++
++        /* Extensions found in Solaris and Linux. */
++        _SC_PHYS_PAGES          = 121,
++
++        /* Commonly provided sysconf() extensions */
++        _SC_NPROCESSORS_CONF    = 1001,
++        _SC_NPROCESSORS_ONLN    = 1002,
++        /* Native variables */
++        _SC_SCHED_RT_TS         = 2001,
++        _SC_SCHED_PRI_MIN       = 2002,
++        _SC_SCHED_PRI_MAX       = 2003
++
++    }
++
++    enum _SC_PAGE_SIZE = _SC_PAGESIZE;
++
++    enum
++    {
++        _CS_PATH                           =   1,
++        _CS_POSIX_V6_ILP32_OFF32_CFLAGS    =   2,
++        _CS_POSIX_V6_ILP32_OFF32_LDFLAGS   =   3,
++        _CS_POSIX_V6_ILP32_OFF32_LIBS      =   4,
++        _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS   =   5,
++        _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS  =   6,
++        _CS_POSIX_V6_ILP32_OFFBIG_LIBS     =   7,
++        _CS_POSIX_V6_LP64_OFF64_CFLAGS     =   8,
++        _CS_POSIX_V6_LP64_OFF64_LDFLAGS    =   9,
++        _CS_POSIX_V6_LP64_OFF64_LIBS       =  10,
++        _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS   =  11,
++        _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS  =  12,
++        _CS_POSIX_V6_LPBIG_OFFBIG_LIBS     =  13,
++        _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS =  14,
++    }
++}
+ else version( CRuntime_Bionic )
+ {
+     enum F_OK       = 0;
+@@ -1106,6 +1248,10 @@ else version( FreeBSD )
+ {
+     int fsync(int) @trusted;
+ }
++else version( NetBSD )
++{
++    int fsync(int) @trusted;
++}
+ else version( Android )
+ {
+     int fsync(int) @trusted;
+@@ -1260,6 +1406,31 @@ else version( FreeBSD )
+     int        usleep(useconds_t) @trusted;
+     pid_t      vfork();
+ }
++else version( NetBSD )
++{
++    char*      crypt(in char*, in char*);
++    //char*      ctermid(char*);
++    void       encrypt(ref char[64], int) @trusted;
++    int        fchdir(int) @trusted;
++    c_long     gethostid() @trusted;
++    int        getpgid(pid_t) @trusted;
++    int        getsid(pid_t) @trusted;
++    char*      getwd(char*); // LEGACY
++    int        lchown(in char*, uid_t, gid_t);
++    int        lockf(int, int, off_t) @trusted;
++    int        nice(int) @trusted;
++    ssize_t    pread(int, void*, size_t, off_t);
++    ssize_t    pwrite(int, in void*, size_t, off_t);
++    int        setpgrp(pid_t, pid_t) @trusted;
++    int        setregid(gid_t, gid_t) @trusted;
++    int        setreuid(uid_t, uid_t) @trusted;
++    void       swab(in void*, void*, ssize_t);
++    void       sync() @trusted;
++    int        truncate(in char*, off_t);
++    useconds_t ualarm(useconds_t, useconds_t) @trusted;
++    int        usleep(useconds_t) @trusted;
++    pid_t      vfork();
++}
+ else version( CRuntime_Bionic )
+ {
+     int        fchdir(int) @trusted;
diff --git a/ldc/patches/patch-runtime_druntime_src_core_sys_posix_utime.d b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_utime.d
new file mode 100644
index 0000000..7f2abe9
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_sys_posix_utime.d
@@ -0,0 +1,23 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/sys/posix/utime.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/utime.d
+@@ -65,6 +65,16 @@ else version( FreeBSD )
+ 
+     int utime(in char*, in utimbuf*);
+ }
++else version( NetBSD )
++{
++    struct utimbuf
++    {
++        time_t  actime;
++        time_t  modtime;
++    }
++
++    int utime(in char*, in utimbuf*);
++}
+ else version( Solaris )
+ {
+     struct utimbuf
diff --git a/ldc/patches/patch-runtime_druntime_src_core_thread.d b/ldc/patches/patch-runtime_druntime_src_core_thread.d
new file mode 100644
index 0000000..827e8d6
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_thread.d
@@ -0,0 +1,113 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/thread.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/thread.d
+@@ -588,7 +588,6 @@ class Thread
+     // General Actions
+     ///////////////////////////////////////////////////////////////////////////
+ 
+-
+     /**
+      * Starts the thread and invokes the function or delegate passed upon
+      * construction.
+@@ -886,6 +885,12 @@ class Thread
+      */
+     __gshared const int PRIORITY_DEFAULT;
+ 
++     version(NetBSD)
++     {
++        //NetBSD does not support priority for default policy
++        // and it is not possible change policy without root access
++        int fakePriority = int.max;
++     }
+ 
+     /**
+      * Gets the scheduling priority for the associated thread.
+@@ -902,6 +907,10 @@ class Thread
+         {
+             return GetThreadPriority( m_hndl );
+         }
++        else version(NetBSD)
++        {
++           return fakePriority==int.max? PRIORITY_DEFAULT : fakePriority;
++        }
+         else version( Posix )
+         {
+             int         policy;
+@@ -966,6 +975,10 @@ class Thread
+             if (priocntl(idtype_t.P_LWPID, P_MYID, PC_SETPARMS, &pcparm) == -1)
+                 throw new ThreadException( "Unable to set scheduling class" );
+         }
++        else version(NetBSD)
++        {
++           fakePriority = val;
++        }
+         else version( Posix )
+         {
+             static if(__traits(compiles, pthread_setschedprio))
+@@ -982,6 +995,7 @@ class Thread
+                 // NOTE: pthread_setschedprio is not implemented on OSX or FreeBSD, so use
+                 //       the more complicated get/set sequence below.
+                 int         policy;
++
+                 sched_param param;
+ 
+                 if (auto err = pthread_getschedparam(m_addr, &policy, &param))
+@@ -991,6 +1005,7 @@ class Thread
+                     throw new ThreadException("Unable to set thread priority");
+                 }
+                 param.sched_priority = val;
++
+                 if (auto err = pthread_setschedparam(m_addr, policy, &param))
+                 {
+                     // ignore error if thread is not running => Bugzilla 8960
+@@ -3195,6 +3210,7 @@ extern (C)
+ nothrow:
+     version (CRuntime_Glibc) int pthread_getattr_np(pthread_t thread, pthread_attr_t* attr);
+     version (FreeBSD) int pthread_attr_get_np(pthread_t thread, pthread_attr_t* attr);
++    version (NetBSD) int pthread_attr_get_np(pthread_t thread, pthread_attr_t* attr);
+     version (Solaris) int thr_stksegment(stack_t* stk);
+     version (CRuntime_Bionic) int pthread_getattr_np(pthread_t thid, pthread_attr_t* attr);
+ }
+@@ -3322,6 +3338,17 @@ private void* getStackBottom() nothrow
+         pthread_attr_destroy(&attr);
+         return addr + size;
+     }
++    else version (NetBSD)
++    {
++        pthread_attr_t attr;
++        void* addr; size_t size;
++
++        pthread_attr_init(&attr);
++        pthread_attr_get_np(pthread_self(), &attr);
++        pthread_attr_getstack(&attr, &addr, &size);
++        pthread_attr_destroy(&attr);
++        return addr + size;
++    }
+     else version (Solaris)
+     {
+         stack_t stk;
+@@ -3905,6 +3932,13 @@ version( LDC )
+         version( X86 ) version = CheckFiberMigration;
+         version( X86_64 ) version = CheckFiberMigration;
+     }
++    version( NetBSD )
++    {
++        version( ARM ) version = CheckFiberMigration;
++        version( AArch64 ) version = CheckFiberMigration;
++        version( X86 ) version = CheckFiberMigration;
++        version( X86_64 ) version = CheckFiberMigration;
++    }
+ }
+ 
+ // Fiber support for SjLj style exceptions
+@@ -4663,6 +4697,7 @@ private:
+         {
+             version (Posix) import core.sys.posix.sys.mman; // mmap
+             version (FreeBSD) import core.sys.freebsd.sys.mman : MAP_ANON;
++            version (NetBSD) import core.sys.netbsd.sys.mman : MAP_ANON;
+             version (CRuntime_Glibc) import core.sys.linux.sys.mman : MAP_ANON;
+             version (OSX) import core.sys.osx.sys.mman : MAP_ANON;
+ 
diff --git a/ldc/patches/patch-runtime_druntime_src_core_threadasm.S b/ldc/patches/patch-runtime_druntime_src_core_threadasm.S
new file mode 100644
index 0000000..dfa1988
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_threadasm.S
@@ -0,0 +1,15 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/threadasm.S.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/threadasm.S
+@@ -13,7 +13,7 @@
+  *          http://www.boost.org/LICENSE_1_0.txt)
+  */
+ 
+-#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__ELF__)
++#if (defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)) && defined(__ELF__)
+ /*
+  * Mark the resulting object file as not requiring execution permissions on
+  * stack memory. The absence of this section would mark the whole resulting
diff --git a/ldc/patches/patch-runtime_druntime_src_core_time.d b/ldc/patches/patch-runtime_druntime_src_core_time.d
new file mode 100644
index 0000000..c103521
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_core_time.d
@@ -0,0 +1,38 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/core/time.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/core/time.d
+@@ -304,6 +304,13 @@ else version(FreeBSD) enum ClockType
+     uptimeCoarse = 9,
+     uptimePrecise = 10,
+ }
++else version(NetBSD) enum ClockType
++{
++    normal = 0,
++    coarse = 2,
++    precise = 3,
++    second = 6,
++}
+ else version(Solaris) enum ClockType
+ {
+     normal = 0,
+@@ -359,6 +366,17 @@ version(Posix)
+             case second: assert(0);
+             }
+         }
++        else version(NetBSD)
++        {
++            import core.sys.netbsd.time;
++            with(ClockType) final switch(clockType)
++            {
++            case coarse: return CLOCK_MONOTONIC;
++            case normal: return CLOCK_MONOTONIC;
++            case precise: return CLOCK_MONOTONIC;
++            case second: assert(0);
++            }
++        }
+         else version(Solaris)
+         {
+             import core.sys.solaris.time;
diff --git a/ldc/patches/patch-runtime_druntime_src_gc_os.d b/ldc/patches/patch-runtime_druntime_src_gc_os.d
new file mode 100644
index 0000000..e4df315
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_gc_os.d
@@ -0,0 +1,14 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/gc/os.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/gc/os.d
+@@ -31,6 +31,7 @@ else version (Posix)
+ {
+     import core.sys.posix.sys.mman;
+     version (FreeBSD) import core.sys.freebsd.sys.mman : MAP_ANON;
++    version (NetBSD) import core.sys.netbsd.sys.mman : MAP_ANON;
+     version (CRuntime_Glibc) import core.sys.linux.sys.mman : MAP_ANON;
+     version (OSX) import core.sys.osx.sys.mman : MAP_ANON;
+     import core.stdc.stdlib;
diff --git a/ldc/patches/patch-runtime_druntime_src_rt_bss__section.c b/ldc/patches/patch-runtime_druntime_src_rt_bss__section.c
new file mode 100644
index 0000000..efcb1f8
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_rt_bss__section.c
@@ -0,0 +1,15 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/rt/bss_section.c.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/rt/bss_section.c
+@@ -10,7 +10,7 @@
+ /* These symbols are defined in the linker script and bracket the
+  * .bss, .lbss, .lrodata and .ldata sections.
+  */
+-#if defined(__linux__) || defined(__FreeBSD__)
++#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
+ // Need to use weak linkage to workaround a bug in ld.bfd (Bugzilla 13025).
+ extern int __attribute__((weak)) __bss_start, _end;
+ 
diff --git a/ldc/patches/patch-runtime_druntime_src_rt_dmain2.d b/ldc/patches/patch-runtime_druntime_src_rt_dmain2.d
new file mode 100644
index 0000000..4a4b138
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_rt_dmain2.d
@@ -0,0 +1,50 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/rt/dmain2.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/rt/dmain2.d
+@@ -36,6 +36,10 @@ version (FreeBSD)
+ {
+     import core.stdc.fenv;
+ }
++version (NetBSD)
++{
++    import core.stdc.fenv;
++}
+ 
+ extern (C) void _d_monitor_staticctor();
+ extern (C) void _d_monitor_staticdtor();
+@@ -324,6 +328,21 @@ extern (C) int _d_run_main(int argc, cha
+             fldcw   fpucw;
+         }
+     }
++    version (NetBSD) version (D_InlineAsm_X86)
++    {
++        /*
++         * NetBSD/i386 sets the FPU precision mode to 53 bit double.
++         * Make it 64 bit extended.
++         */
++        ushort fpucw;
++        asm
++        {
++            fstsw   fpucw;
++            or      fpucw, 0b11_00_111111; // 11: use 64 bit extended-precision
++                                           // 111111: mask all FP exceptions
++            fldcw   fpucw;
++        }
++    }
+     version (CRuntime_Microsoft)
+     {
+         init_msvc();
+@@ -468,8 +487,9 @@ extern (C) int _d_run_main(int argc, cha
+     //       thrown during cleanup, however, will abort the cleanup process.
+     void runAll()
+     {
+-        if (rt_init() && runModuleUnitTests())
++        if (rt_init() && runModuleUnitTests()){
+             tryExec({ result = mainFunc(args); });
++        }
+         else
+             result = EXIT_FAILURE;
+ 
diff --git a/ldc/patches/patch-runtime_druntime_src_rt_sections.d b/ldc/patches/patch-runtime_druntime_src_rt_sections.d
new file mode 100644
index 0000000..e737747
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_rt_sections.d
@@ -0,0 +1,15 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/rt/sections.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/rt/sections.d
+@@ -16,6 +16,8 @@ version (CRuntime_Glibc)
+     public import rt.sections_elf_shared;
+ else version (FreeBSD)
+     public import rt.sections_elf_shared;
++else version (NetBSD)
++    public import rt.sections_elf_shared;
+ else version (Solaris)
+     public import rt.sections_solaris;
+ else version (OSX)
diff --git a/ldc/patches/patch-runtime_druntime_src_rt_sections__elf__shared.d b/ldc/patches/patch-runtime_druntime_src_rt_sections__elf__shared.d
new file mode 100644
index 0000000..7298c94
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_rt_sections__elf__shared.d
@@ -0,0 +1,99 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/rt/sections_elf_shared.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/rt/sections_elf_shared.d
+@@ -12,6 +12,7 @@ module rt.sections_elf_shared;
+ 
+ version (CRuntime_Glibc) enum SharedELF = true;
+ else version (FreeBSD) enum SharedELF = true;
++else version (NetBSD) enum SharedELF = true;
+ else enum SharedELF = false;
+ static if (SharedELF):
+ 
+@@ -32,6 +33,12 @@ else version (FreeBSD)
+     import core.sys.freebsd.sys.elf;
+     import core.sys.freebsd.sys.link_elf;
+ }
++else version (NetBSD)
++{
++    import core.sys.netbsd.dlfcn;
++    import core.sys.netbsd.sys.elf;
++    import core.sys.netbsd.sys.link_elf;
++}
+ else
+ {
+     static assert(0, "unimplemented");
+@@ -115,6 +122,7 @@ __gshared bool _isRuntimeInitialized;
+ 
+ 
+ version (FreeBSD) private __gshared void* dummy_ref;
++version (NetBSD) private __gshared void* dummy_ref;
+ 
+ /****
+  * Gets called on program startup just before GC is initialized.
+@@ -124,6 +132,7 @@ void initSections()
+     _isRuntimeInitialized = true;
+     // reference symbol to support weak linkage
+     version (FreeBSD) dummy_ref = &_d_dso_registry;
++    version (NetBSD) dummy_ref = &_d_dso_registry;
+ }
+ 
+ 
+@@ -243,6 +252,7 @@ private:
+ 
+ // start of linked list for ModuleInfo references
+ version (FreeBSD) deprecated extern (C) __gshared void* _Dmodule_ref;
++version (NetBSD) deprecated extern (C) __gshared void* _Dmodule_ref;
+ 
+ version (Shared)
+ {
+@@ -649,6 +659,8 @@ nothrow:
+                     strtab = cast(const(char)*)dyn.d_un.d_ptr;
+                 else version (FreeBSD)
+                     strtab = cast(const(char)*)(info.dlpi_addr + dyn.d_un.d_ptr); // relocate
++                else version (NetBSD)
++                    strtab = cast(const(char)*)(info.dlpi_addr + dyn.d_un.d_ptr); // relocate
+                 else
+                     static assert(0, "unimplemented");
+                 break;
+@@ -754,6 +766,24 @@ else version (FreeBSD) bool findDSOInfoF
+ {
+     return !!_rtld_addr_phdr(addr, result);
+ }
++else version (NetBSD) bool findDSOInfoForAddr(in void* addr, dl_phdr_info* result=null) nothrow @nogc
++{
++    static struct DG { const(void)* addr; dl_phdr_info* result; }
++
++    extern(C) int callback(dl_phdr_info* info, size_t sz, void* arg) nothrow @nogc
++    {
++
++        auto p = cast(DG*)arg;
++        if (findSegmentForAddr(*info, p.addr))
++        {
++            if (p.result !is null) *p.result = *info;
++            return 1; // break;
++        }
++        return 0; // continue iteration
++    }
++    auto dg = DG(addr, result);
++    return dl_iterate_phdr(&callback, &dg) != 0;
++}
+ 
+ /*********************************
+  * Determine if 'addr' lies within shared object 'info'.
+@@ -779,11 +809,13 @@ bool findSegmentForAddr(in ref dl_phdr_i
+ version (linux) import core.sys.linux.errno : program_invocation_name;
+ // should be in core.sys.freebsd.stdlib
+ version (FreeBSD) extern(C) const(char)* getprogname() nothrow @nogc;
++version (NetBSD) extern(C) const(char)* getprogname() nothrow @nogc;
+ 
+ @property const(char)* progname() nothrow @nogc
+ {
+     version (linux) return program_invocation_name;
+     version (FreeBSD) return getprogname();
++    version (NetBSD) return getprogname();
+ }
+ 
+ nothrow
diff --git a/ldc/patches/patch-runtime_druntime_src_rt_sections__ldc.d b/ldc/patches/patch-runtime_druntime_src_rt_sections__ldc.d
new file mode 100644
index 0000000..61370ba
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_src_rt_sections__ldc.d
@@ -0,0 +1,23 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/src/rt/sections_ldc.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/src/rt/sections_ldc.d
+@@ -16,7 +16,7 @@
+ 
+ module rt.sections_ldc;
+ 
+-version (linux) {} else version (FreeBSD) {} else version(LDC):
++version (linux) {} else version (FreeBSD) {}else version (NetBSD) {} else version(LDC):
+ 
+ import core.stdc.stdlib : alloca;
+ import rt.minfo;
+@@ -387,7 +387,6 @@ void initSections()
+     {
+         dl_phdr_info phdr = void;
+         findPhdrForAddr(&globalSectionGroup, &phdr) || assert(0);
+-
+         scanSegments(phdr, &globalSectionGroup);
+     }
+ }
diff --git a/ldc/patches/patch-runtime_druntime_test_shared_src_load.d b/ldc/patches/patch-runtime_druntime_test_shared_src_load.d
new file mode 100644
index 0000000..f474e99
--- /dev/null
+++ b/ldc/patches/patch-runtime_druntime_test_shared_src_load.d
@@ -0,0 +1,14 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/druntime/tree/netbsd
+
+--- runtime/druntime/test/shared/src/load.d.orig	2016-02-13 20:02:16.000000000 +0000
++++ runtime/druntime/test/shared/src/load.d
+@@ -2,6 +2,7 @@ import core.runtime, core.stdc.stdio, co
+ 
+ version (linux) import core.sys.linux.dlfcn;
+ else version (FreeBSD) import core.sys.freebsd.dlfcn;
++else version (NetBSD) import core.sys.netbsd.dlfcn;
+ else static assert(0, "unimplemented");
+ 
+ void loadSym(T)(void* handle, ref T val, const char* mangle)
diff --git a/ldc/patches/patch-runtime_phobos_osmodel.mak b/ldc/patches/patch-runtime_phobos_osmodel.mak
new file mode 100644
index 0000000..ffaaad0
--- /dev/null
+++ b/ldc/patches/patch-runtime_phobos_osmodel.mak
@@ -0,0 +1,16 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/phobos/tree/netbsd
+
+--- runtime/phobos/osmodel.mak.orig	2016-02-13 20:04:46.000000000 +0000
++++ runtime/phobos/osmodel.mak
+@@ -12,6 +12,9 @@ ifeq (,$(OS))
+   ifeq (FreeBSD,$(uname_S))
+     OS:=freebsd
+   endif
++  ifeq (NetBSD,$(uname_S))
++    OS:=netbsd
++  endif
+   ifeq (OpenBSD,$(uname_S))
+     OS:=openbsd
+   endif
diff --git a/ldc/patches/patch-runtime_phobos_std_complex.d b/ldc/patches/patch-runtime_phobos_std_complex.d
new file mode 100644
index 0000000..328b371
--- /dev/null
+++ b/ldc/patches/patch-runtime_phobos_std_complex.d
@@ -0,0 +1,36 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/phobos/tree/netbsd
+
+--- runtime/phobos/std/complex.d.orig	2016-02-13 20:04:46.000000000 +0000
++++ runtime/phobos/std/complex.d
+@@ -758,8 +758,9 @@ Complex!T sin(T)(Complex!T z)  @safe pur
+ 
+ unittest
+ {
++  import std.math: feqrel;
+   assert(sin(complex(0.0)) == 0.0);
+-  assert(sin(complex(2.0L, 0)) == std.math.sin(2.0L));
++  assert(feqrel(sin(complex(2.0L, 0)).re, std.math.sin(2.0L)) > real.mant_dig-10);
+ }
+ 
+ 
+@@ -776,7 +777,7 @@ unittest{
+     import std.math;
+     import std.complex;
+     assert(cos(complex(0.0)) == 1.0);
+-    assert(cos(complex(1.3L)) == std.math.cos(1.3L));
++    assert(feqrel(cos(complex(1.3L)).re, std.math.cos(1.3L)) >= real.mant_dig-12);
+     assert(cos(complex(0, 5.2L)) == cosh(5.2L));
+ }
+ 
+@@ -801,7 +802,8 @@ unittest
+     assert(expi(0.0L) == 1.0L);
+     auto z1 = expi(1.234);
+     auto z2 = std.math.expi(1.234);
+-    assert(z1.re == z2.re && z1.im == z2.im);
++    import std.math : approxEqual;
++    assert(approxEqual(z1.re, z2.re) && approxEqual(z1.im, z2.im));
+ }
+ 
+ 
diff --git a/ldc/patches/patch-runtime_phobos_std_conv.d b/ldc/patches/patch-runtime_phobos_std_conv.d
new file mode 100644
index 0000000..9750803
--- /dev/null
+++ b/ldc/patches/patch-runtime_phobos_std_conv.d
@@ -0,0 +1,25 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/phobos/tree/netbsd
+
+--- runtime/phobos/std/conv.d.orig	2016-02-13 20:04:46.000000000 +0000
++++ runtime/phobos/std/conv.d
+@@ -2859,7 +2859,17 @@ unittest
+ 
+     // min and max
+     real r = to!real(to!string(real.min_normal));
+-    assert(to!string(r) == to!string(real.min_normal));
++    version(NetBSD)
++    {
++        // NetBSD notice
++        // to!string returns 3.3621e-4932L. It is less than real.min_normal and it is subnormal value
++        // Simple C code
++        //     long double rd = 3.3621e-4932L;
++        //     printf("%Le\n", rd);
++        // has unexpected result: 1.681050e-4932
++    } else {
++        assert(to!string(r) == to!string(real.min_normal));
++    }
+     r = to!real(to!string(real.max));
+     assert(to!string(r) == to!string(real.max));
+ }
diff --git a/ldc/patches/patch-runtime_phobos_std_datetime.d b/ldc/patches/patch-runtime_phobos_std_datetime.d
new file mode 100644
index 0000000..99020c8
--- /dev/null
+++ b/ldc/patches/patch-runtime_phobos_std_datetime.d
@@ -0,0 +1,64 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/phobos/tree/netbsd
+
+--- runtime/phobos/std/datetime.d.orig	2016-02-13 20:04:46.000000000 +0000
++++ runtime/phobos/std/datetime.d
+@@ -26531,6 +26531,7 @@ auto tz = TimeZone.getTimeZone("America/
+         version(Posix)
+         {
+             version(FreeBSD)      enum utcZone = "Etc/UTC";
++            else version(NetBSD)  enum utcZone = "UTC";
+             else version(linux)   enum utcZone = "UTC";
+             else version(OSX)     enum utcZone = "UTC";
+             else static assert(0, "The location of the UTC timezone file on this Posix platform must be set.");
+@@ -26965,19 +26966,31 @@ public:
+         {
+             scope(exit) clearTZEnvVar();
+ 
+-            version(FreeBSD)
++            version(NetBSD)
+             {
+-                // A bug on FreeBSD 9+ makes it so that this test fails.
+-                // https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=168862
++                //According http://mainfacts.com/world-timezones-time-zones/PPT :
++                //Actual zone of this location is PST now. It can be assigned to PPT too.
++                setTZEnvVar("America/Los_Angeles");
++                assert(LocalTime().dstName == "PPT");
++                setTZEnvVar("America/New_York");
++                assert(LocalTime().dstName == "EPT");
+             }
+             else
+             {
+-                setTZEnvVar("America/Los_Angeles");
+-                assert(LocalTime().dstName == "PDT");
+-            }
++                version(FreeBSD)
++                {
++                    // A bug on FreeBSD 9+ makes it so that this test fails.
++                    // https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=168862
++                }
++                else
++                {
++                    setTZEnvVar("America/Los_Angeles");
++                    assert(LocalTime().dstName == "PDT");
++                }
+ 
+-            setTZEnvVar("America/New_York");
+-            assert(LocalTime().dstName == "EDT");
++                setTZEnvVar("America/New_York");
++                assert(LocalTime().dstName == "EDT");
++           }
+         }
+     }
+ 
+@@ -28416,7 +28429,8 @@ assert(tz.dstName == "PDT");
+ 
+                 if(!tzName.extension().empty ||
+                    !tzName.startsWith(subName) ||
+-                   tzName == "+VERSION")
++                   tzName == "+VERSION" ||
++                   tzName == "leapseconds" )
+                 {
+                     continue;
+                 }
diff --git a/ldc/patches/patch-runtime_phobos_std_file.d b/ldc/patches/patch-runtime_phobos_std_file.d
new file mode 100644
index 0000000..0bfbc5f
--- /dev/null
+++ b/ldc/patches/patch-runtime_phobos_std_file.d
@@ -0,0 +1,27 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/phobos/tree/netbsd
+
+--- runtime/phobos/std/file.d.orig	2016-02-13 20:04:46.000000000 +0000
++++ runtime/phobos/std/file.d
+@@ -1816,6 +1816,9 @@ version (OSX)
+ else version (FreeBSD)
+     private extern (C) int sysctl (const int* name, uint namelen, void* oldp,
+         size_t* oldlenp, const void* newp, size_t newlen);
++else version (NetBSD)
++    private extern (C) int sysctl (const int* name, uint namelen, void* oldp,
++        size_t* oldlenp, const void* newp, size_t newlen);
+ 
+ /**
+  * Returns the full path of the current executable.
+@@ -1885,6 +1888,10 @@ else version (FreeBSD)
+ 
+         return buffer.assumeUnique;
+     }
++    else version (NetBSD)
++    {
++        return readLink("/proc/self/exe");
++    }
+     else version (Solaris)
+     {
+         import core.sys.posix.unistd : getpid;
diff --git a/ldc/patches/patch-runtime_phobos_std_internal_math_gammafunction.d b/ldc/patches/patch-runtime_phobos_std_internal_math_gammafunction.d
new file mode 100644
index 0000000..96e8c44
--- /dev/null
+++ b/ldc/patches/patch-runtime_phobos_std_internal_math_gammafunction.d
@@ -0,0 +1,116 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/phobos/tree/netbsd
+
+--- runtime/phobos/std/internal/math/gammafunction.d.orig	2016-02-13 20:04:46.000000000 +0000
++++ runtime/phobos/std/internal/math/gammafunction.d
+@@ -532,16 +532,16 @@ unittest {
+     ];
+    // TODO: test derivatives as well.
+     for (int i=0; i<testpoints.length; i+=3) {
+-        assert( feqrel(logGamma(testpoints[i]), testpoints[i+1]) > real.mant_dig-5);
++        assert( feqrel(logGamma(testpoints[i]), testpoints[i+1]) > real.mant_dig-15);
+         if (testpoints[i]<MAXGAMMA) {
+-            assert( feqrel(log(fabs(gamma(testpoints[i]))), testpoints[i+1]) > real.mant_dig-5);
++            assert( feqrel(log(fabs(gamma(testpoints[i]))), testpoints[i+1]) > real.mant_dig-15);
+         }
+     }
+-    assert(logGamma(-50.2) == log(fabs(gamma(-50.2))));
++    assert(feqrel(logGamma(-50.2), log(fabs(gamma(-50.2)))) > real.mant_dig-11);
+     assert(logGamma(-0.008) == log(fabs(gamma(-0.008))));
+-    assert(feqrel(logGamma(-38.8),log(fabs(gamma(-38.8)))) > real.mant_dig-4);
++    assert(feqrel(logGamma(-38.8),log(fabs(gamma(-38.8)))) > real.mant_dig-11);
+     static if (real.mant_dig >= 64) // incl. 80-bit reals
+-        assert(feqrel(logGamma(1500.0L),log(gamma(1500.0L))) > real.mant_dig-2);
++        assert(feqrel(logGamma(1500.0L),log(gamma(1500.0L))) > real.mant_dig-10);
+     else static if (real.mant_dig >= 53) // incl. 64-bit reals
+         assert(feqrel(logGamma(150.0L),log(gamma(150.0L))) > real.mant_dig-2);
+ }
+@@ -929,10 +929,10 @@ unittest { // also tested by the normal 
+     assert(feqrel(betaIncomplete(8, 10, 0.2), 0.010_934_315_234_099_2L) >=  real.mant_dig - 5);
+     assert(feqrel(betaIncomplete(2, 2.5, 0.9), 0.989_722_597_604_452_767_171_003_59L) >= real.mant_dig - 1);
+     static if (real.mant_dig >= 64) // incl. 80-bit reals
+-        assert(feqrel(betaIncomplete(1000, 800, 0.5), 1.179140859734704555102808541457164E-06L) >= real.mant_dig - 13);
++        assert(feqrel(betaIncomplete(1000, 800, 0.5), 1.179140859734704555102808541457164E-06L) >= real.mant_dig - 24);
+     else
+         assert(feqrel(betaIncomplete(1000, 800, 0.5), 1.179140859734704555102808541457164E-06L) >= real.mant_dig - 14);
+-    assert(feqrel(betaIncomplete(0.0001, 10000, 0.0001), 0.999978059362107134278786L) >= real.mant_dig - 18);
++    assert(feqrel(betaIncomplete(0.0001, 10000, 0.0001), 0.999978059362107134278786L) >= real.mant_dig - 28);
+     assert(betaIncomplete(0.01, 327726.7, 0.545113) == 1.0);
+     assert(feqrel(betaIncompleteInv(8, 10, 0.010_934_315_234_099_2L), 0.2L) >= real.mant_dig - 2);
+     assert(feqrel(betaIncomplete(0.01, 498.437, 0.0121433), 0.99999664562033077636065L) >= real.mant_dig - 1);
+@@ -958,7 +958,12 @@ unittest { // also tested by the normal 
+         assert(feqrel(betaIncompleteInv(0x1.ff1275ae5b939bcap-41, 4.6713e18, 0.0813601),
+             0x1.f97749d90c7adba8p-63L) >= real.mant_dig - 39);
+         real a1 = 3.40483;
+-        assert(betaIncompleteInv(a1, 4.0640301659679627772e19L, 0.545113) == 0x1.ba8c08108aaf5d14p-109);
++        version(NetBSD)
++        {
++            //skip: NetBSD result: 8.37796e-20 != 2.66348e-33
++        } else {
++            assert(betaIncompleteInv(a1, 4.0640301659679627772e19L, 0.545113) == 0x1.ba8c08108aaf5d14p-109);
++        }
+         real b1 = 2.82847e-25;
+         assert(feqrel(betaIncompleteInv(0.01, b1, 9e-26), 0x1.549696104490aa9p-830L) >= real.mant_dig-10);
+ 
+@@ -969,7 +974,7 @@ unittest { // also tested by the normal 
+         // Mathematica states: "(cannot be determined by current methods)"
+         assert(betaIncomplete(1.16251e20, 2.18e39, 5.45e-20) == -real.infinity);
+         // WolframAlpha gives no result for this, though indicates that it approximately 1.0 - 1.3e-9
+-        assert(1 - betaIncomplete(0.01, 328222, 4.0375e-5) == 0x1.5f62926b4p-30);
++        assert(feqrel(1 - betaIncomplete(0.01, 328222, 4.0375e-5), 0x1.5f62926b4p-30) >= real.mant_dig-32);
+     }
+ }
+ 
+@@ -1453,7 +1458,7 @@ assert(gammaIncompleteComplInv(3, 0)==re
+ // x was larger than a, but not by much, and both were large:
+ // The value is from WolframAlpha (Gamma[100000, 100001, inf] / Gamma[100000])
+ static if (real.mant_dig >= 64) // incl. 80-bit reals
+-    assert(fabs(gammaIncompleteCompl(100000, 100001) - 0.49831792109) < 0.000000000005);
++    assert(fabs(gammaIncompleteCompl(100000, 100001) - 0.49831792109) < 0.000000005);
+ else
+     assert(fabs(gammaIncompleteCompl(100000, 100001) - 0.49831792109) < 0.00000005);
+ }
+@@ -1547,10 +1552,10 @@ done:
+ unittest {
+     // Exact values
+     assert(digamma(1.0)== -EULERGAMMA);
+-    assert(feqrel(digamma(0.25), -PI/2 - 3* LN2 - EULERGAMMA) >= real.mant_dig-7);
+-    assert(feqrel(digamma(1.0L/6), -PI/2 *sqrt(3.0L) - 2* LN2 -1.5*log(3.0L) - EULERGAMMA) >= real.mant_dig-7);
++    assert(feqrel(digamma(0.25), -PI/2 - 3* LN2 - EULERGAMMA) >= real.mant_dig-8);
++    assert(feqrel(digamma(1.0L/6), -PI/2 *sqrt(3.0L) - 2* LN2 -1.5*log(3.0L) - EULERGAMMA) >= real.mant_dig-10);
+     assert(digamma(-5.0).isNaN());
+-    assert(feqrel(digamma(2.5), -EULERGAMMA - 2*LN2 + 2.0 + 2.0L/3) >= real.mant_dig-9);
++    assert(feqrel(digamma(2.5), -EULERGAMMA - 2*LN2 + 2.0 + 2.0L/3) >= real.mant_dig-11);
+     assert(isIdentical(digamma(NaN(0xABC)), NaN(0xABC)));
+ 
+     for (int k=1; k<40; ++k) {
+@@ -1558,7 +1563,7 @@ unittest {
+         for (int u=k; u>=1; --u) {
+             y += 1.0L/u;
+         }
+-        assert(feqrel(digamma(k+1.0), -EULERGAMMA + y) >= real.mant_dig-2);
++        assert(feqrel(digamma(k+1.0), -EULERGAMMA + y) >= real.mant_dig-10);
+     }
+ }
+ 
+@@ -1623,8 +1628,17 @@ unittest {
+ real logmdigammaInverse(real y)
+ {
+     import std.numeric: findRoot;
+-    enum maxY = logmdigamma(real.min_normal);
+-    static assert(maxY > 0 && maxY <= real.max);
++    version(NetBSD)
++    {
++        //CTFE uses direct call logl from libmath. NetBSD has broken logl. it is not support real, only double
++        auto maxY = logmdigamma(real.min_normal);
++        assert(maxY > 0 && maxY <= real.max);
++    }
++    else
++    {
++        enum maxY = logmdigamma(real.min_normal);
++        static assert(maxY > 0 && maxY <= real.max);
++    }
+ 
+     if (y >= maxY)
+     {
diff --git a/ldc/patches/patch-runtime_phobos_std_math.d b/ldc/patches/patch-runtime_phobos_std_math.d
new file mode 100644
index 0000000..29188c1
--- /dev/null
+++ b/ldc/patches/patch-runtime_phobos_std_math.d
@@ -0,0 +1,93 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/phobos/tree/netbsd
+
+--- runtime/phobos/std/math.d.orig	2016-02-13 20:04:46.000000000 +0000
++++ runtime/phobos/std/math.d
+@@ -750,7 +750,8 @@ ireal sin(ireal y) @safe pure nothrow @n
+ @safe pure nothrow @nogc unittest
+ {
+   assert(sin(0.0+0.0i) == 0.0);
+-  assert(sin(2.0+0.0i) == sin(2.0L) );
++  assert(sin(2.0+0.0i).im == 0.0L );
++  assert(feqrel(sin(2.0+0.0i).re, sin(2.0L)) >  real.mant_dig-10 );
+ }
+ 
+ /***********************************
+@@ -775,7 +776,8 @@ real cos(ireal y) @safe pure nothrow @no
+ @safe pure nothrow @nogc unittest
+ {
+     assert(cos(0.0+0.0i)==1.0);
+-    assert(cos(1.3L+0.0i)==cos(1.3L));
++    assert(cos(1.3L+0.0i).im == 0.0L );
++    assert(feqrel(cos(1.3L+0.0i).re, cos(1.3L)) >= real.mant_dig-12 );
+     assert(cos(5.2Li)== cosh(5.2L));
+ }
+ 
+@@ -1001,7 +1003,7 @@ Lret: {}
+ 
+ unittest
+ {
+-    assert(equalsDigit(tan(PI / 3), std.math.sqrt(3.0), useDigits));
++    assert(feqrel(tan(PI / 3), std.math.sqrt(3.0)) > real.mant_dig-15 );
+ }
+ 
+ /***************
+@@ -2420,8 +2422,9 @@ creal expi(real y) @trusted pure nothrow
+ 
+ ///
+ @safe pure nothrow @nogc unittest
+-{
+-    assert(expi(1.3e5L) == cos(1.3e5L) + sin(1.3e5L) * 1i);
++{
++    assert(feqrel(expi(1.3e5L).re, (cos(1.3e5L) + sin(1.3e5L) * 1i).re)> real.mant_dig-15);
++    assert(feqrel(expi(1.3e5L).im, (cos(1.3e5L) + sin(1.3e5L) * 1i).im)> real.mant_dig-15);
+     assert(expi(0.0L) == 1L + 0.0Li);
+ }
+ 
+@@ -3541,8 +3544,8 @@ real log2(real x) @safe pure nothrow @no
+ ///
+ unittest
+ {
+-    // check if values are equal to 19 decimal digits of precision
+-    assert(equalsDigit(log2(1024.0L), 10, 19));
++    // check if values are equal except last 10 mantis bits
++    assert(feqrel(log2(1024.0L), 10) > real.mant_dig-10);
+ }
+ 
+ /*****************************************
+@@ -7415,6 +7418,34 @@ private real polyImpl(real x, in real[] 
+                 ;
+             }
+         }
++        else version (NetBSD)
++        {
++            asm pure nothrow @nogc // assembler by W. Bright
++            {
++                // EDX = (A.length - 1) * real.sizeof
++                mov     ECX,A[EBP]              ; // ECX = A.length
++                dec     ECX                     ;
++                lea     EDX,[ECX*8]             ;
++                lea     EDX,[EDX][ECX*4]        ;
++                add     EDX,A+4[EBP]            ;
++                fld     real ptr [EDX]          ; // ST0 = coeff[ECX]
++                jecxz   return_ST               ;
++                fld     x[EBP]                  ; // ST0 = x
++                fxch    ST(1)                   ; // ST1 = x, ST0 = r
++                align   4                       ;
++        L2:     fmul    ST,ST(1)                ; // r *= x
++                fld     real ptr -12[EDX]       ;
++                sub     EDX,12                  ; // deg--
++                faddp   ST(1),ST                ;
++                dec     ECX                     ;
++                jne     L2                      ;
++                fxch    ST(1)                   ; // ST1 = r, ST0 = x
++                fstp    ST(0)                   ; // dump x
++                align   4                       ;
++        return_ST:                              ;
++                ;
++            }
++        }
+         else
+         {
+             static assert(0);
diff --git a/ldc/patches/patch-runtime_phobos_std_numeric.d b/ldc/patches/patch-runtime_phobos_std_numeric.d
new file mode 100644
index 0000000..95aac14
--- /dev/null
+++ b/ldc/patches/patch-runtime_phobos_std_numeric.d
@@ -0,0 +1,16 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/phobos/tree/netbsd
+
+--- runtime/phobos/std/numeric.d.orig	2016-02-13 20:04:46.000000000 +0000
++++ runtime/phobos/std/numeric.d
+@@ -1687,7 +1687,8 @@ unittest
+     assert(sumOfLog2s(new double[0]) == 0);
+     assert(sumOfLog2s([0.0L]) == -real.infinity);
+     assert(sumOfLog2s([-0.0L]) == -real.infinity);
+-    assert(sumOfLog2s([2.0L]) == 1);
++    import std.math;
++    assert(approxEqual(sumOfLog2s([2.0L]), 1));
+     assert(sumOfLog2s([-2.0L]).isNaN());
+     assert(sumOfLog2s([real.nan]).isNaN());
+     assert(sumOfLog2s([-real.nan]).isNaN());
diff --git a/ldc/patches/patch-runtime_phobos_std_parallelism.d b/ldc/patches/patch-runtime_phobos_std_parallelism.d
new file mode 100644
index 0000000..9d9f683
--- /dev/null
+++ b/ldc/patches/patch-runtime_phobos_std_parallelism.d
@@ -0,0 +1,29 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/phobos/tree/netbsd
+
+--- runtime/phobos/std/parallelism.d.orig	2016-02-13 20:04:46.000000000 +0000
++++ runtime/phobos/std/parallelism.d
+@@ -99,6 +99,11 @@ else version(FreeBSD)
+ {
+     version = useSysctlbyname;
+ }
++else version(NetBSD)
++{
++    version = useSysctlbyname;
++}
++
+ 
+ version(Windows)
+ {
+@@ -172,6 +177,10 @@ else version(useSysctlbyname)
+         {
+             auto nameStr = "hw.ncpu\0".ptr;
+         }
++        else version(NetBSD)
++        {
++            auto nameStr = "hw.ncpu\0".ptr;
++        }
+ 
+         uint ans;
+         size_t len = uint.sizeof;
diff --git a/ldc/patches/patch-runtime_phobos_std_socket.d b/ldc/patches/patch-runtime_phobos_std_socket.d
new file mode 100644
index 0000000..9c84a3f
--- /dev/null
+++ b/ldc/patches/patch-runtime_phobos_std_socket.d
@@ -0,0 +1,21 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/phobos/tree/netbsd
+
+--- runtime/phobos/std/socket.d.orig	2016-02-13 20:04:46.000000000 +0000
++++ runtime/phobos/std/socket.d
+@@ -189,6 +189,14 @@ string formatSocketError(int err) @trust
+             else
+                 return "Socket error " ~ to!string(err);
+         }
++        else version (NetBSD)
++        {
++            auto errs = strerror_r(err, buf.ptr, buf.length);
++            if (errs == 0)
++                cs = buf.ptr;
++            else
++                return "Socket error " ~ to!string(err);
++        }
+         else version (Solaris)
+         {
+             auto errs = strerror_r(err, buf.ptr, buf.length);
diff --git a/ldc/patches/patch-runtime_phobos_std_stdio.d b/ldc/patches/patch-runtime_phobos_std_stdio.d
new file mode 100644
index 0000000..776b352
--- /dev/null
+++ b/ldc/patches/patch-runtime_phobos_std_stdio.d
@@ -0,0 +1,19 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/phobos/tree/netbsd
+
+--- runtime/phobos/std/stdio.d.orig	2016-02-13 20:04:46.000000000 +0000
++++ runtime/phobos/std/stdio.d
+@@ -68,6 +68,12 @@ version (FreeBSD)
+     version = HAS_GETDELIM;
+ }
+ 
++version (NetBSD)
++{
++    version = GENERIC_IO;
++    version = HAS_GETDELIM;
++}
++
+ version (Solaris)
+ {
+     version = GENERIC_IO;
diff --git a/ldc/patches/patch-runtime_phobos_std_system.d b/ldc/patches/patch-runtime_phobos_std_system.d
new file mode 100644
index 0000000..3de3b90
--- /dev/null
+++ b/ldc/patches/patch-runtime_phobos_std_system.d
@@ -0,0 +1,22 @@
+$NetBSD$
+
+Stolen from https://github.com/nrTQgc/phobos/tree/netbsd
+
+--- runtime/phobos/std/system.d.orig	2016-02-13 20:04:46.000000000 +0000
++++ runtime/phobos/std/system.d
+@@ -34,6 +34,7 @@ immutable
+         linux,     /// All Linux Systems
+         osx,       /// Mac OS X
+         freeBSD,   /// FreeBSD
++        netBSD,    /// NetBSD
+         solaris,   /// Solaris
+         android,   /// Android
+         otherPosix /// Other Posix Systems
+@@ -46,6 +47,7 @@ immutable
+     else version(linux)   OS os = OS.linux;
+     else version(OSX)     OS os = OS.osx;
+     else version(FreeBSD) OS os = OS.freeBSD;
++    else version(NetBSD) OS os = OS.netBSD;
+     else version(Posix)   OS os = OS.otherPosix;
+     else static assert(0, "Unknown OS.");
+ 



Home | Main Index | Thread Index | Old Index