4 Platforms and Testing
dxtr edited this page 2026-10-17 04:42:07 +02:00

Platforms and Testing

Where cl-ffi runs

Lisp SBCL
Platforms 64-bit only: Linux and Windows on x86-64, where the tests run; AArch64 Linux, whose C layout is x86-64 Linux's, is untested
Dependencies none; Parachute for the tests

The code that uses SBCL's own interfaces is all in one internal package, cl-ffi/sys. The rest is standard Common Lisp.

What differs by platform

  • long is 8 bytes on Linux and 4 on Windows; :long follows the platform.
  • Variadic floats on Windows. Windows x64 has a variadic function read a float among the first four arguments from an integer register. SBCL fills only the float register, so the function would read whatever the integer register held. On Windows, foreign-funcall-varargs therefore passes such a float as an integer holding its 64 bits, which reaches that register and is read as the float. From the fifth argument on, floats pass on the stack.

The tests

stift test

The suite calls the C library, which every platform has: strlen, qsort for callbacks, snprintf (_snprintf on Windows) for variadic calls, strtol for errno, and zlib on Linux or winmm on Windows for libraries. It needs nothing installed beyond the Lisp.

  • Layouts are held to a C program's: tests/layout.c prints the size, alignment and offsets of the test structs, and its output for Linux and for Windows is committed.
  • Saved images: a test starts a Lisp of its own that loads a copy of the library by its full path, saves an image and deletes the copy; the image, started, must find the library by name, and call it, its callbacks and its hooks.
  • Allocation: the per-frame forms must allocate nothing, averaged over 100,000 calls.

It passes on Linux and on Windows, and runs in CI on Linux.