diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2024-01-29 16:18:38 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-29 16:18:38 +0000 |
| commit | f588593ff15fa13e89bd869a52b2ff9bf9d91341 (patch) | |
| tree | 8f2c0a32259c405c53396ead12b1c8f3f5c261d0 /base/runtime/os_specific_linux.odin | |
| parent | a78f062499c7f0112558872a500904e6fbc6761b (diff) | |
| parent | a626adac8e8e0ca0506401cf3376727ad801091c (diff) | |
Merge pull request #3147 from odin-lang/base-work
`base` library collection work
Diffstat (limited to 'base/runtime/os_specific_linux.odin')
| -rw-r--r-- | base/runtime/os_specific_linux.odin | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/base/runtime/os_specific_linux.odin b/base/runtime/os_specific_linux.odin new file mode 100644 index 000000000..abcfc741b --- /dev/null +++ b/base/runtime/os_specific_linux.odin @@ -0,0 +1,24 @@ +//+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) + } + + stderr :: 2 + + 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 +} |