Move runtime os specific freestanding stuff to a separate file

This commit is contained in:
gingerBill
2020-09-15 12:36:37 +01:00
parent b94dde2817
commit 6f1e774a42
2 changed files with 40 additions and 40 deletions

View File

@@ -1,45 +1,24 @@
//+build !freestanding
package runtime
when ODIN_OS == "freestanding" {
_OS_Errno :: distinct int;
_OS_Handle :: distinct uintptr;
import "core:os"
os_stdout :: proc "contextless" () -> _OS_Handle {
return 1;
}
os_stderr :: proc "contextless" () -> _OS_Handle {
return 2;
}
_OS_Errno :: distinct int;
_OS_Handle :: os.Handle;
// TODO(bill): reimplement `os.write`
os_write :: proc(fd: _OS_Handle, data: []byte) -> (int, _OS_Errno) {
return 0, -1;
}
current_thread_id :: proc "contextless" () -> int {
return 0;
}
} else {
import "core:os"
_OS_Errno :: distinct int;
_OS_Handle :: os.Handle;
os_stdout :: proc "contextless" () -> _OS_Handle {
return os.stdout;
}
os_stderr :: proc "contextless" () -> _OS_Handle {
return os.stderr;
}
// TODO(bill): reimplement `os.write`
os_write :: proc(fd: _OS_Handle, data: []byte) -> (int, _OS_Errno) {
n, err := os.write(fd, data);
return int(n), _OS_Errno(err);
}
current_thread_id :: proc "contextless" () -> int {
return os.current_thread_id();
}
os_stdout :: proc "contextless" () -> _OS_Handle {
return os.stdout;
}
os_stderr :: proc "contextless" () -> _OS_Handle {
return os.stderr;
}
// TODO(bill): reimplement `os.write`
os_write :: proc(fd: _OS_Handle, data: []byte) -> (int, _OS_Errno) {
n, err := os.write(fd, data);
return int(n), _OS_Errno(err);
}
current_thread_id :: proc "contextless" () -> int {
return os.current_thread_id();
}

View File

@@ -0,0 +1,21 @@
//+build freestanding
package runtime
_OS_Errno :: distinct int;
_OS_Handle :: distinct uintptr;
os_stdout :: proc "contextless" () -> _OS_Handle {
return 1;
}
os_stderr :: proc "contextless" () -> _OS_Handle {
return 2;
}
// TODO(bill): reimplement `os.write`
os_write :: proc(fd: _OS_Handle, data: []byte) -> (int, _OS_Errno) {
return 0, -1;
}
current_thread_id :: proc "contextless" () -> int {
return 0;
}