authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-03-23 18:55:45+01:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-03-23 18:55:45+01:00
logcda73c3c189924bc085d1e89a9592d6632365c90
tree6ae8ff36042aa44447c61c576070d105842c9dd4
parent761602e3e84afee1a77daf9f850c67cb8e25f7ed

std: Add missing C bits and defines for NetBSD


1 files changed, 138 insertions(+), 24 deletions(-)

lib/std/os/bits/netbsd.zig+138-24
...@@ -25,6 +25,65 @@ pub const dl_phdr_info = extern struct {...@@ -25,6 +25,65 @@ pub const dl_phdr_info = extern struct {
25 dlpi_phnum: u16,25 dlpi_phnum: u16,
26};26};
2727
28pub const addrinfo = extern struct {
29 flags: i32,
30 family: i32,
31 socktype: i32,
32 protocol: i32,
33 addrlen: socklen_t,
34 canonname: ?[*:0]u8,
35 addr: ?*sockaddr,
36 next: ?*addrinfo,
37};
38
39pub const EAI = extern enum(c_int) {
40 /// address family for hostname not supported
41 ADDRFAMILY = 1,
42
43 /// name could not be resolved at this time
44 AGAIN = 2,
45
46 /// flags parameter had an invalid value
47 BADFLAGS = 3,
48
49 /// non-recoverable failure in name resolution
50 FAIL = 4,
51
52 /// address family not recognized
53 FAMILY = 5,
54
55 /// memory allocation failure
56 MEMORY = 6,
57
58 /// no address associated with hostname
59 NODATA = 7,
60
61 /// name does not resolve
62 NONAME = 8,
63
64 /// service not recognized for socket type
65 SERVICE = 9,
66
67 /// intended socket type was not recognized
68 SOCKTYPE = 10,
69
70 /// system error returned in errno
71 SYSTEM = 11,
72
73 /// invalid value for hints
74 BADHINTS = 12,
75
76 /// resolved protocol is unknown
77 PROTOCOL = 13,
78
79 /// argument buffer overflow
80 OVERFLOW = 14,
81
82 _,
83};
84
85pub const EAI_MAX = 15;
86
28pub const msghdr = extern struct {87pub const msghdr = extern struct {
29 /// optional address88 /// optional address
30 msg_name: ?*sockaddr,89 msg_name: ?*sockaddr,
...@@ -122,7 +181,6 @@ pub const dirent = extern struct {...@@ -122,7 +181,6 @@ pub const dirent = extern struct {
122 d_reclen: u16,181 d_reclen: u16,
123 d_namlen: u16,182 d_namlen: u16,
124 d_type: u8,183 d_type: u8,
125 d_off: i64,
126 d_name: [512]u8,184 d_name: [512]u8,
127185
128 pub fn reclen(self: dirent) u16 {186 pub fn reclen(self: dirent) u16 {
...@@ -146,7 +204,7 @@ pub const sockaddr = extern struct {...@@ -146,7 +204,7 @@ pub const sockaddr = extern struct {
146204
147pub const sockaddr_in = extern struct {205pub const sockaddr_in = extern struct {
148 len: u8 = @sizeOf(sockaddr_in),206 len: u8 = @sizeOf(sockaddr_in),
149 family: sa_family_t,207 family: sa_family_t = AF_INET,
150 port: in_port_t,208 port: in_port_t,
151 addr: u32,209 addr: u32,
152 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },210 zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
...@@ -154,7 +212,7 @@ pub const sockaddr_in = extern struct {...@@ -154,7 +212,7 @@ pub const sockaddr_in = extern struct {
154212
155pub const sockaddr_in6 = extern struct {213pub const sockaddr_in6 = extern struct {
156 len: u8 = @sizeOf(sockaddr_in6),214 len: u8 = @sizeOf(sockaddr_in6),
157 family: sa_family_t,215 family: sa_family_t = AF_INET6,
158 port: in_port_t,216 port: in_port_t,
159 flowinfo: u32,217 flowinfo: u32,
160 addr: [16]u8,218 addr: [16]u8,
...@@ -167,12 +225,27 @@ pub const sockaddr_un = extern struct {...@@ -167,12 +225,27 @@ pub const sockaddr_un = extern struct {
167 len: u8 = @sizeOf(sockaddr_un),225 len: u8 = @sizeOf(sockaddr_un),
168226
169 /// AF_LOCAL227 /// AF_LOCAL
170 family: sa_family_t,228 family: sa_family_t = AF_LOCAL,
171229
172 /// path name230 /// path name
173 path: [104]u8,231 path: [104]u8,
174};232};
175233
234/// get address to use bind()
235pub const AI_PASSIVE = 0x00000001;
236
237/// fill ai_canonname
238pub const AI_CANONNAME = 0x00000002;
239
240/// prevent host name resolution
241pub const AI_NUMERICHOST = 0x00000004;
242
243/// prevent service name resolution
244pub const AI_NUMERICSERV = 0x00000008;
245
246/// only if any address is assigned
247pub const AI_ADDRCONFIG = 0x00000400;
248
176pub const CTL_KERN = 1;249pub const CTL_KERN = 1;
177pub const CTL_DEBUG = 5;250pub const CTL_DEBUG = 5;
178251
...@@ -274,30 +347,71 @@ pub const X_OK = 1; // test for execute or search permission...@@ -274,30 +347,71 @@ pub const X_OK = 1; // test for execute or search permission
274pub const W_OK = 2; // test for write permission347pub const W_OK = 2; // test for write permission
275pub const R_OK = 4; // test for read permission348pub const R_OK = 4; // test for read permission
276349
277pub const O_RDONLY = 0x0000;350/// open for reading only
278pub const O_WRONLY = 0x0001;351pub const O_RDONLY = 0x00000000;
279pub const O_RDWR = 0x0002;352
280pub const O_ACCMODE = 0x0003;353/// open for writing only
281354pub const O_WRONLY = 0x00000001;
282pub const O_CREAT = 0x0200;355
283pub const O_EXCL = 0x0800;356/// open for reading and writing
284pub const O_NOCTTY = 0x8000;357pub const O_RDWR = 0x00000002;
285pub const O_TRUNC = 0x0400;358
286pub const O_APPEND = 0x0008;359/// mask for above modes
287pub const O_NONBLOCK = 0x0004;360pub const O_ACCMODE = 0x00000003;
361
362/// no delay
363pub const O_NONBLOCK = 0x00000004;
364
365/// set append mode
366pub const O_APPEND = 0x00000008;
367
368/// open with shared file lock
369pub const O_SHLOCK = 0x00000010;
370
371/// open with exclusive file lock
372pub const O_EXLOCK = 0x00000020;
373
374/// signal pgrp when data ready
375pub const O_ASYNC = 0x00000040;
376
377/// synchronous writes
378pub const O_SYNC = 0x00000080;
379
380/// don't follow symlinks on the last
381pub const O_NOFOLLOW = 0x00000100;
382
383/// create if nonexistent
384pub const O_CREAT = 0x00000200;
385
386/// truncate to zero length
387pub const O_TRUNC = 0x00000400;
388
389/// error if already exists
390pub const O_EXCL = 0x00000800;
391
392/// don't assign controlling terminal
393pub const O_NOCTTY = 0x00008000;
394
395/// write: I/O data completion
288pub const O_DSYNC = 0x00010000;396pub const O_DSYNC = 0x00010000;
289pub const O_SYNC = 0x0080;397
398/// read: I/O completion as for write
290pub const O_RSYNC = 0x00020000;399pub const O_RSYNC = 0x00020000;
291pub const O_DIRECTORY = 0x00080000;
292pub const O_NOFOLLOW = 0x00000100;
293pub const O_CLOEXEC = 0x00400000;
294400
295pub const O_ASYNC = 0x0040;401/// use alternate i/o semantics
402pub const O_ALT_IO = 0x00040000;
403
404/// direct I/O hint
296pub const O_DIRECT = 0x00080000;405pub const O_DIRECT = 0x00080000;
297pub const O_NOATIME = 0;406
298pub const O_PATH = 0;407/// fail if not a directory
299pub const O_TMPFILE = 0;408pub const O_DIRECTORY = 0x00200000;
300pub const O_NDELAY = O_NONBLOCK;409
410/// set close on exec
411pub const O_CLOEXEC = 0x00400000;
412
413/// skip search permission checks
414pub const O_SEARCH = 0x00800000;
301415
302pub const F_DUPFD = 0;416pub const F_DUPFD = 0;
303pub const F_GETFD = 1;417pub const F_GETFD = 1;