Wednesday, September 17, 2014

Raw system calls for Rust

I wrote a small library for making raw system calls from Rust programs. It provides a macro that expands into in-line system call instructions, with no run-time dependencies at all. Here's an example:


#[phase(plugin, link)]
extern crate syscall;

fn write(fd: uint, buf: &[u8]) {
    unsafe {
        syscall!(WRITE, fd, buf.as_ptr(), buf.len());

fn main() {
    write(1, "Hello, world!\n".as_bytes());

Right now it only supports x86-64 Linux, but I'd love to add other platforms. Pull requests are much appreciated. :)


  1. On Linux, the kernel injects a "virtual dynamic library" into every process, containing optimal code for making system calls, including special fast-path code for especially performance-critical calls (e.g. clock_gettime). You should really use that if you possibly can.

  2. Indeed

  3. i really like your blog, thanks for share...
    please visit are website..

  4. "Enjoyed every bit of your blog article.Really looking forward to read more. Really Cool
    Packers And Movers Hyderabad

  5. Brilliant information being shared here with us,This is very interesting, You’re a very skilled blogger.Plz visit here: Packers And Movers Jaipur

  6. Really nice post. Your post is expressing what I actually wanted to know, thanks for sharing…
    Movers and packers in hennur & bagalur main road