Skip to content

add mark curl_easy_setopt variadic; run lib-ajax test on macOS - #15

Merged
funlang merged 1 commit into
mainfrom
add-variadic-ffi
Oct 16, 2026
Merged

funlang merged 1 commit into
mainfrom
add-variadic-ffi

Conversation

@taadis

@taadis taadis commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

macOS arm64 passes variadic arguments on the stack (Apple's AAPCS64), unlike
the other targets fun runs on. lffi.pas prepared every call with the fixed
ffi_prep_cif, so on Apple Silicon every FFI call into a variadic C function
got garbage in the tail. First victim in the stdlib: lib-ajax
(curl_easy_setopt is variadic) -- HTTP never worked on macOS, every transfer
returned rc=3 (URL_MALFORMAT). Minimal repro (before the fix):

  var p = LibC().getapi('printf', 'si:i');
  p('t=%d' & 10.toChar(), 42);   // prints  t=0

Changes:

  • lffi.pas: getapi gains an optional named argument variadic: <fixed count>;
    marked bindings prepare via ffi_prep_cif_var, unmarked bindings take the
    exact old path (falling back to the fixed form if the loaded libffi
    refuses).
  • lib-ajax-unx.fun: the three curl_easy_setopt bindings marked variadic: 2
    (behaviour-neutral on the SysV family; the difference between working and
    not on Darwin arm64).
  • lib-ajax-lnx-test.fun un-skipped on macOS (output matches the shared
    snapshot byte for byte).

Verified: printf t=0 -> t=42 s=abc (unmarked stays t=0); lib-ajax on
Apple Silicon: file fixture, live HTTP 200, 404, saveas all correct; macOS
suite 81/81; full Linux-aarch64 suite 87/87 (SysV unaffected). The variadic
audit found only lib-proc-lnx's open -- Linux-only, left unchanged.

@funlang
funlang merged commit a70e9cd into main Oct 16, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants