mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
haiku: debitrot
This commit is contained in:
parent
c011abc4dd
commit
2dd74cd312
17 changed files with 392 additions and 88 deletions
|
|
@ -64,6 +64,8 @@ static const char *get_host_os(void) {
|
||||||
return "linux";
|
return "linux";
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(__FreeBSD__)
|
||||||
return "freebsd";
|
return "freebsd";
|
||||||
|
#elif defined(__HAIKU__)
|
||||||
|
return "haiku";
|
||||||
#else
|
#else
|
||||||
panic("unknown host os, specify with ZIG_HOST_TARGET_OS");
|
panic("unknown host os, specify with ZIG_HOST_TARGET_OS");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1687,8 +1687,8 @@ pub extern "c" fn getpeername(sockfd: c.fd_t, noalias addr: *c.sockaddr, noalias
|
||||||
pub extern "c" fn connect(sockfd: c.fd_t, sock_addr: *const c.sockaddr, addrlen: c.socklen_t) c_int;
|
pub extern "c" fn connect(sockfd: c.fd_t, sock_addr: *const c.sockaddr, addrlen: c.socklen_t) c_int;
|
||||||
pub extern "c" fn accept(sockfd: c.fd_t, noalias addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t) c_int;
|
pub extern "c" fn accept(sockfd: c.fd_t, noalias addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t) c_int;
|
||||||
pub extern "c" fn accept4(sockfd: c.fd_t, noalias addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t, flags: c_uint) c_int;
|
pub extern "c" fn accept4(sockfd: c.fd_t, noalias addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t, flags: c_uint) c_int;
|
||||||
pub extern "c" fn getsockopt(sockfd: c.fd_t, level: u32, optname: u32, noalias optval: ?*anyopaque, noalias optlen: *c.socklen_t) c_int;
|
pub extern "c" fn getsockopt(sockfd: c.fd_t, level: i32, optname: u32, noalias optval: ?*anyopaque, noalias optlen: *c.socklen_t) c_int;
|
||||||
pub extern "c" fn setsockopt(sockfd: c.fd_t, level: u32, optname: u32, optval: ?*const anyopaque, optlen: c.socklen_t) c_int;
|
pub extern "c" fn setsockopt(sockfd: c.fd_t, level: i32, optname: u32, optval: ?*const anyopaque, optlen: c.socklen_t) c_int;
|
||||||
pub extern "c" fn send(sockfd: c.fd_t, buf: *const anyopaque, len: usize, flags: u32) isize;
|
pub extern "c" fn send(sockfd: c.fd_t, buf: *const anyopaque, len: usize, flags: u32) isize;
|
||||||
pub extern "c" fn sendto(
|
pub extern "c" fn sendto(
|
||||||
sockfd: c.fd_t,
|
sockfd: c.fd_t,
|
||||||
|
|
|
||||||
|
|
@ -1139,7 +1139,7 @@ pub const siginfo_t = extern struct {
|
||||||
pid: pid_t,
|
pid: pid_t,
|
||||||
uid: uid_t,
|
uid: uid_t,
|
||||||
status: c_int,
|
status: c_int,
|
||||||
addr: *anyopaque,
|
addr: *allowzero anyopaque,
|
||||||
value: extern union {
|
value: extern union {
|
||||||
int: c_int,
|
int: c_int,
|
||||||
ptr: *anyopaque,
|
ptr: *anyopaque,
|
||||||
|
|
@ -1151,7 +1151,7 @@ pub const siginfo_t = extern struct {
|
||||||
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name.
|
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name.
|
||||||
pub const Sigaction = extern struct {
|
pub const Sigaction = extern struct {
|
||||||
pub const handler_fn = *align(1) const fn (c_int) callconv(.C) void;
|
pub const handler_fn = *align(1) const fn (c_int) callconv(.C) void;
|
||||||
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*const anyopaque) callconv(.C) void;
|
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*anyopaque) callconv(.C) void;
|
||||||
|
|
||||||
handler: extern union {
|
handler: extern union {
|
||||||
handler: ?handler_fn,
|
handler: ?handler_fn,
|
||||||
|
|
|
||||||
|
|
@ -668,7 +668,7 @@ pub const siginfo_t = extern struct {
|
||||||
pid: c_int,
|
pid: c_int,
|
||||||
uid: uid_t,
|
uid: uid_t,
|
||||||
status: c_int,
|
status: c_int,
|
||||||
addr: ?*anyopaque,
|
addr: *allowzero anyopaque,
|
||||||
value: sigval,
|
value: sigval,
|
||||||
band: c_long,
|
band: c_long,
|
||||||
__spare__: [7]c_int,
|
__spare__: [7]c_int,
|
||||||
|
|
@ -691,7 +691,7 @@ pub const sig_atomic_t = c_int;
|
||||||
|
|
||||||
pub const Sigaction = extern struct {
|
pub const Sigaction = extern struct {
|
||||||
pub const handler_fn = *align(1) const fn (c_int) callconv(.C) void;
|
pub const handler_fn = *align(1) const fn (c_int) callconv(.C) void;
|
||||||
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*const anyopaque) callconv(.C) void;
|
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*anyopaque) callconv(.C) void;
|
||||||
|
|
||||||
/// signal handler
|
/// signal handler
|
||||||
handler: extern union {
|
handler: extern union {
|
||||||
|
|
|
||||||
|
|
@ -1172,7 +1172,7 @@ const NSIG = 32;
|
||||||
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
|
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
|
||||||
pub const Sigaction = extern struct {
|
pub const Sigaction = extern struct {
|
||||||
pub const handler_fn = *align(1) const fn (c_int) callconv(.C) void;
|
pub const handler_fn = *align(1) const fn (c_int) callconv(.C) void;
|
||||||
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*const anyopaque) callconv(.C) void;
|
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*anyopaque) callconv(.C) void;
|
||||||
|
|
||||||
/// signal handler
|
/// signal handler
|
||||||
handler: extern union {
|
handler: extern union {
|
||||||
|
|
@ -1206,7 +1206,7 @@ pub const siginfo_t = extern struct {
|
||||||
/// Exit value.
|
/// Exit value.
|
||||||
status: c_int,
|
status: c_int,
|
||||||
/// Faulting instruction.
|
/// Faulting instruction.
|
||||||
addr: ?*anyopaque,
|
addr: *allowzero anyopaque,
|
||||||
/// Signal value.
|
/// Signal value.
|
||||||
value: sigval,
|
value: sigval,
|
||||||
reason: extern union {
|
reason: extern union {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ extern "c" fn _errnop() *c_int;
|
||||||
|
|
||||||
pub const _errno = _errnop;
|
pub const _errno = _errnop;
|
||||||
|
|
||||||
pub extern "c" fn find_directory(which: c_int, volume: i32, createIt: bool, path_ptr: [*]u8, length: i32) u64;
|
pub extern "c" fn find_directory(which: directory_which, volume: i32, createIt: bool, path_ptr: [*]u8, length: i32) u64;
|
||||||
|
|
||||||
pub extern "c" fn find_thread(thread_name: ?*anyopaque) i32;
|
pub extern "c" fn find_thread(thread_name: ?*anyopaque) i32;
|
||||||
|
|
||||||
|
|
@ -427,23 +427,18 @@ pub const W = struct {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const SA = struct {
|
// posix/signal.h
|
||||||
pub const ONSTACK = 0x20;
|
|
||||||
pub const RESTART = 0x10;
|
pub const sigset_t = u64;
|
||||||
pub const RESETHAND = 0x04;
|
pub const empty_sigset: sigset_t = 0;
|
||||||
pub const NOCLDSTOP = 0x01;
|
pub const filled_sigset = ~@as(sigset_t, 0);
|
||||||
pub const NODEFER = 0x08;
|
|
||||||
pub const NOCLDWAIT = 0x02;
|
|
||||||
pub const SIGINFO = 0x40;
|
|
||||||
pub const NOMASK = NODEFER;
|
|
||||||
pub const STACK = ONSTACK;
|
|
||||||
pub const ONESHOT = RESETHAND;
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const SIG = struct {
|
pub const SIG = struct {
|
||||||
pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
|
|
||||||
pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
|
pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
|
||||||
pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);
|
pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);
|
||||||
|
pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
|
||||||
|
|
||||||
|
pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(3);
|
||||||
|
|
||||||
pub const HUP = 1;
|
pub const HUP = 1;
|
||||||
pub const INT = 2;
|
pub const INT = 2;
|
||||||
|
|
@ -484,6 +479,340 @@ pub const SIG = struct {
|
||||||
pub const SETMASK = 3;
|
pub const SETMASK = 3;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const siginfo_t = extern struct {
|
||||||
|
signo: c_int,
|
||||||
|
code: c_int,
|
||||||
|
errno: c_int,
|
||||||
|
|
||||||
|
pid: pid_t,
|
||||||
|
uid: uid_t,
|
||||||
|
addr: *allowzero anyopaque,
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
|
||||||
|
pub const Sigaction = extern struct {
|
||||||
|
pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
|
||||||
|
pub const sigaction_fn = *const fn (c_int, *allowzero anyopaque, ?*anyopaque) callconv(.C) void;
|
||||||
|
|
||||||
|
/// signal handler
|
||||||
|
handler: extern union {
|
||||||
|
handler: handler_fn,
|
||||||
|
sigaction: sigaction_fn,
|
||||||
|
},
|
||||||
|
|
||||||
|
/// signal mask to apply
|
||||||
|
mask: sigset_t,
|
||||||
|
|
||||||
|
/// see signal options
|
||||||
|
flags: c_int,
|
||||||
|
|
||||||
|
/// will be passed to the signal handler, BeOS extension
|
||||||
|
userdata: *allowzero anyopaque = undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const SA = struct {
|
||||||
|
pub const NOCLDSTOP = 0x01;
|
||||||
|
pub const NOCLDWAIT = 0x02;
|
||||||
|
pub const RESETHAND = 0x04;
|
||||||
|
pub const NODEFER = 0x08;
|
||||||
|
pub const RESTART = 0x10;
|
||||||
|
pub const ONSTACK = 0x20;
|
||||||
|
pub const SIGINFO = 0x40;
|
||||||
|
pub const NOMASK = NODEFER;
|
||||||
|
pub const STACK = ONSTACK;
|
||||||
|
pub const ONESHOT = RESETHAND;
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const SS = struct {
|
||||||
|
pub const ONSTACK = 0x1;
|
||||||
|
pub const DISABLE = 0x2;
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const MINSIGSTKSZ = 8192;
|
||||||
|
pub const SIGSTKSZ = 16384;
|
||||||
|
|
||||||
|
pub const stack_t = extern struct {
|
||||||
|
sp: [*]u8,
|
||||||
|
size: isize,
|
||||||
|
flags: i32,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const NSIG = 65;
|
||||||
|
|
||||||
|
pub const mcontext_t = vregs;
|
||||||
|
|
||||||
|
pub const ucontext_t = extern struct {
|
||||||
|
link: ?*ucontext_t,
|
||||||
|
sigmask: sigset_t,
|
||||||
|
stack: stack_t,
|
||||||
|
mcontext: mcontext_t,
|
||||||
|
};
|
||||||
|
|
||||||
|
// arch/*/signal.h
|
||||||
|
|
||||||
|
pub const vregs = switch (builtin.cpu.arch) {
|
||||||
|
.arm, .thumb => extern struct {
|
||||||
|
r0: u32,
|
||||||
|
r1: u32,
|
||||||
|
r2: u32,
|
||||||
|
r3: u32,
|
||||||
|
r4: u32,
|
||||||
|
r5: u32,
|
||||||
|
r6: u32,
|
||||||
|
r7: u32,
|
||||||
|
r8: u32,
|
||||||
|
r9: u32,
|
||||||
|
r10: u32,
|
||||||
|
r11: u32,
|
||||||
|
r12: u32,
|
||||||
|
r13: u32,
|
||||||
|
r14: u32,
|
||||||
|
r15: u32,
|
||||||
|
cpsr: u32,
|
||||||
|
},
|
||||||
|
.aarch64 => extern struct {
|
||||||
|
x: [10]u64,
|
||||||
|
lr: u64,
|
||||||
|
sp: u64,
|
||||||
|
elr: u64,
|
||||||
|
spsr: u64,
|
||||||
|
fp_q: [32]u128,
|
||||||
|
fpsr: u32,
|
||||||
|
fpcr: u32,
|
||||||
|
},
|
||||||
|
.m68k => extern struct {
|
||||||
|
pc: u32,
|
||||||
|
d0: u32,
|
||||||
|
d1: u32,
|
||||||
|
d2: u32,
|
||||||
|
d3: u32,
|
||||||
|
d4: u32,
|
||||||
|
d5: u32,
|
||||||
|
d6: u32,
|
||||||
|
d7: u32,
|
||||||
|
a0: u32,
|
||||||
|
a1: u32,
|
||||||
|
a2: u32,
|
||||||
|
a3: u32,
|
||||||
|
a4: u32,
|
||||||
|
a5: u32,
|
||||||
|
a6: u32,
|
||||||
|
a7: u32,
|
||||||
|
ccr: u8,
|
||||||
|
f0: f64,
|
||||||
|
f1: f64,
|
||||||
|
f2: f64,
|
||||||
|
f3: f64,
|
||||||
|
f4: f64,
|
||||||
|
f5: f64,
|
||||||
|
f6: f64,
|
||||||
|
f7: f64,
|
||||||
|
f8: f64,
|
||||||
|
f9: f64,
|
||||||
|
f10: f64,
|
||||||
|
f11: f64,
|
||||||
|
f12: f64,
|
||||||
|
f13: f64,
|
||||||
|
},
|
||||||
|
.mipsel => extern struct {
|
||||||
|
r0: u32,
|
||||||
|
},
|
||||||
|
.powerpc => extern struct {
|
||||||
|
pc: u32,
|
||||||
|
r0: u32,
|
||||||
|
r1: u32,
|
||||||
|
r2: u32,
|
||||||
|
r3: u32,
|
||||||
|
r4: u32,
|
||||||
|
r5: u32,
|
||||||
|
r6: u32,
|
||||||
|
r7: u32,
|
||||||
|
r8: u32,
|
||||||
|
r9: u32,
|
||||||
|
r10: u32,
|
||||||
|
r11: u32,
|
||||||
|
r12: u32,
|
||||||
|
f0: f64,
|
||||||
|
f1: f64,
|
||||||
|
f2: f64,
|
||||||
|
f3: f64,
|
||||||
|
f4: f64,
|
||||||
|
f5: f64,
|
||||||
|
f6: f64,
|
||||||
|
f7: f64,
|
||||||
|
f8: f64,
|
||||||
|
f9: f64,
|
||||||
|
f10: f64,
|
||||||
|
f11: f64,
|
||||||
|
f12: f64,
|
||||||
|
f13: f64,
|
||||||
|
reserved: u32,
|
||||||
|
fpscr: u32,
|
||||||
|
ctr: u32,
|
||||||
|
xer: u32,
|
||||||
|
cr: u32,
|
||||||
|
msr: u32,
|
||||||
|
lr: u32,
|
||||||
|
},
|
||||||
|
.riscv64 => extern struct {
|
||||||
|
x: [31]u64,
|
||||||
|
pc: u64,
|
||||||
|
f: [32]f64,
|
||||||
|
fcsr: u64,
|
||||||
|
},
|
||||||
|
.sparc64 => extern struct {
|
||||||
|
g1: u64,
|
||||||
|
g2: u64,
|
||||||
|
g3: u64,
|
||||||
|
g4: u64,
|
||||||
|
g5: u64,
|
||||||
|
g6: u64,
|
||||||
|
g7: u64,
|
||||||
|
o0: u64,
|
||||||
|
o1: u64,
|
||||||
|
o2: u64,
|
||||||
|
o3: u64,
|
||||||
|
o4: u64,
|
||||||
|
o5: u64,
|
||||||
|
sp: u64,
|
||||||
|
o7: u64,
|
||||||
|
l0: u64,
|
||||||
|
l1: u64,
|
||||||
|
l2: u64,
|
||||||
|
l3: u64,
|
||||||
|
l4: u64,
|
||||||
|
l5: u64,
|
||||||
|
l6: u64,
|
||||||
|
l7: u64,
|
||||||
|
i0: u64,
|
||||||
|
i1: u64,
|
||||||
|
i2: u64,
|
||||||
|
i3: u64,
|
||||||
|
i4: u64,
|
||||||
|
i5: u64,
|
||||||
|
fp: u64,
|
||||||
|
i7: u64,
|
||||||
|
},
|
||||||
|
.x86 => extern struct {
|
||||||
|
pub const old_extended_regs = extern struct {
|
||||||
|
control: u16,
|
||||||
|
reserved1: u16,
|
||||||
|
status: u16,
|
||||||
|
reserved2: u16,
|
||||||
|
tag: u16,
|
||||||
|
reserved3: u16,
|
||||||
|
eip: u32,
|
||||||
|
cs: u16,
|
||||||
|
opcode: u16,
|
||||||
|
datap: u32,
|
||||||
|
ds: u16,
|
||||||
|
reserved4: u16,
|
||||||
|
fp_mmx: [8][10]u8,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const fp_register = extern struct { value: [10]u8, reserved: [6]u8 };
|
||||||
|
|
||||||
|
pub const xmm_register = extern struct { value: [16]u8 };
|
||||||
|
|
||||||
|
pub const new_extended_regs = extern struct {
|
||||||
|
control: u16,
|
||||||
|
status: u16,
|
||||||
|
tag: u16,
|
||||||
|
opcode: u16,
|
||||||
|
eip: u32,
|
||||||
|
cs: u16,
|
||||||
|
reserved1: u16,
|
||||||
|
datap: u32,
|
||||||
|
ds: u16,
|
||||||
|
reserved2: u16,
|
||||||
|
mxcsr: u32,
|
||||||
|
reserved3: u32,
|
||||||
|
fp_mmx: [8]fp_register,
|
||||||
|
xmmx: [8]xmm_register,
|
||||||
|
reserved4: [224]u8,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const extended_regs = extern struct {
|
||||||
|
state: extern union {
|
||||||
|
old_format: old_extended_regs,
|
||||||
|
new_format: new_extended_regs,
|
||||||
|
},
|
||||||
|
format: u32,
|
||||||
|
};
|
||||||
|
|
||||||
|
eip: u32,
|
||||||
|
eflags: u32,
|
||||||
|
eax: u32,
|
||||||
|
ecx: u32,
|
||||||
|
edx: u32,
|
||||||
|
esp: u32,
|
||||||
|
ebp: u32,
|
||||||
|
reserved: u32,
|
||||||
|
xregs: extended_regs,
|
||||||
|
edi: u32,
|
||||||
|
esi: u32,
|
||||||
|
ebx: u32,
|
||||||
|
},
|
||||||
|
.x86_64 => extern struct {
|
||||||
|
pub const fp_register = extern struct {
|
||||||
|
value: [10]u8,
|
||||||
|
reserved: [6]u8,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const xmm_register = extern struct {
|
||||||
|
value: [16]u8,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const fpu_state = extern struct {
|
||||||
|
control: u16,
|
||||||
|
status: u16,
|
||||||
|
tag: u16,
|
||||||
|
opcode: u16,
|
||||||
|
rip: u64,
|
||||||
|
rdp: u64,
|
||||||
|
mxcsr: u32,
|
||||||
|
mscsr_mask: u32,
|
||||||
|
|
||||||
|
fp_mmx: [8]fp_register,
|
||||||
|
xmm: [16]xmm_register,
|
||||||
|
reserved: [96]u8,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const xstate_hdr = extern struct {
|
||||||
|
bv: u64,
|
||||||
|
xcomp_bv: u64,
|
||||||
|
reserved: [48]u8,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const savefpu = extern struct {
|
||||||
|
fxsave: fpu_state,
|
||||||
|
xstate: xstate_hdr,
|
||||||
|
ymm: [16]xmm_register,
|
||||||
|
};
|
||||||
|
|
||||||
|
rax: u64,
|
||||||
|
rbx: u64,
|
||||||
|
rcx: u64,
|
||||||
|
rdx: u64,
|
||||||
|
rdi: u64,
|
||||||
|
rsi: u64,
|
||||||
|
rbp: u64,
|
||||||
|
r8: u64,
|
||||||
|
r9: u64,
|
||||||
|
r10: u64,
|
||||||
|
r11: u64,
|
||||||
|
r12: u64,
|
||||||
|
r13: u64,
|
||||||
|
r14: u64,
|
||||||
|
r15: u64,
|
||||||
|
rsp: u64,
|
||||||
|
rip: u64,
|
||||||
|
rflags: u64,
|
||||||
|
fpu: savefpu,
|
||||||
|
},
|
||||||
|
else => void,
|
||||||
|
};
|
||||||
|
|
||||||
// access function
|
// access function
|
||||||
pub const F_OK = 0; // test for existence of file
|
pub const F_OK = 0; // test for existence of file
|
||||||
pub const X_OK = 1; // test for execute or search permission
|
pub const X_OK = 1; // test for execute or search permission
|
||||||
|
|
@ -527,6 +856,15 @@ pub const SOCK = struct {
|
||||||
pub const DGRAM = 2;
|
pub const DGRAM = 2;
|
||||||
pub const RAW = 3;
|
pub const RAW = 3;
|
||||||
pub const SEQPACKET = 5;
|
pub const SEQPACKET = 5;
|
||||||
|
|
||||||
|
/// WARNING: this flag is not supported by windows socket functions directly,
|
||||||
|
/// it is only supported by std.os.socket. Be sure that this value does
|
||||||
|
/// not share any bits with any of the `SOCK` values.
|
||||||
|
pub const CLOEXEC = 0x10000;
|
||||||
|
/// WARNING: this flag is not supported by windows socket functions directly,
|
||||||
|
/// it is only supported by std.os.socket. Be sure that this value does
|
||||||
|
/// not share any bits with any of the `SOCK` values.
|
||||||
|
pub const NONBLOCK = 0x20000;
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const SO = struct {
|
pub const SO = struct {
|
||||||
|
|
@ -686,28 +1024,6 @@ pub const winsize = extern struct {
|
||||||
ws_ypixel: u16,
|
ws_ypixel: u16,
|
||||||
};
|
};
|
||||||
|
|
||||||
const NSIG = 32;
|
|
||||||
|
|
||||||
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
|
|
||||||
pub const Sigaction = extern struct {
|
|
||||||
pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
|
|
||||||
|
|
||||||
/// signal handler
|
|
||||||
__sigaction_u: extern union {
|
|
||||||
__sa_handler: handler_fn,
|
|
||||||
},
|
|
||||||
|
|
||||||
/// see signal options
|
|
||||||
sa_flags: u32,
|
|
||||||
|
|
||||||
/// signal mask to apply
|
|
||||||
sa_mask: sigset_t,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const sigset_t = extern struct {
|
|
||||||
__bits: [SIG.WORDS]u32,
|
|
||||||
};
|
|
||||||
|
|
||||||
const B_POSIX_ERROR_BASE = -2147454976;
|
const B_POSIX_ERROR_BASE = -2147454976;
|
||||||
|
|
||||||
pub const E = enum(i32) {
|
pub const E = enum(i32) {
|
||||||
|
|
@ -802,18 +1118,6 @@ pub const E = enum(i32) {
|
||||||
_,
|
_,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const MINSIGSTKSZ = 8192;
|
|
||||||
pub const SIGSTKSZ = 16384;
|
|
||||||
|
|
||||||
pub const SS_ONSTACK = 0x1;
|
|
||||||
pub const SS_DISABLE = 0x2;
|
|
||||||
|
|
||||||
pub const stack_t = extern struct {
|
|
||||||
sp: [*]u8,
|
|
||||||
size: isize,
|
|
||||||
flags: i32,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const S = struct {
|
pub const S = struct {
|
||||||
pub const IFMT = 0o170000;
|
pub const IFMT = 0o170000;
|
||||||
pub const IFSOCK = 0o140000;
|
pub const IFSOCK = 0o140000;
|
||||||
|
|
|
||||||
|
|
@ -865,7 +865,7 @@ pub const SIG = struct {
|
||||||
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
|
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
|
||||||
pub const Sigaction = extern struct {
|
pub const Sigaction = extern struct {
|
||||||
pub const handler_fn = *align(1) const fn (c_int) callconv(.C) void;
|
pub const handler_fn = *align(1) const fn (c_int) callconv(.C) void;
|
||||||
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*const anyopaque) callconv(.C) void;
|
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*anyopaque) callconv(.C) void;
|
||||||
|
|
||||||
/// signal handler
|
/// signal handler
|
||||||
handler: extern union {
|
handler: extern union {
|
||||||
|
|
@ -908,7 +908,7 @@ pub const _ksiginfo = extern struct {
|
||||||
stime: clock_t,
|
stime: clock_t,
|
||||||
},
|
},
|
||||||
fault: extern struct {
|
fault: extern struct {
|
||||||
addr: ?*anyopaque,
|
addr: *allowzero anyopaque,
|
||||||
trap: i32,
|
trap: i32,
|
||||||
trap2: i32,
|
trap2: i32,
|
||||||
trap3: i32,
|
trap3: i32,
|
||||||
|
|
|
||||||
|
|
@ -843,7 +843,7 @@ pub const SIG = struct {
|
||||||
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
|
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
|
||||||
pub const Sigaction = extern struct {
|
pub const Sigaction = extern struct {
|
||||||
pub const handler_fn = *align(1) const fn (c_int) callconv(.C) void;
|
pub const handler_fn = *align(1) const fn (c_int) callconv(.C) void;
|
||||||
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*const anyopaque) callconv(.C) void;
|
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*anyopaque) callconv(.C) void;
|
||||||
|
|
||||||
/// signal handler
|
/// signal handler
|
||||||
handler: extern union {
|
handler: extern union {
|
||||||
|
|
@ -881,7 +881,7 @@ pub const siginfo_t = extern struct {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
fault: extern struct {
|
fault: extern struct {
|
||||||
addr: ?*anyopaque,
|
addr: *allowzero anyopaque,
|
||||||
trapno: c_int,
|
trapno: c_int,
|
||||||
},
|
},
|
||||||
__pad: [128 - 3 * @sizeOf(c_int)]u8,
|
__pad: [128 - 3 * @sizeOf(c_int)]u8,
|
||||||
|
|
|
||||||
|
|
@ -875,7 +875,7 @@ pub const SIG = struct {
|
||||||
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
|
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
|
||||||
pub const Sigaction = extern struct {
|
pub const Sigaction = extern struct {
|
||||||
pub const handler_fn = *align(1) const fn (c_int) callconv(.C) void;
|
pub const handler_fn = *align(1) const fn (c_int) callconv(.C) void;
|
||||||
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*const anyopaque) callconv(.C) void;
|
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*anyopaque) callconv(.C) void;
|
||||||
|
|
||||||
/// signal options
|
/// signal options
|
||||||
flags: c_uint,
|
flags: c_uint,
|
||||||
|
|
@ -917,7 +917,7 @@ pub const siginfo_t = extern struct {
|
||||||
zone: zoneid_t,
|
zone: zoneid_t,
|
||||||
},
|
},
|
||||||
fault: extern struct {
|
fault: extern struct {
|
||||||
addr: ?*anyopaque,
|
addr: *allowzero anyopaque,
|
||||||
trapno: c_int,
|
trapno: c_int,
|
||||||
pc: ?*anyopaque,
|
pc: ?*anyopaque,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -229,7 +229,7 @@ pub fn relocateContext(context: *ThreadContext) void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const have_getcontext = @hasDecl(posix.system, "getcontext") and
|
pub const have_getcontext = @hasDecl(posix.system, "getcontext") and
|
||||||
native_os != .openbsd and
|
native_os != .openbsd and native_os != .haiku and
|
||||||
(native_os != .linux or switch (builtin.cpu.arch) {
|
(native_os != .linux or switch (builtin.cpu.arch) {
|
||||||
.x86,
|
.x86,
|
||||||
.x86_64,
|
.x86_64,
|
||||||
|
|
|
||||||
|
|
@ -42,15 +42,9 @@ pub fn getAppDataDir(allocator: mem.Allocator, appname: []const u8) GetAppDataDi
|
||||||
return fs.path.join(allocator, &[_][]const u8{ home_dir, ".local", "share", appname });
|
return fs.path.join(allocator, &[_][]const u8{ home_dir, ".local", "share", appname });
|
||||||
},
|
},
|
||||||
.haiku => {
|
.haiku => {
|
||||||
var dir_path_ptr: [*:0]u8 = undefined;
|
var dir_path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
||||||
if (true) {
|
const rc = std.c.find_directory(.B_USER_SETTINGS_DIRECTORY, -1, true, &dir_path_buf, dir_path_buf.len);
|
||||||
_ = &dir_path_ptr;
|
const settings_dir = try allocator.dupeZ(u8, mem.sliceTo(&dir_path_buf, 0));
|
||||||
@compileError("TODO: init dir_path_ptr");
|
|
||||||
}
|
|
||||||
// TODO look into directory_which
|
|
||||||
const be_user_settings = 0xbbe;
|
|
||||||
const rc = std.c.find_directory(be_user_settings, -1, true, dir_path_ptr, 1);
|
|
||||||
const settings_dir = try allocator.dupeZ(u8, mem.sliceTo(dir_path_ptr, 0));
|
|
||||||
defer allocator.free(settings_dir);
|
defer allocator.free(settings_dir);
|
||||||
switch (rc) {
|
switch (rc) {
|
||||||
0 => return fs.path.join(allocator, &[_][]const u8{ settings_dir, appname }),
|
0 => return fs.path.join(allocator, &[_][]const u8{ settings_dir, appname }),
|
||||||
|
|
|
||||||
|
|
@ -610,7 +610,10 @@ pub fn Poller(comptime StreamEnum: type) type {
|
||||||
// allocate grows exponentially.
|
// allocate grows exponentially.
|
||||||
const bump_amt = 512;
|
const bump_amt = 512;
|
||||||
|
|
||||||
const err_mask = posix.POLL.ERR | posix.POLL.NVAL | posix.POLL.HUP;
|
const err_mask = switch (builtin.target.os.tag) {
|
||||||
|
.haiku => posix.POLL.ERR | posix.POLL.HUP,
|
||||||
|
else => posix.POLL.ERR | posix.POLL.NVAL | posix.POLL.HUP,
|
||||||
|
};
|
||||||
|
|
||||||
const events_len = try posix.poll(&self.poll_fds, if (nanoseconds) |ns|
|
const events_len = try posix.poll(&self.poll_fds, if (nanoseconds) |ns|
|
||||||
std.math.cast(i32, ns / std.time.ns_per_ms) orelse std.math.maxInt(i32)
|
std.math.cast(i32, ns / std.time.ns_per_ms) orelse std.math.maxInt(i32)
|
||||||
|
|
|
||||||
|
|
@ -696,7 +696,7 @@ pub const SIG = struct {
|
||||||
|
|
||||||
pub const Sigaction = extern struct {
|
pub const Sigaction = extern struct {
|
||||||
pub const handler_fn = *align(1) const fn (c_int) callconv(.C) void;
|
pub const handler_fn = *align(1) const fn (c_int) callconv(.C) void;
|
||||||
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*const anyopaque) callconv(.C) void;
|
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*anyopaque) callconv(.C) void;
|
||||||
|
|
||||||
handler: extern union {
|
handler: extern union {
|
||||||
handler: ?handler_fn,
|
handler: ?handler_fn,
|
||||||
|
|
@ -738,7 +738,7 @@ const siginfo_fields_union = extern union {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
sigfault: extern struct {
|
sigfault: extern struct {
|
||||||
addr: *anyopaque,
|
addr: *allowzero anyopaque,
|
||||||
addr_lsb: i16,
|
addr_lsb: i16,
|
||||||
first: extern union {
|
first: extern union {
|
||||||
addr_bnd: extern struct {
|
addr_bnd: extern struct {
|
||||||
|
|
|
||||||
|
|
@ -1609,18 +1609,18 @@ pub fn socket(domain: u32, socket_type: u32, protocol: u32) usize {
|
||||||
return syscall3(.socket, domain, socket_type, protocol);
|
return syscall3(.socket, domain, socket_type, protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setsockopt(fd: i32, level: u32, optname: u32, optval: [*]const u8, optlen: socklen_t) usize {
|
pub fn setsockopt(fd: i32, level: i32, optname: u32, optval: [*]const u8, optlen: socklen_t) usize {
|
||||||
if (native_arch == .x86) {
|
if (native_arch == .x86) {
|
||||||
return socketcall(SC.setsockopt, &[5]usize{ @as(usize, @bitCast(@as(isize, fd))), level, optname, @intFromPtr(optval), @as(usize, @intCast(optlen)) });
|
return socketcall(SC.setsockopt, &[5]usize{ @as(usize, @bitCast(@as(isize, fd))), @as(usize, @bitCast(@as(isize, level))), optname, @intFromPtr(optval), @as(usize, @intCast(optlen)) });
|
||||||
}
|
}
|
||||||
return syscall5(.setsockopt, @as(usize, @bitCast(@as(isize, fd))), level, optname, @intFromPtr(optval), @as(usize, @intCast(optlen)));
|
return syscall5(.setsockopt, @as(usize, @bitCast(@as(isize, fd))), @as(usize, @bitCast(@as(isize, level))), optname, @intFromPtr(optval), @as(usize, @intCast(optlen)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn getsockopt(fd: i32, level: u32, optname: u32, noalias optval: [*]u8, noalias optlen: *socklen_t) usize {
|
pub fn getsockopt(fd: i32, level: i32, optname: u32, noalias optval: [*]u8, noalias optlen: *socklen_t) usize {
|
||||||
if (native_arch == .x86) {
|
if (native_arch == .x86) {
|
||||||
return socketcall(SC.getsockopt, &[5]usize{ @as(usize, @bitCast(@as(isize, fd))), level, optname, @intFromPtr(optval), @intFromPtr(optlen) });
|
return socketcall(SC.getsockopt, &[5]usize{ @as(usize, @bitCast(@as(isize, fd))), @as(usize, @bitCast(@as(isize, level))), optname, @intFromPtr(optval), @intFromPtr(optlen) });
|
||||||
}
|
}
|
||||||
return syscall5(.getsockopt, @as(usize, @bitCast(@as(isize, fd))), level, optname, @intFromPtr(optval), @intFromPtr(optlen));
|
return syscall5(.getsockopt, @as(usize, @bitCast(@as(isize, fd))), @as(usize, @bitCast(@as(isize, level))), optname, @intFromPtr(optval), @intFromPtr(optlen));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sendmsg(fd: i32, msg: *const msghdr_const, flags: u32) usize {
|
pub fn sendmsg(fd: i32, msg: *const msghdr_const, flags: u32) usize {
|
||||||
|
|
@ -4329,7 +4329,7 @@ pub const k_sigaction = switch (native_arch) {
|
||||||
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
|
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
|
||||||
pub const Sigaction = extern struct {
|
pub const Sigaction = extern struct {
|
||||||
pub const handler_fn = *align(1) const fn (c_int) callconv(.C) void;
|
pub const handler_fn = *align(1) const fn (c_int) callconv(.C) void;
|
||||||
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*const anyopaque) callconv(.C) void;
|
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*anyopaque) callconv(.C) void;
|
||||||
|
|
||||||
handler: extern union {
|
handler: extern union {
|
||||||
handler: ?handler_fn,
|
handler: ?handler_fn,
|
||||||
|
|
@ -4690,7 +4690,7 @@ const siginfo_fields_union = extern union {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
sigfault: extern struct {
|
sigfault: extern struct {
|
||||||
addr: *anyopaque,
|
addr: *allowzero anyopaque,
|
||||||
addr_lsb: i16,
|
addr_lsb: i16,
|
||||||
first: extern union {
|
first: extern union {
|
||||||
addr_bnd: extern struct {
|
addr_bnd: extern struct {
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,7 @@ pub const siginfo_t = c_long;
|
||||||
// TODO plan9 doesn't have sigaction_fn. Sigaction is not a union, but we incude it here to be compatible.
|
// TODO plan9 doesn't have sigaction_fn. Sigaction is not a union, but we incude it here to be compatible.
|
||||||
pub const Sigaction = extern struct {
|
pub const Sigaction = extern struct {
|
||||||
pub const handler_fn = *const fn (c_int) callconv(.C) void;
|
pub const handler_fn = *const fn (c_int) callconv(.C) void;
|
||||||
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*const anyopaque) callconv(.C) void;
|
pub const sigaction_fn = *const fn (c_int, *const siginfo_t, ?*anyopaque) callconv(.C) void;
|
||||||
|
|
||||||
handler: extern union {
|
handler: extern union {
|
||||||
handler: ?handler_fn,
|
handler: ?handler_fn,
|
||||||
|
|
|
||||||
|
|
@ -3493,7 +3493,7 @@ pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!socket_t
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
const have_sock_flags = !builtin.target.isDarwin();
|
const have_sock_flags = !builtin.target.isDarwin() and native_os != .haiku;
|
||||||
const filtered_sock_type = if (!have_sock_flags)
|
const filtered_sock_type = if (!have_sock_flags)
|
||||||
socket_type & ~@as(u32, SOCK.NONBLOCK | SOCK.CLOEXEC)
|
socket_type & ~@as(u32, SOCK.NONBLOCK | SOCK.CLOEXEC)
|
||||||
else
|
else
|
||||||
|
|
@ -3789,7 +3789,7 @@ pub fn accept(
|
||||||
/// description of the `CLOEXEC` flag in `open` for reasons why this may be useful.
|
/// description of the `CLOEXEC` flag in `open` for reasons why this may be useful.
|
||||||
flags: u32,
|
flags: u32,
|
||||||
) AcceptError!socket_t {
|
) AcceptError!socket_t {
|
||||||
const have_accept4 = !(builtin.target.isDarwin() or native_os == .windows);
|
const have_accept4 = !(builtin.target.isDarwin() or native_os == .windows or native_os == .haiku);
|
||||||
assert(0 == (flags & ~@as(u32, SOCK.NONBLOCK | SOCK.CLOEXEC))); // Unsupported flag(s)
|
assert(0 == (flags & ~@as(u32, SOCK.NONBLOCK | SOCK.CLOEXEC))); // Unsupported flag(s)
|
||||||
|
|
||||||
const accepted_sock: socket_t = while (true) {
|
const accepted_sock: socket_t = while (true) {
|
||||||
|
|
@ -6676,9 +6676,9 @@ pub const SetSockOptError = error{
|
||||||
} || UnexpectedError;
|
} || UnexpectedError;
|
||||||
|
|
||||||
/// Set a socket's options.
|
/// Set a socket's options.
|
||||||
pub fn setsockopt(fd: socket_t, level: u32, optname: u32, opt: []const u8) SetSockOptError!void {
|
pub fn setsockopt(fd: socket_t, level: i32, optname: u32, opt: []const u8) SetSockOptError!void {
|
||||||
if (native_os == .windows) {
|
if (native_os == .windows) {
|
||||||
const rc = windows.ws2_32.setsockopt(fd, @intCast(level), @intCast(optname), opt.ptr, @intCast(opt.len));
|
const rc = windows.ws2_32.setsockopt(fd, level, @intCast(optname), opt.ptr, @intCast(opt.len));
|
||||||
if (rc == windows.ws2_32.SOCKET_ERROR) {
|
if (rc == windows.ws2_32.SOCKET_ERROR) {
|
||||||
switch (windows.ws2_32.WSAGetLastError()) {
|
switch (windows.ws2_32.WSAGetLastError()) {
|
||||||
.WSANOTINITIALISED => unreachable,
|
.WSANOTINITIALISED => unreachable,
|
||||||
|
|
|
||||||
|
|
@ -301,6 +301,7 @@ pub fn libcFullLinkFlags(target: std.Target) []const []const u8 {
|
||||||
"-lroot",
|
"-lroot",
|
||||||
"-lpthread",
|
"-lpthread",
|
||||||
"-lc",
|
"-lc",
|
||||||
|
"-lnetwork",
|
||||||
},
|
},
|
||||||
else => switch (target.abi) {
|
else => switch (target.abi) {
|
||||||
.android => &[_][]const u8{
|
.android => &[_][]const u8{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue