authorgravatar for jethro@jethron.id.auJethro Nederhof <jethro@jethron.id.au> 2019-12-22 17:23:17+11:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-22 02:27:23-05:00
logba1d213f480eb0cb7c8641a8d8cb1d6763e82438
tree2a18119d951059af07af56e732e3ae1c079d79bf
parentbc95c63cf227226861d7fbf63fa6c779fed8abf8

freebsd: add missing OS and libc bits


3 files changed, 201 insertions(+), 92 deletions(-)

lib/std/c/freebsd.zig+74
...@@ -22,3 +22,77 @@ pub const pthread_attr_t = extern struct {...@@ -22,3 +22,77 @@ pub const pthread_attr_t = extern struct {
22 __size: [56]u8,22 __size: [56]u8,
23 __align: c_long,23 __align: c_long,
24};24};
25
26/// address family for hostname not supported
27pub const EAI_ADDRFAMILY = 1;
28
29/// name could not be resolved at this time
30pub const EAI_AGAIN = 2;
31
32/// flags parameter had an invalid value
33pub const EAI_BADFLAGS = 3;
34
35/// non-recoverable failure in name resolution
36pub const EAI_FAIL = 4;
37
38/// address family not recognized
39pub const EAI_FAMILY = 5;
40
41/// memory allocation failure
42pub const EAI_MEMORY = 6;
43
44/// no address associated with hostname
45pub const EAI_NODATA = 7;
46
47/// name does not resolve
48pub const EAI_NONAME = 8;
49
50/// service not recognized for socket type
51pub const EAI_SERVICE = 9;
52
53/// intended socket type was not recognized
54pub const EAI_SOCKTYPE = 10;
55
56/// system error returned in errno
57pub const EAI_SYSTEM = 11;
58
59/// invalid value for hints
60pub const EAI_BADHINTS = 12;
61
62/// resolved protocol is unknown
63pub const EAI_PROTOCOL = 13;
64
65/// argument buffer overflow
66pub const EAI_OVERFLOW = 14;
67
68pub const EAI_MAX = 15;
69
70/// get address to use bind()
71pub const AI_PASSIVE = 0x00000001;
72
73/// fill ai_canonname
74pub const AI_CANONNAME = 0x00000002;
75
76/// prevent host name resolution
77pub const AI_NUMERICHOST = 0x00000004;
78
79/// prevent service name resolution
80pub const AI_NUMERICSERV = 0x00000008;
81
82/// valid flags for addrinfo (not a standard def, apps should not use it)
83pub const AI_MASK = (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_ADDRCONFIG | AI_ALL | AI_V4MAPPED);
84
85/// IPv6 and IPv4-mapped (with AI_V4MAPPED)
86pub const AI_ALL = 0x00000100;
87
88/// accept IPv4-mapped if kernel supports
89pub const AI_V4MAPPED_CFG = 0x00000200;
90
91/// only if any address is assigned
92pub const AI_ADDRCONFIG = 0x00000400;
93
94/// accept IPv4-mapped IPv6 address
95pub const AI_V4MAPPED = 0x00000800;
96
97/// special recommended flags for getipnodebyname
98pub const AI_DEFAULT = (AI_V4MAPPED_CFG | AI_ADDRCONFIG);
lib/std/dynamic_library.zig+2-2
...@@ -13,7 +13,7 @@ const maxInt = std.math.maxInt;...@@ -13,7 +13,7 @@ const maxInt = std.math.maxInt;
13pub const DynLib = switch (builtin.os) {13pub const DynLib = switch (builtin.os) {
14 .linux => if (builtin.link_libc) DlDynlib else LinuxDynLib,14 .linux => if (builtin.link_libc) DlDynlib else LinuxDynLib,
15 .windows => WindowsDynLib,15 .windows => WindowsDynLib,
16 .macosx, .tvos, .watchos, .ios => DlDynlib,16 .macosx, .tvos, .watchos, .ios, .freebsd => DlDynlib,
17 else => void,17 else => void,
18};18};
1919
...@@ -338,7 +338,7 @@ pub const DlDynlib = struct {...@@ -338,7 +338,7 @@ pub const DlDynlib = struct {
338338
339test "dynamic_library" {339test "dynamic_library" {
340 const libname = switch (builtin.os) {340 const libname = switch (builtin.os) {
341 .linux => "invalid_so.so",341 .linux, .freebsd => "invalid_so.so",
342 .windows => "invalid_dll.dll",342 .windows => "invalid_dll.dll",
343 .macosx, .tvos, .watchos, .ios => "invalid_dylib.dylib",343 .macosx, .tvos, .watchos, .ios => "invalid_dylib.dylib",
344 else => return error.SkipZigTest,344 else => return error.SkipZigTest,
lib/std/os/bits/freebsd.zig+125-90
...@@ -4,6 +4,8 @@ const maxInt = std.math.maxInt;...@@ -4,6 +4,8 @@ const maxInt = std.math.maxInt;
4pub const fd_t = c_int;4pub const fd_t = c_int;
5pub const pid_t = c_int;5pub const pid_t = c_int;
66
7pub const socklen_t = u32;
8
7/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.9/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
8pub const Kevent = extern struct {10pub const Kevent = extern struct {
9 ident: usize,11 ident: usize,
...@@ -15,6 +17,32 @@ pub const Kevent = extern struct {...@@ -15,6 +17,32 @@ pub const Kevent = extern struct {
15 // TODO ext17 // TODO ext
16};18};
1719
20// Modes and flags for dlopen()
21// include/dlfcn.h
22
23/// Bind function calls lazily.
24pub const RTLD_LAZY = 1;
25
26/// Bind function calls immediately.
27pub const RTLD_NOW = 2;
28
29pub const RTLD_MODEMASK = 0x3;
30
31/// Make symbols globally available.
32pub const RTLD_GLOBAL = 0x100;
33
34/// Opposite of RTLD_GLOBAL, and the default.
35pub const RTLD_LOCAL = 0;
36
37/// Trace loaded objects and exit.
38pub const RTLD_TRACE = 0x200;
39
40/// Do not remove members.
41pub const RTLD_NODELETE = 0x01000;
42
43/// Do not load if not already loaded.
44pub const RTLD_NOLOAD = 0x02000;
45
18pub const dl_phdr_info = extern struct {46pub const dl_phdr_info = extern struct {
19 dlpi_addr: usize,47 dlpi_addr: usize,
20 dlpi_name: ?[*]const u8,48 dlpi_name: ?[*]const u8,
...@@ -134,7 +162,7 @@ pub const dirent = extern struct {...@@ -134,7 +162,7 @@ pub const dirent = extern struct {
134};162};
135163
136pub const in_port_t = u16;164pub const in_port_t = u16;
137pub const sa_family_t = u16;165pub const sa_family_t = u8;
138166
139pub const sockaddr = extern struct {167pub const sockaddr = extern struct {
140 /// total length168 /// total length
...@@ -342,97 +370,93 @@ pub const SOCK_SEQPACKET = 5;...@@ -342,97 +370,93 @@ pub const SOCK_SEQPACKET = 5;
342pub const SOCK_CLOEXEC = 0x10000000;370pub const SOCK_CLOEXEC = 0x10000000;
343pub const SOCK_NONBLOCK = 0x20000000;371pub const SOCK_NONBLOCK = 0x20000000;
344372
345pub const PF_UNSPEC = 0;373pub const PF_UNSPEC = AF_UNSPEC;
346pub const PF_LOCAL = 1;374pub const PF_LOCAL = AF_LOCAL;
347pub const PF_UNIX = PF_LOCAL;375pub const PF_UNIX = PF_LOCAL;
348pub const PF_FILE = PF_LOCAL;376pub const PF_INET = AF_INET;
349pub const PF_INET = 2;377pub const PF_IMPLINK = AF_IMPLINK;
350pub const PF_AX25 = 3;378pub const PF_PUP = AF_PUP;
351pub const PF_IPX = 4;379pub const PF_CHAOS = AF_CHAOS;
352pub const PF_APPLETALK = 5;380pub const PF_NETBIOS = AF_NETBIOS;
353pub const PF_NETROM = 6;381pub const PF_ISO = AF_ISO;
354pub const PF_BRIDGE = 7;382pub const PF_OSI = AF_ISO;
355pub const PF_ATMPVC = 8;383pub const PF_ECMA = AF_ECMA;
356pub const PF_X25 = 9;384pub const PF_DATAKIT = AF_DATAKIT;
357pub const PF_INET6 = 10;385pub const PF_CCITT = AF_CCITT;
358pub const PF_ROSE = 11;386pub const PF_DECnet = AF_DECnet;
359pub const PF_DECnet = 12;387pub const PF_DLI = AF_DLI;
360pub const PF_NETBEUI = 13;388pub const PF_LAT = AF_LAT;
361pub const PF_SECURITY = 14;389pub const PF_HYLINK = AF_HYLINK;
362pub const PF_KEY = 15;390pub const PF_APPLETALK = AF_APPLETALK;
363pub const PF_NETLINK = 16;391pub const PF_ROUTE = AF_ROUTE;
364pub const PF_ROUTE = PF_NETLINK;392pub const PF_LINK = AF_LINK;
365pub const PF_PACKET = 17;393pub const PF_XTP = pseudo_AF_XTP;
366pub const PF_ASH = 18;394pub const PF_COIP = AF_COIP;
367pub const PF_ECONET = 19;395pub const PF_CNT = AF_CNT;
368pub const PF_ATMSVC = 20;396pub const PF_SIP = AF_SIP;
369pub const PF_RDS = 21;397pub const PF_IPX = AF_IPX;
370pub const PF_SNA = 22;398pub const PF_RTIP = pseudo_AF_RTIP;
371pub const PF_IRDA = 23;399pub const PF_PIP = psuedo_AF_PIP;
372pub const PF_PPPOX = 24;400pub const PF_ISDN = AF_ISDN;
373pub const PF_WANPIPE = 25;401pub const PF_KEY = pseudo_AF_KEY;
374pub const PF_LLC = 26;402pub const PF_INET6 = pseudo_AF_INET6;
375pub const PF_IB = 27;403pub const PF_NATM = AF_NATM;
376pub const PF_MPLS = 28;404pub const PF_ATM = AF_ATM;
377pub const PF_CAN = 29;405pub const PF_NETGRAPH = AF_NETGRAPH;
378pub const PF_TIPC = 30;406pub const PF_SLOW = AF_SLOW;
379pub const PF_BLUETOOTH = 31;407pub const PF_SCLUSTER = AF_SCLUSTER;
380pub const PF_IUCV = 32;408pub const PF_ARP = AF_ARP;
381pub const PF_RXRPC = 33;409pub const PF_BLUETOOTH = AF_BLUETOOTH;
382pub const PF_ISDN = 34;410pub const PF_IEEE80211 = AF_IEE80211;
383pub const PF_PHONET = 35;411pub const PF_INET_SDP = AF_INET_SDP;
384pub const PF_IEEE802154 = 36;412pub const PF_INET6_SDP = AF_INET6_SDP;
385pub const PF_CAIF = 37;413pub const PF_MAX = AF_MAX;
386pub const PF_ALG = 38;414
387pub const PF_NFC = 39;415pub const AF_UNSPEC = 0;
388pub const PF_VSOCK = 40;416pub const AF_UNIX = 1;
389pub const PF_MAX = 41;417pub const AF_LOCAL = AF_UNIX;
390
391pub const AF_UNSPEC = PF_UNSPEC;
392pub const AF_LOCAL = PF_LOCAL;
393pub const AF_UNIX = AF_LOCAL;
394pub const AF_FILE = AF_LOCAL;418pub const AF_FILE = AF_LOCAL;
395pub const AF_INET = PF_INET;419pub const AF_INET = 2;
396pub const AF_AX25 = PF_AX25;420pub const AF_IMPLINK = 3;
397pub const AF_IPX = PF_IPX;421pub const AF_PUP = 4;
398pub const AF_APPLETALK = PF_APPLETALK;422pub const AF_CHAOS = 5;
399pub const AF_NETROM = PF_NETROM;423pub const AF_NETBIOS = 6;
400pub const AF_BRIDGE = PF_BRIDGE;424pub const AF_ISO = 7;
401pub const AF_ATMPVC = PF_ATMPVC;425pub const AF_OSI = AF_ISO;
402pub const AF_X25 = PF_X25;426pub const AF_ECMA = 8;
403pub const AF_INET6 = PF_INET6;427pub const AF_DATAKIT = 9;
404pub const AF_ROSE = PF_ROSE;428pub const AF_CCITT = 10;
405pub const AF_DECnet = PF_DECnet;429pub const AF_SNA = 11;
406pub const AF_NETBEUI = PF_NETBEUI;430pub const AF_DECnet = 12;
407pub const AF_SECURITY = PF_SECURITY;431pub const AF_DLI = 13;
408pub const AF_KEY = PF_KEY;432pub const AF_LAT = 14;
409pub const AF_NETLINK = PF_NETLINK;433pub const AF_HYLINK = 15;
410pub const AF_ROUTE = PF_ROUTE;434pub const AF_APPLETALK = 16;
411pub const AF_PACKET = PF_PACKET;435pub const AF_ROUTE = 17;
412pub const AF_ASH = PF_ASH;436pub const AF_LINK = 18;
413pub const AF_ECONET = PF_ECONET;437pub const pseudo_AF_XTP = 19;
414pub const AF_ATMSVC = PF_ATMSVC;438pub const AF_COIP = 20;
415pub const AF_RDS = PF_RDS;439pub const AF_CNT = 21;
416pub const AF_SNA = PF_SNA;440pub const pseudo_AF_RTIP = 22;
417pub const AF_IRDA = PF_IRDA;441pub const AF_IPX = 23;
418pub const AF_PPPOX = PF_PPPOX;442pub const AF_SIP = 24;
419pub const AF_WANPIPE = PF_WANPIPE;443pub const pseudo_AF_PIP = 25;
420pub const AF_LLC = PF_LLC;444pub const AF_ISDN = 26;
421pub const AF_IB = PF_IB;445pub const AF_E164 = AF_ISDN;
422pub const AF_MPLS = PF_MPLS;446pub const pseudo_AF_KEY = 27;
423pub const AF_CAN = PF_CAN;447pub const AF_INET6 = 28;
424pub const AF_TIPC = PF_TIPC;448pub const AF_NATM = 29;
425pub const AF_BLUETOOTH = PF_BLUETOOTH;449pub const AF_ATM = 30;
426pub const AF_IUCV = PF_IUCV;450pub const pseudo_AF_HDRCMPLT = 31;
427pub const AF_RXRPC = PF_RXRPC;451pub const AF_NETGRAPH = 32;
428pub const AF_ISDN = PF_ISDN;452pub const AF_SLOW = 33;
429pub const AF_PHONET = PF_PHONET;453pub const AF_SCLUSTER = 34;
430pub const AF_IEEE802154 = PF_IEEE802154;454pub const AF_ARP = 35;
431pub const AF_CAIF = PF_CAIF;455pub const AF_BLUETOOTH = 36;
432pub const AF_ALG = PF_ALG;456pub const AF_IEEE80211 = 37;
433pub const AF_NFC = PF_NFC;457pub const AF_INET_SDP = 38;
434pub const AF_VSOCK = PF_VSOCK;458pub const AF_INET6_SDP = 39;
435pub const AF_MAX = PF_MAX;459pub const AF_MAX = 42;
436460
437pub const DT_UNKNOWN = 0;461pub const DT_UNKNOWN = 0;
438pub const DT_FIFO = 1;462pub const DT_FIFO = 1;
...@@ -930,6 +954,17 @@ pub const AT_SYMLINK_FOLLOW = 0x0400;...@@ -930,6 +954,17 @@ pub const AT_SYMLINK_FOLLOW = 0x0400;
930/// Remove directory instead of file954/// Remove directory instead of file
931pub const AT_REMOVEDIR = 0x0800;955pub const AT_REMOVEDIR = 0x0800;
932956
957pub const addrinfo = extern struct {
958 flags: i32,
959 family: i32,
960 socktype: i32,
961 protocol: i32,
962 addrlen: socklen_t,
963 canonname: ?[*:0]u8,
964 addr: ?*sockaddr,
965 next: ?*addrinfo,
966};
967
933/// Fail if not under dirfd968/// Fail if not under dirfd
934pub const AT_BENEATH = 0x1000;969pub const AT_BENEATH = 0x1000;
935970