pkgsrc-WIP-changes archive

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

ldc-git: partially port DRuntime to NetBSD.



Module Name:	pkgsrc-wip
Committed By:	Mateusz Poszwa <old4%o2.pl@localhost>
Pushed By:	f8l
Date:		Thu Feb 11 14:28:26 2016 +0100
Changeset:	b52848726a1810c8439087191d49452d9ab410fe

Modified Files:
	ldc-git/Makefile
Added Files:
	ldc-git/DESCR
	ldc-git/distinfo
	ldc-git/patches/patch-runtime_druntime_src_core_stdc_errno.d
	ldc-git/patches/patch-runtime_druntime_src_core_stdc_fenv.d
	ldc-git/patches/patch-runtime_druntime_src_core_stdc_locale.d
	ldc-git/patches/patch-runtime_druntime_src_core_stdc_math.d
	ldc-git/patches/patch-runtime_druntime_src_core_stdc_stdio.d
	ldc-git/patches/patch-runtime_druntime_src_core_stdc_stdlib.d
	ldc-git/patches/patch-runtime_druntime_src_core_stdc_time.d
	ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_dirent.d
	ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_fcntl.d
	ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_grp.d
	ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_netdb.d
	ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_pthread.d
	ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_pwd.d
	ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sched.d
	ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_semaphore.d
	ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_signal.d
	ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_ioctl.d
	ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_mman.d
	ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_resource.d
	ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_select.d
	ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_socket.d
	ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_stat.d
	ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_time.d
	ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_types.d
	ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_uio.d
	ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_wait.d
	ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_time.d
	ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_ucontext.d
	ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_unistd.d
	ldc-git/patches/patch-runtime_druntime_src_core_thread.d
	ldc-git/patches/patch-runtime_druntime_src_core_time.d
	ldc-git/patches/patch-runtime_druntime_src_rt_sections.d
	ldc-git/patches/patch-runtime_druntime_src_rt_sections__elf__shared.d
	ldc-git/patches/patch-runtime_druntime_src_rt_sections__ldc.d

Log Message:
ldc-git: partially port DRuntime to NetBSD.

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

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

diffstat:
 ldc-git/DESCR                                      |   4 +
 ldc-git/Makefile                                   |   4 +-
 ldc-git/distinfo                                   |  36 +++
 .../patch-runtime_druntime_src_core_stdc_errno.d   | 110 +++++++
 .../patch-runtime_druntime_src_core_stdc_fenv.d    |  45 +++
 .../patch-runtime_druntime_src_core_stdc_locale.d  |  26 ++
 .../patch-runtime_druntime_src_core_stdc_math.d    | 106 +++++++
 .../patch-runtime_druntime_src_core_stdc_stdio.d   | 163 ++++++++++
 .../patch-runtime_druntime_src_core_stdc_stdlib.d  |  12 +
 .../patch-runtime_druntime_src_core_stdc_time.d    |  29 ++
 ...ch-runtime_druntime_src_core_sys_posix_dirent.d |  70 +++++
 ...tch-runtime_druntime_src_core_sys_posix_fcntl.d |  93 ++++++
 ...patch-runtime_druntime_src_core_sys_posix_grp.d |  49 +++
 ...tch-runtime_druntime_src_core_sys_posix_netdb.d |  79 +++++
 ...h-runtime_druntime_src_core_sys_posix_pthread.d | 241 ++++++++++++++
 ...patch-runtime_druntime_src_core_sys_posix_pwd.d |  51 +++
 ...tch-runtime_druntime_src_core_sys_posix_sched.d |  58 ++++
 ...runtime_druntime_src_core_sys_posix_semaphore.d |  39 +++
 ...ch-runtime_druntime_src_core_sys_posix_signal.d | 348 +++++++++++++++++++++
 ...runtime_druntime_src_core_sys_posix_sys_ioctl.d |  15 +
 ...-runtime_druntime_src_core_sys_posix_sys_mman.d | 155 +++++++++
 ...time_druntime_src_core_sys_posix_sys_resource.d |  80 +++++
 ...untime_druntime_src_core_sys_posix_sys_select.d |  48 +++
 ...untime_druntime_src_core_sys_posix_sys_socket.d | 159 ++++++++++
 ...-runtime_druntime_src_core_sys_posix_sys_stat.d | 150 +++++++++
 ...-runtime_druntime_src_core_sys_posix_sys_time.d |  39 +++
 ...runtime_druntime_src_core_sys_posix_sys_types.d | 111 +++++++
 ...h-runtime_druntime_src_core_sys_posix_sys_uio.d |  22 ++
 ...-runtime_druntime_src_core_sys_posix_sys_wait.d |  46 +++
 ...atch-runtime_druntime_src_core_sys_posix_time.d |  98 ++++++
 ...-runtime_druntime_src_core_sys_posix_ucontext.d |  42 +++
 ...ch-runtime_druntime_src_core_sys_posix_unistd.d | 168 ++++++++++
 .../patch-runtime_druntime_src_core_thread.d       |  29 ++
 .../patches/patch-runtime_druntime_src_core_time.d |  39 +++
 .../patch-runtime_druntime_src_rt_sections.d       |  13 +
 ...runtime_druntime_src_rt_sections__elf__shared.d |  25 ++
 .../patch-runtime_druntime_src_rt_sections__ldc.d  |  13 +
 37 files changed, 2812 insertions(+), 3 deletions(-)

diffs:
diff --git a/ldc-git/DESCR b/ldc-git/DESCR
new file mode 100644
index 0000000..79a999a
--- /dev/null
+++ b/ldc-git/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-git/Makefile b/ldc-git/Makefile
index 6466425..88173cd 100644
--- a/ldc-git/Makefile
+++ b/ldc-git/Makefile
@@ -1,12 +1,10 @@
 # $NetBSD$
 
-PKGNAME=	ldc-0.16.1
+PKGNAME=	ldc-0.17.0
 CATEGORIES=	wip
 
 GIT_REPOSITORIES=	ldc
 GIT_REPO.ldc=	https://github.com/ldc-developers/ldc.git
-#GIT_TAG.ldc=	v0.16.1
-GIT_BRANCH.ldc=	release-0.16.1
 WRKSRC=	${WRKDIR}/ldc
 
 MAINTAINER=	pkgsrc-users%NetBSD.org@localhost
