diff options
| author | gingerBill <bill@gingerbill.org> | 2020-09-15 12:36:37 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2020-09-15 12:36:37 +0100 |
| commit | 6f1e774a429165dfbca46cf76a42ce1de644abaf (patch) | |
| tree | 42c5d8321538937e7f35b9ee85cc77eb294e952f | |
| parent | b94dde281726ce16f79167e58159a8026c689ef9 (diff) | |
Move runtime os specific freestanding stuff to a separate file
| -rw-r--r-- | core/runtime/os_specific.odin | 55 | ||||
| -rw-r--r-- | core/runtime/os_specific_freestanding.odin | 21 |
2 files changed, 38 insertions, 38 deletions
diff --git a/core/runtime/os_specific.odin b/core/runtime/os_specific.odin index e09acb51c..ab2d78007 100644 --- a/core/runtime/os_specific.odin +++ b/core/runtime/os_specific.odin @@ -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; - } +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); - } +// 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(); - } +current_thread_id :: proc "contextless" () -> int { + return os.current_thread_id(); } diff --git a/core/runtime/os_specific_freestanding.odin b/core/runtime/os_specific_freestanding.odin new file mode 100644 index 000000000..3906e3ed7 --- /dev/null +++ b/core/runtime/os_specific_freestanding.odin @@ -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; +} |