Skip to content

Add optional FFI_MAX_CLOSURE_ARGS to specification? #703

@hoodmane

Description

@hoodmane

It would be helpful if libffi add an extra optional constant FFI_MAX_CLOSURE_ARGS to the specification. Implementations that are limited in the number of arguments they can use in closures could use this. For instance, on my libffi Emscripten port I can define in ffitarget.h

#define FFI_MAX_CLOSURE_ARGS 122

This could then be consumed by ctypes: they currently have:

#define CTYPES_MAX_ARGCOUNT 1024

https://github.com/python/cpython/blob/main/Modules/_ctypes/ctypes.h
but it would be nice to replace this with:

#ifdef FFI_MAX_CLOSURE_ARGS
#define CTYPES_MAX_ARGCOUNT FFI_MAX_CLOSURE_ARGS
#else
#define CTYPES_MAX_ARGCOUNT 1024
#endif

and then we could fix Python's ctypes test test_callback_too_many_args in Emscripten, which tries to call a function with CTYPES_MAX_ARGCOUNT aguments.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions