From 6c16860be6176ba74f5a9cabf3770b2c006c9740 Mon Sep 17 00:00:00 2001 From: avanspector Date: Sun, 25 Feb 2024 03:43:41 +0100 Subject: [PATCH] fix runtime and libc --- base/runtime/heap_allocator_unix.odin | 4 ++-- core/c/libc/errno.odin | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/base/runtime/heap_allocator_unix.odin b/base/runtime/heap_allocator_unix.odin index bfbbb5303..2b6698885 100644 --- a/base/runtime/heap_allocator_unix.odin +++ b/base/runtime/heap_allocator_unix.odin @@ -1,4 +1,4 @@ -//+build linux, darwin, freebsd, openbsd +//+build linux, darwin, freebsd, openbsd, haiku //+private package runtime @@ -35,4 +35,4 @@ _heap_resize :: proc(ptr: rawptr, new_size: int) -> rawptr { _heap_free :: proc(ptr: rawptr) { _unix_free(ptr) -} \ No newline at end of file +} diff --git a/core/c/libc/errno.odin b/core/c/libc/errno.odin index fe6fbb073..7af763706 100644 --- a/core/c/libc/errno.odin +++ b/core/c/libc/errno.odin @@ -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) + @(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