From ef1e5586a47002a6f21f43871b5fcfdb2c60af5d Mon Sep 17 00:00:00 2001 From: Murilo Ijanc Date: Sun, 26 Jul 2026 14:15:37 -0300 Subject: Document the variadic calling-convention limit in the README MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The caveat lived only in the cepis_http module header. Anyone porting this to another platform reads the README, not the source of the transport module — and on an ABI that passes variadic arguments on the stack the binding fails by corrupting the option value, not by refusing to compile. --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 6ccea02..7d6d6ab 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,27 @@ because the twelve entry points this library needs are a fraction of what such a wrapper brings, and one file with no dependency is easier to audit than one more dependency. +### Platform support and the calling convention + +Built and tested on **Linux x86-64 with gfortran**. Other platforms are +plausible but unverified — including other compilers, `flang` and `ifx` among +them. + +One limit is worth knowing before you port this: `curl_easy_setopt` and +`curl_easy_getinfo` are **variadic** in C, and Fortran cannot express that. +`src/cepis_http.f90` binds them with a single pointer-sized third argument and +passes integers through `transfer`, which is what the **SysV AMD64** and +**AAPCS64** calling conventions ask for — in both, the first several variadic +arguments travel in registers exactly as fixed ones do. + +That assumption does **not** hold on every ABI. On one that passes variadic +arguments on the stack while passing fixed arguments in registers — **Apple +ARM64 is the case to watch** — the binding as written would put the value in +the wrong place, and the failure would be silent corruption of the option +value rather than a compile error. Porting there means giving the variadic +calls their own interface blocks per option type, or routing them through a +small C shim. + ## Usage `use cepis` brings in everything. Every fallible call returns an `integer` -- cgit v1.3