diff options
| author | gingerBill <bill@gingerbill.org> | 2024-01-28 22:05:13 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-01-28 22:05:13 +0000 |
| commit | 9be9f0bb2c6761a424d9e151594c61af29163be7 (patch) | |
| tree | da6485dc0df42be033eeb0599c6a416631e26d3a /base | |
| parent | 9e7cc8cf9357750e3ed5410ef61bb9929ffcf011 (diff) | |
Remove `core:os` dependency for `runtime.os_write` on linux
Diffstat (limited to 'base')
| -rw-r--r-- | base/runtime/os_specific_any.odin | 1 | ||||
| -rw-r--r-- | base/runtime/os_specific_linux.odin | 22 |
2 files changed, 23 insertions, 0 deletions
diff --git a/base/runtime/os_specific_any.odin b/base/runtime/os_specific_any.odin index 7dc41c3c9..c36f43e21 100644 --- a/base/runtime/os_specific_any.odin +++ b/base/runtime/os_specific_any.odin @@ -1,4 +1,5 @@ //+build !darwin +//+build !linux //+build !freestanding //+build !js //+build !wasi diff --git a/base/runtime/os_specific_linux.odin b/base/runtime/os_specific_linux.odin new file mode 100644 index 000000000..9116bb32e --- /dev/null +++ b/base/runtime/os_specific_linux.odin @@ -0,0 +1,22 @@ +//+private +package runtime + +import "base:intrinsics" + +_os_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) { + when ODIN_ARCH == .amd64 { + SYS_write :: uintptr(1) + } else when ODIN_ARCH == .arm64 { + SYS_write :: uintptr(64) + } else when ODIN_ARCH == .i386 { + SYS_write :: uintptr(4) + } else when ODIN_ARCH == .arm32 { + SYS_write :: uintptr(4) + } + + ret := int(intrinsics.syscall(SYS_write, uintptr(stderr), uintptr(raw_data(data)), uintptr(len(data)))) + if ret < 0 && ret > -4096 { + return 0, _OS_Errno(-ret) + } + return ret, 0 +} |