Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Haiku OS support #3230

Merged
merged 39 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c178f71
Get Odin to compile on Haiku
slendidev Feb 15, 2024
824c831
Implement futex
avanspector Feb 24, 2024
88add0b
Improve Haiku support
avanspector Feb 25, 2024
0a66732
Merge branch 'haiku' of https://github.com/avanspector/Odin into haiku
avanspector Feb 25, 2024
028a79e
Update threading.cpp
avanspector Feb 25, 2024
24c8b15
small fixes
avanspector Feb 25, 2024
b03f17d
add haiku to base:runtime and core:c/libc
avanspector Feb 25, 2024
0fa6ba7
add haiku build token
avanspector Feb 25, 2024
c3746d9
fix core and libc
avanspector Feb 25, 2024
d032cff
Update os_specific_haiku.odin
avanspector Feb 25, 2024
6c16860
fix runtime and libc
avanspector Feb 25, 2024
dfa0ccf
Update entry_unix.odin
avanspector Feb 25, 2024
2e80879
Update os_haiku.odin
avanspector Feb 25, 2024
dc5cf23
add haiku to unix
avanspector Feb 25, 2024
05cfc89
fix core:os
avanspector Feb 25, 2024
fc8e5b8
Update os_haiku.odin
avanspector Feb 25, 2024
6645671
update pthread
avanspector Feb 25, 2024
9b83962
Update os_haiku.odin
avanspector Feb 25, 2024
f0a89f8
add sys/haiku
avanspector Feb 26, 2024
c712af3
Update os_haiku.odin
avanspector Feb 26, 2024
8c62145
update sys/haiku
avanspector Feb 26, 2024
31d7ef5
Update os_haiku.odin
avanspector Feb 26, 2024
1d79521
fix sys/haiku
avanspector Feb 26, 2024
9d4c2ba
fix haiku
avanspector Feb 26, 2024
3ebf5dc
fix haiku
avanspector Feb 26, 2024
7290c69
fix haiku
avanspector Feb 26, 2024
1809024
Revert "fix haiku"
avanspector Feb 26, 2024
8d4bb35
Update futex_haiku.odin
avanspector Feb 26, 2024
38c69b9
small fixes
avanspector Feb 27, 2024
494cac0
Merge branch 'odin-lang:master' into haiku
avanspector Feb 27, 2024
fca691a
fix core:thread and a memory leak
avanspector Feb 27, 2024
87f6f3a
Merge branch 'haiku' of https://github.com/avanspector/Odin into haiku
avanspector Feb 27, 2024
bf37bee
improve core:sys
avanspector Feb 28, 2024
290ada7
add exit to core:os
avanspector Feb 28, 2024
5d6b4ed
Merge branch 'odin-lang:master' into haiku
avanspector Feb 29, 2024
d4d9f55
Update threading.cpp
avanspector Feb 29, 2024
1861ecf
Merge branch 'haiku' of https://github.com/avanspector/Odin into haiku
avanspector Feb 29, 2024
f92042e
Merge branch 'odin-lang:master' into haiku
avanspector Feb 29, 2024
0bb2327
Merge branch 'haiku' of https://github.com/avanspector/Odin into haiku
avanspector Feb 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/runtime/entry_unix.odin
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//+private
//+build linux, darwin, freebsd, openbsd
//+build linux, darwin, freebsd, openbsd, haiku
//+no-instrumentation
package runtime

Expand Down
4 changes: 2 additions & 2 deletions base/runtime/heap_allocator_unix.odin
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//+build linux, darwin, freebsd, openbsd
//+build linux, darwin, freebsd, openbsd, haiku
//+private
package runtime

Expand Down Expand Up @@ -35,4 +35,4 @@ _heap_resize :: proc(ptr: rawptr, new_size: int) -> rawptr {

_heap_free :: proc(ptr: rawptr) {
_unix_free(ptr)
}
}
21 changes: 21 additions & 0 deletions base/runtime/os_specific_haiku.odin
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//+build haiku
//+private
package runtime

