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

B.4 Builtin Constants

The RISC-V backend provides constants automatically. RISC-V Linux uses the unified "new-style" syscall table.

Syscall Numbers:

ConstantValueDescription
SYS_GETCWD17Get current directory
SYS_DUP23Duplicate fd
SYS_DUP324Duplicate fd with flags
SYS_IOCTL29Device control
SYS_MKDIRAT34Create directory (relative)
SYS_UNLINKAT35Delete file (relative)
SYS_FTRUNCATE46Truncate file
SYS_FACCESSAT48Check file access
SYS_CHDIR49Change directory
SYS_OPENAT56Open file (relative)
SYS_CLOSE57Close fd
SYS_PIPE259Create pipe
SYS_LSEEK62Seek in file
SYS_READ63Read from fd
SYS_WRITE64Write to fd
SYS_FSTAT80Get file status
SYS_EXIT93Exit process
SYS_EXIT_GROUP94Exit all threads
SYS_KILL129Send signal
SYS_GETPID172Get process ID
SYS_GETUID174Get user ID
SYS_GETEUID175Get effective user ID
SYS_GETGID176Get group ID
SYS_GETEGID177Get effective group ID
SYS_BRK214Change data segment size
SYS_MUNMAP215Unmap memory
SYS_CLONE220Create process
SYS_EXECVE221Execute program
SYS_MMAP222Map memory
SYS_WAIT4260Wait for process

Note: RISC-V uses *at syscalls (e.g., SYS_OPENAT instead of SYS_OPEN). Use AT_FDCWD (-100) as the directory fd for current directory.

File descriptor, open flag, and mmap constants are the same as x86_64 (see Addendum A).