From f40ecb6165036088fb75e1f51066c3e9e289f26d Mon Sep 17 00:00:00 2001
From: raefaldhia <raefaldhiamartya@gmail.com>
Date: Sat, 1 Apr 2017 07:42:48 +0000
Subject: Add platform support


diff --git a/src/backend/backconfig.c b/src/backend/backconfig.c
index a3b3c19..c9a6dab 100644
--- a/src/backend/backconfig.c
+++ b/src/backend/backconfig.c
@@ -171,6 +171,23 @@ void out_config_init(
         config.flags3 |= CFG3pic;
     config.objfmt = OBJ_ELF;
 #endif
+#if TARGET_HAIKU
+    if (model == 64)
+    {   config.exe = EX_HAIKU64;
+        config.fpxmmregs = TRUE;
+    }
+    else
+    {
+        config.exe = EX_HAIKU;
+        if (!exe)
+            config.flags |= CFGromable; // put switch tables in code segment
+    }
+    config.flags |= CFGnoebp;
+    config.flags |= CFGalwaysframe;
+    if (!exe)
+        config.flags3 |= CFG3pic;
+    config.objfmt = OBJ_ELF;
+#endif
     config.flags2 |= CFG2nodeflib;      // no default library
     config.flags3 |= CFG3eseqds;
 #if 0
@@ -303,7 +320,7 @@ void util_set32()
         tysize[TYjhandle + i] = LONGSIZE;
         tysize[TYnptr + i] = LONGSIZE;
         tysize[TYnref + i] = LONGSIZE;
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         tysize[TYldouble + i] = 12;
         tysize[TYildouble + i] = 12;
         tysize[TYcldouble + i] = 24;
@@ -335,7 +352,7 @@ void util_set32()
         tyalignsize[TYjhandle + i] = LONGSIZE;
         tyalignsize[TYnref + i] = LONGSIZE;
         tyalignsize[TYnptr + i] = LONGSIZE;
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         tyalignsize[TYldouble + i] = 4;
         tyalignsize[TYildouble + i] = 4;
         tyalignsize[TYcldouble + i] = 4;
@@ -378,7 +395,7 @@ void util_set64()
         tysize[TYjhandle + i] = 8;
         tysize[TYnptr + i] = 8;
         tysize[TYnref + i] = 8;
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_OSX
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_OSX || TARGET_HAIKU
         tysize[TYldouble + i] = 16;
         tysize[TYildouble + i] = 16;
         tysize[TYcldouble + i] = 32;
@@ -406,7 +423,7 @@ void util_set64()
         tyalignsize[TYjhandle + i] = 8;
         tyalignsize[TYnptr + i] = 8;
         tyalignsize[TYnref + i] = 8;
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS || TARGET_HAIKU
         tyalignsize[TYldouble + i] = 16;
         tyalignsize[TYildouble + i] = 16;
         tyalignsize[TYcldouble + i] = 16;
diff --git a/src/backend/cc.h b/src/backend/cc.h
index 0507def..128b3f7 100644
--- a/src/backend/cc.h
+++ b/src/backend/cc.h
@@ -77,7 +77,7 @@ enum WM
         WM_badnumber    = 24,
         WM_ccast        = 25,
         WM_obsolete     = 26,
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         WM_skip_attribute   = 27, // skip GNUC attribute specification
         WM_warning_message  = 28, // preprocessor warning message
         WM_bad_vastart      = 29, // args for builtin va_start bad
@@ -110,7 +110,7 @@ enum LANG
 #include        "msgs2.h"
 #endif
 #include        "ty.h"
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
 #include        "../tk/mem.h"
 #else
 #include        "mem.h"
@@ -669,7 +669,7 @@ typedef struct FUNC_S
         #define Fnteh           0x08    // uses NT Structured EH
         #define Fdoinline       0x40    // do inline walk
         #define Foverridden     0x80    // ignore for overriding purposes
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         #define Fnowrite        0x100   // SCinline should never output definition
 #else
         #define Fjmonitor       0x100   // Jupiter synchronized function
@@ -1233,7 +1233,7 @@ struct Symbol
         #define SFLmutable      0x100000        // SCmember or SCfield is mutable
         #define SFLdyninit      0x200000        // symbol has dynamic initializer
         #define SFLtmp          0x400000        // symbol is a generated temporary
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         #define SFLthunk        0x40000 // symbol is temporary for thunk
 #endif
 
@@ -1450,7 +1450,7 @@ enum FL
         FLallocatmp,    // temp for built-in alloca()
         FLstack,        // offset from ESP rather than EBP
         FLdsymbol,      // it's a Dsymbol
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         // Change this, update debug.c too
         FLgot,          // global offset table entry outside this object file
         FLgotoff,       // global offset table entry inside this object file
diff --git a/src/backend/cdef.h b/src/backend/cdef.h
index 2dc4657..6fc20ea 100644
--- a/src/backend/cdef.h
+++ b/src/backend/cdef.h
@@ -193,9 +193,14 @@ One and only one of these macros must be set by the makefile:
 #define TARGET_SOLARIS  0               // target is a Solaris executable
 #endif
 
+// Set to 1 using the makefile
+#ifndef TARGET_HAIKU
+#define TARGET_HAIKU  0               // target is a Solaris executable
+#endif
+
 // This is the default
 #ifndef TARGET_WINDOS
-#define TARGET_WINDOS   (!(TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS))
+#define TARGET_WINDOS   (!(TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU))
 #endif
 
 #if __GNUC__
@@ -271,7 +276,7 @@ typedef long double longdouble;
 
 // Precompiled header variations
 #define MEMORYHX        (_WINDLL && _WIN32)     // HX and SYM files are cached in memory
-#define MMFIO           (_WIN32 || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun)  // if memory mapped files
+#define MMFIO           (_WIN32 || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__)  // if memory mapped files
 #define LINEARALLOC     _WIN32  // if we can reserve address ranges
 
 // H_STYLE takes on one of these precompiled header methods
@@ -476,7 +481,7 @@ typedef unsigned        targ_uns;
 #define DOUBLESIZE      8
 #if TARGET_OSX
 #define LNGDBLSIZE      16      // 80 bit reals
-#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
 #define LNGDBLSIZE      12      // 80 bit reals
 #else
 #define LNGDBLSIZE      10      // 80 bit reals
@@ -496,7 +501,7 @@ typedef unsigned        targ_uns;
 #define REGMASK         0xFFFF
 
 // targ_llong is also used to store host pointers, so it should have at least their size
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_OSX || MARS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_OSX || MARS || TARGET_HAIKU
 typedef targ_llong      targ_ptrdiff_t; /* ptrdiff_t for target machine  */
 typedef targ_ullong     targ_size_t;    /* size_t for the target machine */
 #else
@@ -527,14 +532,14 @@ typedef targ_uns        targ_size_t;    /* size_t for the target machine */
 #define OMFOBJ          TARGET_WINDOS
 #endif
 #ifndef ELFOBJ
-#define ELFOBJ          (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS)
+#define ELFOBJ          (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU)
 #endif
 #ifndef MACHOBJ
 #define MACHOBJ         TARGET_OSX
 #endif
 
 #define SYMDEB_CODEVIEW TARGET_WINDOS
-#define SYMDEB_DWARF    (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_OSX)
+#define SYMDEB_DWARF    (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_OSX || TARGET_HAIKU)
 
 #define TOOLKIT_H
 
@@ -733,11 +738,14 @@ struct Config
 #define EX_SOLARIS64    0x200000
 #define EX_OPENBSD      0x400000
 #define EX_OPENBSD64    0x800000
+#define EX_HAIKU      	0x1000000
+#define EX_HAIKU64    	0x2000000
 
 #define EX_flat         (EX_OS2 | EX_NT | EX_LINUX | EX_WIN64 | EX_LINUX64 | \
                          EX_OSX | EX_OSX64 | EX_FREEBSD | EX_FREEBSD64 | \
                          EX_OPENBSD | EX_OPENBSD64 | \
-                         EX_SOLARIS | EX_SOLARIS64)
+                         EX_SOLARIS | EX_SOLARIS64 | \
+                         EX_HAIKU | EX_HAIKU64)
 #define EX_dos          (EX_DOSX | EX_ZPM | EX_RATIONAL | EX_PHARLAP | \
                          EX_COM | EX_MZ /*| EX_WIN16*/)
 
