diff options
| author | Laytan Laats <laytanlaats@hotmail.com> | 2024-07-08 15:39:23 +0200 |
|---|---|---|
| committer | Laytan Laats <laytanlaats@hotmail.com> | 2024-07-08 15:39:23 +0200 |
| commit | ddad2011e241cf1e17ebe6f5bdac557493e3e357 (patch) | |
| tree | fa99dad6c44d7d08589c2a9418ee5992f6ee1ba9 /base/runtime | |
| parent | 861ad2037ffffb22f20a6de328139b7c4817c639 (diff) | |
darwin: remove syscall usage (without -no-crt) to comply to Apple guidelines
Diffstat (limited to 'base/runtime')
| -rw-r--r-- | base/runtime/os_specific_darwin.odin | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/base/runtime/os_specific_darwin.odin b/base/runtime/os_specific_darwin.odin index 61c17a597..1bf29e785 100644 --- a/base/runtime/os_specific_darwin.odin +++ b/base/runtime/os_specific_darwin.odin @@ -5,11 +5,24 @@ package runtime import "base:intrinsics" _stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) { - WRITE :: 0x2000004 STDERR :: 2 - ret := intrinsics.syscall(WRITE, STDERR, uintptr(raw_data(data)), uintptr(len(data))) - if ret < 0 { - return 0, _OS_Errno(-ret) + when ODIN_NO_CRT { + WRITE :: 0x2000004 + ret := intrinsics.syscall(WRITE, STDERR, uintptr(raw_data(data)), uintptr(len(data))) + if ret < 0 { + return 0, _OS_Errno(-ret) + } + return int(ret), 0 + } else { + foreign { + write :: proc(handle: i32, buffer: [^]byte, count: uint) -> int --- + __error :: proc() -> ^i32 --- + } + + if ret := write(STDERR, raw_data(data), len(data)); ret >= 0 { + return int(ret), 0 + } + + return 0, _OS_Errno(__error()^) } - return int(ret), 0 } |