mem: typed allocation helpers + drop bare malloc/free (Phase 2.2); resolve 0119 as |>-contract clarification

This commit is contained in:
agra
2026-06-11 16:17:39 +03:00
parent 3e10809d7e
commit 84e0fb0752
51 changed files with 33256 additions and 32716 deletions

View File

@@ -6,14 +6,15 @@ out :: (str: string) -> void #builtin;
size_of :: ($T: Type) -> s64 #builtin;
align_of :: ($T: Type) -> s64 #builtin;
// Low-level libc bindings, used by allocator implementations to avoid
// recursing through `context.allocator`.
// recursing through `context.allocator`. The bare `malloc`/`free`
// spellings are NOT declared: the Allocator protocol + the std/mem.sx
// helpers are the allocation surface (`free` is the typed slice helper
// there). Raw libc escape hatch: `libc_malloc` / `libc_free`.
libc_malloc :: (size: s64) -> *void #foreign libc "malloc";
libc_free :: (ptr: *void) -> void #foreign libc "free";
malloc :: (size: s64) -> *void #foreign libc "malloc";
memcpy :: (dst: *void, src: *void, size: s64) -> *void #foreign libc "memcpy";
memset :: (dst: *void, val: s64, size: s64) -> void #foreign libc "memset";
free :: (ptr: *void) -> void #foreign libc "free";
type_of :: (val: $T) -> Type #builtin;
type_name :: ($T: Type) -> string #builtin;
field_count :: ($T: Type) -> s64 #builtin;