Unchecked Intrinsics
This section describes intrinsics that require a checked block.
Syscall Intrinsic
The @syscall intrinsic performs a direct system call to the operating system.
The @syscall intrinsic requires the unchecked_code preview feature. Using @syscall without enabling this feature is a compile-time error.
syscall_intrinsic = "@syscall" "(" syscall_number { "," argument } ")" ;
syscall_number = expression ;
argument = expression ;
The @syscall intrinsic takes at least one argument (the syscall number) and at most seven arguments (syscall number plus six syscall arguments). All arguments must be of type u64.
The @syscall intrinsic returns an i64 value representing the result of the syscall. On Linux x86-64, negative values typically indicate errors. The exact behavior depends on the syscall being invoked and the platform.
Syscall numbers and conventions differ between operating systems. Linux x86-64 syscall numbers are different from macOS aarch64 syscall numbers. Users should consult platform-specific documentation.
fn main() -> i32 {
checked {
// Linux x86-64: write(fd=1, buf, len)
let result = @syscall(1_u64, 1_u64, msg_ptr, msg_len);
// Linux x86-64: exit_group(code)
@syscall(231_u64, 0_u64);
};
0
}