Low-level syscall primitives for Go on Linux, Darwin, and experimental FreeBSD.
Language: English | 简体中文 | Español | 日本語 | Français
zcall provides low-level syscall entry points that bypass Go's runtime syscall machinery (entersyscall/exitsyscall). It targets code paths that need direct control over syscall boundaries, such as io_uring submission.
- Direct syscall entry points, provided through assembly stubs for each platform.
- Kernel-style return values, with wrappers returning the raw result alongside
errno. - Syscall numbers and related constants defined internally, without depending on
syscallorx/sys/unix. - Platform-specific implementations selected through build tags.
- Primitive entry points for 4-argument and 6-argument syscalls.
- Wrappers for common I/O, socket, memory, and socket-option operations.
- Linux-specific helpers for network link queries, special file descriptors, zero-copy operations, and
io_uring.
go get code.hybscloud.com/zcallmsg := []byte("Hello from zcall!\n")
// Direct kernel write to stdout
_, _ = zcall.Write(1, msg)msg := []byte("hello\n")
n, errno := zcall.Write(1, msg)
if errno != 0 {
return zcall.Errno(errno)
}fd, errno := zcall.Socket(zcall.AF_INET, zcall.SOCK_STREAM|zcall.SOCK_NONBLOCK|zcall.SOCK_CLOEXEC, 0)
if errno != 0 {
return zcall.Errno(errno)
}
defer zcall.Close(fd)links, err := zcall.Links()
if err != nil {
return err
}// 4-argument syscall
Syscall4(num, a1, a2, a3, a4 uintptr) (r1, errno uintptr)
// 6-argument syscall
Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, errno uintptr)| Category | Functions |
|---|---|
| Basic I/O | Read, Write, Close, Ioctl |
| Vectored I/O | Readv, Writev, Preadv, Pwritev |
| Socket | Socket, Bind, Listen, Accept, Connect, Shutdown, Socketpair |
| Socket Options | Setsockopt, Getsockopt, Getsockname, Getpeername |
| Socket I/O | Sendto, Recvfrom, Sendmsg, Recvmsg |
| Memory | Mmap, Munmap, Pipe2 |
| Category | Functions |
|---|---|
| Vectored I/O | Preadv2, Pwritev2 |
| Socket | Accept4 |
| Socket I/O | Sendmmsg, Recvmmsg |
| Network | Links, LinkByName, LinkByIndex |
| Memory | MemfdCreate |
| Timers | TimerfdCreate, TimerfdSettime, TimerfdGettime |
| Events | Eventfd2, Signalfd4 |
| Process | PidfdOpen, PidfdGetfd, PidfdSendSignal |
| Zero-copy | Splice, Tee, Vmsplice |
| io_uring | IoUringSetup, IoUringEnter, IoUringRegister |
┌─────────────────────────────────────────────────────────┐
│ User Application │
├─────────────────────────────────────────────────────────┤
│ zcall API │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────┐ │
│ │ Syscall4 │ │ Syscall6 │ │ Convenience API │ │
│ └──────┬──────┘ └──────┬──────┘ └────────┬────────┘ │
├─────────┴────────────────┴─────────────────┴────────────┤
│ internal/asm_*.s │
│ Raw Assembly (SYSCALL / SVC / ECALL) │
├─────────────────────────────────────────────────────────┤
│ Operating System │
└─────────────────────────────────────────────────────────┘
| Architecture | Status | Instruction |
|---|---|---|
| linux/amd64 | ✅ Supported | SYSCALL |
| linux/arm64 | ✅ Supported | SVC #0 |
| linux/riscv64 | ✅ Supported | ECALL |
| linux/loong64 | ✅ Supported | SYSCALL |
| darwin/arm64 | ✅ Supported | SVC #0x80 |
| freebsd/amd64 | ⚠ Experimental, untested | SYSCALL |
MIT — see LICENSE.
©2025 Hayabusa Cloud Co., Ltd.