diff --git a/codon/runtime/lib.cpp b/codon/runtime/lib.cpp index 2f905b25..ba99a6cb 100644 --- a/codon/runtime/lib.cpp +++ b/codon/runtime/lib.cpp @@ -173,6 +173,14 @@ SEQ_FUNC void *seq_alloc_uncollectable(size_t n) { #endif } +SEQ_FUNC void *seq_alloc_atomic_uncollectable(size_t n) { +#if USE_STANDARD_MALLOC + return malloc(n); +#else + return GC_MALLOC_ATOMIC_UNCOLLECTABLE(n); +#endif +} + SEQ_FUNC void *seq_calloc(size_t m, size_t n) { #if USE_STANDARD_MALLOC return calloc(m, n); diff --git a/stdlib/internal/gc.codon b/stdlib/internal/gc.codon index abdcd54e..47f57fbd 100644 --- a/stdlib/internal/gc.codon +++ b/stdlib/internal/gc.codon @@ -16,6 +16,11 @@ def seq_alloc_atomic(a: int) -> cobj: def seq_alloc_uncollectable(a: int) -> cobj: pass +@pure +@C +def seq_alloc_atomic_uncollectable(a: int) -> cobj: + pass + @nocapture @derives @C @@ -71,6 +76,11 @@ def alloc_atomic(sz: int): def alloc_uncollectable(sz: int): return seq_alloc_uncollectable(sz) +# Allocates a block of memory via GC that is scanned, +# but not collected itself. Should be free'd explicitly. +def alloc_atomic_uncollectable(sz: int): + return seq_alloc_atomic_uncollectable(sz) + def realloc(p: cobj, newsz: int, oldsz: int): return seq_realloc(p, newsz, oldsz) diff --git a/stdlib/internal/python.codon b/stdlib/internal/python.codon index 379592e5..55c8617b 100644 --- a/stdlib/internal/python.codon +++ b/stdlib/internal/python.codon @@ -1709,6 +1709,7 @@ class _PyWrap: def _err(k, T: type = NoneType) -> T: raise TypeError(F + "() missing required positional argument: '" + k + "'") + def _get_arg(F, p, k, i: Static[int]): if _S.fn_arg_has_type(F, i): return _S.fn_arg_get_type(F, i).__from_py__(p[i]) if p[i] != cobj() else (