A.4 Builtin Constants
The x86_64 backend provides the following constants automatically (no declaration needed):
Syscall Numbers:
| Constant | Value | Description |
|---|---|---|
SYS_READ | 0 | Read from file descriptor |
SYS_WRITE | 1 | Write to file descriptor |
SYS_OPEN | 2 | Open file |
SYS_CLOSE | 3 | Close file descriptor |
SYS_STAT | 4 | Get file status |
SYS_FSTAT | 5 | Get file status by fd |
SYS_LSEEK | 8 | Reposition file offset |
SYS_MMAP | 9 | Map memory |
SYS_MUNMAP | 11 | Unmap memory |
SYS_BRK | 12 | Change data segment size |
SYS_IOCTL | 16 | Device control |
SYS_PIPE | 22 | Create pipe |
SYS_DUP | 32 | Duplicate fd |
SYS_DUP2 | 33 | Duplicate fd to specific number |
SYS_GETPID | 39 | Get process ID |
SYS_FORK | 57 | Create child process |
SYS_EXECVE | 59 | Execute program |
SYS_EXIT | 60 | Exit process |
SYS_WAIT4 | 61 | Wait for process |
SYS_KILL | 62 | Send signal |
SYS_GETCWD | 79 | Get current directory |
SYS_CHDIR | 80 | Change directory |
SYS_MKDIR | 83 | Create directory |
SYS_RMDIR | 84 | Remove directory |
SYS_CREAT | 85 | Create file |
SYS_UNLINK | 87 | Delete file |
SYS_GETUID | 102 | Get user ID |
SYS_GETGID | 104 | Get group ID |
SYS_GETEUID | 107 | Get effective user ID |
SYS_GETEGID | 108 | Get effective group ID |
SYS_CLOCK_GETTIME | 228 | Get time |
SYS_EXIT_GROUP | 231 | Exit all threads |
File Descriptors:
| Constant | Value |
|---|---|
STDIN | 0 |
STDOUT | 1 |
STDERR | 2 |
Open Flags:
| Constant | Value |
|---|---|
O_RDONLY | 0 |
O_WRONLY | 1 |
O_RDWR | 2 |
O_CREAT | 64 |
O_TRUNC | 512 |
O_APPEND | 1024 |
Memory Mapping:
| Constant | Value |
|---|---|
PROT_NONE | 0 |
PROT_READ | 1 |
PROT_WRITE | 2 |
PROT_EXEC | 4 |
MAP_SHARED | 1 |
MAP_PRIVATE | 2 |
MAP_FIXED | 16 |
MAP_ANONYMOUS | 32 |