From 279155468a862f4d358d01c5b8a084b40a700d4b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Sun, 5 May 2019 11:57:46 +0200
Subject: We don't allow unsetting O_NONBLOCK or O_NDELAY on packaged FS


diff --git a/ruby.c b/ruby.c
index 7903f58..0a17782 100644
--- a/ruby.c
+++ b/ruby.c
@@ -2090,10 +2090,10 @@ open_load_file(VALUE fname_v, int *xflag)
 	int fd;
 	/* open(2) may block if fname is point to FIFO and it's empty. Let's
 	   use O_NONBLOCK. */
-#if defined O_NONBLOCK && HAVE_FCNTL && !(O_NONBLOCK & O_ACCMODE)
+#if defined O_NONBLOCK && HAVE_FCNTL && !(O_NONBLOCK & O_ACCMODE) && !defined(__HAIKU__)
 	/* TODO: fix conflicting O_NONBLOCK in ruby/win32.h */
 # define MODE_TO_LOAD (O_RDONLY | O_NONBLOCK)
-#elif defined O_NDELAY && HAVE_FCNTL && !(O_NDELAY & O_ACCMODE)
+#elif defined O_NDELAY && HAVE_FCNTL && !(O_NDELAY & O_ACCMODE) && !defined(__HAIKU__)
 # define MODE_TO_LOAD (O_RDONLY | O_NDELAY)
 #else
 # define MODE_TO_LOAD (O_RDONLY)
-- 
2.26.0


From 6351154529c5e1da2ad33f6ab43544ce3953075c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Sun, 5 May 2019 15:35:20 +0200
Subject: Test fix for Haiku


diff --git a/test/fiddle/helper.rb b/test/fiddle/helper.rb
index 57ded49..8a33200 100644
--- a/test/fiddle/helper.rb
+++ b/test/fiddle/helper.rb
@@ -100,6 +100,18 @@ when /aix/
       end
     end
   end
+when /haiku/
+  libdir = '/system/lib'
+  case [0].pack('L!').size
+  when 4
+    # 32-bit ruby
+    libdir = '/system/lib/x86' if File.directory? '/system/lib/x86'
+  when 8
+    # 64-bit ruby
+    libdir = '/system/lib/' if File.directory? '/system/lib/'
+  end
+  libc_so = File.join(libdir, "libroot.so")
+  libm_so = File.join(libdir, "libroot.so")
 else
   libc_so = ARGV[0] if ARGV[0] && ARGV[0][0] == ?/
   libm_so = ARGV[1] if ARGV[1] && ARGV[1][0] == ?/
-- 
2.26.0


From b584031112ad887a1cb4a38e4a6d0b4c0e28e306 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Wed, 25 Dec 2019 19:53:24 +0100
Subject: Add Haiku to the context support list


diff --git a/configure.ac b/configure.ac
index f1ed36b..fc28564 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2343,6 +2343,9 @@ AS_CASE([$rb_cv_coroutine], [yes|''], [
         [*-openbsd*], [
             rb_cv_coroutine=copy
         ],
+        [*-haiku*], [
+            rb_cv_coroutine=copy
+        ],
         [*], [
             rb_cv_coroutine=ucontext
         ]
-- 
2.26.0