diff --git a/ldc-git/distinfo b/ldc-git/distinfo
new file mode 100644
index 0000000..06741b9
--- /dev/null
+++ b/ldc-git/distinfo
@@ -0,0 +1,36 @@
+$NetBSD$
+
+SHA1 (patch-runtime_druntime_src_core_stdc_errno.d) = ba2331a8ce2e9a826b011d838b01693ac482f66f
+SHA1 (patch-runtime_druntime_src_core_stdc_fenv.d) = 2d4aa890e38e6ee4702a2909168f41e6a050561c
+SHA1 (patch-runtime_druntime_src_core_stdc_locale.d) = da46ec82175f5b15ae742b14936f72f4e6b96d03
+SHA1 (patch-runtime_druntime_src_core_stdc_math.d) = 0b6944b6ea8dd39e0b81c185729fb6ea6d71eb03
+SHA1 (patch-runtime_druntime_src_core_stdc_stdio.d) = 77f8f639d9d10fee47383a901f040724dd3741e5
+SHA1 (patch-runtime_druntime_src_core_stdc_stdlib.d) = cf223156c9914f1400d19ab77de9d4089c9b1b62
+SHA1 (patch-runtime_druntime_src_core_stdc_time.d) = e274138478e5d1aa28933b9d17ad54904e7238b3
+SHA1 (patch-runtime_druntime_src_core_sys_posix_dirent.d) = edcd287870fca3a96da9643f92c728238e98b613
+SHA1 (patch-runtime_druntime_src_core_sys_posix_fcntl.d) = 5d99fed472bc1a2f8dd2a5dc9713f6e537ee492f
+SHA1 (patch-runtime_druntime_src_core_sys_posix_grp.d) = 34cfd6fe0ad27f0f7bbdbd5f7205898e5c52cf1a
+SHA1 (patch-runtime_druntime_src_core_sys_posix_netdb.d) = 030c358511bb153b12b400bcbb983a2dc44bbdd6
+SHA1 (patch-runtime_druntime_src_core_sys_posix_pthread.d) = 033daf8ae6a604b22b445de18a6bc5b91cd2f4b0
+SHA1 (patch-runtime_druntime_src_core_sys_posix_pwd.d) = 46b994e26bb531e6f3b098a9d77752d895997ccd
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sched.d) = b2c62bdbcfa721afeeb57ff9d27f59c61d93a8da
+SHA1 (patch-runtime_druntime_src_core_sys_posix_semaphore.d) = 7e278d5d967d30f6dfdc3ca713d372abca01a761
+SHA1 (patch-runtime_druntime_src_core_sys_posix_signal.d) = dbc9d3ab2e7a27fa4688e2b81a1d503d5bcedc03
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_ioctl.d) = 89e532587388e56c0bb5daac8726c2f311fb1a67
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_mman.d) = c9e37ee56a7e0ed92e27cbf03f5cc77524967070
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_resource.d) = c6b2b9566f6c1ea49dd37911147aec215b760791
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_select.d) = ddca64bfb1f95bc2d86e3cdb4922d2a8dada95c5
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_socket.d) = a84fa3b67371e03e12460b0b9d7dad5b0adae8fd
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_stat.d) = 91628525dd05c858baf06f1d724347c8aedc1384
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_time.d) = 3f54e2a5bb04a886bd058bf8106806d6cd158cb1
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_types.d) = 7c2107641e2deaf832a05a78089a3b4f0b8847f6
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_uio.d) = 5877df16c720726e1255283c3d13956078adb2d1
+SHA1 (patch-runtime_druntime_src_core_sys_posix_sys_wait.d) = 69e63d846452aef059d114a14a84876360173cda
+SHA1 (patch-runtime_druntime_src_core_sys_posix_time.d) = 82d45736e24d2378c0888abd68d8dd75e691d572
+SHA1 (patch-runtime_druntime_src_core_sys_posix_ucontext.d) = f99930c94fe67a7ffa677d6c961602d6d6b4799c
+SHA1 (patch-runtime_druntime_src_core_sys_posix_unistd.d) = a01953af15c5ad6a927d2dcdb91a377faa5133f2
+SHA1 (patch-runtime_druntime_src_core_thread.d) = a3ba91018714d74891feec0236135811f6b148c9
+SHA1 (patch-runtime_druntime_src_core_time.d) = f2d23b3d70259ac1ee437cbe2d0106e380ff6695
+SHA1 (patch-runtime_druntime_src_rt_sections.d) = 837d0efc1c1dc521435b4243dd37a042961818b8
+SHA1 (patch-runtime_druntime_src_rt_sections__elf__shared.d) = 77b6c2ce91fa3c3f34376906f2ee49de9fbea3ef
+SHA1 (patch-runtime_druntime_src_rt_sections__ldc.d) = be073d84701d55394479c845034680cba9835164
diff --git a/ldc-git/patches/patch-runtime_druntime_src_core_stdc_errno.d b/ldc-git/patches/patch-runtime_druntime_src_core_stdc_errno.d
new file mode 100644
index 0000000..5eeb2dd
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_stdc_errno.d
@@ -0,0 +1,110 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/stdc/errno.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/stdc/errno.d
+@@ -1000,6 +1000,105 @@ 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 function call
++    enum EIO                = 5;       /// Input/output error
++    enum ENXIO              = 6;       /// Device not configured
++    enum E2BIG              = 7;       /// Arg 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
++    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;       /// Resource busy
++    enum EEXIST             = 17;       /// File exists
++    enum EXDEV              = 18;       /// Improper 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;       /// Device out of space
++    enum ESPIPE             = 29;       /// Illegal seek
++    enum EROFS              = 30;       /// Read-only file system
++    enum EMLINK             = 31;       /// Too many links
++    enum EPIPE              = 32;       /// Broken pipe
++    enum EDOM               = 33;       /// Numerical argument out of domain
++    enum ERANGE             = 34;       /// Result too large or too small
++    enum EAGAIN             = 35;       /// Resource temporarily unavailable
++    enum EINPROGRESS        = 36;       /// Operation now in progress
++    enum EALREADY           = 37;       /// Operation already in progress
++    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;       /// Cannot assign requested address
++    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;       /// Cannot 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
++    enum EHOSTDOWN          = 64;       /// Host is down
++    enum EHOSTUNREACH       = 65;       /// No route to host
++    enum ENOTEMPTY          = 66;       /// Directory not empty
++    enum EPROCLIM           = 67;       /// Too many processes
++    enum EUSERS             = 68;       /// Too many users
++    enum EDQUOT             = 69;       /// Disc quota exceeded
++    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_
++    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
++    enum EIDRM              = 82;       /// Identifier removed
++    enum ENOMSG             = 83;       /// No message of the desired type
++    enum EOVERFLOW          = 84;       /// Value too large to be stored in data type
++    enum EILSEQ             = 85;       /// Illegal byte sequence
++    enum ENOTSUP            = 86;       /// Not supported
++    enum ECANCELED          = 87;       /// Operation canceled
++    enum EBADMSG            = 88;       /// Bad or corrupt message
++    enum ENODATA            = 89;       /// No message available
++    enum ENOSR              = 90;       /// No STREAM resources
++    enum ENOSTR             = 91;       /// Not a STREAM
++    enum ETIME              = 92;       /// STREAM ioctl timeout
++    enum ENOATTR            = 93;       /// Attribute not found
++    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-git/patches/patch-runtime_druntime_src_core_stdc_fenv.d b/ldc-git/patches/patch-runtime_druntime_src_core_stdc_fenv.d
new file mode 100644
index 0000000..91bacee
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_stdc_fenv.d
@@ -0,0 +1,45 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/stdc/fenv.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/stdc/fenv.d
+@@ -190,6 +190,28 @@ else version ( FreeBSD )
+ 
+     alias ushort fexcept_t;
+ }
++else version( NetBSD )
++{
++    version( X86_64 )
++    {
++        struct fenv_t {
++ 	    struct x87_t {
++ 	        uint    control;	/* Control word register */
++  	        uint    status;	        /* Status word register */
++	        uint    tag;  	        /* Tag word register */
++	        uint[4] others;	        /* EIP, Pointer Selector, etc */
++ 	    }
++	    x87_t x87;
++ 
++            uint mxcsr;			/* Control and status register */
++        }
++	alias uint fexcept_t;
++    }
++    else
++    {
++        static assert(false, "Architecture not supported.");
++    }
++}
+ else version( CRuntime_Bionic )
+ {
+     version(X86)
+@@ -304,6 +326,11 @@ else version( FreeBSD )
+     ///
+     enum FE_DFL_ENV = &__fe_dfl_env;
+ }
++else version( NetBSD )
++{
++    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-git/patches/patch-runtime_druntime_src_core_stdc_locale.d b/ldc-git/patches/patch-runtime_druntime_src_core_stdc_locale.d
new file mode 100644
index 0000000..a161441
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_stdc_locale.d
@@ -0,0 +1,26 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/stdc/locale.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/stdc/locale.d
+@@ -126,6 +126,21 @@ else version(FreeBSD)
+     ///
+     enum LC_MESSAGES       = 6;
+ }
++else version( NetBSD )
++{
++    enum
++    {
++        LC_ALL,
++     	LC_COLLATE,
++     	LC_CTYPE,
++     	LC_MONETARY,
++     	LC_NUMERIC,
++     	LC_TIME,
++        LC_MESSAGES,
++      
++     	_LC_LAST,	/* marks end */
++    }
++}
+ else version(Solaris)
+ {
+     enum LC_CTYPE          = 0;
diff --git a/ldc-git/patches/patch-runtime_druntime_src_core_stdc_math.d b/ldc-git/patches/patch-runtime_druntime_src_core_stdc_math.d
new file mode 100644
index 0000000..3d75dd1
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_stdc_math.d
@@ -0,0 +1,106 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/stdc/math.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/stdc/math.d
+@@ -45,6 +45,11 @@ version (FreeBSD)
+     ///
+     enum int FP_ILOGBNAN      = int.max;
+ }
++else version (NetBSD)
++{
++    enum FP_ILOGB0     = int.min;
++    enum FP_ILOGBNAN   = int.max;
++}
+ else version (CRuntime_Bionic)
+ {
+     ///
+@@ -813,6 +818,89 @@ else version( FreeBSD )
+     int signbit(real x)         { return __signbit(x); }
+   }
+ }
++else version( NetBSD )
++{
++    enum
++    {
++        FP_INFINITE	= 0x00,
++	FP_NAN		= 0x01,
++	FP_NORMAL	= 0x02,
++	FP_SUBNORMAL	= 0x03,
++	FP_ZERO		= 0x04,
++ /* NetBSD extensions */
++	_FP_LOMD	= 0x80,		/* range for machine-specific classes */
++	_FP_HIMD	= 0xff,
++    }
++ /*
++  * Library implementation
++  */
++    int	__fpclassifyf(float);
++    int	__fpclassifyd(double);
++    int	__isfinitef(float);
++    int	__isfinited(double);
++    int	__isinff(float);
++    int	__isinfd(double);
++    int	__isnanf(float);
++    int	__isnand(double);
++    int	__signbitf(float);
++    int	__signbitd(double);
++
++    int	__fpclassifyl(real);
++    int	__isfinitel(real);
++    int	__isinfl(real);
++    int	__isnanl(real);
++    int	__signbitl(real);
++  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 __fpclassifyl(x); }
++
++    //int isfinite(real-floating x);
++    ///
++    int isfinite(float x)       { return __isfinitef(x); }
++    ///
++    int isfinite(double x)      { return __isfinited(x); }
++    ///
++    int isfinite(real x)        { return __isfinitel(x); }
++
++    //int isinf(real-floating x);
++    ///
++    int isinf(float x)          { return __isinff(x); }
++    ///
++    int isinf(double x)         { return __isinfd(x); }
++    ///
++    int isinf(real x)           { return __isinfl(x); }
++
++    //int isnan(real-floating x);
++    ///
++    int isnan(float x)          { return __isnanf(x); }
++    ///
++    int isnan(double x)         { return __isnand(x); }
++    ///
++    int isnan(real x)           { return __isnanl(x); }
++
++    //int isnormal(real-floating x);
++    ///
++    int isnormal(float x)       { return __fpclassifyf(x) == FP_NORMAL; }
++    ///
++    int isnormal(double x)      { return __fpclassifyd(x) == FP_NORMAL; }
++    ///
++    int isnormal(real x)        { return __fpclassifyl(x) == FP_NORMAL; }
++
++    //int signbit(real-floating x);
++    ///
++    int signbit(float x)        { return __signbitf(x); }
++    ///
++    int signbit(double x)       { return __signbitd(x); }
++    ///
++    int signbit(real x)         { return __signbitl(x); }
++  }
++}
+ else version( Solaris )
+ {
+     int __isnanf(float x);
diff --git a/ldc-git/patches/patch-runtime_druntime_src_core_stdc_stdio.d b/ldc-git/patches/patch-runtime_druntime_src_core_stdc_stdio.d
new file mode 100644
index 0000000..0785a17
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_stdc_stdio.d
@@ -0,0 +1,163 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/stdc/stdio.d.orig	2016-01-21 15:39:03.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,36 @@ 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/ansi.h>
++    {
++        long        _mbstateL; // for alignment
++	char[128]   _mbstate8;
++    }
++}
+ else version (Solaris)
+ {
+     enum
+@@ -392,6 +426,57 @@ else version( FreeBSD )
+     ///
+     alias shared(__sFILE) FILE;
+ }
++else version( NetBSD )
++{
++    ///
++    struct __sfpos {
++        off_t _pos;
++        __mbstate_t _mbstate_in, _mbstate_out;
++    }
++
++    ///
++    alias __sfpos fpos_t;
++
++    ///
++    struct __sFILE {
++        ubyte*          _p;       /* current position in (some) buffer */
++        int             _r;       /* read space left for getc() */
++        int             _w;       /* write space left for putc() */
++        ushort          _flags;   /* flags, below; this FILE is free if 0 */
++        short           _file;    /* fileno, if Unix descriptor, else -1 */
++        __sbuf          _bf;      /* the buffer (at least 1 byte, if !NULL) */
++        int             _lbfsize; /* 0 or -_bf._size, for inline putc */
++ 
++        /* operations */
++        void*           _cookie;  /* cookie passed to io functions */
++        int     function(void*)                      _close;
++        ssize_t function(void*, void*, size_t)       _read;
++        off_t   function(void*, off_t, int)          _seek;
++        ssize_t function(void*, in void*, size_t)    _write;
++ 
++        /* file extension */
++        __sbuf          _ext;
++ 
++        /* separate buffer for long sequences of ungetc() */
++        ubyte*          _up;      /* saved _p when _p is doing ungetc data */
++        int             _ur;      /* saved _r when _r is counting ungetc data */
++ 
++        /* tricks to meet minimum requirements even when malloc() fails */
++        ubyte[3]        _ubuf;    /* guarantee an ungetc() buffer */
++        ubyte[1]        _nbuf;    /* guarantee a getc() buffer */
++ 
++        int     function(void*)                      _flush;
++        /* Formerly used by fgetln/fgetwln; kept for binary compatibility */
++        byte[__sbuf.sizeof - (int function(void *)).sizeof] _lb_unused;
++ 
++        /* Unix stdio files get aligned to block boundaries on fseek() */
++        int             _blksize; /* stat.st_blksize (may be != _bf._size) */
++        off_t           _offset;  /* current lseek offset */
++    }
++
++    ///
++    alias shared(__sFILE) FILE;
++}
+ else version (Solaris)
+ {
+     ///
+@@ -637,6 +722,22 @@ else version( FreeBSD )
+     ///
+     alias __stderrp stderr;
+ }
++else version( NetBSD )
++{
++    enum
++    {
++        ///
++        _IOFBF,
++        ///
++        _IOLBF,
++        ///
++        _IONBF,
++    }
++
++    extern shared FILE* stdin;
++    extern shared FILE* stdout;
++    extern shared FILE* stderr;
++}
+ else version (Solaris)
+ {
+     enum
+@@ -1039,6 +1140,29 @@ else version( FreeBSD )
+     ///
+     int  vsnprintf(char* s, size_t n, in char* format, va_list arg);
+ }
++else version( NetBSD )
++{
++  // TODO: verify duplicated code
++  // 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-git/patches/patch-runtime_druntime_src_core_stdc_stdlib.d b/ldc-git/patches/patch-runtime_druntime_src_core_stdc_stdlib.d
new file mode 100644
index 0000000..762d820
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_stdc_stdlib.d
@@ -0,0 +1,12 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/stdc/stdlib.d.orig	2016-01-21 15:39:03.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-git/patches/patch-runtime_druntime_src_core_stdc_time.d b/ldc-git/patches/patch-runtime_druntime_src_core_stdc_time.d
new file mode 100644
index 0000000..61084e4
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_stdc_time.d
@@ -0,0 +1,29 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/stdc/time.d.orig	2016-01-21 15:39:03.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 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-git/patches/patch-runtime_druntime_src_core_sys_posix_dirent.d b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_dirent.d
new file mode 100644
index 0000000..3696656
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_dirent.d
@@ -0,0 +1,70 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/sys/posix/dirent.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/dirent.d
+@@ -142,6 +142,42 @@ else version( FreeBSD )
+ 
+     dirent* readdir(DIR*);
+ }
++else version( NetBSD )
++{
++    alias _dirdesc DIR;
++
++    struct _dirdesc {
++        /*
++         * dd_fd should be kept intact to preserve ABI compat.  see dirfd().
++         */
++        int     dd_fd;          /* file descriptor associated with directory */
++        /*
++         * the rest is hidden from user.
++         */
++        long    dd_loc;         /* offset in current buffer */
++        long    dd_size;        /* amount of data returned by getdents */
++        char*   dd_buf;         /* data buffer */
++        int     dd_len;         /* size of data buffer */
++        off_t   dd_seek;        /* magic cookie returned by getdents */
++        void*   dd_internal;    /* state for seekdir/telldir */
++        int     dd_flags;       /* flags for readdir */
++        void    *dd_lock;       /* lock for concurrent access */
++    }
++
++    enum MAXNAMLEN = 511;      	/* must be kept in sync with NAME_MAX */
++    struct dirent {
++ 	ino_t               d_fileno;	/* file number of entry */
++ 	ushort              d_reclen;	/* length of this record */
++ 	ushort              d_namlen;	/* length of string in d_name */
++ 	ubyte               d_type;	/* file type, see below */
++ 	char[MAXNAMLEN + 1] d_name;	/* name must be no longer than this */
++    }
++
++    int     closedir(DIR*);
++    DIR*    opendir(in char*);
++    dirent* readdir(DIR*);
++    void    rewinddir(DIR*);
++}
+ else version (Solaris)
+ {
+     struct dirent
+@@ -237,6 +273,10 @@ else version( FreeBSD )
+ {
+     int readdir_r(DIR*, dirent*, dirent**);
+ }
++else version( NetBSD )
++{
++    int readdir_r(DIR*, dirent*, dirent**);
++}
+ else version (Solaris)
+ {
+     static if (__USE_LARGEFILE64)
+@@ -276,6 +316,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-git/patches/patch-runtime_druntime_src_core_sys_posix_fcntl.d b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_fcntl.d
new file mode 100644
index 0000000..3def216
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_fcntl.d
@@ -0,0 +1,93 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/sys/posix/fcntl.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/fcntl.d
+@@ -367,6 +367,88 @@ else version( FreeBSD )
+     int creat(in char*, mode_t);
+     int open(in char*, int, ...);
+ }
++else version( NetBSD )
++{
++    enum
++    {
++        F_DUPFD		= 0,		/* duplicate file descriptor */
++	F_GETFD		= 1,		/* get file descriptor flags */
++	F_SETFD		= 2,		/* set file descriptor flags */
++	F_GETFL		= 3,		/* get file status flags */
++	F_SETFL		= 4,		/* set file status flags */
++	F_GETOWN	= 5,		/* get SIGIO/SIGURG proc/pgrp */
++	F_SETOWN	= 6,		/* set SIGIO/SIGURG proc/pgrp */
++
++	F_GETLK		= 7,		/* get record locking information */
++	F_SETLK		= 8,		/* set record locking information */
++	F_SETLKW	= 9,		/* F_SETLK; wait if blocked */
++
++	F_CLOSEM	= 10,		/* close all fds >= to the one given */
++	F_MAXFD		= 11,		/* return the max open fd */
++	F_DUPFD_CLOEXEC	= 12,		/* close on exec duplicated fd */
++	F_GETNOSIGPIPE	= 13,		/* get SIGPIPE disposition */
++	F_SETNOSIGPIPE	= 14,		/* set SIGPIPE disposition */
++    }
++    enum FD_CLOEXEC	= 1;		/* close-on-exec flag */
++    enum
++    {
++	F_RDLCK		= 1,		/* shared or read lock */
++	F_UNLCK		= 2,		/* unlock */
++	F_WRLCK		= 3,		/* exclusive or write lock */
++    }
++    enum
++    {
++        //FREAD		0x00000001
++        //FWRITE		0x00000002
++
++        O_NONBLOCK	= 0x00000004,	/* no delay */
++        O_APPEND	= 0x00000008,	/* set append mode */
++
++	//O_SHLOCK	0x00000010	/* open with shared file lock */
++	//O_EXLOCK	0x00000020	/* open with exclusive file lock */
++	//O_ASYNC		0x00000040	/* signal pgrp when data ready */
++
++	O_SYNC		= 0x00000080,	/* synchronous writes */
++
++	//O_NOFOLLOW	0x00000100	/* don't follow symlinks on the last */
++ 					/* path component */
++        O_CREAT		= 0x00000200,	/* create if nonexistent */
++	O_TRUNC		= 0x00000400,	/* truncate to zero length */
++	O_EXCL		= 0x00000800,	/* error if already exists */
++ /* defined by POSIX 1003.1; BSD default, but required to be bitwise distinct */
++        O_NOCTTY	= 0x00008000,	/* don't assign controlling terminal */
++ 
++	O_DSYNC		= 0x00010000,	/* write: I/O data completion */
++	O_RSYNC		= 0x00020000,	/* read: I/O completion as for write */
++
++	//O_ALT_IO	0x00040000	/* use alternate i/o semantics */
++	//O_DIRECT	0x00080000	/* direct I/O hint */
++ 
++	//O_DIRECTORY	0x00200000	/* fail if not a directory */
++	//O_CLOEXEC	0x00400000	/* set close on exec */
++
++	//O_SEARCH	0x00800000	/* skip search permission checks */
++
++	//O_NOSIGPIPE	0x01000000	/* don't deliver sigpipe */
++    }
++    enum
++    {
++	O_RDONLY	= 0x00000000,	/* open for reading only */
++	O_WRONLY	= 0x00000001,	/* open for writing only */
++	O_RDWR		= 0x00000002,	/* open for reading and writing */
++	O_ACCMODE	= 0x00000003,	/* mask for above modes */
++    }
++    struct flock {
++     	off_t	l_start;	/* starting offset */
++     	off_t	l_len;		/* len = 0 means until end of file */
++     	pid_t	l_pid;		/* lock owner */
++     	short	l_type;		/* lock type: read/write, etc. */
++     	short	l_whence;	/* type of l_start */
++    }
++    int creat(in char*, mode_t);
++    int fcntl(int, int, ...);
++    int open(in char*, int, ...);
++}
+ else version (Solaris)
+ {
+     enum F_DUPFD = 0;
diff --git a/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_grp.d b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_grp.d
new file mode 100644
index 0000000..99e55ae
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_grp.d
@@ -0,0 +1,49 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/sys/posix/grp.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/grp.d
+@@ -68,6 +68,19 @@ else version( FreeBSD )
+         char**  gr_mem;
+     }
+ }
++else version( NetBSD )
++{
++    struct group
++    {
++        char*   gr_name;
++        char*   gr_passwd;
++        gid_t   gr_gid;
++        char**  gr_mem;
++    }
++
++    group* getgrnam(in char*);
++    group* getgrgid(gid_t);
++}
+ else version( Solaris )
+ {
+     struct group
+@@ -119,6 +132,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 +177,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-git/patches/patch-runtime_druntime_src_core_sys_posix_netdb.d b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_netdb.d
new file mode 100644
index 0000000..8a5cd2a
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_netdb.d
@@ -0,0 +1,79 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/sys/posix/netdb.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/netdb.d
+@@ -387,6 +387,74 @@ 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;	/*%< official name of net */
++ 	char**		n_aliases;	/*%< alias list */
++ 	int		n_addrtype;	/*%< net address type */
++      
++      version( SPARC64 )
++          int		__n_pad0;	/* ABI compatibility */
++      version( SH64 )
++      version( BigEndian)
++          int		__n_pad0;	/* ABI compatibility */
++
++        uint32_t	n_net;		/*%< network # */
++
++      version( Alpha )
++ 	  int		__n_pad0;	/* ABI compatibility */
++      version( X86_64 )
++ 	  int		__n_pad0;	/* ABI compatibility */
++      version( SH64 )
++      version( LittleEndian )
++ 	  int		__n_pad0;	/* ABI compatibility */
++    }
++ 
++    struct	servent {
++ 	char*	s_name;	/*%< official service name */
++ 	char**	s_aliases;	/*%< alias list */
++ 	int	s_port;		/*%< port # */
++ 	char*	s_proto;	/*%< protocol to use */
++    }
++ 
++    struct	protoent {
++ 	char*	p_name;	/*%< official protocol name */
++        char**	p_aliases;	/*%< alias list */
++ 	int	p_proto;	/*%< protocol # */
++    }
++
++    struct addrinfo {
++ 	int		ai_flags;	/*%< AI_PASSIVE, AI_CANONNAME */
++ 	int		ai_family;	/*%< PF_xxx */
++ 	int		ai_socktype;	/*%< SOCK_xxx */
++ 	int		ai_protocol;	/*%< 0 or IPPROTO_xxx for IPv4 and IPv6 */
++
++      version( SPARC64 )
++     	  int		__ai_pad0;	/* ABI compatibility */
++
++      socklen_t         ai_addrlen;	/*%< length of ai_addr */
++
++      version( Alpha )
++      	  int		__ai_pad0;	/* ABI compatibility */
++      version( X86_64 )
++  	  int		__ai_pad0;	/* ABI compatibility */
++
++ 	char*		ai_canonname;	/*%< canonical name for hostname */
++        sockaddr*       ai_addr; 	/*%< binary address */
++        addrinfo*       ai_next; 	/*%< next structure in linked list */
++    }
++}
+ else version (Solaris)
+ {
+     struct hostent
diff --git a/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_pthread.d b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_pthread.d
new file mode 100644
index 0000000..f700961
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_pthread.d
@@ -0,0 +1,241 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/sys/posix/pthread.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/pthread.d
+@@ -209,6 +209,57 @@ else version( FreeBSD )
+     enum PTHREAD_COND_INITIALIZER               = null;
+     enum PTHREAD_RWLOCK_INITIALIZER             = null;
+ }
++ else version( NetBSD )
++{
++/* MISSING
++  PTHREAD_EXPLICIT_SCHED
++  PTHREAD_INHERIT_SCHED
++*/
++    enum
++    {
++        PTHREAD_CREATE_JOINABLE,
++        PTHREAD_CREATE_DETACHED,
++    }
++    enum
++    {
++        PTHREAD_INHERIT_SCHED,
++        PTHREAD_EXPLICIT_SCHED,
++    }
++    enum
++    {
++        PTHREAD_PROCESS_PRIVATE,
++        PTHREAD_PROCESS_SHARED,
++    }
++    enum
++    {
++        PTHREAD_CANCEL_DEFERRED,
++        PTHREAD_CANCEL_ASYNCHRONOUS,
++    }
++    enum
++    {
++        PTHREAD_CANCEL_ENABLE,
++        PTHREAD_CANCEL_DISABLE,
++    }
++    enum PTHREAD_BARRIER_SERIAL_THREAD = 1234567;
++/*
++ * POSIX 1003.1-2001, section 2.5.9.3: "The symbolic constant
++ * PTHREAD_CANCELED expands to a constant expression of type (void *)
++ * whose value matches no pointer to an object in memory nor the value
++ * NULL."
++ */
++    enum PTHREAD_CANCELED = cast(void*)1;
++
++/*
++ * Maximum length of a thread's name, including the terminating NUL.
++ */
++    enum PTHREAD_MAX_NAMELEN_NP = 32;
++
++    // enum PTHREAD_COND_INITIALIZER      = _PTHREAD_COND_INITIALIZER;
++    // enum PTHREAD_MUTEX_INITIALIZER     = _PTHREAD_MUTEX_INITIALIZER;
++    // enum PTHREAD_ONCE_INIT             = _PTHREAD_ONCE_INIT;
++    // enum PTHREAD_RWLOCK_INITIALIZER    = _PTHREAD_RWLOCK_INITIALIZER;
++    // enum PTHREAD_SPINLOCK_INITIALIZER  = _PTHREAD_SPINLOCK_INITIALIZER;
++}
+ else version (Solaris)
+ {
+     enum
+@@ -362,6 +413,31 @@ 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] pad;
++    }
++
++    struct pthread_cleanup
++    {
++        pthread_cleanup_store __store = void;
++
++        extern (D) void push()( _pthread_cleanup_routine routine, void* arg)
++        {
++ 	    pthread__cleanup_push(routine, arg, &__store);
++	}
++ 
++        extern (D) void pop()( int execute )
++        {
++            pthread__cleanup_pop(execute, &__store);
++ 	}
++    }
++    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 +583,16 @@ else version( FreeBSD )
+     int pthread_barrierattr_init(pthread_barrierattr_t*);
+     int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
+ }
++else version( NetBSD )
++{
++    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*); (BAR|TSH)
++    int pthread_barrierattr_init(pthread_barrierattr_t*);
++//int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int); (BAR|TSH)
++}
+ else version (OSX)
+ {
+ }
+@@ -565,6 +651,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 +742,27 @@ else version( FreeBSD )
+     int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted;
+     int pthread_setconcurrency(int);
+ }
++else version( NetBSD )
++{
++    /*
++     * Mutex attributes.
++     */
++    enum
++    {
++        PTHREAD_MUTEX_NORMAL,
++        PTHREAD_MUTEX_ERRORCHECK,
++        PTHREAD_MUTEX_RECURSIVE,
++        PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL,
++    }
++    int pthread_attr_getguardsize(in pthread_attr_t*, size_t*);
++    int pthread_attr_setguardsize(pthread_attr_t*, size_t);
++    int pthread_mutexattr_gettype(in pthread_mutexattr_t*, int*);
++    int pthread_mutexattr_settype(pthread_mutexattr_t*, int);
++/* MISSING:
++int pthread_getconcurrency();
++int pthread_setconcurrency(int);
++*/
++}
+ else version (Solaris)
+ {
+     enum
+@@ -698,6 +813,9 @@ else version( FreeBSD )
+ {
+     int pthread_getcpuclockid(pthread_t, clockid_t*);
+ }
++else version( NetBSD )
++{
++}
+ else version (OSX)
+ {
+ }
+@@ -740,6 +858,14 @@ else version( FreeBSD )
+     int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
+     int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
+ }
++else version( NetBSD )
++{
++     /* MISSING:
++      *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 +1002,27 @@ 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,
++	PTHREAD_SCOPE_SYSTEM,
++    }
++
++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(pthread_attr_t*, int);
++int pthread_getschedparam(pthread_t, int*, sched_param*);
++int pthread_setschedparam(pthread_t, int, in sched_param*);
++
++/* MISSING:
++int pthread_setschedprio(pthread_t, int);
++*/
++}
+ else version (Solaris)
+ {
+     enum
+@@ -953,6 +1100,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 +1162,17 @@ else version( FreeBSD )
+     int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
+     int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
+ }
++else version( NetBSD )
++{
++/* MISSING:
++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-git/patches/patch-runtime_druntime_src_core_sys_posix_pwd.d b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_pwd.d
new file mode 100644
index 0000000..ea4887b
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_pwd.d
@@ -0,0 +1,51 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/sys/posix/pwd.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/pwd.d
+@@ -85,6 +85,21 @@ 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 login class */
++    	char*          pw_gecos;	/* general information */
++    	char*          pw_dir;		/* home directory */
++    	char*          pw_shell;	/* default shell */
++    	time_t 	       pw_expire;	/* account expiration */
++    }
++}
+ else version (Solaris)
+ {
+     struct passwd
+@@ -143,6 +158,11 @@ 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_r(in char*, passwd*, char*, size_t, passwd**);
++    int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
++}
+ else version (Solaris)
+ {
+     int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
+@@ -183,6 +203,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-git/patches/patch-runtime_druntime_src_core_sys_posix_sched.d b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sched.d
new file mode 100644
index 0000000..12955eb
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sched.d
@@ -0,0 +1,58 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/sys/posix/sched.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sched.d
+@@ -86,6 +86,29 @@ else version( FreeBSD )
+     enum SCHED_OTHER    = 2;
+     enum SCHED_RR       = 3;
+ }
++else version( NetBSD )
++{
++  struct sched_param {
++    int sched_priority;
++  }
++
++/* MISSING:
++SCHED_SPORADIC (SS|TSP)
++*/
++
++  enum
++  {
++    SCHED_NONE = -1,
++    SCHED_OTHER,
++    SCHED_FIFO,
++    SCHED_RR,
++  }
++
++  int _sched_getparam(pid_t, lwpid_t, int*, sched_param*);
++  int _sched_getscheduler(pid_t);
++  int _sched_setparam(pid_t, lwpid_t, int, const sched_param*);
++  int _sched_setscheduler(pid_t, int, const sched_param*);
++}
+ else version (Solaris)
+ {
+     struct sched_param
+@@ -144,6 +167,10 @@ else version( FreeBSD )
+ {
+     int sched_yield();
+ }
++else version( NetBSD )
++{
++    int sched_yield();
++}
+ else version (Solaris)
+ {
+     int sched_yield();
+@@ -184,6 +211,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-git/patches/patch-runtime_druntime_src_core_sys_posix_semaphore.d b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_semaphore.d
new file mode 100644
index 0000000..63c1bf0
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_semaphore.d
@@ -0,0 +1,39 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/sys/posix/semaphore.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/semaphore.d
+@@ -81,6 +81,23 @@ else version( FreeBSD )
+ 
+     enum SEM_FAILED = cast(sem_t*) null;
+ }
++else version( NetBSD )
++{
++    import core.stdc.stdint;
++    struct _sem_st
++    {
++        uint	ksem_magic;
++        struct Ksem_list
++	{
++            _sem_st*  le_next;	/* next element */
++            _sem_st** le_prev;	/* address of previous next element */
++        }
++  	Ksem_list ksem_list;
++  	intptr_t		ksem_semid;	/* 0 -> user (non-shared) */
++  	sem_t		*ksem_identity;
++    }
++    alias _sem_st* sem_t;
++}
+ else version (Solaris)
+ {
+     struct sem_t
+@@ -137,6 +154,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-git/patches/patch-runtime_druntime_src_core_sys_posix_signal.d b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_signal.d
new file mode 100644
index 0000000..c543f36
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_signal.d
@@ -0,0 +1,348 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/sys/posix/signal.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/signal.d
+@@ -92,6 +92,8 @@ nothrow @nogc
+     private alias void function(int, siginfo_t*, void*) sigactfn_t2;
+ }
+ 
++version( NetBSD ) {}
++else
+ enum
+ {
+   SIGEV_SIGNAL,
+@@ -395,6 +397,62 @@ else version( FreeBSD )
+     enum SIGUSR2    = 31;
+     enum SIGURG     = 16;
+ }
++else version( NetBSD )
++{
++    enum
++    {
++        SIGEV_NONE,
++        SIGEV_SIGNAL,
++        SIGEV_THREAD,
++        SIGEV_SA,
++    }
++/*
++    union sigval
++    {
++        int   sival_int;
++        void* sival_ptr;
++    }
++*/
++    enum        SIGHUP         = 1;      /* hangup */
++// SIGINT (defined in core.stdc.signal)
++//     enum     SIGINT         = 2;      /* interrupt */
++    enum        SIGQUIT        = 3;      /* quit */
++// SIGILL (defined in core.stdc.signal)
++//     enum     SIGILL         = 4;      /* illegal instruction (not reset when caught) */
++// SIGABRT (defined in core.stdc.signal)
++//     enum     SIGABRT        = 6;      /* abort() */
++//     enum     SIGIOT          SIGABRT /* compatibility */
++//     enum     SIGEMT         = 7;      /* EMT instruction */
++// SIGFPE (defined in core.stdc.signal)
++//     enum     SIGFPE         = 8;      /* floating point exception */
++    enum        SIGKILL        = 9;      /* kill (cannot be caught or ignored) */
++    enum        SIGBUS         = 10;     /* bus error */
++// SIGSEGV (defined in core.stdc.signal)
++//     enum     SIGSEGV        = 11;     /* segmentation violation */
++    enum        SIGPIPE        = 13;     /* write on a pipe with no one to read it */
++    enum        SIGALRM        = 14;     /* alarm clock */
++// SIGTERM (defined in core.stdc.signal)
++//     enum     SIGTERM        = 15;     /* software termination signal from kill */
++    enum        SIGURG         = 16;     /* urgent condition on IO channel */
++    enum        SIGSTOP        = 17;     /* sendable stop signal not from tty */
++    enum        SIGTSTP        = 18;     /* stop signal from tty */
++    enum        SIGCONT        = 19;     /* continue a stopped process */
++    enum        SIGCHLD        = 20;     /* to parent on child stop or exit */
++    enum        SIGTTIN        = 21;     /* to readers pgrp upon background tty read */
++    enum        SIGTTOU        = 22;     /* like TTIN for output if (tp->t_local&LTOSTOP) */
++//     enum     SIGIO          = 23;     /* input/output possible signal */
++//     enum     SIGWINCH       = 28;     /* window size changes */
++//     enum     SIGINFO        = 29;     /* information request */
++    enum        SIGUSR1        = 30;     /* user defined signal 1 */
++    enum        SIGUSR2        = 31;     /* user defined signal 2 */
++//     enum     SIGPWR         = 32;     /* power fail/restart (not reset when caught) */
++
++//    enum        SIGRTMIN       = 33;     /* Kernel only; not exposed to userland yet */
++//    enum        SIGRTMAX       = 63;     /* Kernel only; not exposed to userland */
++  
++// sigfn_t signal(int sig, sigfn_t func); (defined in core.stdc.signal)
++// int raise(int sig);                    (defined in core.stdc.signal)
++}
+ else version (Solaris)
+ {
+     enum SIGALRM = 14;
+@@ -453,6 +511,19 @@ else version( FreeBSD )
+         sigset_t sa_mask;
+     }
+ }
++else version( NetBSD )
++{
++    struct sigaction_t
++    {
++        union
++        {
++            void function(int) sa_handler;
++            void function(int, siginfo_t*, void*) sa_siggaction;
++        }
++        sigset_t sa_mask;
++        int sa_flags;
++    }
++}
+ else version (Solaris)
+ {
+     struct sigaction_t
+@@ -855,6 +926,88 @@ else version( FreeBSD )
+     int sigsuspend(in sigset_t *);
+     int sigwait(in sigset_t*, int*);
+ }
++else version( NetBSD )
++{
++    enum SIG_HOLD = cast(sigfn_t2) 3;
++
++    alias int sigset_t;
++
++    enum SA_NOCLDSTOP = 0x0008;	/* do not generate SIGCHLD on child stop */
++    enum
++    {
++	SIG_BLOCK = 1, /* block specified signal set */
++	SIG_UNBLOCK,   /* unblock specified signal set */
++	SIG_SETMASK,   /* set specified signal set */
++    }
++    
++    union siginfo_t {
++        char[128] si_pad;	/* Total size; for future expansion */
++        _ksiginfo _info;
++    }
++
++    struct _ksiginfo
++    {
++      int	_signo;
++      int	_code;
++      int	_errno;
++      /* In _LP64 the union starts on an 8-byte boundary. */
++      version( D_LP64 )
++      int	_pad;
++      union Reason {
++	struct Rt {
++	  pid_t	 _pid;
++	  uid_t	 _uid;
++	  sigval _value;
++	}
++	Rt _rt;
++     
++	struct Child {
++	  pid_t	_pid;
++	  uid_t	_uid;
++	  int	_status;
++	  clock_t	_utime;
++	  clock_t	_stime;
++	}
++	Child _child;
++     
++	struct Fault {
++	  void   *_addr;
++	  int	_trap;
++	  int	_trap2;
++	  int	_trap3;
++	}
++	Fault _fault;
++     
++	struct Poll {
++	  long	_band;
++	  int	_fd;
++     	}
++	Poll _poll;
++      }
++      Reason _reason;
++    }
++
++    enum
++    {
++      SI_USER,
++      SI_QUEUE,
++      SI_TIMER,
++      SI_ASYNCIO = -3,
++      SI_MESGQ = 4,
++    }
++
++    int kill(pid_t, int);
++    int sigaction(int, in sigaction_t*, sigaction_t*);
++    int sigaddset(sigset_t*, int);
++    int sigdelset(sigset_t*, int);
++    int sigemptyset(sigset_t*);
++    int sigfillset(sigset_t*);
++    int sigismember(in sigset_t*, int);
++    int sigpending(sigset_t*);
++    int sigprocmask(int, in sigset_t*, sigset_t*);
++    int sigsuspend(in sigset_t*);
++    int sigwait(in sigset_t*, int*);
++}
+ else version (Solaris)
+ {
+     enum SIG_HOLD = cast(sigfn_t2)2;
+@@ -1626,6 +1779,113 @@ else version( FreeBSD )
+     int sigpause(int);
+     int sigrelse(int);
+ }
++else version( NetBSD )
++{
++    enum     SIGPROF        = 27;     /* profiling time alarm */
++    enum     SIGSYS         = 12;     /* bad argument to system call */
++    enum     SIGTRAP        = 5;      /* trace trap (not reset when caught) */
++    enum     SIGVTALRM      = 26;     /* virtual time alarm */
++    enum     SIGXCPU        = 24;     /* exceeded CPU time limit */
++    enum     SIGXFSZ        = 25;     /* exceeded file size limit */
++
++    enum SA_ONSTACK     = 0x0001;	/* take signal on signal stack */
++    enum SA_RESTART     = 0x0002;	/* restart system call on signal return */
++    enum SA_RESETHAND   = 0x0004;	/* reset to SIG_DFL when taking signal */
++    enum SA_NODEFER     = 0x0010;	/* don't mask the signal we're delivering */
++
++/* Only valid for SIGCHLD. */
++    // enum SA_NOCLDSTOP   = 0x0008;	/* do not generate SIGCHLD on child stop */
++    enum SA_NOCLDWAIT   = 0x0020;	/* do not generate zombies on unwaited child */
++
++    enum SA_SIGINFO     = 0x0040;	/* take sa_sigaction handler */
++
++    enum SA_NOKERNINFO  = 0x0080;	/* siginfo does not print kernel info on tty */
++
++    enum SA_ALLBITS     = 0x00ff;
++
++    enum SS_ONSTACK	= 0x0001;	/* take signals on alternate stack */
++    enum SS_DISABLE	= 0x0004;	/* disable taking signals on alternate stack */
++
++    enum SS_ALLBITS	= 0x0005;
++
++    enum MINSIGSTKSZ	= 8192;			/* minimum allowable stack */
++    enum SIGSTKSZ	= (MINSIGSTKSZ + 32768);	/* recommended stack size */
++
++    struct stack_t
++    {
++        void*   ss_sp;
++        size_t  ss_size;
++        int     ss_flags;
++    }
++
++//
++// XOpen (XSI)
++//
++/*
++SIGPOLL
++
++mcontext_t // from ucontext
++
++struct sigstack
++{
++    int   ss_onstack;
++    void* ss_sp;
++}
++
++ILL_ILLOPC
++ILL_ILLOPN
++ILL_ILLADR
++ILL_ILLTRP
++ILL_PRVOPC
++ILL_PRVREG
++ILL_COPROC
++ILL_BADSTK
++
++FPE_INTDIV
++FPE_INTOVF
++FPE_FLTDIV
++FPE_FLTOVF
++FPE_FLTUND
++FPE_FLTRES
++FPE_FLTINV
++FPE_FLTSUB
++
++SEGV_MAPERR
++SEGV_ACCERR
++
++BUS_ADRALN
++BUS_ADRERR
++BUS_OBJERR
++
++TRAP_BRKPT
++TRAP_TRACE
++
++CLD_EXITED
++CLD_KILLED
++CLD_DUMPED
++CLD_TRAPPED
++CLD_STOPPED
++CLD_CONTINUED
++
++POLL_IN
++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);
++
++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 +2189,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 +2292,21 @@ else version( FreeBSD )
+     int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
+     int sigwaitinfo(in sigset_t*, siginfo_t*);
+ }
++ else version( NetBSD )
++{     
++// MISSING
++//int sigwaitinfo(in sigset_t*, siginfo_t*);
++    struct sigevent
++    {
++        int             sigev_notify;
++        int             sigev_signo;
++        sigval          sigev_value;
++        void function(sigval) sigev_notify_function;
++        pthread_attr_t* sigev_notify_attributes;
++    }
++int sigqueue(pid_t, int, in sigval);
++int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
++}
+ else version (OSX)
+ {
+ }
+@@ -2097,6 +2380,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-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_ioctl.d b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_ioctl.d
new file mode 100644
index 0000000..4217b9c
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_ioctl.d
@@ -0,0 +1,15 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/sys/posix/sys/ioctl.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sys/ioctl.d
+@@ -359,6 +359,10 @@ else version (FreeBSD)
+ 
+     int ioctl(int, c_ulong, ...);
+ }
++else version( NetBSD )
++{
++  //Nothing here yet.
++}
+ else version (Solaris)
+ {
+     int ioctl(int fildes, int request, ...);
diff --git a/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_mman.d b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_mman.d
new file mode 100644
index 0000000..d314eee
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_mman.d
@@ -0,0 +1,155 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/sys/posix/sys/mman.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sys/mman.d
+@@ -76,6 +76,19 @@ else version( FreeBSD )
+     enum POSIX_MADV_DONTNEED    = 4;
+     int posix_madvise(void *addr, size_t len, int advice);
+ }
++else version( NetBSD )
++{
++    int posix_madvise(void*, size_t, int);
++
++    enum
++    {
++        POSIX_MADV_NORMAL,      /* No further special treatment */
++    	POSIX_MADV_RANDOM,      /* Expect random page references */
++    	POSIX_MADV_SEQUENTIAL,  /* Expect sequential page references */
++    	POSIX_MADV_WILLNEED,    /* Will need these pages */
++    	POSIX_MADV_DONTNEED,   	/* Don't need these pages */
++    }
++}
+ else version (Solaris)
+ {
+ }
+@@ -118,6 +131,16 @@ else version( FreeBSD )
+     enum PROT_WRITE     = 0x02;
+     enum PROT_EXEC      = 0x04;
+ }
++else version( NetBSD )
++{
++    enum
++    {
++        PROT_NONE  = 0x00,
++	PROT_READ  = 0x01,
++	PROT_WRITE = 0x02,
++	PROT_EXEC  = 0x04,
++    }
++}
+ else version (Solaris)
+ {
+     enum PROT_NONE = 0x00;
+@@ -164,6 +187,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 +346,51 @@ else version( FreeBSD )
+ 
+     int msync(void*, size_t, int);
+ }
++else version( NetBSD )
++{
++    enum
++    {
++        MAP_SHARED       = 0x0001,      /* share changes */
++        MAP_PRIVATE      = 0x0002,      /* changes are private */
++      
++        MAP_COPY         = 0x0004,      /* "copy" region at mmap time */
++
++        MAP_FIXED        = 0x0010,      /* map addr must be exactly as requested */
++        MAP_RENAME       = 0x0020,      /* Sun: rename private pages to file */
++        MAP_NORESERVE    = 0x0040,      /* Sun: don't reserve needed swap area */
++        MAP_INHERIT      = 0x0080,      /* region is retained after exec */
++        MAP_HASSEMAPHORE = 0x0200,      /* region may contain semaphores */
++        MAP_TRYFIXED     = 0x0400,      /* attempt hint address, even within break */
++        MAP_WIRED        = 0x0800,      /* mlock() mapping when it is established */
++
++        MAP_FILE         = 0x0000,      /* map from file (default) */
++        MAP_ANONYMOUS    = 0x1000,      /* allocated from memory, swap space */
++        MAP_ANON         = MAP_ANONYMOUS,
++        MAP_STACK        = 0x2000,      /* allocated from memory, swap space (stack) */
++	/+
++    105 #define	MAP_ALIGNED(n)		((n) << MAP_ALIGNMENT_SHIFT)
++    106 #define	MAP_ALIGNMENT_SHIFT	24
++    107 #define	MAP_ALIGNMENT_MASK	MAP_ALIGNED(0xff)
++    108 #define	MAP_ALIGNMENT_64KB	MAP_ALIGNED(16)	/* 2^16 */
++    109 #define	MAP_ALIGNMENT_16MB	MAP_ALIGNED(24)	/* 2^24 */
++    110 #define	MAP_ALIGNMENT_4GB	MAP_ALIGNED(32)	/* 2^32 */
++    111 #define	MAP_ALIGNMENT_1TB	MAP_ALIGNED(40)	/* 2^40 */
++    112 #define	MAP_ALIGNMENT_256TB	MAP_ALIGNED(48)	/* 2^48 */
++    113 #define	MAP_ALIGNMENT_64PB	MAP_ALIGNED(56)	/* 2^56 */
++    114 +/
++     /*
++      * Error indicator returned by mmap(2)
++      */
++    	MAP_FAILED	= cast(void*) -1,	/* mmap() failed */
++    }
++    enum
++    {
++        MS_ASYNC      = 0x01,   /* perform asynchronous writes */
++        MS_INVALIDATE = 0x02,   /* invalidate cached data */
++        MS_SYNC       = 0x04,   /* perform synchronous writes */
++    }
++    int msync(void*, size_t, int);
++}
+ else version (Solaris)
+ {
+     enum MAP_SHARED = 0x0001;
+@@ -429,6 +502,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 +554,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 +593,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 +633,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-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_resource.d b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_resource.d
new file mode 100644
index 0000000..23cbe11
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_resource.d
@@ -0,0 +1,80 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/sys/posix/sys/resource.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sys/resource.d
+@@ -234,6 +234,75 @@ else version (FreeBSD)
+         RLIMIT_AS     = 10,
+     }
+ }
++else version( NetBSD )
++{
++    enum
++    {
++        PRIO_PROCESS,
++        PRIO_PGRP,
++        PRIO_USER,
++    }
++
++    alias ulong rlim_t;
++
++    enum
++    {
++        RLIM_INFINITY = rlim_t.max,
++        RLIM_SAVED_MAX = RLIM_INFINITY,
++        RLIM_SAVED_CUR = RLIM_INFINITY,
++    }
++
++    enum
++    {
++        RUSAGE_SELF,
++        RUSAGE_CHILDREN = -1,
++    }
++
++    struct rusage {
++        timeval ru_utime;	/* user time used */
++        timeval ru_stime;	/* system time used */
++ 	long	ru_maxrss;	/* max resident set size */
++        alias 	ru_ixrss ru_first;
++ 	long	ru_ixrss;	/* integral shared memory size */
++ 	long	ru_idrss;	/* integral unshared data " */
++ 	long	ru_isrss;	/* integral unshared stack " */
++ 	long	ru_minflt;	/* page reclaims */
++ 	long	ru_majflt;	/* page faults */
++ 	long	ru_nswap;	/* swaps */
++ 	long	ru_inblock;	/* block input operations */
++ 	long	ru_oublock;	/* block output operations */
++ 	long	ru_msgsnd;	/* messages sent */
++ 	long	ru_msgrcv;	/* messages received */
++ 	long	ru_nsignals;	/* signals received */
++ 	long	ru_nvcsw;	/* voluntary context switches */
++ 	long	ru_nivcsw;	/* involuntary " */
++        alias   ru_nivcsw ru_last;
++    };
++
++    enum
++    {
++        RLIMIT_CPU     = 0,		/* cpu time in milliseconds */
++	RLIMIT_FSIZE   = 1,		/* maximum file size */
++	RLIMIT_DATA    = 2,		/* data size */
++	RLIMIT_STACK   = 3,		/* stack size */
++	RLIMIT_CORE    = 4,		/* core file size */
++	RLIMIT_RSS     = 5,		/* resident set size */
++	RLIMIT_MEMLOCK = 6,		/* locked-in-memory address space */
++	RLIMIT_NPROC   = 7,		/* number of processes */
++	RLIMIT_NOFILE  = 8,		/* number of open files */
++	RLIMIT_SBSIZE  = 9,		/* maximum size of all socket buffers */
++	RLIMIT_AS      = 10,		/* virtual process size (inclusive of mmap) */
++	RLIMIT_VMEM    = RLIMIT_AS,	/* common alias */
++	RLIMIT_NTHR    = 11,		/* number of threads */
++	RLIM_NLIMITS   = 12,		/* number of resource limits */
++    }
++
++    int getpriority(int, id_t);
++    int getrlimit(int, rlimit*);
++    int getrusage(int, rusage*);
++    int setpriority(int, id_t, int);
++    int setrlimit(int, const rlimit*);
++}
+ else version (Solaris)
+ {
+     enum
diff --git a/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_select.d b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_select.d
new file mode 100644
index 0000000..d5c0e2c
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_select.d
@@ -0,0 +1,48 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/sys/posix/sys/select.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sys/select.d
+@@ -218,6 +218,43 @@ 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 )
++{
++    alias uint __fd_mask;
++
++    enum __NFDBITS = 32;
++    /* Note: FD_SETSIZE may be defined by the user.
++       This is the default value. */
++    enum FD_SETSIZE = 256;
++
++    pure auto __NFD_LEN(long a) {
++        return (a + __NFDBITS - 1) / __NFDBITS;
++    }
++    enum __NFD_SIZE = __NFD_LEN(FD_SETSIZE);
++
++    struct fd_set {
++        __fd_mask[__NFD_SIZE] fds_bits;
++    }
++
++//
++// Required
++//
++/*
++NOTE: This module requires timeval from core.sys.posix.sys.time, but timeval
++      is supposedly an XOpen extension.  As a result, this header will not
++      compile on platforms that are not XSI-compliant.  This must be resolved
++      on a per-platform basis.
++
++void FD_CLR(int fd, fd_set* fdset);
++int FD_ISSET(int fd, const(fd_set)* fdset);
++void FD_SET(int fd, fd_set* fdset);
++void FD_ZERO(fd_set* fdset);
++
++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-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_socket.d b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_socket.d
new file mode 100644
index 0000000..4b6eab3
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_socket.d
@@ -0,0 +1,159 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/sys/posix/sys/socket.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sys/socket.d
+@@ -927,6 +927,126 @@ 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;		/* total length */
++     	sa_family_t	sa_family;	/* address family */
++     	char[14]	sa_data;	/* actually longer; address value */
++    }
++    enum
++    {
++        _SS_MAXSIZE   = 128,
++        _SS_ALIGNSIZE = long.sizeof,
++        _SS_PAD1SIZE  = _SS_ALIGNSIZE - 2,
++        _SS_PAD2SIZE  = _SS_MAXSIZE - 2 - _SS_PAD1SIZE - _SS_ALIGNSIZE,
++    }
++    struct sockaddr_storage {
++ 	ubyte	        ss_len;		/* address length */
++ 	sa_family_t	ss_family;	/* address family */
++ 	char[_SS_PAD1SIZE]	__ss_pad1;
++ 	long            __ss_align;/* force desired structure storage alignment */
++ 	char[_SS_PAD2SIZE]	__ss_pad2;
++    }
++
++    struct msghdr {
++ 	void*		msg_name;	/* optional address */
++ 	socklen_t	msg_namelen;	/* size of address */
++ 	iovec*	        msg_iov;	/* scatter/gather array */
++ 	int		msg_iovlen;	/* # elements in msg_iov */
++ 	void*		msg_control;	/* ancillary data, see below */
++ 	socklen_t	msg_controllen;	/* ancillary data buffer len */
++ 	int		msg_flags;	/* flags on received message */
++    }
++
++    struct cmsghdr {
++ 	socklen_t	cmsg_len;	/* data byte count, including hdr */
++ 	int		cmsg_level;	/* originating protocol */
++ 	int		cmsg_type;	/* protocol-specific type */
++ /* followed by	u_char  cmsg_data[]; */
++    }
++    //
++// Required
++//
++/*
++struct iovec {} // from core.sys.posix.sys.uio
++
++SCM_RIGHTS
++
++CMSG_DATA(cmsg)
++CMSG_NXTHDR(mhdr,cmsg)
++CMSG_FIRSTHDR(mhdr)
++
++struct linger
++{
++    int l_onoff;
++    int l_linger;
++}
++
++SOCK_DGRAM
++SOCK_SEQPACKET
++SOCK_STREAM
++
++SOL_SOCKET
++
++SO_ACCEPTCONN
++SO_BROADCAST
++SO_DEBUG
++SO_DONTROUTE
++SO_ERROR
++SO_KEEPALIVE
++SO_LINGER
++SO_OOBINLINE
++SO_RCVBUF
++SO_RCVLOWAT
++SO_RCVTIMEO
++SO_REUSEADDR
++SO_SNDBUF
++SO_SNDLOWAT
++SO_SNDTIMEO
++SO_TYPE
++
++SOMAXCONN
++
++MSG_CTRUNC
++MSG_DONTROUTE
++MSG_EOR
++MSG_OOB
++MSG_PEEK
++MSG_TRUNC
++MSG_WAITALL
++
++AF_INET
++AF_UNIX
++AF_UNSPEC
++
++SHUT_RD
++SHUT_RDWR
++SHUT_WR
++
++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 +1431,13 @@ else version( FreeBSD )
+         AF_INET6    = 28
+     }
+ }
++else version( NetBSD )
++{
++    enum
++    {
++        AF_INET6 = 24,
++    }
++}
+ else version (Solaris)
+ {
+     enum
+@@ -1358,6 +1485,13 @@ else version( FreeBSD )
+         SOCK_RAW    = 3
+     }
+ }
++else version( NetBSD )
++{
++    enum
++    {
++        SOCK_RAW = 3
++    }
++}
+ else version (Solaris)
+ {
+     enum
diff --git a/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_stat.d b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_stat.d
new file mode 100644
index 0000000..9e17860
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_stat.d
@@ -0,0 +1,150 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/sys/posix/sys/stat.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sys/stat.d
+@@ -777,6 +777,103 @@ 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 */
++ // #if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0) >= 700 || \
++ //    defined(_NETBSD_SOURCE)
++ 	// struct	  timespec st_atim;	/* time of last access */
++ 	// struct	  timespec st_mtim;	/* time of last data modification */
++ 	// struct	  timespec st_ctim;	/* time of last file status change */
++ 	// struct	  timespec st_birthtim;	/* time of creation */
++ // #else
++ 	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 */
++ // #endif
++ 	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_ISUID = 0x4<<(3*3),                 /* set user id on execution */
++        S_ISGID = 0x2<<(3*3),                 /* set group id on execution */
++        S_ISTXT = 0x1<<(3*3),                 /* sticky bit */
++    }
++    enum
++    {
++        S_IRWXU = 0x7<<(3*2),                 /* RWX mask for owner */
++        S_IRUSR = 0x4<<(3*2),                 /* R for owner */
++        S_IWUSR = 0x2<<(3*2),                 /* W for owner */
++        S_IXUSR = 0x1<<(3*2),                 /* X for owner */
++    }
++    enum
++    {
++        S_IREAD        = S_IRUSR,
++        S_IWRITE       = S_IWUSR,
++        S_IEXEC        = S_IXUSR,
++    }
++    enum
++    {
++        S_IRWXG = 0x7<<(3*1),                 /* RWX mask for group */
++        S_IRGRP = 0x4<<(3*1),                 /* R for group */
++        S_IWGRP = 0x2<<(3*1),                 /* W for group */
++        S_IXGRP = 0x1<<(3*1),                 /* X for group */
++    }
++    enum
++    {
++        S_IRWXO = 0x7<<(3*0),                 /* RWX mask for other */
++        S_IROTH = 0x4<<(3*0),                 /* R for other */
++        S_IWOTH = 0x2<<(3*0),                 /* W for other */
++        S_IXOTH = 0x1<<(3*0),                 /* X for other */
++    }
++    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 ); }
++/* MISSING:
++S_ISVTX
++
++S_TYPEISMQ(buf)
++S_TYPEISSEM(buf)
++S_TYPEISSHM(buf)
++*/
++    int    chmod(in char*, mode_t);
++    int    fchmod(int, mode_t);
++    int    fstat(int, stat_t*);
++    int    lstat(in char*, stat_t*);
++    int    mkdir(in char*, mode_t);
++    int    mkfifo(in char*, mode_t);
++    int    stat(in char*, stat_t*);
++    mode_t umask(mode_t);
++
++}
+ else version (Solaris)
+ {
+     private enum _ST_FSTYPSZ = 16;
+@@ -1174,6 +1271,41 @@ else version( FreeBSD )
+ 
+     int mknod(in char*, mode_t, dev_t);
+ }
++else version( NetBSD )
++{
++    enum
++    {
++	_S_IFMT	  = 0xf<<(3*4),		/* type of file mask */
++	_S_IFIFO  = 0x1<<(3*4),		/* named pipe (fifo) */
++	_S_IFCHR  = 0x2<<(3*4),		/* character special */
++	_S_IFDIR  = 0x4<<(3*4),		/* directory */
++	_S_IFBLK  = 0x6<<(3*4),		/* block special */
++	_S_IFREG  = 0x1<<(3*5),		/* regular */
++	_S_IFLNK  = 0xa<<(3*4),		/* symbolic link */
++	_S_ISVTX  = 0x1<<(3*3),		/* save swapped text even after use */
++	_S_IFSOCK = 0xc<<(3*4),		/* socket */
++	_S_IFWHT  = 0xe<<(3*4),		/* whiteout */
++	_S_ARCH1  = 0x2<<(3*5),		/* Archive state 1, ls -l shows 'a' */
++	_S_ARCH2  = 0x4<<(3*5),		/* Archive state 2, ls -l shows 'A' */
++    }
++    enum
++    {
++	S_IFMT   = _S_IFMT,
++	S_IFIFO  = _S_IFIFO,
++	S_IFCHR  = _S_IFCHR,
++	S_IFDIR  = _S_IFDIR,
++	S_IFBLK  = _S_IFBLK,
++	S_IFREG  = _S_IFREG,
++	S_IFLNK  = _S_IFLNK,
++	S_ISVTX  = _S_ISVTX,
++	S_IFSOCK = _S_IFSOCK,
++   	S_IFWHT  = _S_IFWHT,
++    	S_ARCH1  = _S_ARCH1,
++    	S_ARCH2  = _S_ARCH2,
++    }
++
++    int mknod(in char*, mode_t, dev_t);
++}
+ else version (Solaris)
+ {
+     enum S_IFMT = 0xF000;
diff --git a/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_time.d b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_time.d
new file mode 100644
index 0000000..675b78a
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_time.d
@@ -0,0 +1,39 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/sys/posix/sys/time.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sys/time.d
+@@ -123,6 +123,34 @@ 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;
++    }
++
++    enum
++    {
++        ITIMER_REAL,
++	ITIMER_VIRTUAL,
++	ITIMER_PROF,
++	ITIMER_MONOTONIC,
++    }
++
++    int getitimer(int, itimerval*);
++    int gettimeofday(timeval*, void*);
++//int select(int, fd_set*, fd_set*, fd_set*, timeval*); (defined in core.sys.posix.sys.signal)
++    int setitimer(int, in itimerval*, itimerval*);
++    int utimes(in char*, ref const(timeval)[2]); // LEGACY
++}
+ else version (Solaris)
+ {
+     struct timeval
diff --git a/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_types.d b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_types.d
new file mode 100644
index 0000000..a097fec
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_types.d
@@ -0,0 +1,111 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/sys/posix/sys/types.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sys/types.d
+@@ -138,6 +138,29 @@ 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 long	    off_t;
++    alias int	    pid_t;
++    //size_t (defined in core.stdc.stddef)
++    version (D_LP64)  //TODO: There are more rules to follow.
++    {
++	alias long  ssize_t;
++    }
++    else
++    {
++	alias int   ssize_t;
++    }
++    alias long      time_t;
++    alias uint	    uid_t;
++}
+ else version (Solaris)
+ {
+     alias char* caddr_t;
+@@ -269,6 +292,16 @@ else version( FreeBSD )
+     alias c_long    suseconds_t;
+     alias uint      useconds_t;
+ }
++else version( NetBSD )
++{
++    alias uint      clock_t;
++    alias ulong	    fsblkcnt_t;
++    alias ulong	    fsfilcnt_t;
++    alias uint	    id_t;
++    alias c_long    key_t;
++    alias int	    suseconds_t;
++    alias uint      useconds_t;
++}
+ else version (Solaris)
+ {
+     static if (__USE_FILE_OFFSET64)
+@@ -645,6 +678,24 @@ else version( FreeBSD )
+     alias void* pthread_rwlockattr_t;
+     alias void* pthread_t;
+ }
++else version ( NetBSD )
++{
++    alias int lwpid_t;
++
++    alias void** pthread_t;
++    alias void* pthread_attr_t;
++    alias void* pthread_mutex_t;
++    alias void* pthread_mutexattr_t;
++    alias void* pthread_cond_t;
++    alias void* pthread_condattr_t;
++    alias void* pthread_once_t;
++    alias void* pthread_spinlock_t;
++    alias void* pthread_rwlock_t;
++    alias void* pthread_rwlockattr_t;
++    // alias void* pthread_barrier_t;
++    // alias void* pthread_barrierattr_t;
++    alias int pthread_key_t;
++}
+ else version (Solaris)
+ {
+     alias uint pthread_t;
+@@ -809,6 +860,34 @@ 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;
++}
++/+
++    alias __pthread_barrier_st pthread_barrier_t;
++    alias __pthread_barrierattr_st pthread_barrierattr_t;
++
++    struct __pthread_barrier_st {
++        uint    ptb_magic;
++ 
++        /* Protects data below */
++        pthread_spin_t	ptb_lock;
++ 
++        pthread_queue_t	ptb_waiters;
++        uint    ptb_initcount;
++        uint    ptb_curcount;
++        uint    ptb_generation;
++ 
++        void*  	ptb_private;
++    };
++ 
++    struct __pthread_barrierattr_st {
++        uint    ptba_magic;
++        void*   ptba_private;
++    };
+++/
+ else version( OSX )
+ {
+ }
diff --git a/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_uio.d b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_uio.d
new file mode 100644
index 0000000..0359a10
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_uio.d
@@ -0,0 +1,22 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/sys/posix/sys/uio.d.orig	2016-01-21 15:39:03.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;	/* Base address. */
++        size_t	 iov_len;	/* Length. */
++    }
++
++    ssize_t readv(int, in iovec*, int);
++    ssize_t writev(int, in iovec*, int);
++}
+ else version (Solaris)
+ {
+     struct iovec
diff --git a/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_wait.d b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_wait.d
new file mode 100644
index 0000000..83d701d
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_sys_wait.d
@@ -0,0 +1,46 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/sys/posix/sys/wait.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/sys/wait.d
+@@ -113,6 +113,30 @@ 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         = 0x00000001;	/* don't hang in wait */
++    enum WUNTRACED       = 0x00000002;	/* tell about stopped,
++ 					   untraced children */
++    enum WALTSIG         = 0x00000004;	/* wait for processes that exit
++ 					   with an alternate signal (i.e.
++ 					   not SIGCHLD) */
++    enum WALLSIG         = 0x00000008;	/* wait for processes that exit
++ 					   with any signal, i.e. SIGCHLD
++ 					   and alternates */
++
++    pure nothrow int _WSTATUS(int x)    { return x & 0x7f; }
++    enum	_WSTOPPED      = 0x7f;		/* _WSTATUS if process is stopped */
++    pure nothrow int WIFSTOPPED(int x)	{ return _WSTATUS(x) == _WSTOPPED; }
++    pure nothrow int WSTOPSIG(int x)	{ return x >>> 8 & 0xff; }
++    pure nothrow int WIFSIGNALED(int x)	{ return _WSTATUS(x) != _WSTOPPED && _WSTATUS(x) != 0; }
++    pure nothrow int WTERMSIG(int x)	{ return _WSTATUS(x); }
++    pure nothrow int WIFEXITED(int x)	{ return _WSTATUS(x) == 0; }
++    pure nothrow int WEXITSTATUS(int x)	{ return x >>> 8 & 0xff; }
++/* MISSING:
++WIFCONTINUED
++*/
++}
+ else version (Solaris)
+ {
+     enum WNOHANG        = 64;
+@@ -205,6 +229,10 @@ else version (FreeBSD)
+ 
+     // http://www.freebsd.org/projects/c99/
+ }
++else version( NetBSD )
++{
++    // Empty for now.
++}
+ else version (Solaris)
+ {
+     enum WEXITED = 1;
diff --git a/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_time.d b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_time.d
new file mode 100644
index 0000000..256d326
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_time.d
@@ -0,0 +1,98 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/sys/posix/time.d.orig	2016-01-21 15:39:03.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,10 @@ 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 )
++{
++    enum CLOCK_MONOTONIC =3;
++}
+ else version (OSX)
+ {
+     // No CLOCK_MONOTONIC defined
+@@ -245,6 +253,43 @@ else version( FreeBSD )
+     int timer_getoverrun(timer_t);
+     int timer_settime(timer_t, int, in itimerspec*, itimerspec*);
+ }
++ else version( NetBSD )
++{
++  // MISSING:
++  /*
++CLOCK_PROCESS_CPUTIME_ID (TMR|CPT)
++CLOCK_THREAD_CPUTIME_ID (TMR|TCT)
++  */
++// NOTE: timespec must be defined in core.sys.posix.signal to break
++//       a circular import.
++    // struct timespec
++    // {
++    //     time_t tv_sec;
++    //     c_long tv_nsec;
++    // }
++
++    struct itimerspec
++    {
++      timespec it_interval;
++      timespec it_value;
++    }
++
++    enum CLOCK_REALTIME = 0;
++    enum TIMER_ABSTIME  = 0;
++
++    alias int clockid_t;
++    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 +383,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 +443,13 @@ else version( FreeBSD )
+     //tm*   getdate(in char*);
+     char* strptime(in char*, in char*, tm*);
+ }
++else version( NetBSD )
++{
++    extern __gshared int    daylight;
++
++    tm*   getdate(in char*);
++    char* strptime(in char*, in char*, tm*);
++}
+ else version (Solaris)
+ {
+     extern __gshared c_long timezone, altzone;
diff --git a/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_ucontext.d b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_ucontext.d
new file mode 100644
index 0000000..4332e4f
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_ucontext.d
@@ -0,0 +1,42 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/sys/posix/ucontext.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/sys/posix/ucontext.d
+@@ -701,6 +701,37 @@ else version( FreeBSD )
+         int[4]          __spare__;
+     }
+ }
++else version( NetBSD )
++{
++    alias __ucontext ucontext_t;
++
++    struct __ucontext {
++	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 */
++//#if defined(_UC_MACHINE_PAD)
++//	long		__uc_pad[_UC_MACHINE_PAD];
++    }
++
++    version( X86_64 )
++    {
++        enum _NGREG = 26;
++	alias c_ulong  __greg_t;
++        alias __greg_t[_NGREG] __gregset_t;
++        alias char[512] __fpregset_t; //__aligned(8);
++
++        struct mcontext_t {
++      	    __gregset_t	__gregs;
++	    __greg_t	_mc_tlsbase;
++	    __fpregset_t	__fpregs;
++        }
++    }
++    else
++      static assert(false, "Unsupported architecture");
++
++}
+ else version ( Solaris )
+ {
+     alias uint[4] upad128_t;
diff --git a/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_unistd.d b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_unistd.d
new file mode 100644
index 0000000..17e0c88b
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_sys_posix_unistd.d
@@ -0,0 +1,168 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/sys/posix/unistd.d.orig	2016-01-21 15:39:03.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,117 @@ else version( FreeBSD )
+         _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS =  14,
+     }
+ }
++else version( NetBSD )
++{
++    enum
++    {
++        F_ULOCK	       = 0,	/* unlock locked section */
++     	F_LOCK	       = 1,	/* lock a section for exclusive use */
++     	F_TLOCK	       = 2,	/* test and lock a section for exclusive use */
++     	F_TEST	       = 3,	/* test a section for locks by other procs */
++    }
++    enum
++    {
++        _SC_ARG_MAX	        =  1,
++	_SC_CHILD_MAX		=  2,
++	_O_SC_CLK_TCK		=  3, /* Old version, always 100 */
++	_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_PAGE_SIZE		= _SC_PAGESIZE,	/* 1170 compatibility */
++	_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, /* New, variable version */
++	_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,
++    }
++}
+ else version( CRuntime_Bionic )
+ {
+     enum F_OK       = 0;
+@@ -1260,6 +1376,33 @@ 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);
++    int        fchdir(int);
++    c_long     gethostid();
++    pid_t      getpgid(pid_t);
++    pid_t      getpgrp();
++    pid_t      getsid(pid_t);
++    char*      getwd(char*); // LEGACY
++    int        lchown(in char*, uid_t, gid_t);
++    int        lockf(int, int, off_t);
++    int        nice(int);
++    ssize_t    pread(int, void*, size_t, off_t);
++    ssize_t    pwrite(int, in void*, size_t, off_t);
++    int        setpgid(pid_t, pid_t);
++    int        setpgrp(pid_t, pid_t);
++    int        setregid(gid_t, gid_t);
++    int        setreuid(uid_t, uid_t);
++    void       swab(in void*, void*, ssize_t);
++    void       sync();
++    int        truncate(in char*, off_t);
++    useconds_t ualarm(useconds_t, useconds_t);
++    int        usleep(useconds_t);
++    pid_t      vfork();
++}
+ else version( CRuntime_Bionic )
+ {
+     int        fchdir(int) @trusted;
diff --git a/ldc-git/patches/patch-runtime_druntime_src_core_thread.d b/ldc-git/patches/patch-runtime_druntime_src_core_thread.d
new file mode 100644
index 0000000..a717698
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_thread.d
@@ -0,0 +1,29 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/thread.d.orig	2016-02-04 22:58:14.000000000 +0000
++++ runtime/druntime/src/core/thread.d
+@@ -3195,6 +3195,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_getattr_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 +3323,16 @@ private void* getStackBottom() nothrow
+         pthread_attr_destroy(&attr);
+         return addr + size;
+     }
++    else version (NetBSD)
++    {
++        pthread_attr_t attr;
++        void* addr; size_t size;
++
++        pthread_getattr_np(pthread_self(), &attr);
++        pthread_attr_getstack(&attr, &addr, &size);
++        pthread_attr_destroy(&attr);
++        return addr + size;
++    }
+     else version (Solaris)
+     {
+         stack_t stk;
diff --git a/ldc-git/patches/patch-runtime_druntime_src_core_time.d b/ldc-git/patches/patch-runtime_druntime_src_core_time.d
new file mode 100644
index 0000000..c74526e
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_core_time.d
@@ -0,0 +1,39 @@
+$NetBSD$
+
+--- runtime/druntime/src/core/time.d.orig	2016-01-21 15:39:03.000000000 +0000
++++ runtime/druntime/src/core/time.d
+@@ -304,6 +304,11 @@ else version(FreeBSD) enum ClockType
+     uptimeCoarse = 9,
+     uptimePrecise = 10,
+ }
++else version(NetBSD) enum ClockType
++{
++     normal,
++     processCPUTime = 4,
++} 
+ else version(Solaris) enum ClockType
+ {
+     normal = 0,
+@@ -359,6 +364,22 @@ version(Posix)
+             case second: assert(0);
+             }
+         }
++	else version(NetBSD)
++	{
++	    enum
++	    {
++	        CLOCK_REALTIME,
++	        CLOCK_VIRTUAL,
++                CLOCK_PROF,
++                CLOCK_MONOTONIC,
++	    }
++
++	    with(ClockType) final switch(clockType)
++	    {
++            case normal: return CLOCK_MONOTONIC; // Should it be CLOCK_REALTIME?
++            case processCPUTime: return CLOCK_PROF; // Should it be CLOCK_VIRTUAL?
++            }
++	}
+         else version(Solaris)
+         {
+             import core.sys.solaris.time;
diff --git a/ldc-git/patches/patch-runtime_druntime_src_rt_sections.d b/ldc-git/patches/patch-runtime_druntime_src_rt_sections.d
new file mode 100644
index 0000000..c615159
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_rt_sections.d
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- runtime/druntime/src/rt/sections.d.orig	2016-01-21 15:39:03.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-git/patches/patch-runtime_druntime_src_rt_sections__elf__shared.d b/ldc-git/patches/patch-runtime_druntime_src_rt_sections__elf__shared.d
new file mode 100644
index 0000000..31ab396
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_rt_sections__elf__shared.d
@@ -0,0 +1,25 @@
+$NetBSD$
+
+--- runtime/druntime/src/rt/sections_elf_shared.d.orig	2016-01-21 15:39:03.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");
diff --git a/ldc-git/patches/patch-runtime_druntime_src_rt_sections__ldc.d b/ldc-git/patches/patch-runtime_druntime_src_rt_sections__ldc.d
new file mode 100644
index 0000000..0d0a499
--- /dev/null
+++ b/ldc-git/patches/patch-runtime_druntime_src_rt_sections__ldc.d
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- runtime/druntime/src/rt/sections_ldc.d.orig	2016-01-21 15:39:03.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;


Home | Main Index | Thread Index | Old Index