$NetBSD$

--- src/dmd/backend/cdef.h.orig	2010-12-20 20:02:36.000000000 +0000
+++ src/dmd/backend/cdef.h
@@ -25,6 +25,7 @@
         linux           Linux
         __APPLE__       Mac OSX
         __FreeBSD__     FreeBSD
+        __NetBSD__      NetBSD
         __sun&&__SVR4   Solaris, OpenSolaris (yes, both macros are necessary)
         __OS2__         IBM OS/2
         DOS386          32 bit DOS extended executable
@@ -119,6 +120,11 @@ One and only one of these macros must be
  * with these goals, and should be fixed.
  */
 
+/* NetBSD Version
+ * --------------
+ * Strongly oriented on the FreeBSD Version, read there for now.
+ */
+
 /* Solaris Version
  * -------------
  * There are two main issues: hosting the compiler on Solaris,
@@ -167,13 +173,18 @@ One and only one of these macros must be
 #endif
 
 // Set to 1 using the makefile
+#ifndef TARGET_NETBSD
+#define TARGET_NETBSD  0               // target is a NetBSD executable
+#endif
+
+// Set to 1 using the makefile
 #ifndef TARGET_SOLARIS
 #define TARGET_SOLARIS  0               // target is a Solaris executable
 #endif
 
 // This is the default
 #ifndef TARGET_WINDOS
-#define TARGET_WINDOS   (!(TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS))
+#define TARGET_WINDOS   (!(TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_NETBSD || TARGET_SOLARIS))
 #endif
 
 #if __GNUC__
@@ -242,7 +253,7 @@ One and only one of these macros must be
 
 // Precompiled header variations
 #define MEMORYHX        (_WINDLL && _WIN32)     // HX and SYM files are cached in memory
-#define MMFIO           (_WIN32 || linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4)  // if memory mapped files
+#define MMFIO           (_WIN32 || linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 || __NetBSD__)  // if memory mapped files
 #define LINEARALLOC     _WIN32  // if we can reserve address ranges
 
 // H_STYLE takes on one of these precompiled header methods
@@ -458,7 +469,7 @@ typedef unsigned        targ_uns;
 #define DOUBLESIZE      8
 #if TARGET_OSX
 #define LNGDBLSIZE      16      // 80 bit reals
-#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_NETBSD || TARGET_SOLARIS
 #define LNGDBLSIZE      12      // 80 bit reals
 #else
 #define LNGDBLSIZE      10      // 80 bit reals
@@ -509,7 +520,7 @@ typedef targ_uns        targ_size_t;    
 #define OMFOBJ          TARGET_WINDOS
 #endif
 #ifndef ELFOBJ
-#define ELFOBJ          (TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS)
+#define ELFOBJ          (TARGET_LINUX || TARGET_FREEBSD || TARGET_NETBSD || TARGET_SOLARIS)
 #endif
 #ifndef MACHOBJ
 #define MACHOBJ         TARGET_OSX
@@ -704,10 +715,12 @@ struct Config
 #define EX_FREEBSD64    0x80000
 #define EX_SOLARIS      0x100000
 #define EX_SOLARIS64    0x200000
+#define EX_NETBSD       0x400000
+#define EX_NETBSD64     0x800000
 
 #define EX_flat         (EX_OS2 | EX_NT | EX_LINUX | EX_WIN64 | EX_LINUX64 | \
                          EX_OSX | EX_OSX64 | EX_FREEBSD | EX_FREEBSD64 | \
-                         EX_SOLARIS | EX_SOLARIS64)
+                         EX_SOLARIS | EX_SOLARIS64 | EX_NETBSD | EX_NETBSD64)
 #define EX_dos          (EX_DOSX | EX_ZPM | EX_RATIONAL | EX_PHARLAP | \
                          EX_COM | EX_MZ /*| EX_WIN16*/)
 
@@ -760,7 +773,7 @@ struct Config
 #define CFG3relax       0x200   // relaxed type checking (C only)
 #define CFG3cpp         0x400   // C++ compile
 #define CFG3igninc      0x800   // ignore standard include directory
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_NETBSD || TARGET_SOLARIS
 #define CFG3mars        0x1000  // use mars libs and headers
 #define NO_FAR          (TRUE)  // always ignore __far and __huge keywords
 #else
@@ -772,7 +785,7 @@ struct Config
 #define CFG3cppcomment  0x8000  // allow C++ style comments
 #define CFG3wkfloat     0x10000 // make floating point references weak externs
 #define CFG3digraphs    0x20000 // support ANSI C++ digraphs
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_NETBSD || TARGET_SOLARIS
 #define CFG3semirelax   0x40000 // moderate relaxed type checking
 #endif
 #define CFG3pic         0x80000 // position independent code
@@ -975,7 +988,7 @@ union eve
 #define SYMBOLZERO
 #endif
 
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_NETBSD || TARGET_SOLARIS
 #define UNIXFIELDS      (unsigned)-1,(unsigned)-1,0,0,
 #elif TARGET_OSX
 #define UNIXFIELDS      (unsigned)-1,(unsigned)-1,0,0,0,
