Haiku build fix. (#207)

Avoiding atomic_add* conflicts, TLS model unsupported on this platform.
diff --git a/build/ninja/clang.py b/build/ninja/clang.py
index 2394b2f..38fd09d 100644
--- a/build/ninja/clang.py
+++ b/build/ninja/clang.py
@@ -78,6 +78,10 @@
       self.oslibs += ['dl']
     if self.target.is_bsd():
       self.oslibs += ['execinfo']
+    if self.target.is_haiku():
+      self.cflags += ['-D_GNU_SOURCE=1']
+      self.linkflags += ['-lpthread']
+      self.oslibs += ['m']
     if not self.target.is_windows():
       self.linkflags += ['-fomit-frame-pointer']
 
diff --git a/build/ninja/gcc.py b/build/ninja/gcc.py
index 299be53..4309436 100644
--- a/build/ninja/gcc.py
+++ b/build/ninja/gcc.py
@@ -56,6 +56,9 @@
       self.oslibs += ['dl']
     if self.target.is_bsd():
       self.oslibs += ['execinfo']
+    if self.target.is_haiku():
+      self.cflags += ['-D_GNU_SOURCE=1']
+      self.linkflags += ['-lpthread']
 
     self.includepaths = self.prefix_includepaths((includepaths or []) + ['.'])
 
diff --git a/build/ninja/platform.py b/build/ninja/platform.py
index 8f4477b..5867ed6 100644
--- a/build/ninja/platform.py
+++ b/build/ninja/platform.py
@@ -5,7 +5,7 @@
 import sys
 
 def supported_platforms():
-  return [ 'windows', 'linux', 'macos', 'bsd', 'ios', 'android', 'raspberrypi', 'tizen', 'sunos' ]
+  return [ 'windows', 'linux', 'macos', 'bsd', 'ios', 'android', 'raspberrypi', 'tizen', 'sunos', 'haiku' ]
 
 class Platform(object):
   def __init__(self, platform):
@@ -32,6 +32,8 @@
       self.platform = 'tizen'
     elif self.platform.startswith('sunos'):
       self.platform = 'sunos'
+    elif self.platform.startswith('haiku'):
+      self.platform = 'haiku'
 
   def platform(self):
     return self.platform
@@ -63,5 +65,8 @@
   def is_sunos(self):
     return self.platform == 'sunos'
 
+  def is_haiku(self):
+    return self.platform == 'haiku'
+
   def get(self):
     return self.platform
diff --git a/build/ninja/toolchain.py b/build/ninja/toolchain.py
index be72eba..30fda08 100644
--- a/build/ninja/toolchain.py
+++ b/build/ninja/toolchain.py
@@ -133,7 +133,7 @@
   def initialize_default_archs(self):
     if self.target.is_windows():
       self.archs = ['x86-64']
-    elif self.target.is_linux() or self.target.is_bsd() or self.target.is_sunos():
+    elif self.target.is_linux() or self.target.is_bsd() or self.target.is_sunos() or self.target.is_haiku():
       localarch = subprocess.check_output(['uname', '-m']).decode().strip()
       if localarch == 'x86_64' or localarch == 'amd64':
         self.archs = ['x86-64']
diff --git a/rpmalloc/rpmalloc.c b/rpmalloc/rpmalloc.c
index 6a506b7..291a361 100644
--- a/rpmalloc/rpmalloc.c
+++ b/rpmalloc/rpmalloc.c
@@ -137,7 +137,6 @@
 #    include <pthread.h>
 #  endif
 #  if defined(__HAIKU__)
-#    include <OS.h>
 #    include <pthread.h>
 #  endif
 #endif
@@ -659,7 +658,11 @@
 #    define _Thread_local __declspec(thread)
 #    define TLS_MODEL
 #  else
-#    define TLS_MODEL __attribute__((tls_model("initial-exec")))
+#    ifndef __HAIKU__
+#      define TLS_MODEL __attribute__((tls_model("initial-exec")))
+#    else
+#      define TLS_MODEL
+#    endif
 #    if !defined(__clang__) && defined(__GNUC__)
 #      define _Thread_local __thread
 #    endif