Portable system calls for Common Lisp
This library enables any Lisp, as long as supported by CFFI, to invoke system calls through a low-level foreign function interface.
⚠ Note: Only these OS and architectures are supported at the moment:
To install syscall
, you can use Quicklisp:
"syscall") (ql:quickload
The C shared libraries are bundled with the source distributed and
will be loaded during the evaluation of
(ql:quickload "syscall")
.
Here is a basic example of how to use syscall on Linux x86-64 platform:
;; getpid (sc:syscall syscall.constants:+GETPID+)
This will show you the current Lisp process's PID.
sc:syscall
can take up to six arguments to the system
call; alternatively, you may explicitly use these APIs if preferred,
where sc:syscallN
denotes that N
arguments
shall be passed to a system call:
sc:syscall0
sc:syscall1
sc:syscall2
sc:syscall3
sc:syscall4
sc:syscall5
sc:syscall6
syscall
and the variants only takes and return unsigned
machine integer(s), so it is the caller's responsibility to:
(unsigned-byte
64)
)syscall.constants
packageFor convenience, a set of system call numbers were parsed as
constants in advance for all supported platforms. See
src/platform/your-platform/constants.lisp
and
gen-platform-constants.lisp
for more details.
Contributions are welcome! Please submit a pull request or open an issue on GitHub.
syscall
is licensed under the MIT License.