Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

A.4 Builtin Constants

The x86_64 backend provides the following constants automatically (no declaration needed):

Syscall Numbers:

ConstantValueDescription
SYS_READ0Read from file descriptor
SYS_WRITE1Write to file descriptor
SYS_OPEN2Open file
SYS_CLOSE3Close file descriptor
SYS_STAT4Get file status
SYS_FSTAT5Get file status by fd
SYS_LSEEK8Reposition file offset
SYS_MMAP9Map memory
SYS_MUNMAP11Unmap memory
SYS_BRK12Change data segment size
SYS_IOCTL16Device control
SYS_PIPE22Create pipe
SYS_DUP32Duplicate fd
SYS_DUP233Duplicate fd to specific number
SYS_GETPID39Get process ID
SYS_FORK57Create child process
SYS_EXECVE59Execute program
SYS_EXIT60Exit process
SYS_WAIT461Wait for process
SYS_KILL62Send signal
SYS_GETCWD79Get current directory
SYS_CHDIR80Change directory
SYS_MKDIR83Create directory
SYS_RMDIR84Remove directory
SYS_CREAT85Create file
SYS_UNLINK87Delete file
SYS_GETUID102Get user ID
SYS_GETGID104Get group ID
SYS_GETEUID107Get effective user ID
SYS_GETEGID108Get effective group ID
SYS_CLOCK_GETTIME228Get time
SYS_EXIT_GROUP231Exit all threads

File Descriptors:

ConstantValue
STDIN0
STDOUT1
STDERR2

Open Flags:

ConstantValue
O_RDONLY0
O_WRONLY1
O_RDWR2
O_CREAT64
O_TRUNC512
O_APPEND1024

Memory Mapping:

ConstantValue
PROT_NONE0
PROT_READ1
PROT_WRITE2
PROT_EXEC4
MAP_SHARED1
MAP_PRIVATE2
MAP_FIXED16
MAP_ANONYMOUS32