Skip to content

Commit 9e83001

Browse files
committedApr 4, 2026
Changes to support Haiku OS
1 parent 66a98f9 commit 9e83001

13 files changed

Lines changed: 62 additions & 10 deletions

File tree

 

‎pumpkin.sh‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
PATH=./bin:$PATH
22
export LD_LIBRARY_PATH=./bin
3+
export LIBRARY_PATH=$LIBRARY_PATH:%A/bin
34
./pumpkin -d 1 -f pumpkin.log -s libscriptlua ./script/pumpkin.lua

‎script/pumpkin.lua‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ if not lib then
4848
return
4949
end
5050

51+
fullrefresh = false
52+
if pit.getenv("BE_HOST_CPU") then
53+
fullrefresh = true
54+
end
55+
5156
pit.mount("./vfs/", "/")
5257

5358
pumpkin = pit.loadlib("libos")
@@ -58,6 +63,7 @@ pumpkin.start {
5863
width = 1024,
5964
height = 768,
6065
abgr = abgr,
66+
fullrefresh = fullrefresh,
6167
depth = 16,
6268
hdepth = lib.hdepth
6369
}

‎src/Launcher/Launcher.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3050,6 +3050,9 @@ UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
30503050
case 6:
30513051
debug(DEBUG_INFO, PUMPKINOS, "Host OS is Kernel");
30523052
break;
3053+
case 7:
3054+
debug(DEBUG_INFO, PUMPKINOS, "Host OS is Haiku");
3055+
break;
30533056
default:
30543057
debug(DEBUG_ERROR, PUMPKINOS, "Host OS is unknown");
30553058
break;

‎src/Makefile‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ endif
3232

3333
EXTRA_MODULES=$(UNICORN_MODULE) windows
3434

35+
else ifeq ($(OSNAME),Haiku)
36+
37+
EXTRA_MODULES=liblsdl2 haiku
38+
3539
else ifeq ($(OSNAME),Emscripten)
3640

3741
EMCC=$(shell which emcc)

‎src/common.mak‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,16 @@ OSDEFS=$(MBITS) -DKERNEL $(RPI_DEFS) -DSOEXT=\"$(SOEXT)\"
164164
PILRCDEFS=-D KERNEL
165165
CC=gcc
166166

167+
else ifeq ($(OSNAME),Haiku)
168+
SYS_OS=7
169+
EXTLIBS=-lnetwork
170+
SOEXT=.so
171+
LUAPLAT=posix
172+
OS=Haiku
173+
OSDEFS=$(MBITS) -DHAIKU -DSOEXT=\"$(SOEXT)\"
174+
CC=gcc
175+
FC=gfortran
176+
167177
else
168178
$(error Unknown OS $(OSNAME))
169179
endif

‎src/haiku/Makefile‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
include ../common.mak
2+
3+
PROGRAM=$(ROOT)/pumpkin
4+
5+
OBJS=main.o
6+
7+
$(PROGRAM): $(OBJS)
8+
@echo Linking pumpkin
9+
@$(CC) -o $(PROGRAM) $(OBJS) -L$(BIN) -lpit -lpthread
10+
11+
clean:
12+
@rm -f $(PROGRAM) $(OBJS)

‎src/haiku/main.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <stdlib.h>
2+
3+
#include "main.h"
4+
5+
int main(int argc, char *argv[]) {
6+
exit(pit_main(argc, argv, NULL, NULL));
7+
}

‎src/libpit/sys.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,19 @@
4545
#include <sys/select.h>
4646
#include <sys/statvfs.h>
4747
#else
48+
#if !defined(HAIKU)
4849
#include <sys/syscall.h>
4950
#include <sys/vfs.h>
5051
#endif
52+
#endif
5153
#include <sys/wait.h>
5254
#include <arpa/inet.h>
5355
#include <netinet/in.h>
5456
#include <netinet/tcp.h>
5557
#include <netdb.h>
58+
#if defined(HAIKU)
59+
#include <OS.h>
60+
#endif
5661
#endif
5762

