mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 03:30:14 +01:00
unix/modffi: Clean up FFI closures memory management.
This commit removes custom FFI closures alloc/free functions, in favour of using the tracked allocation facility to allocate memory for FFI callback objects. This stems from linking issues in the Arm port when updating LibFFI to the latest stable version, as the overridden alloc/free functions didn't replace LibFFI's (unlike in other ports). The original code did no effective cleanup for allocated callback objects, so there is no real impact when switching allocation strategy. The tracked allocation feature used to be enabled only if the Bluetooth stack integration was enabled. This commit also enables tracked allocation support if FFI support is enabled. Co-authored-by: Damien George <damien@micropython.org> Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit is contained in:
committed by
Damien George
parent
2b5feb9121
commit
9796625457
@@ -85,25 +85,6 @@ void mp_unix_mark_exec(void) {
|
||||
}
|
||||
}
|
||||
|
||||
#if MICROPY_FORCE_PLAT_ALLOC_EXEC
|
||||
// Provide implementation of libffi ffi_closure_* functions in terms
|
||||
// of the functions above. On a normal Linux system, this save a lot
|
||||
// of code size.
|
||||
void *ffi_closure_alloc(size_t size, void **code);
|
||||
void ffi_closure_free(void *ptr);
|
||||
|
||||
void *ffi_closure_alloc(size_t size, void **code) {
|
||||
size_t dummy;
|
||||
mp_unix_alloc_exec(size, code, &dummy);
|
||||
return *code;
|
||||
}
|
||||
|
||||
void ffi_closure_free(void *ptr) {
|
||||
(void)ptr;
|
||||
// TODO
|
||||
}
|
||||
#endif
|
||||
|
||||
MP_REGISTER_ROOT_POINTER(void *mmap_region_head);
|
||||
|
||||
#endif // MICROPY_EMIT_NATIVE || (MICROPY_PY_FFI && MICROPY_FORCE_PLAT_ALLOC_EXEC)
|
||||
|
||||
Reference in New Issue
Block a user