mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-09 14:32:41 +00:00
Move runtime os specific freestanding stuff to a separate file
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
21
core/runtime/os_specific_freestanding.odin
Normal file
21
core/runtime/os_specific_freestanding.odin
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user