diff options
| author | gingerBill <bill@gingerbill.org> | 2024-01-28 23:11:38 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-01-28 23:11:38 +0000 |
| commit | 535b8a94832e7f0935bd7a6ccdc6a59bf68d4d9f (patch) | |
| tree | 0074f9665d97e9ed5be880478caead2cbcb5737d /base | |
| parent | 038086d1d90e93a093caa438dd4a1c8f23c440c2 (diff) | |
Remove `core:os` dependency completely from `base:runtime`
Diffstat (limited to 'base')
| -rw-r--r-- | base/runtime/os_specific_any.odin | 18 | ||||
| -rw-r--r-- | base/runtime/os_specific_bsd.odin | 21 |
2 files changed, 21 insertions, 18 deletions
diff --git a/base/runtime/os_specific_any.odin b/base/runtime/os_specific_any.odin deleted file mode 100644 index c36f43e21..000000000 --- a/base/runtime/os_specific_any.odin +++ /dev/null @@ -1,18 +0,0 @@ -//+build !darwin -//+build !linux -//+build !freestanding -//+build !js -//+build !wasi -//+build !windows -//+private -package runtime - -import "core:os" - -// TODO(bill): reimplement `os.write` so that it does not rely on package os -// NOTE: Use os_specific_linux.odin, os_specific_darwin.odin, etc -_os_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) { - context = default_context() - n, err := os.write(os.stderr, data) - return int(n), _OS_Errno(err) -} diff --git a/base/runtime/os_specific_bsd.odin b/base/runtime/os_specific_bsd.odin new file mode 100644 index 000000000..93ed9b4e6 --- /dev/null +++ b/base/runtime/os_specific_bsd.odin @@ -0,0 +1,21 @@ +//+build freebsd, openbsd +//+private +package runtime + +foreign import libc "system:c" + +foreign libc { + @(link_name="write") + _unix_write :: proc(fd: uintptr, buf: rawptr, size: int) -> int --- + + __error :: proc() -> ^i32 --- +} + +_os_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) { + ret := _unix_write(2, raw_data(data), len(data)) + if ret < len(data) { + err := __error() + return int(ret), _OS_Errno(err^ if err != nil else 0) + } + return int(ret), 0 +} |