authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2021-06-16 02:38:43-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-06-17 20:28:37-07:00
log4adbdcb587c4fadde0d1c45772d1b4d140bf6a46
tree2a783ca040a07a23f11f2a2b8760264a1271371f
parent162b92c93ee36ab8c8668cb22f63a298cadd6d38

netbsd: add more std.os.bits


5 files changed, 149 insertions(+), 51 deletions(-)

lib/std/c.zig+1
......@@ -192,6 +192,7 @@ pub usingnamespace switch (builtin.os.tag) {
192192 pub const sigaction = __sigaction14;
193193 pub const sigaltstack = __sigaltstack14;
194194 pub const sigprocmask = __sigprocmask14;
195 pub const socket = __socket30;
195196 pub const stat = __stat50;
196197 },
197198 .macos, .ios, .watchos, .tvos => struct {
lib/std/dynamic_library.zig+1-1
......@@ -19,7 +19,7 @@ const max = std.math.max;
1919pub const DynLib = switch (builtin.os.tag) {
2020 .linux => if (builtin.link_libc) DlDynlib else ElfDynLib,
2121 .windows => WindowsDynLib,
22 .macos, .tvos, .watchos, .ios, .freebsd, .openbsd, .dragonfly => DlDynlib,
22 .macos, .tvos, .watchos, .ios, .freebsd, .netbsd, .openbsd, .dragonfly => DlDynlib,
2323 else => void,
2424};
2525
lib/std/fs/test.zig+11-6
......@@ -278,7 +278,7 @@ test "directory operations on files" {
278278 try testing.expectError(error.NotDir, tmp_dir.dir.deleteDir(test_file_name));
279279
280280 switch (builtin.os.tag) {
281 .wasi, .freebsd, .openbsd, .dragonfly => {},
281 .wasi, .freebsd, .netbsd, .openbsd, .dragonfly => {},
282282 else => {
283283 const absolute_path = try tmp_dir.dir.realpathAlloc(testing.allocator, test_file_name);
284284 defer testing.allocator.free(absolute_path);
......@@ -308,17 +308,22 @@ test "file operations on directories" {
308308
309309 try testing.expectError(error.IsDir, tmp_dir.dir.createFile(test_dir_name, .{}));
310310 try testing.expectError(error.IsDir, tmp_dir.dir.deleteFile(test_dir_name));
311 // Currently, WASI will return error.Unexpected (via ENOTCAPABLE) when attempting fd_read on a directory handle.
312 // TODO: Re-enable on WASI once https://github.com/bytecodealliance/wasmtime/issues/1935 is resolved.
313 if (builtin.os.tag != .wasi) {
314 try testing.expectError(error.IsDir, tmp_dir.dir.readFileAlloc(testing.allocator, test_dir_name, std.math.maxInt(usize)));
311 switch (builtin.os.tag) {
312 // NetBSD does not error when reading a directory.
313 .netbsd => {},
314 // Currently, WASI will return error.Unexpected (via ENOTCAPABLE) when attempting fd_read on a directory handle.
315 // TODO: Re-enable on WASI once https://github.com/bytecodealliance/wasmtime/issues/1935 is resolved.
316 .wasi => {},
317 else => {
318 try testing.expectError(error.IsDir, tmp_dir.dir.readFileAlloc(testing.allocator, test_dir_name, std.math.maxInt(usize)));
319 },
315320 }
316321 // Note: The `.write = true` is necessary to ensure the error occurs on all platforms.
317322 // TODO: Add a read-only test as well, see https://github.com/ziglang/zig/issues/5732
318323 try testing.expectError(error.IsDir, tmp_dir.dir.openFile(test_dir_name, .{ .write = true }));
319324
320325 switch (builtin.os.tag) {
321 .wasi, .freebsd, .openbsd, .dragonfly => {},
326 .wasi, .freebsd, .netbsd, .openbsd, .dragonfly => {},
322327 else => {
323328 const absolute_path = try tmp_dir.dir.realpathAlloc(testing.allocator, test_dir_name);
324329 defer testing.allocator.free(absolute_path);
lib/std/os/bits/netbsd.zig+126-42
......@@ -34,6 +34,17 @@ pub const Kevent = extern struct {
3434 udata: usize,
3535};
3636
37pub const RTLD_LAZY = 1;
38pub const RTLD_NOW = 2;
39pub const RTLD_GLOBAL = 0x100;
40pub const RTLD_LOCAL = 0x200;
41pub const RTLD_NODELETE = 0x01000;
42pub const RTLD_NOLOAD = 0x02000;
43
44pub const RTLD_NEXT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -1)));
45pub const RTLD_DEFAULT = @intToPtr(*c_void, @bitCast(usize, @as(isize, -2)));
46pub const RTLD_SELF = @intToPtr(*c_void, @bitCast(usize, @as(isize, -3)));
47
3748pub const dl_phdr_info = extern struct {
3849 dlpi_addr: usize,
3950 dlpi_name: ?[*:0]const u8,
......@@ -212,6 +223,121 @@ pub const dirent = extern struct {
212223 }
213224};
214225
226pub const SOCK_STREAM = 1;
227pub const SOCK_DGRAM = 2;
228pub const SOCK_RAW = 3;
229pub const SOCK_RDM = 4;
230pub const SOCK_SEQPACKET = 5;
231pub const SOCK_CONN_DGRAM = 6;
232pub const SOCK_DCCP = SOCK_CONN_DGRAM;
233
234pub const SOCK_CLOEXEC = 0x10000000;
235pub const SOCK_NONBLOCK = 0x20000000;
236pub const SOCK_NOSIGPIPE = 0x40000000;
237pub const SOCK_FLAGS_MASK = 0xf0000000;
238
239pub const SO_DEBUG = 0x0001;
240pub const SO_ACCEPTCONN = 0x0002;
241pub const SO_REUSEADDR = 0x0004;
242pub const SO_KEEPALIVE = 0x0008;
243pub const SO_DONTROUTE = 0x0010;
244pub const SO_BROADCAST = 0x0020;
245pub const SO_USELOOPBACK = 0x0040;
246pub const SO_LINGER = 0x0080;
247pub const SO_OOBINLINE = 0x0100;
248pub const SO_REUSEPORT = 0x0200;
249pub const SO_NOSIGPIPE = 0x0800;
250pub const SO_ACCEPTFILTER = 0x1000;
251pub const SO_TIMESTAMP = 0x2000;
252pub const SO_RERROR = 0x4000;
253
254pub const SO_SNDBUF = 0x1001;
255pub const SO_RCVBUF = 0x1002;
256pub const SO_SNDLOWAT = 0x1003;
257pub const SO_RCVLOWAT = 0x1004;
258pub const SO_ERROR = 0x1007;
259pub const SO_TYPE = 0x1008;
260pub const SO_OVERFLOWED = 0x1009;
261
262pub const SO_NOHEADER = 0x100a;
263pub const SO_SNDTIMEO = 0x100b;
264pub const SO_RCVTIMEO = 0x100c;
265
266pub const SOL_SOCKET = 0xffff;
267
268pub const PF_UNSPEC = AF_UNSPEC;
269pub const PF_LOCAL = AF_LOCAL;
270pub const PF_UNIX = PF_LOCAL;
271pub const PF_INET = AF_INET;
272pub const PF_IMPLINK = AF_IMPLINK;
273pub const PF_PUP = AF_PUP;
274pub const PF_CHAOS = AF_CHAOS;
275pub const PF_NS = AF_NS;
276pub const PF_ISO = AF_ISO;
277pub const PF_OSI = AF_ISO;
278pub const PF_ECMA = AF_ECMA;
279pub const PF_DATAKIT = AF_DATAKIT;
280pub const PF_CCITT = AF_CCITT;
281pub const PF_SNA = AF_SNA;
282pub const PF_DECnet = AF_DECnet;
283pub const PF_DLI = AF_DLI;
284pub const PF_LAT = AF_LAT;
285pub const PF_HYLINK = AF_HYLINK;
286pub const PF_APPLETALK = AF_APPLETALK;
287pub const PF_OROUTE = AF_OROUTE;
288pub const PF_LINK = AF_LINK;
289pub const PF_COIP = AF_COIP;
290pub const PF_CNT = AF_CNT;
291pub const PF_INET6 = AF_INET6;
292pub const PF_IPX = AF_IPX;
293pub const PF_ISDN = AF_ISDN;
294pub const PF_E164 = AF_E164;
295pub const PF_NATM = AF_NATM;
296pub const PF_ARP = AF_ARP;
297pub const PF_BLUETOOTH = AF_BLUETOOTH;
298pub const PF_MPLS = AF_MPLS;
299pub const PF_ROUTE = AF_ROUTE;
300pub const PF_CAN = AF_CAN;
301pub const PF_ETHER = AF_ETHER;
302pub const PF_MAX = AF_MAX;
303
304pub const AF_UNSPEC = 0;
305pub const AF_LOCAL = 1;
306pub const AF_UNIX = AF_LOCAL;
307pub const AF_INET = 2;
308pub const AF_IMPLINK = 3;
309pub const AF_PUP = 4;
310pub const AF_CHAOS = 5;
311pub const AF_NS = 6;
312pub const AF_ISO = 7;
313pub const AF_OSI = AF_ISO;
314pub const AF_ECMA = 8;
315pub const AF_DATAKIT = 9;
316pub const AF_CCITT = 10;
317pub const AF_SNA = 11;
318pub const AF_DECnet = 12;
319pub const AF_DLI = 13;
320pub const AF_LAT = 14;
321pub const AF_HYLINK = 15;
322pub const AF_APPLETALK = 16;
323pub const AF_OROUTE = 17;
324pub const AF_LINK = 18;
325pub const AF_COIP = 20;
326pub const AF_CNT = 21;
327pub const AF_IPX = 23;
328pub const AF_INET6 = 24;
329pub const AF_ISDN = 26;
330pub const AF_E164 = AF_ISDN;
331pub const AF_NATM = 27;
332pub const AF_ARP = 28;
333pub const AF_BLUETOOTH = 31;
334pub const AF_IEEE80211 = 32;
335pub const AF_MPLS = 33;
336pub const AF_ROUTE = 34;
337pub const AF_CAN = 35;
338pub const AF_ETHER = 36;
339pub const AF_MAX = 37;
340
215341pub const in_port_t = u16;
216342pub const sa_family_t = u8;
217343
......@@ -471,48 +597,6 @@ pub const SIG_BLOCK = 1;
471597pub const SIG_UNBLOCK = 2;
472598pub const SIG_SETMASK = 3;
473599
474pub const SOCK_STREAM = 1;
475pub const SOCK_DGRAM = 2;
476pub const SOCK_RAW = 3;
477pub const SOCK_RDM = 4;
478pub const SOCK_SEQPACKET = 5;
479
480pub const SOCK_CLOEXEC = 0x10000000;
481pub const SOCK_NONBLOCK = 0x20000000;
482
483pub const PF_UNSPEC = 0;
484pub const PF_LOCAL = 1;
485pub const PF_UNIX = PF_LOCAL;
486pub const PF_FILE = PF_LOCAL;
487pub const PF_INET = 2;
488pub const PF_APPLETALK = 16;
489pub const PF_INET6 = 24;
490pub const PF_DECnet = 12;
491pub const PF_KEY = 29;
492pub const PF_ROUTE = 34;
493pub const PF_SNA = 11;
494pub const PF_MPLS = 33;
495pub const PF_CAN = 35;
496pub const PF_BLUETOOTH = 31;
497pub const PF_ISDN = 26;
498pub const PF_MAX = 37;
499
500pub const AF_UNSPEC = PF_UNSPEC;
501pub const AF_LOCAL = PF_LOCAL;
502pub const AF_UNIX = AF_LOCAL;
503pub const AF_FILE = AF_LOCAL;
504pub const AF_INET = PF_INET;
505pub const AF_APPLETALK = PF_APPLETALK;
506pub const AF_INET6 = PF_INET6;
507pub const AF_KEY = PF_KEY;
508pub const AF_ROUTE = PF_ROUTE;
509pub const AF_SNA = PF_SNA;
510pub const AF_MPLS = PF_MPLS;
511pub const AF_CAN = PF_CAN;
512pub const AF_BLUETOOTH = PF_BLUETOOTH;
513pub const AF_ISDN = PF_ISDN;
514pub const AF_MAX = PF_MAX;
515
516600pub const DT_UNKNOWN = 0;
517601pub const DT_FIFO = 1;
518602pub const DT_CHR = 2;
lib/std/os/test.zig+10-2
......@@ -732,8 +732,16 @@ test "sigaction" {
732732 const S = struct {
733733 fn handler(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_void) callconv(.C) void {
734734 // Check that we received the correct signal.
735 if (sig == os.SIGUSR1 and sig == info.signo)
736 signal_test_failed = false;
735 switch (native_os) {
736 .netbsd => {
737 if (sig == os.SIGUSR1 and sig == info.info.signo)
738 signal_test_failed = false;
739 },
740 else => {
741 if (sig == os.SIGUSR1 and sig == info.signo)
742 signal_test_failed = false;
743 },
744 }
737745 }
738746 };
739747