diff options
Diffstat (limited to 'unix/alloc.c')
-rw-r--r-- | unix/alloc.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/unix/alloc.c b/unix/alloc.c index a0676a0aef..04c635ee97 100644 --- a/unix/alloc.c +++ b/unix/alloc.c @@ -33,7 +33,7 @@ #include "py/mpstate.h" #include "py/gc.h" -#if MICROPY_EMIT_NATIVE +#if MICROPY_EMIT_NATIVE || (MICROPY_PY_FFI && MICROPY_FORCE_PLAT_ALLOC_EXEC) #if defined(__OpenBSD__) || defined(__MACH__) #define MAP_ANONYMOUS MAP_ANON @@ -85,4 +85,23 @@ void mp_unix_mark_exec(void) { } } -#endif // MICROPY_EMIT_NATIVE +#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) { + mp_uint_t dummy; + mp_unix_alloc_exec(size, code, &dummy); + return *code; +} + +void ffi_closure_free(void *ptr) { + (void)ptr; + // TODO +} +#endif + +#endif // MICROPY_EMIT_NATIVE || (MICROPY_PY_FFI && MICROPY_FORCE_PLAT_ALLOC_EXEC) |