Merge pull request #5558 from odin-lang/bill/init-fini-changes

`@(init)` & `@(finit)` Changes.
This commit is contained in:
gingerBill
2025-08-10 12:47:15 +01:00
committed by GitHub
67 changed files with 226 additions and 136 deletions
+3 -2
View File
@@ -10,8 +10,9 @@ g_ctx: runtime.Context
g_allocator: mem.Compat_Allocator
@(init)
init_context :: proc() {
g_ctx = context
init_context :: proc "contextless" () {
g_ctx = runtime.default_context()
context = g_ctx
// Wrapping the allocator with the mem.Compat_Allocator so we can
// mimic the realloc semantics.
+1 -1
View File
@@ -169,7 +169,7 @@ exit :: proc "c" (exit_code: c.int) -> ! {
}
@(private, fini)
finish_atexit :: proc "c" () {
finish_atexit :: proc "contextless" () {
n := intrinsics.atomic_exchange(&atexit_functions_count, 0)
for function in atexit_functions[:n] {
function()
+2 -2
View File
@@ -25,7 +25,7 @@ BINDINGS_VERSION :: [3]u32{BINDINGS_VERSION_MAJOR, BINDINGS_VERSION_MIN
BINDINGS_VERSION_STRING :: "0.11.22"
@(init)
version_check :: proc() {
version_check :: proc "contextless" () {
v: [3]u32
version(&v.x, &v.y, &v.z)
if v != BINDINGS_VERSION {
@@ -43,7 +43,7 @@ version_check :: proc() {
n += copy(buf[n:], "and executing `make`")
}
panic(string(buf[:n]))
panic_contextless(string(buf[:n]))
}
}
+1 -1
View File
@@ -5,7 +5,7 @@ import "base:runtime"
g_context: runtime.Context
@(private="file", init)
wgpu_init_allocator :: proc() {
wgpu_init_allocator :: proc "contextless" () {
if g_context.allocator.procedure == nil {
g_context = runtime.default_context()
}