B.4 Builtin Constants
The RISC-V backend provides constants automatically. RISC-V Linux uses the unified "new-style" syscall table.
Syscall Numbers:
| Constant | Value | Description |
|---|---|---|
SYS_GETCWD | 17 | Get current directory |
SYS_DUP | 23 | Duplicate fd |
SYS_DUP3 | 24 | Duplicate fd with flags |
SYS_IOCTL | 29 | Device control |
SYS_MKDIRAT | 34 | Create directory (relative) |
SYS_UNLINKAT | 35 | Delete file (relative) |
SYS_FTRUNCATE | 46 | Truncate file |
SYS_FACCESSAT | 48 | Check file access |
SYS_CHDIR | 49 | Change directory |
SYS_OPENAT | 56 | Open file (relative) |
SYS_CLOSE | 57 | Close fd |
SYS_PIPE2 | 59 | Create pipe |
SYS_LSEEK | 62 | Seek in file |
SYS_READ | 63 | Read from fd |
SYS_WRITE | 64 | Write to fd |
SYS_FSTAT | 80 | Get file status |
SYS_EXIT | 93 | Exit process |
SYS_EXIT_GROUP | 94 | Exit all threads |
SYS_KILL | 129 | Send signal |
SYS_GETPID | 172 | Get process ID |
SYS_GETUID | 174 | Get user ID |
SYS_GETEUID | 175 | Get effective user ID |
SYS_GETGID | 176 | Get group ID |
SYS_GETEGID | 177 | Get effective group ID |
SYS_BRK | 214 | Change data segment size |
SYS_MUNMAP | 215 | Unmap memory |
SYS_CLONE | 220 | Create process |
SYS_EXECVE | 221 | Execute program |
SYS_MMAP | 222 | Map memory |
SYS_WAIT4 | 260 | Wait 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).