From 33b1dca76db5ab527a0cb441dd70b27c339dafca Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sat, 9 Aug 2014 18:44:13 +0200
Subject: Add Haiku support.


diff --git a/Makefile b/Makefile
index 705b585..bcf562e 100644
--- a/Makefile
+++ b/Makefile
@@ -36,12 +36,12 @@ ifdef CONFIG_WIN64
 CONFIG_WIN32=yes
 endif
 
-ifndef CONFIG_WIN32
-LIBS=-lm
-ifndef CONFIG_NOLDL
-LIBS+=-ldl
-endif
-endif
+#ifndef CONFIG_WIN32
+#LIBS=-lm
+#ifndef CONFIG_NOLDL
+#LIBS+=-ldl
+#endif
+#endif
 
 # make libtcc as static or dynamic library?
 ifdef DISABLE_STATIC
diff --git a/lib/bcheck.c b/lib/bcheck.c
index 54124b9..7af69ff 100644
--- a/lib/bcheck.c
+++ b/lib/bcheck.c
@@ -42,7 +42,7 @@
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
     || defined(__DragonFly__) || defined(__dietlibc__) \
     || defined(__UCLIBC__) || defined(__OpenBSD__) \
-    || defined(_WIN32) || defined(TCC_UCLIBC)
+    || defined(_WIN32) || defined(TCC_UCLIBC) || defined(__HAIKU__)
 #warning Bound checking does not support malloc (etc.) in this environment.
 #undef CONFIG_TCC_MALLOC_HOOKS
 #undef HAVE_MEMALIGN
diff --git a/tccrun.c b/tccrun.c
index 50178a8..c67bebb 100644
--- a/tccrun.c
+++ b/tccrun.c
@@ -481,7 +481,7 @@ static int rt_get_caller_pc(addr_t *paddr, ucontext_t *uc, int level)
         *paddr = uc->uc_mcontext->__ss.__eip;
 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
         *paddr = uc->uc_mcontext.mc_eip;
-#elif defined(__dietlibc__)
+#elif defined(__dietlibc__) || defined(__HAIKU__)
         *paddr = uc->uc_mcontext.eip;
 #else
         *paddr = uc->uc_mcontext.gregs[REG_EIP];
@@ -492,7 +492,7 @@ static int rt_get_caller_pc(addr_t *paddr, ucontext_t *uc, int level)
         fp = uc->uc_mcontext->__ss.__ebp;
 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
         fp = uc->uc_mcontext.mc_ebp;
-#elif defined(__dietlibc__)
+#elif defined(__dietlibc__) || defined(__HAIKU__)
         fp = uc->uc_mcontext.ebp;
 #else
         fp = uc->uc_mcontext.gregs[REG_EBP];
-- 
1.8.3.4

