| Crates.io | syscaller-core |
| lib.rs | syscaller-core |
| version | 0.2.3 |
| created_at | 2025-08-07 19:28:23.783038+00 |
| updated_at | 2025-09-03 20:36:11.535049+00 |
| description | No-std Linux direct syscall library |
| homepage | https://github.com/mathyslv/syscaller |
| repository | https://github.com/mathyslv/syscaller |
| max_upload_size | |
| id | 1785699 |
| size | 11,498 |
A no-std Rust library providing direct system call interfaces for Linux x86_64 systems with hand-optimized assembly implementations and procedural macros for type-safe syscall wrapper generation.
Add to your Cargo.toml:
[dependencies]
syscaller = { version = "0.1", features = ["macro"] }
syscaller defines 7 basic, low-level functions that allow to invoke a Linux syscall with 0 to 6 arguments
(syscall0(...) to syscall6(...)).
Their signatures are syscallX(syscallId: usize, args...: usize).
use syscaller::*;
let written = unsafe { syscall3(1, 1, b"Hello, World!\n".as_ptr() as usize, 14) }; // write syscall
The wrap_syscall proc-macro allow convenient conversion between C-like functions and syscallX calls.
Syntax
wrap_syscall! {
syscallId1 : C-style-signature,
syscallId2 : C-style-signature,
...
}
Example
The following :
syscall::wrap_syscall! {
1 : ssize_t write(int fd, void *buf, size_t count),
59 : int execve(const char *path, char *const *argv, char *const *envp),
}
Will generate this :
#[inline(always)]
pub unsafe fn write(fd: i32, buf: *mut u8, count: usize) -> isize {
unsafe { syscaller::syscall3(1, fd as usize, buf as usize, count) as isize }
}
#[inline(always)]
pub unsafe fn execve(path: impl AsRef<[u8]>, argv: *mut u8, envp: *mut u8) -> i32 {
unsafe {
syscaller::syscall3(59, path.as_ref().as_ptr() as usize, argv as usize, envp as usize) as i32
}
}
You can then use this more convenient function :
const HELLO: &str = "Hello, world!";
unsafe { write(1, HELLO.as_ptr().cast_mut(), HELLO.len()) };
syscaller)The core library provides hand-written x86_64 assembly implementations:
syscall0 through syscall6 - Support 0-6 arguments#![no_std] compatible with zero dependenciessyscaller-wrap-macro)The macro crate provides type-safe wrapper generation:
⚠️ This library provides direct access to system calls without safety guarantees.
unsafe as they can cause undefined behaviorCurrently supports:
Planned support:
Licensed under either of
at your option.
Contributions are welcome! Please feel free to submit a Pull Request.