Files
Odin/core/prof/spall/spall_linux.odin
T
2024-08-04 11:58:04 +01:00

37 lines
851 B
Odin

//+private
package spall
// Only for types and constants.
import "core:os"
// Package is `//+no-instrumentation`, safe to use.
import "core:sys/linux"
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, nil
}
for n < len(data) {
chunk := data[:min(len(data), MAX_RW)]
written, errno := linux.write(linux.Fd(fd), chunk)
if errno != nil {
return n, os.Platform_Error(errno)
}
n += written
}
return n, nil
}
CLOCK_MONOTONIC_RAW :: 4 // NOTE(tetra): "RAW" means: Not adjusted by NTP.
@(no_instrumentation)
_tick_now :: proc "contextless" () -> (ns: i64) {
t, _ := linux.clock_gettime(.MONOTONIC_RAW)
return i64(t.time_sec)*1e9 + i64(t.time_nsec)
}