@@ -792,7 +800,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_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
 #define CFG3mars        0x1000  // use mars libs and headers
 #define NO_FAR          (TRUE)  // always ignore __far and __huge keywords
 #else
@@ -804,7 +812,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_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
 #define CFG3semirelax   0x40000 // moderate relaxed type checking
 #endif
 #define CFG3pic         0x80000 // position independent code
@@ -1013,7 +1021,7 @@ union eve
 #define SYMBOLZERO
 #endif
 
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
 #define UNIXFIELDS      (unsigned)-1,(unsigned)-1,0,0,
 #elif TARGET_OSX
 #define UNIXFIELDS      (unsigned)-1,(unsigned)-1,0,0,0,
diff --git a/src/backend/cgcod.c b/src/backend/cgcod.c
index 726bf87..0f9dac5 100644
--- a/src/backend/cgcod.c
+++ b/src/backend/cgcod.c
@@ -2392,7 +2392,7 @@ reload:                                 /* reload result from memory    */
         case OPrelconst:
             c = cdrelconst(e,pretregs);
             break;
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         case OPgot:
             c = cdgot(e,pretregs);
             break;
diff --git a/src/backend/cgcv.c b/src/backend/cgcv.c
index c6e3d6c..5c3d1b1 100644
--- a/src/backend/cgcv.c
+++ b/src/backend/cgcv.c
@@ -17,7 +17,7 @@
 #include        <time.h>
 #include        <stdlib.h>
 
-#if _WIN32 || __linux__
+#if _WIN32 || __linux__ || __HAIKU__
 #include        <malloc.h>
 #endif
 
