Require @(init) and @(fini) to be proc "contextless" ()

This commit is contained in:
gingerBill
2025-08-08 12:10:01 +01:00
parent 3194fda8f3
commit 7642e0a0e0
47 changed files with 170 additions and 102 deletions
+2 -2
View File
@@ -16,7 +16,7 @@ MAX_TEMP_ARENA_COLLISIONS :: MAX_TEMP_ARENA_COUNT - 1
global_default_temp_allocator_arenas: [MAX_TEMP_ARENA_COUNT]runtime.Arena
@(fini, private)
temp_allocator_fini :: proc() {
temp_allocator_fini :: proc "contextless" () {
for &arena in global_default_temp_allocator_arenas {
runtime.arena_destroy(&arena)
}
@@ -69,6 +69,6 @@ _temp_allocator_end :: proc(tmp: runtime.Arena_Temp) {
}
@(init, private)
init_thread_local_cleaner :: proc() {
init_thread_local_cleaner :: proc "contextless" () {
runtime.add_thread_local_cleaner(temp_allocator_fini)
}
+2 -2
View File
@@ -25,8 +25,8 @@ File_Impl :: struct {
}
@(init)
init_std_files :: proc() {
new_std :: proc(impl: ^File_Impl, fd: posix.FD, name: cstring) -> ^File {
init_std_files :: proc "contextless" () {
new_std :: proc "contextless" (impl: ^File_Impl, fd: posix.FD, name: cstring) -> ^File {
impl.file.impl = impl
impl.fd = fd
impl.allocator = runtime.nil_allocator()
+2 -2
View File
@@ -30,8 +30,8 @@ Preopen :: struct {
preopens: []Preopen
@(init)
init_std_files :: proc() {
new_std :: proc(impl: ^File_Impl, fd: wasi.fd_t, name: string) -> ^File {
init_std_files :: proc "contextless" () {
new_std :: proc "contextless" (impl: ^File_Impl, fd: wasi.fd_t, name: string) -> ^File {
impl.file.impl = impl
impl.allocator = runtime.nil_allocator()
impl.fd = fd
+4 -4
View File
@@ -43,8 +43,8 @@ File_Impl :: struct {
}
@(init)
init_std_files :: proc() {
new_std :: proc(impl: ^File_Impl, code: u32, name: string) -> ^File {
init_std_files :: proc "contextless" () {
new_std :: proc "contextless" (impl: ^File_Impl, code: u32, name: string) -> ^File {
impl.file.impl = impl
impl.allocator = runtime.nil_allocator()
@@ -77,7 +77,7 @@ init_std_files :: proc() {
stderr = new_std(&files[2], win32.STD_ERROR_HANDLE, "<stderr>")
}
_handle :: proc(f: ^File) -> win32.HANDLE {
_handle :: proc "contextless" (f: ^File) -> win32.HANDLE {
return win32.HANDLE(_fd(f))
}
@@ -234,7 +234,7 @@ _clone :: proc(f: ^File) -> (clone: ^File, err: Error) {
return _new_file(uintptr(clonefd), name(f), file_allocator())
}
_fd :: proc(f: ^File) -> uintptr {
_fd :: proc "contextless" (f: ^File) -> uintptr {
if f == nil || f.impl == nil {
return INVALID_HANDLE
}
+1 -1
View File
@@ -160,7 +160,7 @@ _get_executable_path :: proc(allocator: runtime.Allocator) -> (path: string, err
can_use_long_paths: bool
@(init)
init_long_path_support :: proc() {
init_long_path_support :: proc "contextless" () {
can_use_long_paths = false
key: win32.HKEY