mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-24 23:35:19 +00:00
Remove core:os dependency for runtime.os_write on linux
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
//+build !darwin
|
||||
//+build !linux
|
||||
//+build !freestanding
|
||||
//+build !js
|
||||
//+build !wasi
|
||||
|
||||
22
base/runtime/os_specific_linux.odin
Normal file
22
base/runtime/os_specific_linux.odin
Normal file
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user