diff --git a/src/backend/cgelem.c b/src/backend/cgelem.c
index 07482d3..dc65de4 100644
--- a/src/backend/cgelem.c
+++ b/src/backend/cgelem.c
@@ -791,7 +791,7 @@ L1:
   e2 = e->E2;
   if (e2->Eoper == OPconst)
   {
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         if (e1->Eoper == OPrelconst && e1->EV.sp.Vsym->Sfl == FLgot)
                 goto ret;
 #endif
@@ -807,7 +807,7 @@ L1:
   }
   else if (e1->Eoper == OPconst)
   {
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         if (e2->Eoper == OPrelconst && e2->EV.sp.Vsym->Sfl == FLgot)
                 goto ret;
 #endif
@@ -4880,7 +4880,7 @@ STATIC elem * elvalist(elem *e, goal_t goal)
 
 #endif
 
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
 
     assert(I64); // va_start is not an intrinsic on 32-bit
     // (OPva_start &va)
diff --git a/src/backend/cgen.c b/src/backend/cgen.c
index ac2e139..34a7220 100644
--- a/src/backend/cgen.c
+++ b/src/backend/cgen.c
@@ -630,7 +630,7 @@ void searchfixlist(symbol *s)
                 // resolve directly.
                 if (s->Sseg == p->Lseg &&
                     (s->Sclass == SCstatic ||
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
                      (!(config.flags3 & CFG3pic) && s->Sclass == SCglobal)) &&
 #else
                         s->Sclass == SCglobal) &&
diff --git a/src/backend/cod1.c b/src/backend/cod1.c
index d56949b..be25a1d 100644
--- a/src/backend/cod1.c
+++ b/src/backend/cod1.c
@@ -1324,7 +1324,7 @@ code *getlvalue(code *pcs,elem *e,regm_t keepmsk)
     case FLextern:
         if (s->Sident[0] == '_' && memcmp(s->Sident + 1,"tls_array",10) == 0)
         {
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
             // Rewrite as GS:[0000], or FS:[0000] for 64 bit
             if (I64)
             {
@@ -1370,7 +1370,7 @@ code *getlvalue(code *pcs,elem *e,regm_t keepmsk)
 #if TARGET_SEGMENTED
     case FLcsdata:
 #endif
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     case FLgot:
     case FLgotoff:
     case FLtlsdata:
@@ -1420,7 +1420,7 @@ code *getlvalue(code *pcs,elem *e,regm_t keepmsk)
             pcs->Iflags |= CFcs | CFoff;
         }
 #endif
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         if (I64 && config.flags3 & CFG3pic &&
             (fl == FLtlsdata || s->ty() & mTYthread))
         {
@@ -1869,12 +1869,12 @@ code *callclib(elem *e,unsigned clib,regm_t *pretregs,regm_t keepmask)
 {
     //printf("callclib(e = %p, clib = %d, *pretregs = %s, keepmask = %s\n", e, clib, regm_str(*pretregs), regm_str(keepmask));
     //elem_print(e);
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
   static symbol lib[] =
   {
 /* Convert destroyed regs into saved regs       */
 #define Z(desregs)      (~(desregs) & (mBP| mES | ALLREGS))
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
 #define N(name) "_" name
 #else
 #define N(name) name
@@ -2106,7 +2106,7 @@ code *callclib(elem *e,unsigned clib,regm_t *pretregs,regm_t keepmask)
     {DOUBLEREGS_16,DOUBLEREGS_32,0,INFfloat,1,1},       // _INTDBL@     intdbl
     {mAX,mAX,0,INFfloat,1,1},                           // _DBLUNS@     dbluns
     {DOUBLEREGS_16,DOUBLEREGS_32,0,INFfloat,1,1},       // _UNSDBL@     unsdbl
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     {mDX|mAX,mAX,0,INF32|INFfloat,0,1},                 // _DBLULNG@    dblulng
 #else
     {mDX|mAX,mAX,0,INFfloat,1,1},                       // _DBLULNG@    dblulng
@@ -2119,7 +2119,7 @@ code *callclib(elem *e,unsigned clib,regm_t *pretregs,regm_t keepmask)
 
     {DOUBLEREGS_16,mDX|mAX,0,INFfloat,1,1},             // _DBLLLNG@
     {DOUBLEREGS_16,DOUBLEREGS_32,0,INFfloat,1,1},       // _LLNGDBL@
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     {DOUBLEREGS_16,mDX|mAX,0,INFfloat,2,2},             // _DBLULLNG@
 #else
     {DOUBLEREGS_16,mDX|mAX,0,INFfloat,1,1},             // _DBLULLNG@
@@ -2164,7 +2164,7 @@ code *callclib(elem *e,unsigned clib,regm_t *pretregs,regm_t keepmask)
             lib[i].Stypidx = 0;
 #endif
         }
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         clibldiv2.Stype = tsclib;
         clibuldiv2.Stype = tsclib;
         clibldiv3.Stype = tsclib;
@@ -2293,7 +2293,7 @@ code *callclib(elem *e,unsigned clib,regm_t *pretregs,regm_t keepmask)
   {
         code *cgot = NULL;
         bool pushebx = false;
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         if (I32)
         {
             /* Pass EBX on the stack instead, this is because EBX is used
@@ -2303,7 +2303,7 @@ code *callclib(elem *e,unsigned clib,regm_t *pretregs,regm_t keepmask)
             {
                 cgot = load_localgot();     // EBX gets set to this value
             }
-#if TARGET_LINUX || TARGET_FREEBSD
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_HAIKU
             switch (clib)
             {
                 case CLIBldiv:
@@ -2354,7 +2354,7 @@ code *callclib(elem *e,unsigned clib,regm_t *pretregs,regm_t keepmask)
         }
         if (pushebx)
         {
-#if TARGET_LINUX || TARGET_FREEBSD
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_HAIKU
             c = gen1(c, 0x50 + CX);                             // PUSH ECX
             c = gen1(c, 0x50 + BX);                             // PUSH EBX
             c = gen1(c, 0x50 + DX);                             // PUSH EDX
@@ -3083,7 +3083,7 @@ STATIC code * funccall(elem *e,unsigned numpara,unsigned numalign,regm_t *pretre
             if (tym1 == TYifunc)
                 c1 = gen1(c1,0x9C);                             // PUSHF
             ce = CNIL;
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
             if (s != tls_get_addr_sym)
             {
                 //printf("call %s\n", s->Sident);
@@ -3092,7 +3092,7 @@ STATIC code * funccall(elem *e,unsigned numpara,unsigned numalign,regm_t *pretre
 #endif
             ce = gencs(ce,farfunc ? 0x9A : 0xE8,0,fl,s);      // CALL extern
             code_orflag(ce, farfunc ? (CFseg | CFoff) : (CFselfrel | CFoff));
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
             if (s == tls_get_addr_sym)
             {
                 if (I64)
@@ -3125,7 +3125,7 @@ STATIC code * funccall(elem *e,unsigned numpara,unsigned numalign,regm_t *pretre
         assert(!I16 || (e11ty == TYnptr));
 #endif
         c = cat(c, load_localgot());
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         if (config.flags3 & CFG3pic && I32)
             keepmsk |= mBX;
 #endif
diff --git a/src/backend/cod2.c b/src/backend/cod2.c
index 3d7c2eb..e4c0863 100644
--- a/src/backend/cod2.c
+++ b/src/backend/cod2.c
@@ -175,7 +175,7 @@ code *cdorth(elem *e,regm_t *pretregs)
   {
         if (*pretregs & XMMREGS || tyvector(ty1))
             return orthxmm(e,pretregs);
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         return orth87(e,pretregs);
 #else
         return opdouble(e,pretregs,(e->Eoper == OPadd) ? CLIBdadd
@@ -874,7 +874,7 @@ code *cdmul(elem *e,regm_t *pretregs)
     {
         if (*pretregs & XMMREGS && oper != OPmod && tyxmmreg(tyml))
             return orthxmm(e,pretregs);
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         return orth87(e,pretregs);
 #else
         return opdouble(e,pretregs,(oper == OPmul) ? CLIBdmul : CLIBddiv);
@@ -4178,7 +4178,7 @@ code *getoffset(elem *e,unsigned reg)
 #endif
 
     case FLtlsdata:
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     {
       L5:
         if (config.flags3 & CFG3pic)
@@ -4305,7 +4305,7 @@ code *getoffset(elem *e,unsigned reg)
         goto L4;
 
     case FLextern:
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         if (e->EV.sp.Vsym->ty() & mTYthread)
             goto L5;
 #endif
@@ -4315,7 +4315,7 @@ code *getoffset(elem *e,unsigned reg)
 #endif
     case FLdata:
     case FLudata:
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     case FLgot:
     case FLgotoff:
 #endif
@@ -4639,7 +4639,7 @@ code *cdpost(elem *e,regm_t *pretregs)
 
   if (tyfloating(tyml))
   {
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         return post87(e,pretregs);
 #else
         if (config.inline8087)
@@ -5142,7 +5142,7 @@ code *cdddtor(elem *e,regm_t *pretregs)
     code *c = codelem(e->E1,pretregs,FALSE);
     gen1(c,0xC3);               // RET
 
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     if (config.flags3 & CFG3pic)
     {
         int nalign = 0;
diff --git a/src/backend/cod3.c b/src/backend/cod3.c
index 10dc347..279bbe7 100644
--- a/src/backend/cod3.c
+++ b/src/backend/cod3.c
@@ -622,7 +622,7 @@ regm_t regmask(tym_t tym, tym_t tyf)
             return mST0;
 
         case TYcfloat:
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
             if (I32 && tybasic(tyf) == TYnfunc)
                 return mDX | mAX;
 #endif
@@ -1363,7 +1363,7 @@ void doswitch(block *b)
         regm_t retregs = IDXREGS;
         if (dword)
             retregs |= mMSW;
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         if (I32 && config.flags3 & CFG3pic)
             retregs &= ~mBX;                            // need EBX for GOT
 #endif
@@ -1555,7 +1555,7 @@ void doswitch(block *b)
             genjmp(c,JNE,FLblock,list_block(b->Bsucc)); /* JNE default  */
         }
         ce = getregs(mCX|mDI);
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         if (config.flags3 & CFG3pic)
         {   // Add in GOT
             code *cx;
@@ -1635,7 +1635,7 @@ void doswitch(block *b)
         mod = (disp > 127) ? 2 : 1;     /* 1 or 2 byte displacement     */
         if (csseg)
             gen1(ce,SEGCS);             // table is in code segment
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         if (config.flags3 & CFG3pic)
         {                               // ADD EDX,(ncases-1)*2[EDI]
             ct = genc1(CNIL,0x03,modregrm(mod,DX,7),FLconst,disp);
@@ -1708,7 +1708,7 @@ void outjmptab(block *b)
                         break;
                 }
         }
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         if (I64)
         {
             if (config.flags3 & CFG3pic)
@@ -2286,7 +2286,7 @@ code *cdgot(elem *e, regm_t *pretregs)
     gen1(c, 0x58 + reg);                // L1: POP reg
 
     return cat(c,fixresult(e,retregs,pretregs));
-#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     regm_t retregs;
     unsigned reg;
     code *c;
@@ -2325,7 +2325,7 @@ code *cdgot(elem *e, regm_t *pretregs)
 
 code *load_localgot()
 {
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     if (config.flags3 & CFG3pic && I32)
     {
         if (localgot && !(localgot->Sflags & SFLdead))
@@ -2351,7 +2351,7 @@ code *load_localgot()
     return NULL;
 }
 
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
 /*****************************
  * Returns:
  *      # of bytes stored
@@ -2969,7 +2969,7 @@ code* prolog_frame(unsigned farfunc, unsigned* xlocalsize, bool* enter)
     if (config.wflags & WFincbp && farfunc)
         c = gen1(c,0x40 + BP);      /* INC  BP                      */
     if (config.target_cpu < TARGET_80286 ||
-        config.exe & (EX_LINUX | EX_LINUX64 | EX_OSX | EX_OSX64 | EX_FREEBSD | EX_FREEBSD64 | EX_SOLARIS | EX_SOLARIS64 | EX_WIN64) ||
+        config.exe & (EX_LINUX | EX_LINUX64 | EX_OSX | EX_OSX64 | EX_FREEBSD | EX_FREEBSD64 | EX_SOLARIS | EX_SOLARIS64 | EX_WIN64 | EX_HAIKU | EX_HAIKU64) ||
         !localsize ||
         config.flags & CFGstack ||
         (*xlocalsize >= 0x1000 && config.exe & EX_flat) ||
@@ -4159,7 +4159,7 @@ void cod3_thunk(symbol *sthunk,symbol *sfunc,unsigned p,tym_t thisty,
     sthunk->Soffset = thunkoffset;
     sthunk->Ssize = Coffset - thunkoffset; /* size of thunk */
     sthunk->Sseg = cseg;
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     objmod->pubdef(cseg,sthunk,sthunk->Soffset);
 #endif
 #if TARGET_WINDOS
@@ -6307,7 +6307,7 @@ STATIC void do64bit(enum FL fl,union evc *uev,int flags)
             // un-named external with is the start of .rodata or .data
         case FLextern:                      /* external data symbol         */
         case FLtlsdata:
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         case FLgot:
         case FLgotoff:
 #endif
@@ -6421,7 +6421,7 @@ STATIC void do32bit(enum FL fl,union evc *uev,int flags, int val)
         // un-named external with is the start of .rodata or .data
     case FLextern:                      /* external data symbol         */
     case FLtlsdata:
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     case FLgot:
     case FLgotoff:
 #endif
diff --git a/src/backend/cod4.c b/src/backend/cod4.c
index 2ac097c..204cb9f 100644
--- a/src/backend/cod4.c
+++ b/src/backend/cod4.c
@@ -824,7 +824,7 @@ code *cdaddass(elem *e,regm_t *pretregs)
 
     if (tyfloating(tyml))
     {
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
       if (op == OPnegass)
             c = cdnegass87(e,pretregs);
         else
@@ -1335,7 +1335,7 @@ code *cdmulass(elem *e,regm_t *pretregs)
 
     if (tyfloating(tyml))
     {
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         return opass87(e,pretregs);
 #else
         return opassdbl(e,pretregs,op);
@@ -1837,7 +1837,7 @@ code *cdcmp(elem *e,regm_t *pretregs)
     unsigned rex = (I64 && sz == 8) ? REX_W : 0;
     unsigned grex = rex << 16;          // 64 bit operands
 
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
   if (tyfloating(tym))                  /* if floating operation        */
   {
         retregs = mPSW;
@@ -2715,7 +2715,7 @@ code *cdcnvt(elem *e, regm_t *pretregs)
                     return xmmcnvt(e,pretregs);
                 if (I32 || I64)
                     return cdd_u32(e,pretregs);
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
                 retregs = mST0;
 #else
                 retregs = DOUBLEREGS;
diff --git a/src/backend/code.h b/src/backend/code.h
index 774eb93..77a341e 100644
--- a/src/backend/code.h
+++ b/src/backend/code.h
@@ -292,7 +292,7 @@ void WRcodlst (code *c );
 cd_t cdcomma;
 cd_t cdloglog;
 cd_t cdshift;
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
 cd_t cdindpic;
 #endif
 cd_t cdind;
diff --git a/src/backend/code_x86.h b/src/backend/code_x86.h
index 42b4370..e2c242a 100644
--- a/src/backend/code_x86.h
+++ b/src/backend/code_x86.h
@@ -116,7 +116,7 @@ enum // #defining R12-R15 interfere with setjmps' _JUMP_BUFFER members
 
 extern regm_t ALLREGS;
 extern regm_t BYTEREGS;
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     // To support positional independent code,
     // must be able to remove BX from available registers
 #define ALLREGS_INIT            (mAX|mBX|mCX|mDX|mSI|mDI)
diff --git a/src/backend/debug.c b/src/backend/debug.c
index a319f5a..20b2d20 100644
--- a/src/backend/debug.c
+++ b/src/backend/debug.c
@@ -91,7 +91,7 @@ void WRTYxx(tym_t t)
         dbg_printf("mTYconst|");
     if (t & mTYvolatile)
         dbg_printf("mTYvolatile|");
-#if !MARS && (__linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun)
+#if !MARS && (__linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__)
     if (t & mTYtransu)
         dbg_printf("mTYtransu|");
 #endif
@@ -270,7 +270,7 @@ void WRFL(enum FL fl)
          "local ","tlsdat",
          "bprel ","frameh","blocko","alloca",
          "stack ","dsym  ",
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
          "got   ","gotoff",
 #endif
         };
diff --git a/src/backend/dwarf.c b/src/backend/dwarf.c
index 73a71e7..4ae325b 100644
--- a/src/backend/dwarf.c
+++ b/src/backend/dwarf.c
@@ -18,11 +18,11 @@
 #include        <fcntl.h>
 #include        <ctype.h>
 
-#if __DMC__ || __linux__
+#if __DMC__ || __linux__ || __HAIKU__
 #include        <malloc.h>
 #endif
 
-#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
 #include        <signal.h>
 #include        <unistd.h>
 #include        <errno.h>
diff --git a/src/backend/el.c b/src/backend/el.c
index de5ff31..cc65d45 100644
--- a/src/backend/el.c
+++ b/src/backend/el.c
@@ -1154,7 +1154,7 @@ Lnodep:
 
 symbol *el_alloc_localgot()
 {
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     /* Since localgot is a local variable to each function,
      * localgot must be set back to NULL
      * at the start of code gen for each function.
@@ -1279,7 +1279,7 @@ elem *el_picvar(symbol *s)
     return e;
 }
 #endif
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
 
 elem *el_picvar(symbol *s)
 {   elem *e;
@@ -1474,13 +1474,13 @@ elem * el_var(symbol *s)
 
     //printf("el_var(s = '%s')\n", s->Sident);
     //printf("%x\n", s->Stype->Tty);
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     if (config.flags3 & CFG3pic &&
         !tyfunc(s->ty()))
         // Position Independent Code
         return el_picvar(s);
 #endif
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     if (config.flags3 & CFG3pic && tyfunc(s->ty()))
     {
         switch (s->Sclass)
@@ -1506,7 +1506,7 @@ elem * el_var(symbol *s)
         //printf("thread local %s\n", s->Sident);
 #if TARGET_OSX
         ;
-#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         /* For 32 bit:
          * Generate for var locals:
          *      MOV reg,GS:[00000000]   // add GS: override in back end
@@ -1625,7 +1625,7 @@ elem * el_var(symbol *s)
 {   elem *e;
 
     //printf("el_var(s = '%s')\n", s->Sident);
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     if (config.flags3 & CFG3pic && !tyfunc(s->ty()))
         return el_picvar(s);
 #endif
@@ -1716,7 +1716,7 @@ elem * el_ptr(symbol *s)
         return e;
     }
 #endif
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     if (config.flags3 & CFG3pic &&
         tyfunc(s->ty()))
         e = el_picvar(s);
diff --git a/src/backend/elfobj.c b/src/backend/elfobj.c
index d7f1cd4..d8209f2 100644
--- a/src/backend/elfobj.c
+++ b/src/backend/elfobj.c
@@ -50,6 +50,8 @@
 #  define ELFOSABI ELFOSABI_SYSV
 # elif TARGET_OPENBSD
 #  define ELFOSABI ELFOSABI_OPENBSD
+# elif TARGET_HAIKU
+#  define ELFOSABI ELFOSABI_HAIKU
 # else
 #  error "No ELF OS ABI defined.  Please fix"
 # endif
@@ -77,7 +79,7 @@ char *obj_mangle2(Symbol *s,char *dest);
  * section registration and will no longer create global bracket
  * symbols (_deh_beg,_deh_end,_tlsstart,_tlsend).
  */
-#define REQUIRE_DSO_REGISTRY (DMDV2 && (TARGET_LINUX || TARGET_FREEBSD))
+#define REQUIRE_DSO_REGISTRY (DMDV2 && (TARGET_LINUX || TARGET_FREEBSD || TARGET_HAIKU))
 
 /***************************************************
  * Correspondence of relocation types
@@ -2017,7 +2019,7 @@ char *obj_mangle2(Symbol *s,char *dest)
             }
             break;
         case mTYman_std:
-#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
             if (tyfunc(s->ty()) && !variadic(s->Stype))
 #else
             if (!(config.flags4 & CFG4oldstdmangle) &&
diff --git a/src/backend/evalu8.c b/src/backend/evalu8.c
index ec8c7b8..5a12dfb 100644
--- a/src/backend/evalu8.c
+++ b/src/backend/evalu8.c
@@ -547,7 +547,7 @@ elem *poptelem(elem *e)
                 if (e2->Eoper == OPconst)
                 {   targ_int i = e2->EV.Vint;
 
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
                     if (i && e1->EV.sp.Vsym->Sfl == FLgot)
                         break;
 #endif
diff --git a/src/backend/global.h b/src/backend/global.h
index 02b0abb..b10d6d0 100644
--- a/src/backend/global.h
+++ b/src/backend/global.h
@@ -502,7 +502,7 @@ void dwarf_CFA_offset(int reg, int offset);
 void dwarf_CFA_args_size(size_t sz);
 #endif
 
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
 elem * exp_isconst();
 elem *lnx_builtin_next_arg(elem *efunc,list_t arglist);
 char *lnx_redirect_funcname(const char *);
diff --git a/src/backend/machobj.c b/src/backend/machobj.c
index aabc365..547293e 100644
--- a/src/backend/machobj.c
+++ b/src/backend/machobj.c
@@ -17,11 +17,11 @@
 #include        <fcntl.h>
 #include        <ctype.h>
 
-#if _WIN32 || __linux__
+#if _WIN32 || __linux__ || __HAIKU__
 #include        <malloc.h>
 #endif
 
-#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
 #include        <signal.h>
 #include        <unistd.h>
 #endif
@@ -1925,7 +1925,7 @@ char *obj_mangle2(Symbol *s,char *dest)
                 *p = toupper(*p);
             break;
         case mTYman_std:
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
             if (tyfunc(s->ty()) && !variadic(s->Stype))
 #else
             if (!(config.flags4 & CFG4oldstdmangle) &&
diff --git a/src/backend/melf.h b/src/backend/melf.h
index 69276ee..b32b925 100644
--- a/src/backend/melf.h
+++ b/src/backend/melf.h
@@ -49,6 +49,7 @@ typedef struct
             #define ELFOSABI_LINUX      3
             #define ELFOSABI_FREEBSD    9
             #define ELFOSABI_OPENBSD    12
+            #define ELFOSABI_HAIKU      15            
             #define ELFOSABI_ARM        97      /* ARM */
             #define ELFOSABI_STANDALONE 255     /* Standalone/embedded */
 
diff --git a/src/backend/mscoffobj.c b/src/backend/mscoffobj.c
index e7d11c1..818af68 100644
--- a/src/backend/mscoffobj.c
+++ b/src/backend/mscoffobj.c
@@ -18,7 +18,7 @@
 #include        <ctype.h>
 #include        <time.h>
 
-#if _WIN32 || __linux__
+#if _WIN32 || __linux__ || __HAIKU__
 #include        <malloc.h>
 #endif
 
@@ -1797,7 +1797,7 @@ char *obj_mangle2(Symbol *s,char *dest)
             strupr(dest);               // to upper case
             break;
         case mTYman_std:
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
             if (tyfunc(s->ty()) && !variadic(s->Stype))
 #else
             if (!(config.flags4 & CFG4oldstdmangle) &&
diff --git a/src/backend/nteh.c b/src/backend/nteh.c
index 2e0771a..56a4af3 100644
--- a/src/backend/nteh.c
+++ b/src/backend/nteh.c
@@ -315,7 +315,7 @@ code *nteh_prolog()
         /* An sindex value of -2 is a magic value that tells the
          * stack unwinder to skip this frame.
          */
-        assert(config.exe & (EX_LINUX | EX_LINUX64 | EX_OSX | EX_OSX64 | EX_FREEBSD | EX_FREEBSD64 | EX_SOLARIS | EX_SOLARIS64 | EX_OPENBSD | EX_OPENBSD64));
+        assert(config.exe & (EX_LINUX | EX_LINUX64 | EX_OSX | EX_OSX64 | EX_FREEBSD | EX_FREEBSD64 | EX_SOLARIS | EX_SOLARIS64 | EX_OPENBSD | EX_OPENBSD64 | EX_HAIKU | EX_HAIKU64));
         cs.Iop = 0x68;
         cs.Iflags = 0;
         cs.Irex = 0;
diff --git a/src/backend/obj.h b/src/backend/obj.h
index 9d00631..9210ca3 100644
--- a/src/backend/obj.h
+++ b/src/backend/obj.h
@@ -86,7 +86,7 @@ struct Obj
     VIRTUAL void func_start(Symbol *sfunc);
     VIRTUAL void func_term(Symbol *sfunc);
 
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     static unsigned addstr(Outbuffer *strtab, const char *);
     static void gotref(symbol *s);
     static symbol *getGOTsym();
diff --git a/src/backend/optabgen.c b/src/backend/optabgen.c
index 449767c..5aaa81c 100644
--- a/src/backend/optabgen.c
+++ b/src/backend/optabgen.c
@@ -799,7 +799,7 @@ void fltables()
                 case FLctor:    segfl[i] = -1;  break;
                 case FLdtor:    segfl[i] = -1;  break;
                 case FLdsymbol: segfl[i] = -1;  break;
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
                 case FLgot:     segfl[i] = -1;  break;
                 case FLgotoff:  segfl[i] = -1;  break;
 #endif
@@ -1113,7 +1113,7 @@ void dotytab()
             case TYcldouble:
 #if TARGET_OSX
                 sz = 16;
-#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
                 sz = 4;
 #elif TARGET_WINDOS
                 sz = 2;
diff --git a/src/backend/os.c b/src/backend/os.c
index cac16f5..737b548 100644
--- a/src/backend/os.c
+++ b/src/backend/os.c
@@ -25,7 +25,7 @@
 #include <sys\stat.h>
 #endif
 
-#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -666,7 +666,7 @@ int os_file_exists(const char *name)
     if (!find)
         return 0;
     return (find->attribute & FA_DIREC) ? 2 : 1;
-#elif __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#elif __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
     struct stat buf;
 
     return stat(name,&buf) == 0;        /* file exists if stat succeeded */
@@ -743,7 +743,7 @@ char *file_8dot3name(const char *filename)
 
 int file_write(char *name, void *buffer, unsigned len)
 {
-#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
     int fd;
     ssize_t numwritten;
 
@@ -819,7 +819,7 @@ err:
 
 int file_createdirs(char *name)
 {
-#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
     return 1;
 #endif
 #if _WIN32
diff --git a/src/backend/out.c b/src/backend/out.c
index 608ede1..7ffb0f3 100644
--- a/src/backend/out.c
+++ b/src/backend/out.c
@@ -366,7 +366,7 @@ void outdata(symbol *s)
                     objmod->reftocodeseg(seg,offset,dt->DTabytes);
                 else
 #endif
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
                     objmod->reftodatseg(seg,offset,dt->DTabytes,dt->DTseg,flags);
 #else
                 /*else*/ if (dt->DTseg == DATA)
diff --git a/src/backend/strtold.c b/src/backend/strtold.c
index 4f284c6..64e0829 100644
--- a/src/backend/strtold.c
+++ b/src/backend/strtold.c
@@ -19,7 +19,7 @@
 #include        <fenv.h>
 #include        <fltpnt.h>
 #endif
-#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
 #include        <errno.h>
 #endif
 
@@ -31,7 +31,7 @@ extern char * __cdecl __locale_decpoint;
 void __pascal __set_errno (int an_errno);
 #endif
 
-#if _WIN32 || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if _WIN32 || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
 
 #if 0
 /* This is for compilers that don't support hex float literals,
diff --git a/src/backend/token.h b/src/backend/token.h
index e12c828..68ac7e4 100644
--- a/src/backend/token.h
+++ b/src/backend/token.h
@@ -174,7 +174,7 @@ enum TK {
         TK_stdcall,
         TK_syscall,
         TK_try,
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         TK_attribute,
         TK_extension,
         TK_format,
@@ -206,7 +206,7 @@ enum TK {
         TKandand,TKshl,TKshr,TKrcur,TKeq,TKaddass,TKminass,TKmulass,TKdivass,
         TKmodass,TKshrass,TKshlass,TKandass,TKxorass,TKorass,TKsemi,
         TKadd,TKellipsis,
-#if !TX86 || TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if !TX86 || TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         TKdollar,
 #endif
 
diff --git a/src/backend/ty.h b/src/backend/ty.h
index 3e826eb..cd6124e 100644
--- a/src/backend/ty.h
+++ b/src/backend/ty.h
@@ -169,7 +169,7 @@ extern int TYptrdiff, TYsize, TYsize_t;
 #define mTYnothrow      0x00200000       // nothrow function
 
 #if !MARS
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
 #define mTYnoret        0x01000000        // function has no return
 #define mTYtransu       0x01000000        // transparent union
 #else
@@ -183,7 +183,7 @@ extern int TYptrdiff, TYsize, TYsize_t;
 #define mTYsyscall      0x40000000
 #define mTYjava         0x80000000
 
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
 #define mTYTFF          0xFE000000
 #else
 #define mTYTFF          0xFF000000
@@ -351,7 +351,7 @@ extern const tym_t tytouns[];
 /* Array to give the 'relaxed' type for relaxed type checking   */
 extern unsigned char _tyrelax[];
 #define type_relax      (config.flags3 & CFG3relax)     // !=0 if relaxed type checking
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
 #define type_semirelax  (config.flags3 & CFG3semirelax) // !=0 if semi-relaxed type checking
 #else
 #define type_semirelax  type_relax
diff --git a/src/backend/util2.c b/src/backend/util2.c
index 74ee4d0..913ba6e 100644
--- a/src/backend/util2.c
+++ b/src/backend/util2.c
@@ -142,7 +142,7 @@ void util_progress(int linnum)
 
 #endif
 
-#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || _MSC_VER
+#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || _MSC_VER || __HAIKU__
 void util_progress()
 {
 }
diff --git a/src/backend/var.c b/src/backend/var.c
index 4bdd1ef..b070079 100644
--- a/src/backend/var.c
+++ b/src/backend/var.c
@@ -61,7 +61,7 @@ int linkage_spec = 0;           /* using the default                    */
 #if MEMMODELS == 1
 tym_t functypetab[LINK_MAXDIM] =
 {
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     TYnfunc,
     TYnpfunc,
     TYnpfunc,
diff --git a/src/cppmangle.c b/src/cppmangle.c
index c2c90fc..3f10394 100644
--- a/src/cppmangle.c
+++ b/src/cppmangle.c
@@ -38,7 +38,7 @@
  * so nothing would be compatible anyway.
  */
 
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
 
 /*
  * Follows Itanium C++ ABI 1.86
diff --git a/src/eh.c b/src/eh.c
index 783ee57..e758f1a 100644
--- a/src/eh.c
+++ b/src/eh.c
@@ -32,7 +32,7 @@ static char __file__[] = __FILE__;      /* for tassert.h                */
 /* If we do our own EH tables and stack walking scheme
  * (Otherwise use NT Structured Exception Handling)
  */
-#if (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS)
+#if (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU)
 #define OUREH 1
 #elif TARGET_WINDOS
 #define OUREH I64
diff --git a/src/errors.c b/src/errors.c
index 428d3f3..04bc931 100644
--- a/src/errors.c
+++ b/src/errors.c
@@ -16,7 +16,7 @@
 #include <io.h>
 #endif
 
-#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
@@ -59,7 +59,7 @@ bool isConsoleColorSupported()
 {
 #if _WIN32
     return _isatty(_fileno(stderr)) != 0;
-#elif __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#elif __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
     const char *term = getenv("TERM");
     return isatty(STDERR_FILENO) && term && term[0] && 0 != strcmp(term, "dumb");
 #else
diff --git a/src/globals.c b/src/globals.c
index 9110227..3f22cf1 100644
--- a/src/globals.c
+++ b/src/globals.c
@@ -27,7 +27,7 @@ void Global::init()
 
 #if TARGET_WINDOS
     obj_ext  = "obj";
-#elif TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#elif TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     obj_ext  = "o";
 #else
 #error "fix this"
@@ -35,7 +35,7 @@ void Global::init()
 
 #if TARGET_WINDOS
     lib_ext  = "lib";
-#elif TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#elif TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     lib_ext  = "a";
 #else
 #error "fix this"
@@ -43,7 +43,7 @@ void Global::init()
 
 #if TARGET_WINDOS
     dll_ext  = "dll";
-#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     dll_ext  = "so";
 #elif TARGET_OSX
     dll_ext = "dylib";
@@ -53,7 +53,7 @@ void Global::init()
 
 #if TARGET_WINDOS
     run_noext = false;
-#elif TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#elif TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     // Allow 'script' D source files to have no extension.
     run_noext = true;
 #else
diff --git a/src/glue.c b/src/glue.c
index 5011be6..26382b9 100644
--- a/src/glue.c
+++ b/src/glue.c
@@ -910,7 +910,7 @@ void FuncDeclaration_toObjFile(FuncDeclaration *fd, bool multiobj)
         // Pull in RTL startup code (but only once)
         if (fd->isMain() && onlyOneMain(fd->loc))
         {
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
             objmod->external_def("_main");
             objmod->ehsections();   // initialize exception handling sections
 #endif
@@ -1314,7 +1314,7 @@ void FuncDeclaration_toObjFile(FuncDeclaration *fd, bool multiobj)
         }
     }
 
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     // A hack to get a pointer to this function put in the .dtors segment
     if (fd->ident && memcmp(fd->ident->toChars(), "_STD", 4) == 0)
         objmod->staticdtor(s);
@@ -1379,7 +1379,7 @@ unsigned totym(Type *tx)
         case Tbool:     t = TYbool;     break;
         case Tchar:     t = TYchar;     break;
         case Twchar:    t = TYwchar_t;  break;
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         case Tdchar:    t = TYdchar;    break;
 #else
         case Tdchar:
@@ -1462,7 +1462,7 @@ unsigned totym(Type *tx)
                 case LINKcpp:
                 Lc:
                     t = TYnfunc;
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
                     if (I32 && retStyle(tf) == RETstack)
                         t = TYhfunc;
 #endif
diff --git a/src/inifile.c b/src/inifile.c
index bcdab2f..5342541 100644
--- a/src/inifile.c
+++ b/src/inifile.c
@@ -81,7 +81,7 @@ const char *findConfFile(const char *argv0, const char *inifile)
     if (FileName::exists(filename))
         return filename;
 
-#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
     // Search PATH for argv0
     const char *p = getenv("PATH");
 #if LOG
diff --git a/src/lib.h b/src/lib.h
index 465fb4e..415c268 100644
--- a/src/lib.h
+++ b/src/lib.h
@@ -28,7 +28,7 @@ class Library
     {
 #if TARGET_WINDOS
         return global.params.is64bit ? LibMSCoff_factory() : LibOMF_factory();
-#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
         return LibElf_factory();
 #elif TARGET_OSX
         return LibMach_factory();
diff --git a/src/link.c b/src/link.c
index 272bdb4..8bfda24 100644
--- a/src/link.c
+++ b/src/link.c
@@ -23,7 +23,7 @@
 #endif
 #endif
 
-#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
 #include        <sys/types.h>
 #include        <sys/wait.h>
 #include        <unistd.h>
@@ -83,7 +83,7 @@ void writeFilename(OutBuffer *buf, const char *filename)
     writeFilename(buf, filename, strlen(filename));
 }
 
-#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
 
 /*****************************
  * As it forwards the linker error message to stderr, checks for the presence
@@ -446,7 +446,7 @@ int runLINK()
         }
         return status;
     }
-#elif __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#elif __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
     pid_t childpid;
     int status;
 
@@ -464,7 +464,7 @@ int runLINK()
     // add the "-dynamiclib" flag
     if (global.params.dll)
         argv.push("-dynamiclib");
-#elif __linux__ || __FreeBSD__ || __OpenBSD__ || __sun
+#elif __linux__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
     if (global.params.dll)
         argv.push("-shared");
 #endif
@@ -648,7 +648,7 @@ int runLINK()
 //    argv.push("-ldruntime");
     argv.push("-lpthread");
     argv.push("-lm");
-#if __linux__
+#if __linux__ || __HAIKU__
     // Changes in ld for Ubuntu 11.10 require this to appear after phobos2
     argv.push("-lrt");
 #endif
@@ -871,7 +871,7 @@ int runProgram()
         ex = global.params.exefile;
     // spawnlp returns intptr_t in some systems, not int
     return spawnv(0,ex,argv.tdata());
-#elif __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#elif __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
     pid_t childpid;
     int status;
 
diff --git a/src/mars.c b/src/mars.c
index dc17d5c..4587d2d 100644
--- a/src/mars.c
+++ b/src/mars.c
@@ -16,7 +16,7 @@
 #include <limits.h>
 #include <string.h>
 
-#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
 #include <errno.h>
 #endif
 
@@ -327,7 +327,7 @@ int tryMain(size_t argc, const char *argv[])
     global.params.defaultlibname = "phobos";
 #elif TARGET_LINUX
     global.params.defaultlibname = "libphobos2.a";
-#elif TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#elif TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     global.params.defaultlibname = "phobos2";
 #else
 #error "fix this"
@@ -367,6 +367,11 @@ int tryMain(size_t argc, const char *argv[])
     VersionCondition::addPredefinedGlobalIdent("Solaris");
     VersionCondition::addPredefinedGlobalIdent("ELFv1");
     global.params.isSolaris = true;
+#elif TARGET_HAIKU
+    VersionCondition::addPredefinedGlobalIdent("Posix");
+    VersionCondition::addPredefinedGlobalIdent("Haiku");
+    VersionCondition::addPredefinedGlobalIdent("ELFv1");
+    global.params.isLinux = true;
 #else
 #error "fix this"
 #endif
@@ -386,7 +391,7 @@ int tryMain(size_t argc, const char *argv[])
     {
 #if _WIN32
         global.inifilename = findConfFile(argv[0], "sc.ini");
-#elif __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#elif __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
         global.inifilename = findConfFile(argv[0], "dmd.conf");
 #else
 #error "fix this"
diff --git a/src/msc.c b/src/msc.c
index efe1ad9..658691f 100644
--- a/src/msc.c
+++ b/src/msc.c
@@ -85,7 +85,7 @@ void backend_init()
             exe = true;
     }
 #endif
-#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
+#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU
     exe = params->pic == 0;
 #endif
 
diff --git a/src/osmodel.mak b/src/osmodel.mak
index a8ac16f..b842e51 100644
--- a/src/osmodel.mak
+++ b/src/osmodel.mak
@@ -20,6 +20,9 @@ ifeq (,$(OS))
   ifeq (SunOS,$(uname_S))
     OS:=solaris
   endif
+  ifeq (Haiku,$(uname_S))
+    OS:=haiku
+  endif
   ifeq (,$(OS))
     $(error Unrecognized or unsupported OS for uname: $(uname_S))
   endif
@@ -40,7 +43,7 @@ ifeq (,$(MODEL))
   ifneq (,$(findstring $(uname_M),x86_64 amd64))
     MODEL:=64
   endif
-  ifneq (,$(findstring $(uname_M),i386 i586 i686))
+  ifneq (,$(findstring $(uname_M),i386 i586 i686 BePC))
     MODEL:=32
   endif
   ifeq (,$(MODEL))
diff --git a/src/root/async.c b/src/root/async.c
index 5abdebe..6fe2cce 100644
--- a/src/root/async.c
+++ b/src/root/async.c
@@ -119,7 +119,7 @@ unsigned __stdcall startthread(void *p)
     return EXIT_SUCCESS;                // if skidding
 }
 
-#elif __linux__  // Posix
+#elif __linux__ || __HAIKU__ // Posix
 
 #include <errno.h>
 #include <pthread.h>
diff --git a/src/root/man.c b/src/root/man.c
index c5dbd8e..476cbbd 100644
--- a/src/root/man.c
+++ b/src/root/man.c
@@ -25,7 +25,7 @@ void browse(const char *url)
 
 #endif
 
-#if __linux__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if __linux__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
 
 #include        <sys/types.h>
 #include        <sys/wait.h>
diff --git a/src/root/object.h b/src/root/object.h
index 2474223..e8c81b7 100644
--- a/src/root/object.h
+++ b/src/root/object.h
@@ -10,7 +10,7 @@
 #ifndef OBJECT_H
 #define OBJECT_H
 
-#define POSIX (__linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun)
+#define POSIX (__linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__)
 
 #if __DMC__
 #pragma once
diff --git a/src/root/port.c b/src/root/port.c
index e62082c..f392fa0 100644
--- a/src/root/port.c
+++ b/src/root/port.c
@@ -579,7 +579,7 @@ longdouble Port::strtold(const char *p, char **endp)
 
 #endif
 
-#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__
+#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __HAIKU__
 
 #include <math.h>
 #if __linux__
@@ -672,6 +672,8 @@ int Port::isNan(double r)
 #endif
 #elif __FreeBSD__ || __OpenBSD__
     return isnan(r);
+#elif __HAIKU__
+	return ::__isnan(r);
 #else
     #undef isnan
     return ::isnan(r);
@@ -688,6 +690,8 @@ int Port::isNan(longdouble r)
 #endif
 #elif __FreeBSD__ || __OpenBSD__
     return isnan(r);
+#elif __HAIKU__
+	return ::__isnan(r);
 #else
     #undef isnan
     return ::isnan(r);
@@ -716,6 +720,8 @@ int Port::isInfinity(double r)
     return fpclassify(r) == FP_INFINITE;
 #elif __FreeBSD__ || __OpenBSD__
     return isinf(r);
+#elif __HAIKU__
+	return ::__isinf(r);
 #else
     #undef isinf
     return ::isinf(r);
diff --git a/src/root/response.c b/src/root/response.c
index 33d28e9..101147a 100644
--- a/src/root/response.c
+++ b/src/root/response.c
@@ -20,7 +20,7 @@
 #include <io.h>
 #endif
 
-#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <fcntl.h>
diff --git a/src/tk/filespec.c b/src/tk/filespec.c
index f4376c4..7165b82 100644
--- a/src/tk/filespec.c
+++ b/src/tk/filespec.c
@@ -25,7 +25,7 @@
 #include        <ctype.h>
 #endif
 
-#if M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
 #include        <stdlib.h>
 #include        <unistd.h>
 #endif
@@ -87,7 +87,7 @@ char * filespecaddpath(const char *path,const char *filename)
 /**********************/
 char * filespecrootpath(char *filespec)
 {
-#if SUN || M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if SUN || M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
 #define DIRCHAR '/'
 #endif
 #if MSDOS || __OS2__ || __NT__ || _WIN32
@@ -112,7 +112,7 @@ char * filespecrootpath(char *filespec)
 #endif
 
     /* get current working directory path */
-#if SUN || M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if SUN || M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
     cwd_t = (char *)getcwd(NULL, 256);
 #endif
 #if MSDOS || __OS2__ || __NT__ || _WIN32
@@ -134,7 +134,7 @@ char * filespecrootpath(char *filespec)
     if (cwd[strlen(cwd) - 1] == DIRCHAR)
         cwd[strlen(cwd) - 1] = '\0';
 #endif
-#if SUN || M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if SUN || M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
     free(cwd_t);
 #endif
     p = filespec;
@@ -151,7 +151,7 @@ char * filespecrootpath(char *filespec)
             {
                 cwd_t = cwd;
                 cwd = (char *)mem_calloc(strlen(cwd_t) + 1 + strlen(p) + 1);
-#if SUN || M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if SUN || M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
                 sprintf(cwd, "%s/%s", cwd_t, p);  /* add relative directory */
 #endif
 #if MSDOS || __OS2__ || __NT__ || _WIN32
@@ -172,7 +172,7 @@ char * filespecrootpath(char *filespec)
         {   /* ... save remaining string */
             cwd_t = cwd;
             cwd = (char *)mem_calloc(strlen(cwd_t) + 1 + strlen(p) + 1);
-#if SUN || M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if SUN || M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
             sprintf(cwd, "%s/%s", cwd_t, p);  /* add relative directory */
 #endif
 #if MSDOS || __OS2__ || __NT__ || _WIN32
@@ -403,7 +403,7 @@ char * filespecbackup(const char *filespec)
 #if MSDOS || __OS2__ || __NT__ || _WIN32
     return filespecforceext(filespec,"BAK");
 #endif
-#if BSDUNIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if BSDUNIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
     char *p,*f;
 
     /* Prepend .B to file name, if it isn't already there       */
diff --git a/src/tk/mem.c b/src/tk/mem.c
index 03c60e4..8083d4a 100644
--- a/src/tk/mem.c
+++ b/src/tk/mem.c
@@ -326,7 +326,7 @@ static struct mem_debug
         11111,
         0,
         BEFOREVAL,
-#if !(__linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun)
+#if !(__linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__)
         AFTERVAL
 #endif
 };
@@ -838,7 +838,7 @@ void mem_init()
                 mem_numalloc = 0;
                 mem_maxalloc = 0;
                 mem_alloclist.Mnext = NULL;
-#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
                 *(long *) &(mem_alloclist.data[0]) = AFTERVAL;
 #endif
 #endif
diff --git a/test/runnable/extra-files/cppb.cpp b/test/runnable/extra-files/cppb.cpp
index da99068..eb4d934 100644
--- a/test/runnable/extra-files/cppb.cpp
+++ b/test/runnable/extra-files/cppb.cpp
@@ -313,12 +313,12 @@ size_t getoffset13161a()
 
 /****************************************************/
 
-#if __linux__ || __APPLE__ || __FreeBSD__
+#if __linux__ || __APPLE__ || __FreeBSD__ || __HAIKU__
 #include <memory>
 #include <vector>
 #include <string>
 
-#if __linux__
+#if __linux__ || __HAIKU__
 template struct std::allocator<int>;
 template struct std::vector<int>;
 
@@ -370,7 +370,7 @@ wchar_t f13289_cpp_wchar_t(wchar_t ch)
     }
 }
 
-#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
 unsigned short f13289_d_wchar(unsigned short ch);
 wchar_t f13289_d_dchar(wchar_t ch);
 #elif _WIN32
@@ -380,7 +380,7 @@ unsigned int f13289_d_dchar(unsigned int ch);
 
 bool f13289_cpp_test()
 {
-#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun
+#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __HAIKU__
     if (!(f13289_d_wchar((unsigned short)'c') == (unsigned short)'C')) return false;
     if (!(f13289_d_wchar((unsigned short)'D') == (unsigned short)'D')) return false;
     if (!(f13289_d_dchar(L'e') == L'E')) return false;
-- 
2.2.2


From 6e8ac7ee1fa64b7ad5b7123370d69ae81e2efb43 Mon Sep 17 00:00:00 2001
From: raefaldhia <raefaldhiamartya@gmail.com>
Date: Sat, 1 Apr 2017 13:31:23 +0000
Subject: Add haiku.mak


diff --git a/haiku.mak b/haiku.mak
new file mode 100644
index 0000000..ae2df76
--- /dev/null
+++ b/haiku.mak
@@ -0,0 +1,31 @@
+ECTAGS_LANGS = Make,C,C++,Sh
+ECTAGS_FILES = src/*.[ch] src/backend/*.[ch] src/root/*.[ch] src/tk/*.[ch]
+
+.PHONY: all clean test install
+
+all:
+	$(QUIET)$(MAKE) -C src -f posix.mak SYSCONFDIR=$(DATADIR)/dmd/
+
+clean:
+	$(QUIET)$(MAKE) -C src -f posix.mak clean
+	$(QUIET)$(MAKE) -C test -f Makefile clean
+	$(RM) tags
+
+test:
+	$(QUIET)$(MAKE) -C test -f Makefile
+
+# Creates Exuberant Ctags tags file
+tags: posix.mak $(ECTAGS_FILES)
+	ctags --sort=yes --links=no --excmd=number --languages=$(ECTAGS_LANGS) \
+		--langmap='C++:+.c,C++:+.h' --extra=+f --file-scope=yes --fields=afikmsSt --totals=yes posix.mak $(ECTAGS_FILES)
+
+install: all
+	mkdir -p $(BINDIR)
+	cp src/dmd $(BINDIR)/dmd$(ARCH_SUFFIX)
+	mkdir -p $(MANDIR)/man1/
+	cp -r docs/man/man1/* $(MANDIR)/man1/
+	mkdir -p $(DATADIR)/dmd
+	cp ini/haiku/bin/dmd.conf $(DATADIR)/dmd/dmd.conf
+	cp src/backendlicense.txt $(DATADIR)/dmd/dmd-backendlicense.txt
+	cp src/boostlicense.txt $(DATADIR)/dmd/dmd-boostlicense.txt
+	cp -r samples $(DATADIR)/dmd
diff --git a/ini/haiku/bin/dmd.conf b/ini/haiku/bin/dmd.conf
new file mode 100644
index 0000000..77e55fb
--- /dev/null
+++ b/ini/haiku/bin/dmd.conf
@@ -0,0 +1,2 @@
+[Environment]
+DFLAGS=-I%@P%/../../src/phobos -I%@P%/../../src/druntime/import -L-L%@P%/../lib32 -L--export-dynamic
\ No newline at end of file
diff --git a/src/e2ir.c b/src/e2ir.c
index 5c3820e..8cb30a3 100644
--- a/src/e2ir.c
+++ b/src/e2ir.c
@@ -255,7 +255,8 @@ elem *callfunc(Loc loc,
         if ((global.params.isLinux ||
              global.params.isOSX ||
              global.params.isFreeBSD ||
-             global.params.isSolaris) && tf->linkage != LINKd)
+             global.params.isSolaris ||
+             global.params.isHaiku) && tf->linkage != LINKd)
             ;   // ehidden goes last on Linux/OSX C++
         else
         {
@@ -1750,7 +1751,7 @@ elem *toElem(Expression *e, IRState *irs)
                 {
                     ts = symbol_genauto(Type_toCtype(t1));
                     int rtl;
-                    if (global.params.isLinux || global.params.isFreeBSD || global.params.isSolaris ||
+                    if (global.params.isLinux || global.params.isFreeBSD || global.params.isSolaris || global.params.isHaiku ||
                         I64 && global.params.isWindows)
                         rtl = RTLSYM__DINVARIANT;
                     else
diff --git a/src/globals.h b/src/globals.h
index bb57840..faf8b9c 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -49,6 +49,7 @@ struct Param
     bool isFreeBSD;     // generate code for FreeBSD
     bool isOpenBSD;     // generate code for OpenBSD
     bool isSolaris;     // generate code for Solaris
+    bool isHaiku;       // generate code for Haiku    
     bool mscoff;        // for Win32: write COFF object files instead of OMF
     char useDeprecated; // 0: don't allow use of deprecated features
                         // 1: silently allow use of deprecated features
diff --git a/src/glue.c b/src/glue.c
index 26382b9..d9409ec 100644
--- a/src/glue.c
+++ b/src/glue.c
@@ -1112,7 +1112,7 @@ void FuncDeclaration_toObjFile(FuncDeclaration *fd, bool multiobj)
         pi++;
     }
 
-    if ((global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isSolaris) &&
+    if ((global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isSolaris || global.params.isHaiku) &&
          fd->linkage != LINKd && shidden && sthis)
     {
         /* swap shidden and sthis
diff --git a/src/mars.c b/src/mars.c
index 4587d2d..e2bb653 100644
--- a/src/mars.c
+++ b/src/mars.c
@@ -371,7 +371,7 @@ int tryMain(size_t argc, const char *argv[])
     VersionCondition::addPredefinedGlobalIdent("Posix");
     VersionCondition::addPredefinedGlobalIdent("Haiku");
     VersionCondition::addPredefinedGlobalIdent("ELFv1");
-    global.params.isLinux = true;
+    global.params.isHaiku = true;
 #else
 #error "fix this"
 #endif
diff --git a/src/target.c b/src/target.c
index ecb4575..b0c4a04 100644
--- a/src/target.c
+++ b/src/target.c
@@ -33,7 +33,7 @@ void Target::init()
         ptrsize = 8;
 
     if (global.params.isLinux || global.params.isFreeBSD
-        || global.params.isOpenBSD || global.params.isSolaris)
+        || global.params.isOpenBSD || global.params.isSolaris || global.params.isHaiku)
     {
         realsize = 12;
         realpad = 2;
@@ -60,7 +60,7 @@ void Target::init()
 
     if (global.params.is64bit)
     {
-        if (global.params.isLinux || global.params.isFreeBSD || global.params.isSolaris)
+        if (global.params.isLinux || global.params.isFreeBSD || global.params.isSolaris || global.params.isHaiku)
         {
             realsize = 16;
             realpad = 6;
@@ -95,7 +95,7 @@ unsigned Target::alignsize(Type* type)
 
         case Tcomplex32:
             if (global.params.isLinux || global.params.isOSX || global.params.isFreeBSD
-                || global.params.isOpenBSD || global.params.isSolaris)
+                || global.params.isOpenBSD || global.params.isSolaris || global.params.isHaiku)
                 return 4;
             break;
 
@@ -105,7 +105,7 @@ unsigned Target::alignsize(Type* type)
         case Timaginary64:
         case Tcomplex64:
             if (global.params.isLinux || global.params.isOSX || global.params.isFreeBSD
-                || global.params.isOpenBSD || global.params.isSolaris)
+                || global.params.isOpenBSD || global.params.isSolaris || global.params.isHaiku)
                 return global.params.is64bit ? 8 : 4;
             break;
 
@@ -165,6 +165,10 @@ unsigned Target::critsecsize()
         // sizeof(pthread_mutex_t) for Solaris.
         return 24;
     }
+	else if (global.params.isHaiku)
+	{
+		return 20;
+	}
     assert(0);
     return 0;
 }
@@ -184,7 +188,8 @@ Type *Target::va_listType()
              global.params.isFreeBSD ||
              global.params.isOpenBSD ||
              global.params.isSolaris ||
-             global.params.isOSX)
+             global.params.isOSX ||
+             global.params.isHaiku)
     {
         if (global.params.is64bit)
         {
diff --git a/src/toir.c b/src/toir.c
index c314102..929940c 100644
--- a/src/toir.c
+++ b/src/toir.c
@@ -934,7 +934,7 @@ L2:
         //printf("  3 RETstack\n");
         return RETstack;
     }
-    else if ((global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isSolaris) &&
+    else if ((global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isSolaris || global.params.isHaiku) &&
              tf->linkage == LINKc &&
              tns->iscomplex())
     {
-- 
2.2.2