foreign import libc "system:c"

foreign libc {
@(link_name="write")
_unix_write :: proc(fd: i32, buf: rawptr, size: int) -> int ---

_errnop :: proc() -> ^i32 ---
}

_stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
ret := _unix_write(2, raw_data(data), len(data))
if ret < len(data) {
err := _errnop()
return int(ret), _OS_Errno(err^ if err != nil else 0)
}
return int(ret), 0
}
5 changes: 5 additions & 0 deletions build_odin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ OpenBSD)
LDFLAGS="$LDFLAGS -liconv"
LDFLAGS="$LDFLAGS $($LLVM_CONFIG --libs core native --system-libs)"
;;
Haiku)
CXXFLAGS="$CXXFLAGS $($LLVM_CONFIG --cxxflags --ldflags) -I/system/develop/headers/private/shared -I/system/develop/headers/private/kernel"
LDFLAGS="$LDFLAGS -liconv"
LDFLAGS="$LDFLAGS $($LLVM_CONFIG --libs core native --system-libs)"
;;
*)
error "Platform \"$OS_NAME\" unsupported"
;;
Expand Down
18 changes: 18 additions & 0 deletions core/c/libc/errno.odin
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,24 @@ when ODIN_OS == .Darwin {
ERANGE :: 34
}

when ODIN_OS == .Haiku {
@(private="file")
@(default_calling_convention="c")
foreign libc {
@(link_name="_errnop")
_get_errno :: proc() -> ^int ---
}

@(private="file")
B_GENERAL_ERROR_BASE :: min(i32)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do -(1<<31) instead here to keep it untyped.

@(private="file")
B_POSIX_ERROR_BASE :: B_GENERAL_ERROR_BASE + 0x7000

EDOM :: B_POSIX_ERROR_BASE + 16
EILSEQ :: B_POSIX_ERROR_BASE + 38
ERANGE :: B_POSIX_ERROR_BASE + 17
}

// Odin has no way to make an identifier "errno" behave as a function call to
// read the value, or to produce an lvalue such that you can assign a different
// error value to errno. To work around this, just expose it as a function like
Expand Down
30 changes: 30 additions & 0 deletions core/c/libc/stdio.odin
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,36 @@ when ODIN_OS == .Darwin {
}
}

when ODIN_OS == .Haiku {
fpos_t :: distinct i64

_IOFBF :: 0
_IOLBF :: 1
_IONBF :: 2

BUFSIZ :: 8192

EOF :: int(-1)

FOPEN_MAX :: 128

FILENAME_MAX :: 256

L_tmpnam :: 512

SEEK_SET :: 0
SEEK_CUR :: 1
SEEK_END :: 2

TMP_MAX :: 32768

foreign libc {
stderr: ^FILE
stdin: ^FILE
stdout: ^FILE
}
}

@(default_calling_convention="c")
foreign libc {
// 7.21.4 Operations on files
Expand Down
2 changes: 1 addition & 1 deletion core/c/libc/time.odin
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ when ODIN_OS == .Windows {
}
}

when ODIN_OS == .Linux || ODIN_OS == .FreeBSD || ODIN_OS == .Darwin || ODIN_OS == .OpenBSD {
when ODIN_OS == .Linux || ODIN_OS == .FreeBSD || ODIN_OS == .Darwin || ODIN_OS == .OpenBSD || ODIN_OS == .Haiku {
@(default_calling_convention="c")
foreign libc {
// 7.27.2 Time manipulation functions
Expand Down
6 changes: 5 additions & 1 deletion core/c/libc/wctype.odin
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ when ODIN_OS == .Windows {
} else when ODIN_OS == .FreeBSD {
wctrans_t :: distinct int
wctype_t :: distinct ulong


} else when ODIN_OS == .Haiku {
wctrans_t :: distinct i32
wctype_t :: distinct i32

}

@(default_calling_convention="c")
Expand Down
Loading