aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2026-02-10 20:19:26 +0100
committerGitHub <noreply@github.com>2026-02-10 20:19:26 +0100
commit855bc31350a9a6aa23193c0b4e13f17e6e6f68ea (patch)
tree549a3e3a3b8527e070363548aaf4c8f439274ac1
parent132e4e470f9662f308bba86e09199ec4bc400d60 (diff)
parent83489c07f1123e1994e40a08a32206d8d78414a9 (diff)
Merge pull request #6254 from jakubtomsu/more-import-cleanup
More import cleanup
-rw-r--r--core/bytes/bytes.odin18
-rw-r--r--core/debug/trace/trace.odin32
-rw-r--r--core/debug/trace/trace_cpp.odin3
-rw-r--r--core/debug/trace/trace_windows.odin3
-rw-r--r--core/hash/xxhash/streaming.odin4
5 files changed, 47 insertions, 13 deletions
diff --git a/core/bytes/bytes.odin b/core/bytes/bytes.odin
index 79de89d2f..911c62d5d 100644
--- a/core/bytes/bytes.odin
+++ b/core/bytes/bytes.odin
@@ -1,8 +1,8 @@
// Procedures for manipulation of `[]byte` slices.
package bytes
+import "base:runtime"
import "base:intrinsics"
-import "core:mem"
import "core:simd"
import "core:unicode"
import "core:unicode/utf8"
@@ -40,7 +40,7 @@ clone :: proc(s: []byte, allocator := context.allocator, loc := #caller_location
return c[:len(s)]
}
-clone_safe :: proc(s: []byte, allocator := context.allocator, loc := #caller_location) -> (data: []byte, err: mem.Allocator_Error) {
+clone_safe :: proc(s: []byte, allocator := context.allocator, loc := #caller_location) -> (data: []byte, err: runtime.Allocator_Error) {
c := make([]byte, len(s), allocator, loc) or_return
copy(c, s)
return c[:len(s)], nil
@@ -48,7 +48,7 @@ clone_safe :: proc(s: []byte, allocator := context.allocator, loc := #caller_loc
ptr_from_slice :: ptr_from_bytes
ptr_from_bytes :: proc(str: []byte) -> ^byte {
- d := transmute(mem.Raw_String)str
+ d := transmute(runtime.Raw_String)str
return d.data
}
@@ -70,7 +70,13 @@ truncate_to_rune :: proc(str: []byte, r: rune) -> []byte {
// Compares two strings, returning a value representing which one comes first lexiographically.
// -1 for `a`; 1 for `b`, or 0 if they are equal.
compare :: proc(lhs, rhs: []byte) -> int {
- return mem.compare(lhs, rhs)
+ res := runtime.memory_compare(raw_data(lhs), raw_data(rhs), min(len(lhs), len(rhs)))
+ if res == 0 && len(lhs) != len(rhs) {
+ return len(lhs) <= len(rhs) ? -1 : +1
+ } else if len(lhs) == 0 && len(rhs) == 0 {
+ return 0
+ }
+ return res
}
contains_rune :: proc(s: []byte, r: rune) -> int {
@@ -176,7 +182,7 @@ join :: proc(a: [][]byte, sep: []byte, allocator := context.allocator) -> []byte
return b
}
-join_safe :: proc(a: [][]byte, sep: []byte, allocator := context.allocator) -> (data: []byte, err: mem.Allocator_Error) {
+join_safe :: proc(a: [][]byte, sep: []byte, allocator := context.allocator) -> (data: []byte, err: runtime.Allocator_Error) {
if len(a) == 0 {
return nil, nil
}
@@ -212,7 +218,7 @@ concatenate :: proc(a: [][]byte, allocator := context.allocator) -> []byte {
return b
}
-concatenate_safe :: proc(a: [][]byte, allocator := context.allocator) -> (data: []byte, err: mem.Allocator_Error) {
+concatenate_safe :: proc(a: [][]byte, allocator := context.allocator) -> (data: []byte, err: runtime.Allocator_Error) {
if len(a) == 0 {
return nil, nil
}
diff --git a/core/debug/trace/trace.odin b/core/debug/trace/trace.odin
index 134609b05..6a9ba9dab 100644
--- a/core/debug/trace/trace.odin
+++ b/core/debug/trace/trace.odin
@@ -44,4 +44,34 @@ resolve :: proc(ctx: ^Context, frame: Frame, allocator: runtime.Allocator) -> (r
@(require_results)
in_resolve :: proc "contextless" (ctx: ^Context) -> bool {
return intrinsics.atomic_load(&ctx.in_resolve)
-} \ No newline at end of file
+}
+
+_format_hex :: proc(buf: []byte, val: uintptr, allocator: runtime.Allocator) -> int {
+ _digits := "0123456789abcdef"
+
+ shift := (size_of(uintptr) * 8) - 4
+ offs := 0
+
+ for shift >= 0 {
+ d := (val >> uint(shift)) & 0xf
+ buf[offs] = _digits[d]
+ shift -= 4
+ offs += 1
+ }
+
+ return offs
+}
+
+_format_missing_proc :: proc(addr: uintptr, allocator: runtime.Allocator) -> string {
+ PREFIX :: "proc:0x"
+ buf, buf_err := make([]byte, len(PREFIX) + 16, allocator)
+ copy(buf, PREFIX)
+
+ if buf_err != nil {
+ return "OUT_OF_MEMORY"
+ }
+
+ offs := len(PREFIX)
+ offs += _format_hex(buf[offs:], uintptr(addr), allocator)
+ return string(buf[:offs])
+}
diff --git a/core/debug/trace/trace_cpp.odin b/core/debug/trace/trace_cpp.odin
index 8ef377cef..1a96ee112 100644
--- a/core/debug/trace/trace_cpp.odin
+++ b/core/debug/trace/trace_cpp.odin
@@ -5,7 +5,6 @@ package debug_trace
import "base:intrinsics"
import "base:runtime"
import "core:strings"
-import "core:fmt"
import "core:c"
// NOTE: Relies on C++23 which adds <stacktrace> and becomes ABI and that can be used
@@ -164,7 +163,7 @@ _resolve :: proc(ctx: ^Context, frame: Frame, allocator: runtime.Allocator) -> F
} else if info: Dl_info; dladdr(rawptr(address), &info) != 0 && info.dli_sname != "" {
frame.procedure = strings.clone_from_cstring(info.dli_sname, btc.allocator)
} else {
- frame.procedure = fmt.aprintf("(procedure: 0x%x)", allocator=btc.allocator)
+ frame.procedure = _format_missing_proc(address, btc.allocator)
}
frame.line = i32(line)
return 0
diff --git a/core/debug/trace/trace_windows.odin b/core/debug/trace/trace_windows.odin
index 04e92f125..b27b0ee29 100644
--- a/core/debug/trace/trace_windows.odin
+++ b/core/debug/trace/trace_windows.odin
@@ -6,7 +6,6 @@ import "base:intrinsics"
import "base:runtime"
import win32 "core:sys/windows"
-import "core:fmt"
_Context :: struct {
hProcess: win32.HANDLE,
@@ -56,7 +55,7 @@ _resolve :: proc(ctx: ^Context, frame: Frame, allocator: runtime.Allocator) -> (
if win32.SymFromAddrW(ctx.impl.hProcess, win32.DWORD64(frame), &{}, symbol) {
fl.procedure, _ = win32.wstring_to_utf8(cstring16(&symbol.Name[0]), -1, allocator)
} else {
- fl.procedure = fmt.aprintf("(procedure: 0x%x)", frame, allocator=allocator)
+ fl.procedure = _format_missing_proc(uintptr(frame), allocator)
}
line: win32.IMAGEHLP_LINE64
diff --git a/core/hash/xxhash/streaming.odin b/core/hash/xxhash/streaming.odin
index d34206fdb..22d99be1d 100644
--- a/core/hash/xxhash/streaming.odin
+++ b/core/hash/xxhash/streaming.odin
@@ -10,7 +10,7 @@ package xxhash
Jeroen van Rijn: Initial implementation.
*/
-import "core:mem"
+import "base:runtime"
import "base:intrinsics"
/*
@@ -121,7 +121,7 @@ XXH3_init_state :: proc(state: ^XXH3_state) {
}
XXH3_create_state :: proc(allocator := context.allocator) -> (res: ^XXH3_state, err: Error) {
- state, mem_error := mem.new_aligned(XXH3_state, 64, allocator)
+ state, mem_error := runtime.new_aligned(XXH3_state, 64, allocator)
err = nil if mem_error == nil else .Error
XXH3_init_state(state)