We call ecl_musleep that avoids the hassle of converting values back and forth
between lisp and c world.
The change is prompted by a potential bug in cosmopolitan libc, where the value
stored in a static variable can't be passed to a function in a different
compilation unit. Unmodified code lead to a segmentation fault with cosmocc.
These are badly optimized by C compilers (even single use static
functions are not inlined by both gcc and clang), so instead of
generating a separate variadic entrypoint just generate one single
entrypoint with C compatible signature.
The presence of setjmp calls in function bodies means that some
function arguments have to be volatile. However, this doesn't apply to
variadic entrypoints which never include setjmp calls. Thus,
set *volatile* to be empty before writing out the header.
Only applies for COMPILE calls where the name of a setf function
definition will not be equal under the EQ test to the name of the same
function at a later call. Thus, we have to use EQUAL to find those
names in the vv array.
For C compatible variadic dispatch, the compiler now generates two
entrypoints for variadic functions. An entrypoint with specialized
signature that is used for direct C calls from the same file and an
entrypoint with generic signature that implements the variadic to
variadic dispatch, i.e. checking the number of arguments and then
calling the specialized entrypoint.
This approach is faster than using the wrapper functions in
variadic_dispatch_table. The reasons are threefold: we save a call to
ecl_process_env(), we don't need a call through a function pointer but
instead use a direct call to the specialized entrypoint and we emit
better code to deal with required arguments since the number of those
are known.
Moreover, for functions with optional arguments the new approach is
less stack hungry since we can allocate an array of size smaller than
ECL_C_ARGUMENTS_LIMIT to store the arguments.
We now generate entrypoints for both fixed and variable number of
arguments. The entrypoint with fixed number of arguments is used for
direct C calls from the same file while the one with variable number
of arguments for indirect calls from other files or via funcall.
This approach is faster than using the wrapper functions in
fixed_dispatch_table as we did previously for two reasons. First, it
does not require a call to ecl_process_env() and second, it can use a
direct jump to the fixed entrypoint once the number of arguments have
been checked instead of an indirect call through a function pointer.