Atom

ffi module

Call functions in C libraries and pass native values across the boundary.

Import it with 'use ffi'.

This example uses glibc on Linux. Use an appropriate shared library for your target.

Atom
use ffi
lib = ffi.load('libc.so.6')
try:
    abs = ffi.bind(lib, 'abs', [i32], i32)
    print(abs(-7))
finally:
    ffi.close(lib)
Output
7

Requires ATOM_WITH_FFI and host permission. Libraries and pointers carry native lifetimes. See Foreign function interface for descriptors, ownership, examples and the extension ABI. The fixture described there supplies the native_fixture binary used in several entries.

Functions