From 7346bc44a1d1f47b38d556b0cc291fc948725042 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 21 Sep 2014 18:59:06 +0200
Subject: gcc2 fix.


diff --git a/include/ffi_common.h b/include/ffi_common.h
index 650ca69..02a1913 100644
--- a/include/ffi_common.h
+++ b/include/ffi_common.h
@@ -115,7 +115,7 @@ typedef signed int   SINT64 __attribute__((__mode__(__DI__)));
 
 typedef float FLOAT32;
 
-#ifndef __GNUC__
+#if !defined(__GNUC__) || __GNUC__ < 3
 #define __builtin_expect(x, expected_value) (x)
 #endif
 #define LIKELY(x)    __builtin_expect(!!(x),1)
-- 
1.8.3.4


From 46ac95d3636b845de417cc97c426b98c89d9ea54 Mon Sep 17 00:00:00 2001
From: Michael Lotz <mmlr@mlotz.ch>
Date: Fri, 12 Jun 2020 13:14:57 +0000
Subject: Mark Haiku as needing PROT_WRITE | PROTO_EXEC for allocations.

It uses the heap as a fallback, but its areas are marked non-executable
in Haiku so function calls into there will segfault with a permission
denied error.

diff --git a/configure b/configure
index c6da467..d856e1a 100755
--- a/configure
+++ b/configure
@@ -18530,7 +18530,7 @@ case "$target" in
 $as_echo "#define FFI_EXEC_TRAMPOLINE_TABLE 1" >>confdefs.h
 
      ;;
-     *-apple-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris*)
+     *-apple-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris* | *-*-haiku*)
 
 $as_echo "#define FFI_MMAP_EXEC_WRIT 1" >>confdefs.h
 
-- 
2.26.0

