Skip to content

Instantly share code, notes, and snippets.

@suhr
Created February 1, 2024 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suhr/85a451a72bd0b97304b52f7224d3199f to your computer and use it in GitHub Desktop.
Save suhr/85a451a72bd0b97304b52f7224d3199f to your computer and use it in GitHub Desktop.
diff --git a/platforms/unix/plugins/SocketPlugin/sqUnixSocket.c b/platforms/unix/plugins/SocketPlugin/sqUnixSocket.c
index df8a1eec0..22f3cae87 100644
--- a/platforms/unix/plugins/SocketPlugin/sqUnixSocket.c
+++ b/platforms/unix/plugins/SocketPlugin/sqUnixSocket.c
@@ -57,6 +57,10 @@
#endif
#endif
+#ifdef __HAIKU__
+#define IFF_RUNNING IFF_LINK
+#endif
+
#ifdef ACORN
# include <time.h>
# define __time_t
diff --git a/platforms/unix/plugins/SqueakSSL/openssl_overlay.h b/platforms/unix/plugins/SqueakSSL/openssl_overlay.h
index 66f07a537..85a828b17 100644
--- a/platforms/unix/plugins/SqueakSSL/openssl_overlay.h
+++ b/platforms/unix/plugins/SqueakSSL/openssl_overlay.h
@@ -360,7 +360,7 @@ OPENSSL_INIT_SETTINGS;
#include <dlfcn.h>
#if !defined(SQO_DL_FLAGS)
-# if !defined(__OpenBSD__)
+# if !defined(__OpenBSD__) && !defined(__HAIKU__)
# define SQO_DL_FLAGS (RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE)
# else
# define SQO_DL_FLAGS (RTLD_NOW | RTLD_GLOBAL)
diff --git a/platforms/unix/vm-display-X11/sqUnixX11Scale.c b/platforms/unix/vm-display-X11/sqUnixX11Scale.c
index d17c33749..63402966a 100644
--- a/platforms/unix/vm-display-X11/sqUnixX11Scale.c
+++ b/platforms/unix/vm-display-X11/sqUnixX11Scale.c
@@ -14,7 +14,9 @@
#include "debug.h"
#include <X11/Xresource.h>
+#ifndef __HAIKU__
#include <X11/extensions/Xrandr.h> /* at least at compiletime */
+#endif
/*
*
@@ -24,7 +26,7 @@
*
*/
-#if !defined(__OpenBSD__)
+#if !defined(__OpenBSD__) && !defined(__HAIKU__)
# define DL_FLAGS (RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE)
#else
# define DL_FLAGS (RTLD_NOW | RTLD_GLOBAL)
@@ -153,7 +155,7 @@ double scale_Xftdpi(void)
}
-
+#ifndef __HAIKU__
USING_SYM(Xrandr, XRRScreenResources *, XRRGetScreenResources, Display *dpy, Window window)
USING_SYM(Xrandr, void, XRRFreeScreenResources, XRRScreenResources *resources)
USING_SYM(Xrandr, XRROutputInfo * , XRRGetOutputInfo, Display *dpy, XRRScreenResources *resources, RROutput output)
@@ -161,6 +163,7 @@ USING_SYM(Xrandr, XRRCrtcInfo *, XRRGetCrtcInfo, Display *dpy, XRRScreenResource
USING_SYM(Xrandr, void, XRRFreeCrtcInfo, XRRCrtcInfo *crtcInfo)
USING_SYM(Xrandr, XRRScreenResources *, XRRGetScreenResourcesCurrent, Display *dpy, Window window)
USING_SYM(Xrandr, void, XRRFreeOutputInfo, XRROutputInfo *outputInfo)
+#endif
typedef int px_pos;
typedef unsigned int px_len;
@@ -231,6 +234,7 @@ should_use_for_scale(px_pos wx, px_pos wy, px_len ww, px_len wh,
}
+#ifndef __HAIKU__
bool scale_xrandr_usable(void)
{
LOADING_SYM(Xrandr, XRRScreenResources *, XRRGetScreenResources, Display *dpy, Window window);
@@ -242,6 +246,7 @@ bool scale_xrandr_usable(void)
LOADING_SYM(Xrandr, void, XRRFreeOutputInfo, XRROutputInfo *outputInfo);
return true;
}
+
double scale_xrandr(void)
{
double scale = sqDefaultScale();
@@ -318,3 +323,7 @@ double scale_xrandr(void)
Xrandr_XRRFreeScreenResources(res);
return scale;
}
+#else
+bool scale_xrandr_usable(void) { return false; }
+double scale_xrandr(void) { return sqDefaultScale() / 96.0; }
+#endif
diff --git a/platforms/unix/vm/aio.c b/platforms/unix/vm/aio.c
index 1f7153fbc..cac95691d 100644
--- a/platforms/unix/vm/aio.c
+++ b/platforms/unix/vm/aio.c
@@ -88,6 +88,10 @@
# define signal(a, b) sigset(a, b)
# endif
+# if __HAIKU__
+ # define SIGIO SIGPOLL
+# endif
+
#else /* !HAVE_CONFIG_H -- assume lowest common demoninator */
# include <errno.h>
diff --git a/platforms/unix/vm/include_ucontext.h b/platforms/unix/vm/include_ucontext.h
index 3fb578445..63521f942 100644
--- a/platforms/unix/vm/include_ucontext.h
+++ b/platforms/unix/vm/include_ucontext.h
@@ -16,6 +16,8 @@
#endif
#ifdef __OpenBSD__
# include <sys/signal.h>
+#elif __HAIKU__
+# include <signal.h>
#elif __sun
/* Single UNIX Specification (SUS), Version 2 specifies <ucontext.h> */
# include <ucontext.h>
@@ -63,6 +65,14 @@
# define _PC_IN_UCONTEXT uc_mcontext.gregs[EIP]
# define _FP_IN_UCONTEXT uc_mcontext.gregs[REG_FP]
# define _SP_IN_UCONTEXT uc_mcontext.gregs[REG_SP]
+#elif __HAIKU__ && __i386__
+# define _PC_IN_UCONTEXT uc_mcontext.eip
+# define _FP_IN_UCONTEXT uc_mcontext.ebp
+# define _SP_IN_UCONTEXT uc_mcontext.esp
+#elif __HAIKU__ && __amd64__
+# define _PC_IN_UCONTEXT uc_mcontext.rip
+# define _FP_IN_UCONTEXT uc_mcontext.rbp
+# define _SP_IN_UCONTEXT uc_mcontext.rsp
#elif __linux__ && __i386__
# define _PC_IN_UCONTEXT uc_mcontext.gregs[REG_EIP]
# define _FP_IN_UCONTEXT uc_mcontext.gregs[REG_EBP]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment