aboutsummaryrefslogtreecommitdiff
path: root/core/prof
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-08-04 11:58:04 +0100
committergingerBill <bill@gingerbill.org>2024-08-04 11:58:04 +0100
commit97c499dbb40deeef3778c9a20aa2b38d96aa46f1 (patch)
tree66b5ed8c30068770766d8183bfb0951986a628f0 /core/prof
parent1d75a612d54f102ef530c1f58546e3cdb239160c (diff)
Begin mapping `os.Error` in the rest of the codebase
Diffstat (limited to 'core/prof')
-rw-r--r--core/prof/spall/spall.odin2
-rw-r--r--core/prof/spall/spall_linux.odin8
-rw-r--r--core/prof/spall/spall_unix.odin11
-rw-r--r--core/prof/spall/spall_windows.odin7
4 files changed, 11 insertions, 17 deletions
diff --git a/core/prof/spall/spall.odin b/core/prof/spall/spall.odin
index 38c563248..12f082b2c 100644
--- a/core/prof/spall/spall.odin
+++ b/core/prof/spall/spall.odin
@@ -68,7 +68,7 @@ BUFFER_DEFAULT_SIZE :: 0x10_0000
context_create_with_scale :: proc(filename: string, precise_time: bool, timestamp_scale: f64) -> (ctx: Context, ok: bool) #optional_ok {
fd, err := os.open(filename, os.O_WRONLY | os.O_APPEND | os.O_CREATE | os.O_TRUNC, 0o600)
- if err != os.ERROR_NONE {
+ if err != nil {
return
}
diff --git a/core/prof/spall/spall_linux.odin b/core/prof/spall/spall_linux.odin
index deee15aa1..89a4225d3 100644
--- a/core/prof/spall/spall_linux.odin
+++ b/core/prof/spall/spall_linux.odin
@@ -12,19 +12,19 @@ MAX_RW :: 0x7fffffff
@(no_instrumentation)
_write :: proc "contextless" (fd: os.Handle, data: []byte) -> (n: int, err: os.Error) #no_bounds_check /* bounds check would segfault instrumentation */ {
if len(data) == 0 {
- return 0, os.ERROR_NONE
+ return 0, nil
}
for n < len(data) {
chunk := data[:min(len(data), MAX_RW)]
written, errno := linux.write(linux.Fd(fd), chunk)
- if errno != .NONE {
- return n, os.Error(errno)
+ if errno != nil {
+ return n, os.Platform_Error(errno)
}
n += written
}
- return n, os.ERROR_NONE
+ return n, nil
}
CLOCK_MONOTONIC_RAW :: 4 // NOTE(tetra): "RAW" means: Not adjusted by NTP.
diff --git a/core/prof/spall/spall_unix.odin b/core/prof/spall/spall_unix.odin
index 6da57ee95..174b3a11b 100644
--- a/core/prof/spall/spall_unix.odin
+++ b/core/prof/spall/spall_unix.odin
@@ -22,29 +22,24 @@ foreign libc {
@(link_name="clock_gettime") _unix_clock_gettime :: proc(clock_id: u64, timespec: ^timespec) -> i32 ---
}
-@(no_instrumentation)
-get_last_error :: proc "contextless" () -> os.Platform_Error {
- return os.Platform_Error(__error()^)
-}
-
MAX_RW :: 0x7fffffff
@(no_instrumentation)
_write :: proc "contextless" (fd: os.Handle, data: []byte) -> (n: int, err: os.Error) #no_bounds_check /* bounds check would segfault instrumentation */ {
if len(data) == 0 {
- return 0, os.ERROR_NONE
+ return 0, nil
}
for n < len(data) {
chunk := data[:min(len(data), MAX_RW)]
written := _unix_write(fd, raw_data(chunk), len(chunk))
if written < 0 {
- return n, os.Error(get_last_error())
+ return n, os.get_last_error()
}
n += written
}
- return n, os.ERROR_NONE
+ return n, nil
}
CLOCK_MONOTONIC_RAW :: 4 // NOTE(tetra): "RAW" means: Not adjusted by NTP.
diff --git a/core/prof/spall/spall_windows.odin b/core/prof/spall/spall_windows.odin
index 105a61891..c8b044963 100644
--- a/core/prof/spall/spall_windows.odin
+++ b/core/prof/spall/spall_windows.odin
@@ -12,7 +12,7 @@ MAX_RW :: 1<<30
@(no_instrumentation)
_write :: proc "contextless" (fd: os.Handle, data: []byte) -> (int, os.Error) #no_bounds_check /* bounds check would segfault instrumentation */ {
if len(data) == 0 {
- return 0, os.ERROR_NONE
+ return 0, nil
}
single_write_length: win32.DWORD
@@ -25,12 +25,11 @@ _write :: proc "contextless" (fd: os.Handle, data: []byte) -> (int, os.Error) #n
e := win32.WriteFile(win32.HANDLE(fd), &data[total_write], to_write, &single_write_length, nil)
if single_write_length <= 0 || !e {
- err := os.Platform_Error(win32.GetLastError())
- return int(total_write), err
+ return int(total_write), os.get_last_error()
}
total_write += i64(single_write_length)
}
- return int(total_write), os.ERROR_NONE
+ return int(total_write), nil
}
@(no_instrumentation)