5863
#include "sys.h"
@@ -537,6 +542,10 @@ uint32_t sys_get_tid(void) {
537542
#if defined(EMSCRIPTEN)
538543
return 0;
539544
#endif
545+
#if defined(HAIKU)
546+
thread_id id = find_thread(NULL);
547+
return id;
548+
#endif
540549
#if defined(KERNEL)
541550
return 0;
542551
#endif
@@ -2116,7 +2125,7 @@ int64_t sys_get_clock(void) {
21162125
ticks.QuadPart *= 1000000;
21172126
ticks.QuadPart /= ticks_per_second.QuadPart;
21182127
ts = ticks.QuadPart;
2119-
#elif defined(EMSCRIPTEN)
2128+
#elif defined(EMSCRIPTEN) || defined(HAIKU)
21202129
ts = gettime(CLOCK_MONOTONIC);
21212130
#else
21222131
#if _POSIX_TIMERS > 0

‎src/libpumpkin/tos/gemdos.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ typedef void *XATTR;
3838
typedef void *STAT;
3939
typedef void *POLLFD;
4040
typedef void *COOKIE;
41-
typedef void *timezone;
41+
typedef void *timezone_t;
4242
typedef void *MPB;
4343
typedef void *BPB;
4444
typedef void *MOUSE;

‎src/libpumpkin/tos/gemdos.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@
148148
338 int32_t Dreadlabel 3 char@* path char@* label int16_t length
149149
339 int32_t Dwritelabel 2 char@* path char@* label
150150
340 int32_t Ssystem 3 int16_t mode int32_t arg1 int32_t arg2
151-
341 int32_t Tgettimeofday 2 struct@timeval@* tv timezone@* tzp
152-
342 int32_t Tsettimeofday 2 struct@timeval@* tv timezone@* tzp
151+
341 int32_t Tgettimeofday 2 struct@timeval@* tv timezone_t@* tzp
152+
342 int32_t Tsettimeofday 2 struct@timeval@* tv timezone_t@* tzp
153153
343 int Tadjtime 2 struct@timeval@* delta struct@timeval@* olddelta
154154
344 int32_t Pgetpriority 2 int16_t which int16_t who
155155
345 int32_t Psetpriority 3 int16_t which int16_t who int16_t pri

‎src/libpumpkin/tos/gemdos_case.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,7 @@
16461646
struct g_timeval *tv = (struct g_timeval *)(memory + atv);
16471647
valid |= (uint8_t *)tv >= data->memory && (uint8_t *)tv < data->memory + data->memorySize;
16481648
uint32_t atzp = ARG32;
1649-
timezone *tzp = (timezone *)(memory + atzp);
1649+
timezone_t *tzp = (timezone_t *)(memory + atzp);
16501650
valid |= (uint8_t *)tzp >= data->memory && (uint8_t *)tzp < data->memory + data->memorySize;
16511651
int32_t res = 0;
16521652
if (valid) {
@@ -1663,7 +1663,7 @@
16631663
struct g_timeval *tv = (struct g_timeval *)(memory + atv);
16641664
valid |= (uint8_t *)tv >= data->memory && (uint8_t *)tv < data->memory + data->memorySize;
16651665
uint32_t atzp = ARG32;
1666-
timezone *tzp = (timezone *)(memory + atzp);
1666+
timezone_t *tzp = (timezone_t *)(memory + atzp);
16671667
valid |= (uint8_t *)tzp >= data->memory && (uint8_t *)tzp < data->memory + data->memorySize;
16681668
int32_t res = 0;
16691669
if (valid) {

‎src/libpumpkin/tos/gemdos_impl.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,12 +1122,12 @@ int32_t Ssystem(int16_t mode, int32_t arg1, int32_t arg2) {
11221122
return 0;
11231123
}
11241124

1125-
int32_t Tgettimeofday(struct g_timeval *tv, timezone *tzp) {
1125+
int32_t Tgettimeofday(struct g_timeval *tv, timezone_t *tzp) {
11261126
debug(DEBUG_ERROR, "TOS", "Tgettimeofday not implemented");
11271127
return 0;
11281128
}
11291129

1130-
int32_t Tsettimeofday(struct g_timeval *tv, timezone *tzp) {
1130+
int32_t Tsettimeofday(struct g_timeval *tv, timezone_t *tzp) {
11311131
debug(DEBUG_ERROR, "TOS", "Tsettimeofday not implemented");
11321132
return 0;
11331133
}

‎src/libpumpkin/tos/gemdos_proto.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ int32_t Shutdown(int32_t mode);
140140
int32_t Dreadlabel(char *path, char *label, int16_t length);
141141
int32_t Dwritelabel(char *path, char *label);
142142
int32_t Ssystem(int16_t mode, int32_t arg1, int32_t arg2);
143-
int32_t Tgettimeofday(struct g_timeval *tv, timezone *tzp);
144-
int32_t Tsettimeofday(struct g_timeval *tv, timezone *tzp);
143+
int32_t Tgettimeofday(struct g_timeval *tv, timezone_t *tzp);
144+
int32_t Tsettimeofday(struct g_timeval *tv, timezone_t *tzp);
145145
int Tadjtime(struct g_timeval *delta, struct g_timeval *olddelta);
146146
int32_t Pgetpriority(int16_t which, int16_t who);
147147
int32_t Psetpriority(int16_t which, int16_t who, int16_t pri);

0 commit comments

Comments
 (0)
Please sign in to comment.