mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-09-10 14:39:31 +00:00
02021b5853
C malloc storage has explicit lifetime: it must remain allocated until free even when no GC-visible pointer references it. Treating it as an ordinary NoPtrs allocation breaks bare-metal C object graphs, while conservatively scanning arbitrary C bytes creates false Go roots. Add allocManual/freeManual so collectors can represent pointer-free, explicitly managed storage. Block GC keeps these objects permanently marked and releases their blocks on free; Boehm uses atomic uncollectable allocations; leaking and custom collectors provide equivalent behavior. Wasm keeps its allocation map only for validation and sizes, and WASIp2 realloc now copies min(oldSize, newSize). Bump the Boehm library cache version because enabling atomic uncollectable allocations changes its compiled flags and exported API. Also handle zero-size and overflowing allocations, serialize allocation registries, reject Go finalizers on manual storage, and add CGo regressions for C pointer graphs, hidden until-free allocations, repeated free/reuse, and allocation edge cases.
90 lines
1.8 KiB
Plaintext
90 lines
1.8 KiB
Plaintext
fortytwo: 42
|
|
add: 8
|
|
myint: 3 5
|
|
myint size: 2
|
|
longlong: -1099511627776
|
|
global: 3
|
|
defined ints: 5 5
|
|
defined floats: +5.800000e+000 +5.800000e+000
|
|
defined string: defined string
|
|
defined char: 99
|
|
defined expr: 9
|
|
15: 15
|
|
25: 25
|
|
callback 1: 50
|
|
callback 2: 600
|
|
callback inside generic function: 50
|
|
variadic0: 1
|
|
variadic2: 15
|
|
headerfunc: 6
|
|
static headerfunc: 4
|
|
static headerfunc 2: +4.000000e+000
|
|
static headerfunc void: 3
|
|
bool: true true
|
|
float: +3.100000e+000
|
|
double: +3.200000e+000
|
|
complex float: (+4.100000e+000+3.300000e+000i)
|
|
complex double: (+4.200000e+000+3.400000e+000i)
|
|
complex long double: (+4.300000e+000+3.500000e+000i)
|
|
char match: true
|
|
void* match: true true true
|
|
int64_t match: true
|
|
struct: true 256 -123456 +3.140000e+000
|
|
array: 5 6 7
|
|
union: true
|
|
union s: 22
|
|
union f (C.float): +6.280000e+000
|
|
union f (float32): +3.140000e+000
|
|
union global data: 5 8 1
|
|
union local data: 5 8 1
|
|
union s: true
|
|
union f: +6.280000e+000
|
|
union field: +6.280000e+000
|
|
bitfield a: 15
|
|
bitfield b: 1
|
|
bitfield c: 2
|
|
bitfield d: 47
|
|
bitfield e: 5
|
|
bitfield a: 7
|
|
bitfield b: 0
|
|
bitfield c: 3
|
|
bitfield d: 47
|
|
bitfield e: 5
|
|
struct: 3 5
|
|
n in chain: 3
|
|
n in chain: 6
|
|
n in chain: 7
|
|
option: 12
|
|
option A: 0
|
|
option B: 1
|
|
option C: -5
|
|
option D: -4
|
|
option E: 10
|
|
option F: 11
|
|
option G: 12
|
|
option 2A: 20
|
|
option 3A: 21
|
|
enum width matches: true
|
|
CFLAGS value: 17
|
|
cstr length: 18
|
|
C.CString: string passed to C
|
|
C.charBuf: 2 0 4 8
|
|
C.CStringN: 4 2 0 4 8
|
|
C.GoString(nil):
|
|
len(C.GoStringN(nil, 0)): 0
|
|
len(C.GoBytes(nil, 0)): 0
|
|
len(C.GoBytes(C.CBytes(nil),0)): 0
|
|
rountrip CBytes: hello
|
|
malloc chain: 42
|
|
hidden malloc: 84
|
|
malloc/free stress: ok
|
|
malloc zero: ok
|
|
calloc overflow: true
|
|
EINVAL: true
|
|
EAGAIN: true
|
|
copied string: foobar
|
|
CGo sqrt(3): +1.732051e+000
|
|
C sqrt(3): +1.732051e+000
|
|
line written using C puts
|
|
line written using C printf with value=-21
|