From f32feb728fef969265603f6476ebc2bb05d5b74f Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Mon, 16 Aug 2021 09:28:50 +0300
Subject: gcc2 fix.


diff --git a/include/ffi_common.h b/include/ffi_common.h
index 2bd31b0..d9e1997 100644
--- a/include/ffi_common.h
+++ b/include/ffi_common.h
@@ -165,7 +165,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)
-- 
2.30.2


From 3fb7941ca3d21a00ae902d67b8e1b545980bb616 Mon Sep 17 00:00:00 2001
From: Michael Lotz <mmlr@mlotz.ch>
Date: Mon, 16 Aug 2021 09:29:06 +0300
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 94e149c..c66f2aa 100755
--- a/configure
+++ b/configure
@@ -18658,7 +18658,7 @@ case "$target" in
 $as_echo "#define FFI_EXEC_TRAMPOLINE_TABLE 1" >>confdefs.h
 
      ;;
-     *-apple-* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris* | *-linux-android*)
+     *-apple-* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris* | *-linux-android* | *-*-haiku*)
 
 $as_echo "#define FFI_MMAP_EXEC_WRIT 1" >>confdefs.h
 
-- 
2.30.2

