opensmalltalk_vm: new package (#12616)

Co-authored-by: Jérôme Duval <jerome.duval@gmail.com>
This commit is contained in:
Сухарик
2025-08-01 16:34:10 +03:00
committed by GitHub
parent 5f62244f45
commit 1bef3e6649
2 changed files with 289 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
SUMMARY="Cross-platform virtual machine for Squeak, Pharo, and Cuis"
DESCRIPTION="opensmalltalk-vm (a.k.a. the Cog VM) is the virtual machine beneath the Cuis, \
Pharo and Squeak Smalltalk dialects."
HOMEPAGE="https://opensmalltalk.org/"
COPYRIGHT="2002-2025 OpenSmalltalk developers"
LICENSE="MIT"
REVISION="1"
SOURCE_URI="https://github.com/OpenSmalltalk/opensmalltalk-vm/archive/refs/tags/$portVersion.tar.gz"
CHECKSUM_SHA256="3d5dd4dc8f6ffd5af6535479a84081442319b738d6c580dae043b7b0069e73cd"
SOURCE_DIR="opensmalltalk-vm-$portVersion"
PATCHES="opensmalltalk_vm-$portVersion.patchset"
ARCHITECTURES="x86_64"
PROVIDES="
opensmalltalk_vm = $portVersion
cmd:spur64
"
REQUIRES="
haiku
lib:libX11
lib:libssl
"
BUILD_REQUIRES="
haiku_devel
xlibe_devel
devel:libssl
"
BUILD_PREREQUIRES="
cmd:awk
cmd:gcc
cmd:sed
cmd:make
cmd:perl
"
BUILD()
{
vmVersionFiles=$(sed -n 's/^versionfiles="\(.*\)"/\1/p' ./scripts/updateSCCSVersions)
for vf in $vmVersionFiles
do
sed -i -e "s|\\\$Rev\\\$|\$Rev: $portVersion \$|g" $vf
sed -i -e "s|\\\$Date\\\$|\$Date: Thu Jan 1 00:00:00 1970 +0000 \$|g" $vf
sed -i -e "s|\\\$URL\\\$|\$URL: $SOURCE_URI \$|g" $vf
sed -i -e "s|\\\$CommitHash\\\$|\$CommitHash: 000000000000 \$|g" $vf
done
cd building/linux64x64/squeak.cog.spur/build
./mvm
}
INSTALL()
{
cd building/linux64x64/squeak.cog.spur/build
make install-squeak install-plugins prefix=$prefix
rm $prefix/squeak
sed -i -e 's:`/usr/bin/dirname "$0"`/..:/system:' $prefix/bin/spur64
sed -i -e 's:OpenBSD:Haiku:' $prefix/bin/spur64
}

View File

@@ -0,0 +1,229 @@
From 4c306a517b004d84a64caaca818714b01a990887 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=A1=D1=83=D1=85=D0=B0=D1=80=D0=B8=D0=BA?=
<65870+suhr@users.noreply.github.com>
Date: Tue, 22 Jul 2025 12:05:56 +0000
Subject: Patch for Haiku
diff --git a/building/linux64x64/squeak.cog.spur/build/mvm b/building/linux64x64/squeak.cog.spur/build/mvm
index d7486aa..5964599 100755
--- a/building/linux64x64/squeak.cog.spur/build/mvm
+++ b/building/linux64x64/squeak.cog.spur/build/mvm
@@ -14,6 +14,8 @@ case $(uname -s) in
LIBS="$LIBS -lexecinfo"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
;;
+ Haiku)
+ LIBS="$LIBS -lnetwork -lbsd"
esac
# Prefer clang over gcc, but use gcc if clang isn't available...
@@ -24,18 +26,12 @@ if [ $# -ge 1 ]; then
INSTALLDIR="$1"; shift
fi
-if ../../../../scripts/checkSCCSversion ; then exit 1; fi
-echo -n "clean? "
-read a
-case $a in
-n|no|N|NO) echo "ok but this isn't safe!!";;
-*) test -f Makefile && make reallyclean
-esac
../../../../scripts/copylinuxpluginspecfiles
test -f config.h || ../../../../platforms/unix/config/configure --without-npsqueak \
--with-vmversion=5.0 \
--with-src=src/spur64.cog \
--with-scriptname=spur64 \
+ --without-gl \
TARGET_ARCH="-m64" \
CC=$CC \
CFLAGS="$CFLAGS" \
@@ -45,4 +41,3 @@ rm -f vm/sqUnixMain.o # nuke version info
rm -rf ../../../../products/$INSTALLDIR
# prefer make install prefix=`readlink -f \`pwd\`/../../../../products/$INSTALLDIR`
# but older linux readlinks lack the -f flag
-make install-squeak install-plugins prefix=`(cd ../../../../;pwd)`/products/$INSTALLDIR 2>&1 | tee LOG ; test ${PIPESTATUS[0]} -eq 0
diff --git a/platforms/Cross/vm/sqVirtualMachine.c b/platforms/Cross/vm/sqVirtualMachine.c
index 6140152..0fd4de8 100755
--- a/platforms/Cross/vm/sqVirtualMachine.c
+++ b/platforms/Cross/vm/sqVirtualMachine.c
@@ -361,7 +361,7 @@ struct VirtualMachine* sqGetInterpreterProxy(void)
#ifndef MUSL
#define STDOUT_STACK_SZ 5
static int stdoutStackIdx = -1;
-static FILE stdoutStack[STDOUT_STACK_SZ];
+static FILE *stdoutStack[STDOUT_STACK_SZ];
#endif
/* N.B. As of cygwin 1.5.25 fopen("crash.dmp","a") DOES NOT WORK! crash.dmp
@@ -412,8 +412,8 @@ pushOutputFile(char *filenameOrStdioIndex)
return;
}
}
- stdoutStack[++stdoutStackIdx] = *stdout;
- *stdout = *output;
+ stdoutStack[++stdoutStackIdx] = stdout;
+ stdout = output;
}
void
@@ -434,7 +434,7 @@ popOutputFile()
fclose(stdout);
#endif
}
- *stdout = stdoutStack[stdoutStackIdx--];
+ stdout = stdoutStack[stdoutStackIdx--];
}
#endif
diff --git a/platforms/unix/plugins/SocketPlugin/sqUnixSocket.c b/platforms/unix/plugins/SocketPlugin/sqUnixSocket.c
index df8a1ee..22f3cae 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 66f07a5..85a828b 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 d17c337..6340296 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 1f7153f..bca9fe7 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>
@@ -591,6 +595,12 @@ makeFileDescriptorNonBlockingAndSetupSigio(int fd) {
if (ioctl(fd, FIOASYNC, &arg) < 0)
perror("ioctl(FIOASYNC, 1)");
FPRINTF((stderr, "makeFileDescriptorNonBlockingAndSetupSigio(%d): Elicit SIGIO via FIOASYNC/fcntl\n", fd));
+
+#elif __HAIKU__
+ if ((arg = fcntl(fd, F_GETFL, 0)) < 0)
+ perror("fcntl(F_GETFL)");
+ if (fcntl(fd, F_SETFL, arg | O_NONBLOCK) < 0)
+ perror("fcntl(F_SETFL, O_NONBLOCK)");
#else
FPRINTF((stderr, "makeFileDescriptorNonBlockingAndSetupSigio(%d): UNABLE TO ELICIT SIGIO!!\n", fd));
#endif
diff --git a/platforms/unix/vm/include_ucontext.h b/platforms/unix/vm/include_ucontext.h
index 3fb5784..63521f9 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]
--
2.48.1