diff --git a/porth.py b/porth.py index 0b06ed84..310e4ae5 100755 --- a/porth.py +++ b/porth.py @@ -10,6 +10,7 @@ from dataclasses import dataclass from copy import copy import traceback +import platform PORTH_EXT = '.porth' DEFAULT_EXPANSION_LIMIT=1000 @@ -1204,6 +1205,368 @@ def generate_nasm_linux_x86_64(program: Program, out_file_path: str): out.write("args_ptr: resq 1\n") out.write("mem: resb %d\n" % MEM_CAPACITY) +def generate_nasm_linux_aarch64(program: Program, out_file_path: str): + strs: List[bytes] = [] + cond_count = 0 + with open(out_file_path, "w") as out: + out.write(".section .text\n") + out.write("print:\n") + out.write(" ldr x9, =-3689348814741910323\n") + out.write(" sub sp, sp, 40\n") + out.write(" mov x3, #10\n") + out.write(" strb w3, [sp, #31]\n") + out.write(" add x3, sp, #30\n") + out.write(".L2:\n") + out.write(" mov x4, x0\n") + out.write(" add x8, sp, #32\n") + out.write(" umulh x6, x4, x9\n") + out.write(" mov x4, x0\n") + out.write(" sub x8, x8, x3\n") + out.write(" lsr x6, x6, 3\n") + out.write(" mov x7, #4\n") + out.write(" mul x2, x6, x7\n") + out.write(" add x5, x6, x2\n") + out.write(" add x5, x5, x5\n") + out.write(" sub x4, x4, x5\n") + out.write(" add x4, x4, #48\n") + out.write(" strb w4, [x3, #0]\n") + out.write(" mov x4, x0\n") + out.write(" mov x0, x6\n") + out.write(" mov x6, x3\n") + out.write(" sub x3, x3, #1\n") + out.write(" cmp x4, #9\n") + out.write(" bhi .L2\n") + out.write(" add x4, sp, #32\n") + out.write(" mov w0, #1\n") + out.write(" sub x6, x6, x4\n") + out.write(" mov x4, #0\n") + out.write(" add x1, sp, #32\n") + out.write(" add x1, x1, x6\n") + out.write(" mov x2, x8\n") + out.write(" mov x8, #64\n") + out.write(" svc #0\n") + out.write(" add sp, sp, 40\n") + out.write(" ret\n") + out.write(".globl _start\n") + out.write("_start:\n") + out.write(" adr x0, args_ptr\n") + out.write(" mov x1, sp\n") + out.write(" str x1, [x0, #0]\n") + for ip in range(len(program)): + op = program[ip] + assert len(OpType) == 8, "Exhaustive ops handling in generate_nasm_linux_aarch64" + out.write("addr_%d:\n" % ip) + if op.typ == OpType.PUSH_INT: + assert isinstance(op.operand, int), "This could be a bug in the compilation step" + out.write(" //;; -- push int %d --\n" % op.operand) + out.write(" ldr x0, =%d\n" % op.operand) + out.write(" str x0, [sp, #-8]!\n") + elif op.typ == OpType.PUSH_STR: + assert isinstance(op.operand, str), "This could be a bug in the compilation step" + value = op.operand.encode('utf-8') + n = len(value) + out.write(" //;; -- push str --\n") + out.write(" mov x0, %d\n" % n) + out.write(" str x0, [sp, #-8]!\n") + out.write(" adr x0, str_%d\n" % len(strs)) + out.write(" str x0, [sp, #-8]!\n") + strs.append(value) + elif op.typ == OpType.IF: + out.write(" //;; -- if --\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" cmp x0, #0\n") + assert isinstance(op.operand, int), "This could be a bug in the compilation step" + out.write(" beq addr_%d\n" % op.operand) + elif op.typ == OpType.ELSE: + out.write(" //;; -- else --\n") + assert isinstance(op.operand, int), "This could be a bug in the compilation step" + out.write(" bl addr_%d\n" % op.operand) + elif op.typ == OpType.END: + assert isinstance(op.operand, int), "This could be a bug in the compilation step" + out.write(" //;; -- end --\n") + if ip + 1 != op.operand: + out.write(" bl addr_%d\n" % op.operand) + elif op.typ == OpType.WHILE: + out.write(" //;; -- while --\n") + elif op.typ == OpType.DO: + out.write(" //;; -- do --\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" cmp x0, #0\n") + assert isinstance(op.operand, int), "This could be a bug in the compilation step" + out.write(" beq addr_%d\n" % op.operand) + elif op.typ == OpType.INTRINSIC: + assert len(Intrinsic) == 34, "Exhaustive intrinsic handling in generate_nasm_linux_aarch64()" + if op.operand == Intrinsic.PLUS: + out.write(" //;; -- plus --\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" ldr x1, [sp], #8\n") + out.write(" add x0, x1, x0\n") + out.write(" str x0, [sp, #-8]!\n") + elif op.operand == Intrinsic.MINUS: + out.write(" //;; -- plus --\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" ldr x1, [sp], #8\n") + out.write(" sub x0, x1, x0\n") + out.write(" str x0, [sp, #-8]!\n") + elif op.operand == Intrinsic.MUL: + out.write(" //;; -- mul --\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" ldr x1, [sp], #8\n") + out.write(" mul x0, x1, x0\n") + out.write(" str x0, [sp, #-8]!\n") + elif op.operand == Intrinsic.DIVMOD: + out.write(" //;; -- mod --\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" ldr x1, [sp], #8\n") + out.write(" udiv x2, x1, x0\n") + out.write(" msub x3, x2, x0, x1\n") + out.write(" str x2, [sp, #-8]!\n") + out.write(" str x3, [sp, #-8]!\n") + elif op.operand == Intrinsic.SHR: + out.write(" //;; -- shr --\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" ldr x1, [sp], #8\n") + out.write(" lsr x0, x1, x0\n") + out.write(" str x0, [sp, #-8]!\n") + elif op.operand == Intrinsic.SHL: + out.write(" //;; -- shl --\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" ldr x1, [sp], #8\n") + out.write(" lsl x0, x1, x0\n") + out.write(" str x0, [sp, #-8]!\n") + elif op.operand == Intrinsic.BOR: + out.write(" //;; -- bor --\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" ldr x1, [sp], #8\n") + out.write(" orr x0, x1, x0\n") + out.write(" str x0, [sp, #-8]!\n") + elif op.operand == Intrinsic.BAND: + out.write(" //;; -- band --\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" ldr x1, [sp], #8\n") + out.write(" and x0, x1, x0\n") + out.write(" str x0, [sp, #-8]!\n") + elif op.operand == Intrinsic.PRINT: + out.write(" //;; -- print --\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" bl print\n") + elif op.operand == Intrinsic.EQ: + out.write(" //;; -- equal -- \n") + out.write(" ldr x0, [sp], #8\n") + out.write(" ldr x1, [sp], #8\n") + out.write(" cmp x0, x1\n"); + out.write(" beq cond_%s\n" % str(cond_count)) + out.write(" mov x3, #0\n") + out.write(" str x3, [sp, #-8]!\n") + out.write(" bl end_%s\n" % str(cond_count)) + out.write(" cond_%s:\n" % str(cond_count)) + out.write(" mov x3, #1\n") + out.write(" str x3, [sp, #-8]!\n") + out.write(" end_%s:\n" % str(cond_count)) + cond_count += 1 + elif op.operand == Intrinsic.GT: + out.write(" //;; -- gt --\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" ldr x1, [sp], #8\n") + out.write(" cmp x1, x0\n"); + out.write(" bgt cond_%s\n" % str(cond_count)) + out.write(" mov x3, #0\n") + out.write(" str x3, [sp, #-8]!\n") + out.write(" bl end_%s\n" % str(cond_count)) + out.write(" cond_%s:\n" % str(cond_count)) + out.write(" mov x3, #1\n") + out.write(" str x3, [sp, #-8]!\n") + out.write(" end_%s:\n" % str(cond_count)) + cond_count += 1 + elif op.operand == Intrinsic.LT: + out.write(" //;; -- lt --\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" ldr x1, [sp], #8\n") + out.write(" cmp x1, x0\n"); + out.write(" blt cond_%s\n" % str(cond_count)) + out.write(" mov x3, #0\n") + out.write(" str x3, [sp, #-8]!\n") + out.write(" bl end_%s\n" % str(cond_count)) + out.write(" cond_%s:\n" % str(cond_count)) + out.write(" mov x3, #1\n") + out.write(" str x3, [sp, #-8]!\n") + out.write(" end_%s:\n" % str(cond_count)) + cond_count += 1 + elif op.operand == Intrinsic.GE: + out.write(" //;; -- ge --\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" ldr x1, [sp], #8\n") + out.write(" cmp x1, x0\n"); + out.write(" bge cond_%s\n" % str(cond_count)) + out.write(" mov x3, #0\n") + out.write(" str x3, [sp, #-8]!\n") + out.write(" bl end_%s\n" % str(cond_count)) + out.write(" cond_%s:\n" % str(cond_count)) + out.write(" mov x3, #1\n") + out.write(" str x3, [sp, #-8]!\n") + out.write(" end_%s:\n" % str(cond_count)) + cond_count += 1 + elif op.operand == Intrinsic.LE: + out.write(" //;; -- le --\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" ldr x1, [sp], #8\n") + out.write(" cmp x1, x0\n"); + out.write(" ble cond_%s\n" % str(cond_count)) + out.write(" mov x3, #0\n") + out.write(" str x3, [sp, #-8]!\n") + out.write(" bl end_%s\n" % str(cond_count)) + out.write(" cond_%s:\n" % str(cond_count)) + out.write(" mov x3, #1\n") + out.write(" str x3, [sp, #-8]!\n") + out.write(" end_%s:\n" % str(cond_count)) + cond_count += 1 + elif op.operand == Intrinsic.NE: + out.write(" //;; -- ne --\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" ldr x1, [sp], #8\n") + out.write(" cmp x1, x0\n"); + out.write(" bne cond_%s\n" % str(cond_count)) + out.write(" mov x3, #0\n") + out.write(" str x3, [sp, #-8]!\n") + out.write(" bl end_%s\n" % str(cond_count)) + out.write(" cond_%s:\n" % str(cond_count)) + out.write(" mov x3, #1\n") + out.write(" str x3, [sp, #-8]!\n") + out.write(" end_%s:\n" % str(cond_count)) + cond_count += 1 + elif op.operand == Intrinsic.DUP: + out.write(" //;; -- dup -- \n") + out.write(" ldr x0, [sp], #8\n") + out.write(" str x0, [sp, #-8]!\n") + out.write(" str x0, [sp, #-8]!\n") + elif op.operand == Intrinsic.SWAP: + out.write(" //;; -- swap --\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" ldr x1, [sp], #8\n") + out.write(" str x0, [sp, #-8]!\n") + out.write(" str x1, [sp, #-8]!\n") + elif op.operand == Intrinsic.DROP: + out.write(" //;; -- drop --\n") + out.write(" ldr x0, [sp], #8\n") + elif op.operand == Intrinsic.OVER: + out.write(" //;; -- over --\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" ldr x1, [sp], #8\n") + out.write(" str x1, [sp, #-8]!\n") + out.write(" str x0, [sp, #-8]!\n") + out.write(" str x1, [sp, #-8]!\n") + elif op.operand == Intrinsic.MEM: + out.write(" //;; -- mem --\n") + out.write(" adr x0, mem\n") + out.write(" str x0, [sp, #-8]!\n") + elif op.operand == Intrinsic.LOAD: + out.write(" //;; -- load --\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" mov x1, #0\n") + out.write(" ldrb w1, [x0, #0]\n") + out.write(" str x1, [sp, #-8]!\n") + elif op.operand == Intrinsic.STORE: + out.write(" //;; -- store --\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" ldr x1, [sp], #8\n") + out.write(" strb w0, [x1, #0]\n") + elif op.operand == Intrinsic.ARGC: + out.write(" //;; -- argc --\n") + out.write(" adr x0, args_ptr\n") + out.write(" ldr x0, [x0, #0]\n") + out.write(" ldr x0, [x0, #0]\n") + out.write(" str x0, [sp, #-8]!\n") + elif op.operand == Intrinsic.ARGV: + out.write(" //;; -- argv --\n") + out.write(" adr x0, args_ptr\n") + out.write(" ldr x0, [x0, #0]\n") + out.write(" add x0, x0, 8\n") + out.write(" str x0, [sp, #-8]!\n") + elif op.operand == Intrinsic.LOAD64: + out.write(" //;; -- load64 --\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" mov x1, #0\n") + out.write(" ldr x1, [x0, #0]\n") + out.write(" str x1, [sp, #-8]!\n") + elif op.operand == Intrinsic.STORE64: + out.write(" //;; -- store64 --\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" ldr x1, [sp], #8\n") + out.write(" str x0, [x1, #0]\n") + elif op.operand == Intrinsic.CAST_PTR: + out.write(" //;; -- cast(ptr) --\n") + elif op.operand == Intrinsic.SYSCALL0: + out.write(" //;; -- syscall0 --\n") + out.write(" ldr x8, [sp], #8\n") + out.write(" svc #0\n") + out.write(" str x0, [sp, #-8]!\n") + elif op.operand == Intrinsic.SYSCALL1: + out.write(" //;; -- syscall1 --\n") + out.write(" ldr x8, [sp], #8\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" svc #0\n") + out.write(" str x0, [sp, #-8]!\n") + elif op.operand == Intrinsic.SYSCALL2: + out.write(" //;; -- syscall2 -- \n") + out.write(" ldr x8, [sp], #8\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" ldr x1, [sp], #8\n") + out.write(" svc #0\n") + out.write(" str x0, [sp, #-8]!\n") + elif op.operand == Intrinsic.SYSCALL3: + out.write(" //;; -- syscall3 --\n") + out.write(" ldr x8, [sp], #8\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" ldr x1, [sp], #8\n") + out.write(" ldr x2, [sp], #8\n") + out.write(" svc #0\n") + out.write(" str x0, [sp, #-8]!\n") + elif op.operand == Intrinsic.SYSCALL4: + out.write(" //;; -- syscall4 --\n") + out.write(" ldr x8, [sp], #8\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" ldr x1, [sp], #8\n") + out.write(" ldr x2, [sp], #8\n") + out.write(" ldr x3, [sp], #8\n") + out.write(" svc #0\n") + out.write(" str x0, [sp, #-8]!\n") + elif op.operand == Intrinsic.SYSCALL5: + out.write(" //;; -- syscall5 --\n") + out.write(" ldr x8, [sp], #8\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" ldr x1, [sp], #8\n") + out.write(" ldr x2, [sp], #8\n") + out.write(" ldr x3, [sp], #8\n") + out.write(" ldr x4, [sp], #8\n") + out.write(" svc #0\n") + out.write(" str x0, [sp, #-8]!\n") + elif op.operand == Intrinsic.SYSCALL6: + out.write(" //;; -- syscall6 --\n") + out.write(" ldr x8, [sp], #8\n") + out.write(" ldr x0, [sp], #8\n") + out.write(" ldr x1, [sp], #8\n") + out.write(" ldr x2, [sp], #8\n") + out.write(" ldr x3, [sp], #8\n") + out.write(" ldr x4, [sp], #8\n") + out.write(" ldr x5, [sp], #8\n") + out.write(" svc #0\n") + out.write(" str x0, [sp, #-8]!\n") + else: + assert False, "unreachable" + else: + assert False, "unreachable" + + out.write("addr_%d:\n" % len(program)) + out.write(" mov x8, #93\n") + out.write(" mov x0, #0\n") + out.write(" svc #0\n") + out.write(".section .data\n") + for index, s in enumerate(strs): + out.write("str_%d: .byte %s\n" % (index, ','.join(map(hex, list(s))))) + out.write(".section .bss\n") + out.write("args_ptr: .quad 0\n") + out.write("mem:\n .rept %d\n .quad 0\n .endr\n" % (MEM_CAPACITY/8)) + assert len(Keyword) == 7, "Exhaustive KEYWORD_NAMES definition." KEYWORD_NAMES = { 'if': Keyword.IF, @@ -1524,6 +1887,7 @@ def usage(compiler_name: str): print("Usage: %s [OPTIONS] [ARGS]" % compiler_name) print(" OPTIONS:") print(" -debug Enable debug mode.") + print(" -ARCH Architecture for native code(aarch64, x86_64). Default: platform architecture") print(" -I Add the path to the include search list") print(" -E Macro and include expansion limit. (Default %d)" % DEFAULT_EXPANSION_LIMIT) print(" -unsafe Disable type checking.") @@ -1541,6 +1905,9 @@ def usage(compiler_name: str): assert len(argv) >= 1 compiler_name, *argv = argv + platform_arch = platform.machine() + arch = "" + include_paths = ['.', './std/'] expansion_limit = DEFAULT_EXPANSION_LIMIT unsafe = False @@ -1549,6 +1916,14 @@ def usage(compiler_name: str): if argv[0] == '-debug': argv = argv[1:] debug = True + elif argv[0] == '-ARCH': + argv = argv[1:] + if len(argv) == 0: + usage(compiler_name) + print("[ERROR] no arch is provided for `-ARCH` flag", file=sys.stderr) + exit(1) + arch, *argv = argv + include_paths.append("./std/" + arch + "/") elif argv[0] == '-I': argv = argv[1:] if len(argv) == 0: @@ -1571,6 +1946,10 @@ def usage(compiler_name: str): else: break + if(not arch): + include_paths.append("./std/" + platform_arch + "/") + arch = platform_arch + if debug: print("[INFO] Debug mode is enabled") @@ -1649,11 +2028,18 @@ def usage(compiler_name: str): program = compile_file_to_program(program_path, include_paths, expansion_limit); if not unsafe: type_check_program(program) - generate_nasm_linux_x86_64(program, basepath + ".asm") - cmd_call_echoed(["nasm", "-felf64", basepath + ".asm"], silent) - cmd_call_echoed(["ld", "-o", basepath, basepath + ".o"], silent) + + if(arch == "x86_64"): + generate_nasm_linux_x86_64(program, basepath + ".asm") + cmd_call_echoed(["nasm", "-felf64", basepath + ".asm"], silent) + cmd_call_echoed(["ld", "-o", basepath, basepath + ".o"], silent) + elif(arch == "aarch64"): + generate_nasm_linux_aarch64(program, basepath + ".S") + cmd_call_echoed(["aarch64-linux-gnu-as", basepath + ".S", "-o", basepath+".o"], silent) + cmd_call_echoed(["aarch64-linux-gnu-ld", "-o", basepath, basepath + ".o"], silent) if run: - exit(cmd_call_echoed([basepath] + argv, silent)) + exit(cmd_call_echoed(["qemu-" + arch, basepath] + argv, silent)) + elif subcommand == "help": usage(compiler_name) exit(0) diff --git a/std/aarch64/syscall.porth b/std/aarch64/syscall.porth new file mode 100644 index 00000000..71a1bc9b --- /dev/null +++ b/std/aarch64/syscall.porth @@ -0,0 +1,285 @@ +/// Syscalls +// Stolen from https://filippo.io/linux-syscall-table/ +// Not all of the syscalls here are useful/implemented. I literally just copy-pasted them. +// We can clean this up later. +macro SYS_io_setup 0 end +macro SYS_io_destroy 1 end +macro SYS_io_submit 2 end +macro SYS_io_cancel 3 end +macro SYS_io_getevents 4 end +macro SYS_setxattr 5 end +macro SYS_lsetxattr 6 end +macro SYS_fsetxattr 7 end +macro SYS_getxattr 8 end +macro SYS_lgetxattr 9 end +macro SYS_fgetxattr 10 end +macro SYS_listxattr 11 end +macro SYS_llistxattr 12 end +macro SYS_flistxattr 13 end +macro SYS_removexattr 14 end +macro SYS_lremovexattr 15 end +macro SYS_fremovexattr 16 end +macro SYS_getcwd 17 end +macro SYS_lookup_dcookie 18 end +macro SYS_eventfd2 19 end +macro SYS_epoll_create1 20 end +macro SYS_epoll_ctl 21 end +macro SYS_epoll_pwait 22 end +macro SYS_dup 23 end +macro SYS_dup3 24 end +macro SYS_fcntl 25 end +macro SYS_inotify_init1 26 end +macro SYS_inotify_add_watch 27 end +macro SYS_inotify_rm_watch 28 end +macro SYS_ioctl 29 end +macro SYS_ioprio_set 30 end +macro SYS_ioprio_get 31 end +macro SYS_flock 32 end +macro SYS_mknodat 33 end +macro SYS_mkdirat 34 end +macro SYS_unlinkat 35 end +macro SYS_symlinkat 36 end +macro SYS_linkat 37 end +macro SYS_renameat 38 end +macro SYS_umount2 39 end +macro SYS_mount 40 end +macro SYS_pivot_root 41 end +macro SYS_nfsservctl 42 end +macro SYS_statfs 43 end +macro SYS_fstatfs 44 end +macro SYS_truncate 45 end +macro SYS_ftruncate 46 end +macro SYS_fallocate 47 end +macro SYS_faccessat 48 end +macro SYS_chdir 49 end +macro SYS_fchdir 50 end +macro SYS_chroot 51 end +macro SYS_fchmod 52 end +macro SYS_fchmodat 53 end +macro SYS_fchownat 54 end +macro SYS_fchown 55 end +macro SYS_openat 56 end +macro SYS_close 57 end +macro SYS_vhangup 58 end +macro SYS_pipe2 59 end +macro SYS_quotactl 60 end +macro SYS_getdents64 61 end +macro SYS_lseek 62 end +macro SYS_read 63 end +macro SYS_write 64 end +macro SYS_readv 65 end +macro SYS_writev 66 end +macro SYS_pread64 67 end +macro SYS_pwrite64 68 end +macro SYS_preadv 69 end +macro SYS_pwritev 70 end +macro SYS_sendfile 71 end +macro SYS_pselect6 72 end +macro SYS_ppoll 73 end +macro SYS_signalfd4 74 end +macro SYS_vmsplice 75 end +macro SYS_splice 76 end +macro SYS_tee 77 end +macro SYS_readlinkat 78 end +macro SYS_newfstatat 79 end +macro SYS_fstat 80 end +macro SYS_sync 81 end +macro SYS_fsync 82 end +macro SYS_fdatasync 83 end +macro SYS_sync_file_range 84 end +macro SYS_timerfd_create 85 end +macro SYS_timerfd_settime 86 end +macro SYS_timerfd_gettime 87 end +macro SYS_utimensat 88 end +macro SYS_acct 89 end +macro SYS_capget 90 end +macro SYS_capset 91 end +macro SYS_personality 92 end +macro SYS_exit 93 end +macro SYS_exit_group 94 end +macro SYS_waitid 95 end +macro SYS_set_tid_address 96 end +macro SYS_unshare 97 end +macro SYS_futex 98 end +macro SYS_set_robust_list 99 end +macro SYS_get_robust_list 100 end +macro SYS_nanosleep 101 end +macro SYS_getitimer 102 end +macro SYS_setitimer 103 end +macro SYS_kexec_load 104 end +macro SYS_init_module 105 end +macro SYS_delete_module 106 end +macro SYS_timer_create 107 end +macro SYS_timer_gettime 108 end +macro SYS_timer_getoverrun 109 end +macro SYS_timer_settime 110 end +macro SYS_timer_delete 111 end +macro SYS_clock_settime 112 end +macro SYS_clock_gettime 113 end +macro SYS_clock_getres 114 end +macro SYS_clock_nanosleep 115 end +macro SYS_syslog 116 end +macro SYS_ptrace 117 end +macro SYS_sched_setparam 118 end +macro SYS_sched_setscheduler 119 end +macro SYS_sched_getscheduler 120 end +macro SYS_sched_getparam 121 end +macro SYS_sched_setaffinity 122 end +macro SYS_sched_getaffinity 123 end +macro SYS_sched_yield 124 end +macro SYS_sched_get_priority_max 125 end +macro SYS_sched_get_priority_min 126 end +macro SYS_sched_rr_get_interval 127 end +macro SYS_restart_syscall 128 end +macro SYS_kill 129 end +macro SYS_tkill 130 end +macro SYS_tgkill 131 end +macro SYS_sigaltstack 132 end +macro SYS_rt_sigsuspend 133 end +macro SYS_rt_sigaction 134 end +macro SYS_rt_sigprocmask 135 end +macro SYS_rt_sigpending 136 end +macro SYS_rt_sigtimedwait 137 end +macro SYS_rt_sigqueueinfo 138 end +macro SYS_rt_sigreturn 139 end +macro SYS_setpriority 140 end +macro SYS_getpriority 141 end +macro SYS_reboot 142 end +macro SYS_setregid 143 end +macro SYS_setgid 144 end +macro SYS_setreuid 145 end +macro SYS_setuid 146 end +macro SYS_setresuid 147 end +macro SYS_getresuid 148 end +macro SYS_setresgid 149 end +macro SYS_getresgid 150 end +macro SYS_setfsuid 151 end +macro SYS_setfsgid 152 end +macro SYS_times 153 end +macro SYS_setpgid 154 end +macro SYS_getpgid 155 end +macro SYS_getsid 156 end +macro SYS_setsid 157 end +macro SYS_getgroups 158 end +macro SYS_setgroups 159 end +macro SYS_uname 160 end +macro SYS_sethostname 161 end +macro SYS_setdomainname 162 end +macro SYS_getrlimit 163 end +macro SYS_setrlimit 164 end +macro SYS_getrusage 165 end +macro SYS_umask 166 end +macro SYS_prctl 167 end +macro SYS_getcpu 168 end +macro SYS_gettimeofday 169 end +macro SYS_settimeofday 170 end +macro SYS_adjtimex 171 end +macro SYS_getpid 172 end +macro SYS_getppid 173 end +macro SYS_getuid 174 end +macro SYS_geteuid 175 end +macro SYS_getgid 176 end +macro SYS_getegid 177 end +macro SYS_gettid 178 end +macro SYS_sysinfo 179 end +macro SYS_mq_open 180 end +macro SYS_mq_unlink 181 end +macro SYS_mq_timedsend 182 end +macro SYS_mq_timedreceive 183 end +macro SYS_mq_notify 184 end +macro SYS_mq_getsetattr 185 end +macro SYS_msgget 186 end +macro SYS_msgctl 187 end +macro SYS_msgrcv 188 end +macro SYS_msgsnd 189 end +macro SYS_semget 190 end +macro SYS_semctl 191 end +macro SYS_semtimedop 192 end +macro SYS_semop 193 end +macro SYS_shmget 194 end +macro SYS_shmctl 195 end +macro SYS_shmat 196 end +macro SYS_shmdt 197 end +macro SYS_socket 198 end +macro SYS_socketpair 199 end +macro SYS_bind 200 end +macro SYS_listen 201 end +macro SYS_accept 202 end +macro SYS_connect 203 end +macro SYS_getsockname 204 end +macro SYS_getpeername 205 end +macro SYS_sendto 206 end +macro SYS_recvfrom 207 end +macro SYS_setsockopt 208 end +macro SYS_getsockopt 209 end +macro SYS_shutdown 210 end +macro SYS_sendmsg 211 end +macro SYS_recvmsg 212 end +macro SYS_readahead 213 end +macro SYS_brk 214 end +macro SYS_munmap 215 end +macro SYS_mremap 216 end +macro SYS_add_key 217 end +macro SYS_request_key 218 end +macro SYS_keyctl 219 end +macro SYS_clone 220 end +macro SYS_execve 221 end +macro SYS_mmap 222 end +macro SYS_fadvise64 223 end +macro SYS_swapon 224 end +macro SYS_swapoff 225 end +macro SYS_mprotect 226 end +macro SYS_msync 227 end +macro SYS_mlock 228 end +macro SYS_munlock 229 end +macro SYS_mlockall 230 end +macro SYS_munlockall 231 end +macro SYS_mincore 232 end +macro SYS_madvise 233 end +macro SYS_remap_file_pages 234 end +macro SYS_mbind 235 end +macro SYS_get_mempolicy 236 end +macro SYS_set_mempolicy 237 end +macro SYS_migrate_pages 238 end +macro SYS_move_pages 239 end +macro SYS_rt_tgsigqueueinfo 240 end +macro SYS_perf_event_open 241 end +macro SYS_accept4 242 end +macro SYS_recvmmsg 243 end +macro SYS_wait4 260 end +macro SYS_prlimit64 261 end +macro SYS_fanotify_init 262 end +macro SYS_fanotify_mark 263 end +macro SYS_name_to_handle_at 264 end +macro SYS_open_by_handle_at 265 end +macro SYS_clock_adjtime 266 end +macro SYS_syncfs 267 end +macro SYS_setns 268 end +macro SYS_sendmmsg 269 end +macro SYS_process_vm_readv 270 end +macro SYS_process_vm_writev 271 end +macro SYS_kcmp 272 end +macro SYS_finit_module 273 end +macro SYS_sched_setattr 274 end +macro SYS_sched_getattr 275 end +macro SYS_renameat2 276 end +macro SYS_seccomp 277 end +macro SYS_getrandom 278 end +macro SYS_memfd_create 279 end +macro SYS_bpf 280 end +macro SYS_execveat 281 end +macro SYS_userfaultfd 282 end +macro SYS_membarrier 283 end +macro SYS_mlock2 284 end +macro SYS_copy_file_range 285 end +macro SYS_preadv2 286 end +macro SYS_pwritev2 287 end +macro SYS_pkey_mprotect 288 end +macro SYS_pkey_alloc 289 end +macro SYS_pkey_free 290 end +macro SYS_statx 291 end + +// Wrappers for common syscalls +macro write SYS_write syscall3 end +macro read SYS_read syscall3 end +macro exit SYS_exit syscall1 end diff --git a/std/std.porth b/std/std.porth index 9688496d..606999df 100644 --- a/std/std.porth +++ b/std/std.porth @@ -1,337 +1,13 @@ +include "syscall.porth" + /// Standard streams macro stdin 0 end macro stdout 1 end macro stderr 2 end -/// Syscalls -// Stolen from https://filippo.io/linux-syscall-table/ -// Not all of the syscalls here are useful/implemented. I literally just copy-pasted them. -// We can clean this up later. -macro SYS_read 0 end -macro SYS_write 1 end -macro SYS_open 2 end -macro SYS_close 3 end -macro SYS_stat 4 end -macro SYS_fstat 5 end -macro SYS_lstat 6 end -macro SYS_poll 7 end -macro SYS_lseek 8 end -macro SYS_mmap 9 end -macro SYS_mprotect 10 end -macro SYS_munmap 11 end -macro SYS_brk 12 end -macro SYS_rt_sigaction 13 end -macro SYS_rt_sigprocmask 14 end -macro SYS_rt_sigreturn 15 end -macro SYS_ioctl 16 end -macro SYS_pread64 17 end -macro SYS_pwrite64 18 end -macro SYS_readv 19 end -macro SYS_writev 20 end -macro SYS_access 21 end -macro SYS_pipe 22 end -macro SYS_select 23 end -macro SYS_sched_yield 24 end -macro SYS_mremap 25 end -macro SYS_msync 26 end -macro SYS_mincore 27 end -macro SYS_madvise 28 end -macro SYS_shmget 29 end -macro SYS_shmat 30 end -macro SYS_shmctl 31 end -macro SYS_dup 32 end -macro SYS_dup2 33 end -macro SYS_pause 34 end -macro SYS_nanosleep 35 end -macro SYS_getitimer 36 end -macro SYS_alarm 37 end -macro SYS_setitimer 38 end -macro SYS_getpid 39 end -macro SYS_sendfile 40 end -macro SYS_socket 41 end -macro SYS_connect 42 end -macro SYS_accept 43 end -macro SYS_sendto 44 end -macro SYS_recvfrom 45 end -macro SYS_sendmsg 46 end -macro SYS_recvmsg 47 end -macro SYS_shutdown 48 end -macro SYS_bind 49 end -macro SYS_listen 50 end -macro SYS_getsockname 51 end -macro SYS_getpeername 52 end -macro SYS_socketpair 53 end -macro SYS_setsockopt 54 end -macro SYS_getsockopt 55 end -macro SYS_clone 56 end -macro SYS_fork 57 end -macro SYS_vfork 58 end -macro SYS_execve 59 end -macro SYS_exit 60 end -macro SYS_wait4 61 end -macro SYS_kill 62 end -macro SYS_uname 63 end -macro SYS_semget 64 end -macro SYS_semop 65 end -macro SYS_semctl 66 end -macro SYS_shmdt 67 end -macro SYS_msgget 68 end -macro SYS_msgsnd 69 end -macro SYS_msgrcv 70 end -macro SYS_msgctl 71 end -macro SYS_fcntl 72 end -macro SYS_flock 73 end -macro SYS_fsync 74 end -macro SYS_fdatasync 75 end -macro SYS_truncate 76 end -macro SYS_ftruncate 77 end -macro SYS_getdents 78 end -macro SYS_getcwd 79 end -macro SYS_chdir 80 end -macro SYS_fchdir 81 end -macro SYS_rename 82 end -macro SYS_mkdir 83 end -macro SYS_rmdir 84 end -macro SYS_creat 85 end -macro SYS_link 86 end -macro SYS_unlink 87 end -macro SYS_symlink 88 end -macro SYS_readlink 89 end -macro SYS_chmod 90 end -macro SYS_fchmod 91 end -macro SYS_chown 92 end -macro SYS_fchown 93 end -macro SYS_lchown 94 end -macro SYS_umask 95 end -macro SYS_gettimeofday 96 end -macro SYS_getrlimit 97 end -macro SYS_getrusage 98 end -macro SYS_sysinfo 99 end -macro SYS_times 100 end -macro SYS_ptrace 101 end -macro SYS_getuid 102 end -macro SYS_syslog 103 end -macro SYS_getgid 104 end -macro SYS_setuid 105 end -macro SYS_setgid 106 end -macro SYS_geteuid 107 end -macro SYS_getegid 108 end -macro SYS_setpgid 109 end -macro SYS_getppid 110 end -macro SYS_getpgrp 111 end -macro SYS_setsid 112 end -macro SYS_setreuid 113 end -macro SYS_setregid 114 end -macro SYS_getgroups 115 end -macro SYS_setgroups 116 end -macro SYS_setresuid 117 end -macro SYS_getresuid 118 end -macro SYS_setresgid 119 end -macro SYS_getresgid 120 end -macro SYS_getpgid 121 end -macro SYS_setfsuid 122 end -macro SYS_setfsgid 123 end -macro SYS_getsid 124 end -macro SYS_capget 125 end -macro SYS_capset 126 end -macro SYS_rt_sigpending 127 end -macro SYS_rt_sigtimedwait 128 end -macro SYS_rt_sigqueueinfo 129 end -macro SYS_rt_sigsuspend 130 end -macro SYS_sigaltstack 131 end -macro SYS_utime 132 end -macro SYS_mknod 133 end -macro SYS_uselib 134 end -macro SYS_personality 135 end -macro SYS_ustat 136 end -macro SYS_statfs 137 end -macro SYS_fstatfs 138 end -macro SYS_sysfs 139 end -macro SYS_getpriority 140 end -macro SYS_setpriority 141 end -macro SYS_sched_setparam 142 end -macro SYS_sched_getparam 143 end -macro SYS_sched_setscheduler 144 end -macro SYS_sched_getscheduler 145 end -macro SYS_sched_get_priority_max 146 end -macro SYS_sched_get_priority_min 147 end -macro SYS_sched_rr_get_interval 148 end -macro SYS_mlock 149 end -macro SYS_munlock 150 end -macro SYS_mlockall 151 end -macro SYS_munlockall 152 end -macro SYS_vhangup 153 end -macro SYS_modify_ldt 154 end -macro SYS_pivot_root 155 end -macro SYS__sysctl 156 end -macro SYS_prctl 157 end -macro SYS_arch_prctl 158 end -macro SYS_adjtimex 159 end -macro SYS_setrlimit 160 end -macro SYS_chroot 161 end -macro SYS_sync 162 end -macro SYS_acct 163 end -macro SYS_settimeofday 164 end -macro SYS_mount 165 end -macro SYS_umount2 166 end -macro SYS_swapon 167 end -macro SYS_swapoff 168 end -macro SYS_reboot 169 end -macro SYS_sethostname 170 end -macro SYS_setdomainname 171 end -macro SYS_iopl 172 end -macro SYS_ioperm 173 end -macro SYS_create_module 174 end -macro SYS_init_module 175 end -macro SYS_delete_module 176 end -macro SYS_get_kernel_syms 177 end -macro SYS_query_module 178 end -macro SYS_quotactl 179 end -macro SYS_nfsservctl 180 end -macro SYS_getpmsg 181 end -macro SYS_putpmsg 182 end -macro SYS_afs_syscall 183 end -macro SYS_tuxcall 184 end -macro SYS_security 185 end -macro SYS_gettid 186 end -macro SYS_readahead 187 end -macro SYS_setxattr 188 end -macro SYS_lsetxattr 189 end -macro SYS_fsetxattr 190 end -macro SYS_getxattr 191 end -macro SYS_lgetxattr 192 end -macro SYS_fgetxattr 193 end -macro SYS_listxattr 194 end -macro SYS_llistxattr 195 end -macro SYS_flistxattr 196 end -macro SYS_removexattr 197 end -macro SYS_lremovexattr 198 end -macro SYS_fremovexattr 199 end -macro SYS_tkill 200 end -macro SYS_time 201 end -macro SYS_futex 202 end -macro SYS_sched_setaffinity 203 end -macro SYS_sched_getaffinity 204 end -macro SYS_set_thread_area 205 end -macro SYS_io_setup 206 end -macro SYS_io_destroy 207 end -macro SYS_io_getevents 208 end -macro SYS_io_submit 209 end -macro SYS_io_cancel 210 end -macro SYS_get_thread_area 211 end -macro SYS_lookup_dcookie 212 end -macro SYS_epoll_create 213 end -macro SYS_epoll_ctl_old 214 end -macro SYS_epoll_wait_old 215 end -macro SYS_remap_file_pages 216 end -macro SYS_getdents64 217 end -macro SYS_set_tid_address 218 end -macro SYS_restart_syscall 219 end -macro SYS_semtimedop 220 end -macro SYS_fadvise64 221 end -macro SYS_timer_create 222 end -macro SYS_timer_settime 223 end -macro SYS_timer_gettime 224 end -macro SYS_timer_getoverrun 225 end -macro SYS_timer_delete 226 end -macro SYS_clock_settime 227 end -macro SYS_clock_gettime 228 end -macro SYS_clock_getres 229 end -macro SYS_clock_nanosleep 230 end -macro SYS_exit_group 231 end -macro SYS_epoll_wait 232 end -macro SYS_epoll_ctl 233 end -macro SYS_tgkill 234 end -macro SYS_utimes 235 end -macro SYS_vserver 236 end -macro SYS_mbind 237 end -macro SYS_set_mempolicy 238 end -macro SYS_get_mempolicy 239 end -macro SYS_mq_open 240 end -macro SYS_mq_unlink 241 end -macro SYS_mq_timedsend 242 end -macro SYS_mq_timedreceive 243 end -macro SYS_mq_notify 244 end -macro SYS_mq_getsetattr 245 end -macro SYS_kexec_load 246 end -macro SYS_waitid 247 end -macro SYS_add_key 248 end -macro SYS_request_key 249 end -macro SYS_keyctl 250 end -macro SYS_ioprio_set 251 end -macro SYS_ioprio_get 252 end -macro SYS_inotify_init 253 end -macro SYS_inotify_add_watch 254 end -macro SYS_inotify_rm_watch 255 end -macro SYS_migrate_pages 256 end -macro SYS_openat 257 end -macro SYS_mkdirat 258 end -macro SYS_mknodat 259 end -macro SYS_fchownat 260 end -macro SYS_futimesat 261 end -macro SYS_newfstatat 262 end -macro SYS_unlinkat 263 end -macro SYS_renameat 264 end -macro SYS_linkat 265 end -macro SYS_symlinkat 266 end -macro SYS_readlinkat 267 end -macro SYS_fchmodat 268 end -macro SYS_faccessat 269 end -macro SYS_pselect6 270 end -macro SYS_ppoll 271 end -macro SYS_unshare 272 end -macro SYS_set_robust_list 273 end -macro SYS_get_robust_list 274 end -macro SYS_splice 275 end -macro SYS_tee 276 end -macro SYS_sync_file_range 277 end -macro SYS_vmsplice 278 end -macro SYS_move_pages 279 end -macro SYS_utimensat 280 end -macro SYS_epoll_pwait 281 end -macro SYS_signalfd 282 end -macro SYS_timerfd_create 283 end -macro SYS_eventfd 284 end -macro SYS_fallocate 285 end -macro SYS_timerfd_settime 286 end -macro SYS_timerfd_gettime 287 end -macro SYS_accept4 288 end -macro SYS_signalfd4 289 end -macro SYS_eventfd2 290 end -macro SYS_epoll_create1 291 end -macro SYS_dup3 292 end -macro SYS_pipe2 293 end -macro SYS_inotify_init1 294 end -macro SYS_preadv 295 end -macro SYS_pwritev 296 end -macro SYS_rt_tgsigqueueinfo 297 end -macro SYS_perf_event_open 298 end -macro SYS_recvmmsg 299 end -macro SYS_fanotify_init 300 end -macro SYS_fanotify_mark 301 end -macro SYS_prlimit64 302 end -macro SYS_name_to_handle_at 303 end -macro SYS_open_by_handle_at 304 end -macro SYS_clock_adjtime 305 end -macro SYS_syncfs 306 end -macro SYS_sendmmsg 307 end -macro SYS_setns 308 end -macro SYS_getcpu 309 end -macro SYS_process_vm_readv 310 end -macro SYS_process_vm_writev 311 end -macro SYS_kcmp 312 end -macro SYS_finit_module 313 end - macro AT_FDCWD -100 end macro O_RDONLY 0 end -// Wrappers for common syscalls -macro write SYS_write syscall3 end -macro read SYS_read syscall3 end -macro openat SYS_openat syscall3 end -macro close SYS_close syscall1 end -macro exit SYS_exit syscall1 drop end - macro 2dup over over end macro 2drop drop drop end diff --git a/std/x86_64/syscall.porth b/std/x86_64/syscall.porth new file mode 100644 index 00000000..efbdb379 --- /dev/null +++ b/std/x86_64/syscall.porth @@ -0,0 +1,325 @@ +/// Syscalls +// Stolen from https://filippo.io/linux-syscall-table/ +// Not all of the syscalls here are useful/implemented. I literally just copy-pasted them. +// We can clean this up later. +macro SYS_read 0 end +macro SYS_write 1 end +macro SYS_open 2 end +macro SYS_close 3 end +macro SYS_stat 4 end +macro SYS_fstat 5 end +macro SYS_lstat 6 end +macro SYS_poll 7 end +macro SYS_lseek 8 end +macro SYS_mmap 9 end +macro SYS_mprotect 10 end +macro SYS_munmap 11 end +macro SYS_brk 12 end +macro SYS_rt_sigaction 13 end +macro SYS_rt_sigprocmask 14 end +macro SYS_rt_sigreturn 15 end +macro SYS_ioctl 16 end +macro SYS_pread64 17 end +macro SYS_pwrite64 18 end +macro SYS_readv 19 end +macro SYS_writev 20 end +macro SYS_access 21 end +macro SYS_pipe 22 end +macro SYS_select 23 end +macro SYS_sched_yield 24 end +macro SYS_mremap 25 end +macro SYS_msync 26 end +macro SYS_mincore 27 end +macro SYS_madvise 28 end +macro SYS_shmget 29 end +macro SYS_shmat 30 end +macro SYS_shmctl 31 end +macro SYS_dup 32 end +macro SYS_dup2 33 end +macro SYS_pause 34 end +macro SYS_nanosleep 35 end +macro SYS_getitimer 36 end +macro SYS_alarm 37 end +macro SYS_setitimer 38 end +macro SYS_getpid 39 end +macro SYS_sendfile 40 end +macro SYS_socket 41 end +macro SYS_connect 42 end +macro SYS_accept 43 end +macro SYS_sendto 44 end +macro SYS_recvfrom 45 end +macro SYS_sendmsg 46 end +macro SYS_recvmsg 47 end +macro SYS_shutdown 48 end +macro SYS_bind 49 end +macro SYS_listen 50 end +macro SYS_getsockname 51 end +macro SYS_getpeername 52 end +macro SYS_socketpair 53 end +macro SYS_setsockopt 54 end +macro SYS_getsockopt 55 end +macro SYS_clone 56 end +macro SYS_fork 57 end +macro SYS_vfork 58 end +macro SYS_execve 59 end +macro SYS_exit 60 end +macro SYS_wait4 61 end +macro SYS_kill 62 end +macro SYS_uname 63 end +macro SYS_semget 64 end +macro SYS_semop 65 end +macro SYS_semctl 66 end +macro SYS_shmdt 67 end +macro SYS_msgget 68 end +macro SYS_msgsnd 69 end +macro SYS_msgrcv 70 end +macro SYS_msgctl 71 end +macro SYS_fcntl 72 end +macro SYS_flock 73 end +macro SYS_fsync 74 end +macro SYS_fdatasync 75 end +macro SYS_truncate 76 end +macro SYS_ftruncate 77 end +macro SYS_getdents 78 end +macro SYS_getcwd 79 end +macro SYS_chdir 80 end +macro SYS_fchdir 81 end +macro SYS_rename 82 end +macro SYS_mkdir 83 end +macro SYS_rmdir 84 end +macro SYS_creat 85 end +macro SYS_link 86 end +macro SYS_unlink 87 end +macro SYS_symlink 88 end +macro SYS_readlink 89 end +macro SYS_chmod 90 end +macro SYS_fchmod 91 end +macro SYS_chown 92 end +macro SYS_fchown 93 end +macro SYS_lchown 94 end +macro SYS_umask 95 end +macro SYS_gettimeofday 96 end +macro SYS_getrlimit 97 end +macro SYS_getrusage 98 end +macro SYS_sysinfo 99 end +macro SYS_times 100 end +macro SYS_ptrace 101 end +macro SYS_getuid 102 end +macro SYS_syslog 103 end +macro SYS_getgid 104 end +macro SYS_setuid 105 end +macro SYS_setgid 106 end +macro SYS_geteuid 107 end +macro SYS_getegid 108 end +macro SYS_setpgid 109 end +macro SYS_getppid 110 end +macro SYS_getpgrp 111 end +macro SYS_setsid 112 end +macro SYS_setreuid 113 end +macro SYS_setregid 114 end +macro SYS_getgroups 115 end +macro SYS_setgroups 116 end +macro SYS_setresuid 117 end +macro SYS_getresuid 118 end +macro SYS_setresgid 119 end +macro SYS_getresgid 120 end +macro SYS_getpgid 121 end +macro SYS_setfsuid 122 end +macro SYS_setfsgid 123 end +macro SYS_getsid 124 end +macro SYS_capget 125 end +macro SYS_capset 126 end +macro SYS_rt_sigpending 127 end +macro SYS_rt_sigtimedwait 128 end +macro SYS_rt_sigqueueinfo 129 end +macro SYS_rt_sigsuspend 130 end +macro SYS_sigaltstack 131 end +macro SYS_utime 132 end +macro SYS_mknod 133 end +macro SYS_uselib 134 end +macro SYS_personality 135 end +macro SYS_ustat 136 end +macro SYS_statfs 137 end +macro SYS_fstatfs 138 end +macro SYS_sysfs 139 end +macro SYS_getpriority 140 end +macro SYS_setpriority 141 end +macro SYS_sched_setparam 142 end +macro SYS_sched_getparam 143 end +macro SYS_sched_setscheduler 144 end +macro SYS_sched_getscheduler 145 end +macro SYS_sched_get_priority_max 146 end +macro SYS_sched_get_priority_min 147 end +macro SYS_sched_rr_get_interval 148 end +macro SYS_mlock 149 end +macro SYS_munlock 150 end +macro SYS_mlockall 151 end +macro SYS_munlockall 152 end +macro SYS_vhangup 153 end +macro SYS_modify_ldt 154 end +macro SYS_pivot_root 155 end +macro SYS__sysctl 156 end +macro SYS_prctl 157 end +macro SYS_arch_prctl 158 end +macro SYS_adjtimex 159 end +macro SYS_setrlimit 160 end +macro SYS_chroot 161 end +macro SYS_sync 162 end +macro SYS_acct 163 end +macro SYS_settimeofday 164 end +macro SYS_mount 165 end +macro SYS_umount2 166 end +macro SYS_swapon 167 end +macro SYS_swapoff 168 end +macro SYS_reboot 169 end +macro SYS_sethostname 170 end +macro SYS_setdomainname 171 end +macro SYS_iopl 172 end +macro SYS_ioperm 173 end +macro SYS_create_module 174 end +macro SYS_init_module 175 end +macro SYS_delete_module 176 end +macro SYS_get_kernel_syms 177 end +macro SYS_query_module 178 end +macro SYS_quotactl 179 end +macro SYS_nfsservctl 180 end +macro SYS_getpmsg 181 end +macro SYS_putpmsg 182 end +macro SYS_afs_syscall 183 end +macro SYS_tuxcall 184 end +macro SYS_security 185 end +macro SYS_gettid 186 end +macro SYS_readahead 187 end +macro SYS_setxattr 188 end +macro SYS_lsetxattr 189 end +macro SYS_fsetxattr 190 end +macro SYS_getxattr 191 end +macro SYS_lgetxattr 192 end +macro SYS_fgetxattr 193 end +macro SYS_listxattr 194 end +macro SYS_llistxattr 195 end +macro SYS_flistxattr 196 end +macro SYS_removexattr 197 end +macro SYS_lremovexattr 198 end +macro SYS_fremovexattr 199 end +macro SYS_tkill 200 end +macro SYS_time 201 end +macro SYS_futex 202 end +macro SYS_sched_setaffinity 203 end +macro SYS_sched_getaffinity 204 end +macro SYS_set_thread_area 205 end +macro SYS_io_setup 206 end +macro SYS_io_destroy 207 end +macro SYS_io_getevents 208 end +macro SYS_io_submit 209 end +macro SYS_io_cancel 210 end +macro SYS_get_thread_area 211 end +macro SYS_lookup_dcookie 212 end +macro SYS_epoll_create 213 end +macro SYS_epoll_ctl_old 214 end +macro SYS_epoll_wait_old 215 end +macro SYS_remap_file_pages 216 end +macro SYS_getdents64 217 end +macro SYS_set_tid_address 218 end +macro SYS_restart_syscall 219 end +macro SYS_semtimedop 220 end +macro SYS_fadvise64 221 end +macro SYS_timer_create 222 end +macro SYS_timer_settime 223 end +macro SYS_timer_gettime 224 end +macro SYS_timer_getoverrun 225 end +macro SYS_timer_delete 226 end +macro SYS_clock_settime 227 end +macro SYS_clock_gettime 228 end +macro SYS_clock_getres 229 end +macro SYS_clock_nanosleep 230 end +macro SYS_exit_group 231 end +macro SYS_epoll_wait 232 end +macro SYS_epoll_ctl 233 end +macro SYS_tgkill 234 end +macro SYS_utimes 235 end +macro SYS_vserver 236 end +macro SYS_mbind 237 end +macro SYS_set_mempolicy 238 end +macro SYS_get_mempolicy 239 end +macro SYS_mq_open 240 end +macro SYS_mq_unlink 241 end +macro SYS_mq_timedsend 242 end +macro SYS_mq_timedreceive 243 end +macro SYS_mq_notify 244 end +macro SYS_mq_getsetattr 245 end +macro SYS_kexec_load 246 end +macro SYS_waitid 247 end +macro SYS_add_key 248 end +macro SYS_request_key 249 end +macro SYS_keyctl 250 end +macro SYS_ioprio_set 251 end +macro SYS_ioprio_get 252 end +macro SYS_inotify_init 253 end +macro SYS_inotify_add_watch 254 end +macro SYS_inotify_rm_watch 255 end +macro SYS_migrate_pages 256 end +macro SYS_openat 257 end +macro SYS_mkdirat 258 end +macro SYS_mknodat 259 end +macro SYS_fchownat 260 end +macro SYS_futimesat 261 end +macro SYS_newfstatat 262 end +macro SYS_unlinkat 263 end +macro SYS_renameat 264 end +macro SYS_linkat 265 end +macro SYS_symlinkat 266 end +macro SYS_readlinkat 267 end +macro SYS_fchmodat 268 end +macro SYS_faccessat 269 end +macro SYS_pselect6 270 end +macro SYS_ppoll 271 end +macro SYS_unshare 272 end +macro SYS_set_robust_list 273 end +macro SYS_get_robust_list 274 end +macro SYS_splice 275 end +macro SYS_tee 276 end +macro SYS_sync_file_range 277 end +macro SYS_vmsplice 278 end +macro SYS_move_pages 279 end +macro SYS_utimensat 280 end +macro SYS_epoll_pwait 281 end +macro SYS_signalfd 282 end +macro SYS_timerfd_create 283 end +macro SYS_eventfd 284 end +macro SYS_fallocate 285 end +macro SYS_timerfd_settime 286 end +macro SYS_timerfd_gettime 287 end +macro SYS_accept4 288 end +macro SYS_signalfd4 289 end +macro SYS_eventfd2 290 end +macro SYS_epoll_create1 291 end +macro SYS_dup3 292 end +macro SYS_pipe2 293 end +macro SYS_inotify_init1 294 end +macro SYS_preadv 295 end +macro SYS_pwritev 296 end +macro SYS_rt_tgsigqueueinfo 297 end +macro SYS_perf_event_open 298 end +macro SYS_recvmmsg 299 end +macro SYS_fanotify_init 300 end +macro SYS_fanotify_mark 301 end +macro SYS_prlimit64 302 end +macro SYS_name_to_handle_at 303 end +macro SYS_open_by_handle_at 304 end +macro SYS_clock_adjtime 305 end +macro SYS_syncfs 306 end +macro SYS_sendmmsg 307 end +macro SYS_setns 308 end +macro SYS_getcpu 309 end +macro SYS_process_vm_readv 310 end +macro SYS_process_vm_writev 311 end +macro SYS_kcmp 312 end +macro SYS_finit_module 313 end + +// Wrappers for common syscalls +macro write SYS_write syscall3 end +macro read SYS_read syscall3 end +macro openat SYS_openat syscall3 end +macro close SYS_close syscall1 end +macro exit SYS_exit syscall1 drop end