+x86_64.ha (1605B)
1 // SPDX-License-Identifier: MPL-2.0 2 // (c) Hare authors <https://harelang.org> 3 4 // #define __ADDR_BND_PKEY_PAD (_Alignof(void *) < sizeof(short) ? sizeof(short) : _Alignof(void *)) 5 def __ADDR_BND_PKEY_PAD: size = 8; 6 7 // Returns the new PID to the parent, void to the child, or errno if something 8 // goes wrong. 9 export fn clone( 10 stack: nullable *opaque, 11 flags: int, 12 parent_tid: nullable *int, 13 child_tid: nullable *int, 14 tls: u64, 15 ) (int | void | errno) = { 16 match (wrap_return(syscall5(SYS_clone, 17 flags: u64, stack: uintptr: u64, 18 parent_tid: uintptr: u64, child_tid: uintptr: u64, 19 tls))) { 20 case let u: u64 => 21 switch (u) { 22 case 0 => 23 return; 24 case => 25 return u: int; 26 }; 27 case let err: errno => 28 return err; 29 }; 30 }; 31 32 export def O_DIRECTORY: int = 0o200000; 33 export def O_DIRECT: int = 0o40000; 34 35 export type cmsghdr = struct { 36 cmsg_len: socklen_t, 37 _padding: int, 38 cmsg_level: int, 39 cmsg_type: int, 40 }; 41 42 export def EDEADLOCK: int = EDEADLK; 43 44 export type epoll_event = struct @packed { 45 // Packed on x86_64 46 events: u32, 47 data: epoll_data, 48 }; 49 50 export type cpu_set = struct { 51 __bits: [16]u64, 52 }; 53 54 export type ucontext = struct { 55 uc_flags: u64, 56 uc_link: *ucontext, 57 uc_stack: stack_t, 58 uc_mcontext: sigcontext, 59 uc_sigmask: sigset, 60 }; 61 62 export type sigcontext = struct { 63 r8: u64, 64 r9: u64, 65 r10: u64, 66 r11: u64, 67 r12: u64, 68 r13: u64, 69 r14: u64, 70 r15: u64, 71 di: u64, 72 si: u64, 73 bp: u64, 74 bx: u64, 75 dx: u64, 76 ax: u64, 77 cx: u64, 78 sp: u64, 79 ip: u64, 80 flags: u64, 81 cs: u16, 82 gs: u16, 83 fs: u16, 84 ss: u16, 85 err: u64, 86 trapno: u64, 87 oldmask: u64, 88 cr2: u64, 89 fpstate: u64, 90 reserved1: [8]u64, 91 };