How can I make syscalls directly?

Viewed 54

How can I execute syscalls directly? I'm using OpenBSD right now, the Unix platform. I want to be able to call syscalls without the 'wrapper', as an example: instead of write(1, "hello!", 6) I'd like to be able to type syscall (4, 1, "hello!", 6).

1 Answers

You can use syscall(2) or __syscall(2).

#include <sys/syscall.h> /* syscall constants */
#include <unistd.h>      /* syscall() */

int
main(void)
{
    syscall(SYS_write, 1, "Hello\n", 7);
}
Related