mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Remove core:os dependency from base:runtime; change to base:intrinsics
This commit is contained in:
@@ -1,12 +1,25 @@
|
||||
//+build darwin
|
||||
//+private
|
||||
package runtime
|
||||
|
||||
import "core:intrinsics"
|
||||
foreign import libc "system:System.framework"
|
||||
|
||||
foreign libc {
|
||||
@(link_name="__stderrp")
|
||||
_stderr: rawptr
|
||||
|
||||
@(link_name="fwrite")
|
||||
_fwrite :: proc(ptr: rawptr, size: uint, nmemb: uint, stream: rawptr) -> uint ---
|
||||
|
||||
@(link_name="__error")
|
||||
_get_errno :: proc() -> ^i32 ---
|
||||
}
|
||||
|
||||
_os_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
|
||||
ret := intrinsics.syscall(0x2000004, 1, uintptr(raw_data(data)), uintptr(len(data)))
|
||||
if ret < 0 {
|
||||
return 0, _OS_Errno(-ret)
|
||||
ret := _fwrite(raw_data(data), 1, len(data), _stderr)
|
||||
if ret < len(data) {
|
||||
err := _get_errno()
|
||||
return int(ret), _OS_Errno(err^ if err != nil else 0)
|
||||
}
|
||||
return int(ret), 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user