diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-02-25 16:00:00 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-25 16:00:00 -0800 |
| commit | 7edb204edfa41e11776ac009da5a20fb1c907f5f (patch) | |
| tree | 9c6eae297ebc492c0a1a94a4d3d25fc3bcd07bd9 /lib/std/os.zig | |
| parent | 297eabd4accbcae42bfe821078a79e4af06a2dde (diff) | |
| parent | 37a1d08de2ce263439713180f57741d16fb27e23 (diff) | |
| download | zig-7edb204edfa41e11776ac009da5a20fb1c907f5f.tar.gz zig-7edb204edfa41e11776ac009da5a20fb1c907f5f.zip | |
Merge pull request #7546 from hoanga/haiku-support
initial support for haiku
Diffstat (limited to 'lib/std/os.zig')
| -rw-r--r-- | lib/std/os.zig | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/lib/std/os.zig b/lib/std/os.zig index 61d9749415..6b13ec94c9 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -32,6 +32,7 @@ const MAX_PATH_BYTES = std.fs.MAX_PATH_BYTES; pub const darwin = @import("os/darwin.zig"); pub const dragonfly = @import("os/dragonfly.zig"); pub const freebsd = @import("os/freebsd.zig"); +pub const haiku = @import("os/haiku.zig"); pub const netbsd = @import("os/netbsd.zig"); pub const openbsd = @import("os/openbsd.zig"); pub const linux = @import("os/linux.zig"); @@ -52,6 +53,7 @@ test { _ = uefi; _ = wasi; _ = windows; + _ = haiku; _ = @import("os/test.zig"); } @@ -66,6 +68,7 @@ else if (builtin.link_libc) else switch (builtin.os.tag) { .macos, .ios, .watchos, .tvos => darwin, .freebsd => freebsd, + .haiku => haiku, .linux => linux, .netbsd => netbsd, .openbsd => openbsd, @@ -599,7 +602,7 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void { /// On these systems, the read races with concurrent writes to the same file descriptor. pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize { const have_pread_but_not_preadv = switch (std.Target.current.os.tag) { - .windows, .macos, .ios, .watchos, .tvos => true, + .windows, .macos, .ios, .watchos, .tvos, .haiku => true, else => false, }; if (have_pread_but_not_preadv) { @@ -932,7 +935,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize { /// If `iov.len` is larger than will fit in a `u31`, a partial write will occur. pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usize { const have_pwrite_but_not_pwritev = switch (std.Target.current.os.tag) { - .windows, .macos, .ios, .watchos, .tvos => true, + .windows, .macos, .ios, .watchos, .tvos, .haiku => true, else => false, }; @@ -3889,6 +3892,21 @@ pub fn pipe2(flags: u32) PipeError![2]fd_t { } } } + if (std.Target.current.os.tag == .haiku) { + var fds: [2]fd_t = try pipe(); + if (flags == 0) return fds; + errdefer { + close(fds[0]); + close(fds[1]); + } + for (fds) |fd| switch (errno(system.fcntl(fd, F_SETFL, flags))) { + 0 => {}, + EINVAL => unreachable, // Invalid flags + EBADF => unreachable, // Always a race condition + else => |err| return unexpectedErrno(err), + }; + return fds; + } const new_flags = flags & ~@as(u32, O_CLOEXEC); // Set every other flag affecting the file status using F_SETFL. @@ -3921,7 +3939,10 @@ pub fn sysctl( newlen: usize, ) SysCtlError!void { if (builtin.os.tag == .wasi) { - @panic("unsupported"); + @panic("unsupported"); // TODO should be compile error, not panic + } + if (builtin.os.tag == .haiku) { + @panic("unsupported"); // TODO should be compile error, not panic } const name_len = math.cast(c_uint, name.len) catch return error.NameTooLong; @@ -3945,7 +3966,10 @@ pub fn sysctlbynameZ( newlen: usize, ) SysCtlError!void { if (builtin.os.tag == .wasi) { - @panic("unsupported"); + @panic("unsupported"); // TODO should be compile error, not panic + } + if (builtin.os.tag == .haiku) { + @panic("unsupported"); // TODO should be compile error, not panic } switch (errno(system.sysctlbyname(name, oldp, oldlenp, newp, newlen))) { |
