Skip to content

macdavid313/syscall

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

syscall

https://github.com/macdavid313/syscall/actions/workflows/ci.yaml/badge.svghttps://github.com/macdavid313/syscall/actions/workflows/doc.yaml/badge.svg

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:

  • linux-x86_64
  • linux-aarch64
  • macos-aarch64

Installation

To install syscall, you can use Quicklisp:

(ql:quickload "syscall")

The C shared libraries are bundled with the source distributed and will be loaded during the evaluation of (ql:quickload "syscall").

Usage

Here is a basic example of how to use syscall on Linux x86-64 platform:

(sc:syscall syscall.constants:+GETPID+) ;; 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

Argument types and the return type

syscall and the variants only takes and return unsigned machine integer(s), so it is the caller’s responsibility to:

  1. carefully convert all arguments to unsigned machine integers ((unsigned-byte 64))
  2. interpret the returned unsigned machine integer

syscall.constants package

For 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.

Contributing

Contributions are welcome! Please submit a pull request or open an issue on GitHub.

License

syscall is licensed under the MIT License.

About

Portable system calls for Common Lisp

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published