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 {
2222 __size: [56]u8,
2323 __align: c_long,
2424};
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;
1313pub const DynLib = switch (builtin.os) {
1414 .linux => if (builtin.link_libc) DlDynlib else LinuxDynLib,
1515 .windows => WindowsDynLib,
16 .macosx, .tvos, .watchos, .ios => DlDynlib,
16 .macosx, .tvos, .watchos, .ios, .freebsd => DlDynlib,
1717 else => void,
1818};
1919
......@@ -338,7 +338,7 @@ pub const DlDynlib = struct {
338338
339339test "dynamic_library" {
340340 const libname = switch (builtin.os) {
341 .linux => "invalid_so.so",
341 .linux, .freebsd => "invalid_so.so",
342342 .windows => "invalid_dll.dll",
343343 .macosx, .tvos, .watchos, .ios => "invalid_dylib.dylib",
344344 else => return error.SkipZigTest,
lib/std/os/bits/freebsd.zig+125-90
......@@ -4,6 +4,8 @@ const maxInt = std.math.maxInt;
44pub const fd_t = c_int;
55pub const pid_t = c_int;
66
7pub const socklen_t = u32;
8
79/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
810pub const Kevent = extern struct {
911 ident: usize,
......@@ -15,6 +17,32 @@ pub const Kevent = extern struct {
1517 // TODO ext
1618};
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
1846pub const dl_phdr_info = extern struct {
1947 dlpi_addr: usize,
2048 dlpi_name: ?[*]const u8,
......@@ -134,7 +162,7 @@ pub const dirent = extern struct {
134162};
135163
136164pub const in_port_t = u16;
137pub const sa_family_t = u16;
165pub const sa_family_t = u8;
138166
139167pub const sockaddr = extern struct {
140168 /// total length
......@@ -342,97 +370,93 @@ pub const SOCK_SEQPACKET = 5;
342370pub const SOCK_CLOEXEC = 0x10000000;
343371pub const SOCK_NONBLOCK = 0x20000000;
344372
345pub const PF_UNSPEC = 0;
346pub const PF_LOCAL = 1;
373pub const PF_UNSPEC = AF_UNSPEC;
374pub const PF_LOCAL = AF_LOCAL;
347375pub const PF_UNIX = PF_LOCAL;
348pub const PF_FILE = PF_LOCAL;
349pub const PF_INET = 2;
350pub const PF_AX25 = 3;
351pub const PF_IPX = 4;
352pub const PF_APPLETALK = 5;
353pub const PF_NETROM = 6;
354pub const PF_BRIDGE = 7;
355pub const PF_ATMPVC = 8;
356pub const PF_X25 = 9;
357pub const PF_INET6 = 10;
358pub const PF_ROSE = 11;
359pub const PF_DECnet = 12;
360pub const PF_NETBEUI = 13;
361pub const PF_SECURITY = 14;
362pub const PF_KEY = 15;
363pub const PF_NETLINK = 16;
364pub const PF_ROUTE = PF_NETLINK;
365pub const PF_PACKET = 17;
366pub const PF_ASH = 18;
367pub const PF_ECONET = 19;
368pub const PF_ATMSVC = 20;
369pub const PF_RDS = 21;
370pub const PF_SNA = 22;
371pub const PF_IRDA = 23;
372pub const PF_PPPOX = 24;
373pub const PF_WANPIPE = 25;
374pub const PF_LLC = 26;
375pub const PF_IB = 27;
376pub const PF_MPLS = 28;
377pub const PF_CAN = 29;
378pub const PF_TIPC = 30;
379pub const PF_BLUETOOTH = 31;
380pub const PF_IUCV = 32;
381pub const PF_RXRPC = 33;
382pub const PF_ISDN = 34;
383pub const PF_PHONET = 35;
384pub const PF_IEEE802154 = 36;
385pub const PF_CAIF = 37;
386pub const PF_ALG = 38;
387pub const PF_NFC = 39;
388pub const PF_VSOCK = 40;
389pub const PF_MAX = 41;
390
391pub const AF_UNSPEC = PF_UNSPEC;
392pub const AF_LOCAL = PF_LOCAL;
393pub const AF_UNIX = AF_LOCAL;
376pub const PF_INET = AF_INET;
377pub const PF_IMPLINK = AF_IMPLINK;
378pub const PF_PUP = AF_PUP;
379pub const PF_CHAOS = AF_CHAOS;
380pub const PF_NETBIOS = AF_NETBIOS;
381pub const PF_ISO = AF_ISO;
382pub const PF_OSI = AF_ISO;
383pub const PF_ECMA = AF_ECMA;
384pub const PF_DATAKIT = AF_DATAKIT;
385pub const PF_CCITT = AF_CCITT;
386pub const PF_DECnet = AF_DECnet;
387pub const PF_DLI = AF_DLI;
388pub const PF_LAT = AF_LAT;
389pub const PF_HYLINK = AF_HYLINK;
390pub const PF_APPLETALK = AF_APPLETALK;
391pub const PF_ROUTE = AF_ROUTE;
392pub const PF_LINK = AF_LINK;
393pub const PF_XTP = pseudo_AF_XTP;
394pub const PF_COIP = AF_COIP;
395pub const PF_CNT = AF_CNT;
396pub const PF_SIP = AF_SIP;
397pub const PF_IPX = AF_IPX;
398pub const PF_RTIP = pseudo_AF_RTIP;
399pub const PF_PIP = psuedo_AF_PIP;
400pub const PF_ISDN = AF_ISDN;
401pub const PF_KEY = pseudo_AF_KEY;
402pub const PF_INET6 = pseudo_AF_INET6;
403pub const PF_NATM = AF_NATM;
404pub const PF_ATM = AF_ATM;
405pub const PF_NETGRAPH = AF_NETGRAPH;
406pub const PF_SLOW = AF_SLOW;
407pub const PF_SCLUSTER = AF_SCLUSTER;
408pub const PF_ARP = AF_ARP;
409pub const PF_BLUETOOTH = AF_BLUETOOTH;
410pub const PF_IEEE80211 = AF_IEE80211;
411pub const PF_INET_SDP = AF_INET_SDP;
412pub const PF_INET6_SDP = AF_INET6_SDP;
413pub const PF_MAX = AF_MAX;
414
415pub const AF_UNSPEC = 0;
416pub const AF_UNIX = 1;
417pub const AF_LOCAL = AF_UNIX;
394418pub const AF_FILE = AF_LOCAL;
395pub const AF_INET = PF_INET;
396pub const AF_AX25 = PF_AX25;
397pub const AF_IPX = PF_IPX;
398pub const AF_APPLETALK = PF_APPLETALK;
399pub const AF_NETROM = PF_NETROM;
400pub const AF_BRIDGE = PF_BRIDGE;
401pub const AF_ATMPVC = PF_ATMPVC;
402pub const AF_X25 = PF_X25;
403pub const AF_INET6 = PF_INET6;
404pub const AF_ROSE = PF_ROSE;
405pub const AF_DECnet = PF_DECnet;
406pub const AF_NETBEUI = PF_NETBEUI;
407pub const AF_SECURITY = PF_SECURITY;
408pub const AF_KEY = PF_KEY;
409pub const AF_NETLINK = PF_NETLINK;
410pub const AF_ROUTE = PF_ROUTE;
411pub const AF_PACKET = PF_PACKET;
412pub const AF_ASH = PF_ASH;
413pub const AF_ECONET = PF_ECONET;
414pub const AF_ATMSVC = PF_ATMSVC;
415pub const AF_RDS = PF_RDS;
416pub const AF_SNA = PF_SNA;
417pub const AF_IRDA = PF_IRDA;
418pub const AF_PPPOX = PF_PPPOX;
419pub const AF_WANPIPE = PF_WANPIPE;
420pub const AF_LLC = PF_LLC;
421pub const AF_IB = PF_IB;
422pub const AF_MPLS = PF_MPLS;
423pub const AF_CAN = PF_CAN;
424pub const AF_TIPC = PF_TIPC;
425pub const AF_BLUETOOTH = PF_BLUETOOTH;
426pub const AF_IUCV = PF_IUCV;
427pub const AF_RXRPC = PF_RXRPC;
428pub const AF_ISDN = PF_ISDN;
429pub const AF_PHONET = PF_PHONET;
430pub const AF_IEEE802154 = PF_IEEE802154;
431pub const AF_CAIF = PF_CAIF;
432pub const AF_ALG = PF_ALG;
433pub const AF_NFC = PF_NFC;
434pub const AF_VSOCK = PF_VSOCK;
435pub const AF_MAX = PF_MAX;
419pub const AF_INET = 2;
420pub const AF_IMPLINK = 3;
421pub const AF_PUP = 4;
422pub const AF_CHAOS = 5;
423pub const AF_NETBIOS = 6;
424pub const AF_ISO = 7;
425pub const AF_OSI = AF_ISO;
426pub const AF_ECMA = 8;
427pub const AF_DATAKIT = 9;
428pub const AF_CCITT = 10;
429pub const AF_SNA = 11;
430pub const AF_DECnet = 12;
431pub const AF_DLI = 13;
432pub const AF_LAT = 14;
433pub const AF_HYLINK = 15;
434pub const AF_APPLETALK = 16;
435pub const AF_ROUTE = 17;
436pub const AF_LINK = 18;
437pub const pseudo_AF_XTP = 19;
438pub const AF_COIP = 20;
439pub const AF_CNT = 21;
440pub const pseudo_AF_RTIP = 22;
441pub const AF_IPX = 23;
442pub const AF_SIP = 24;
443pub const pseudo_AF_PIP = 25;
444pub const AF_ISDN = 26;
445pub const AF_E164 = AF_ISDN;
446pub const pseudo_AF_KEY = 27;
447pub const AF_INET6 = 28;
448pub const AF_NATM = 29;
449pub const AF_ATM = 30;
450pub const pseudo_AF_HDRCMPLT = 31;
451pub const AF_NETGRAPH = 32;
452pub const AF_SLOW = 33;
453pub const AF_SCLUSTER = 34;
454pub const AF_ARP = 35;
455pub const AF_BLUETOOTH = 36;
456pub const AF_IEEE80211 = 37;
457pub const AF_INET_SDP = 38;
458pub const AF_INET6_SDP = 39;
459pub const AF_MAX = 42;
436460
437461pub const DT_UNKNOWN = 0;
438462pub const DT_FIFO = 1;
......@@ -930,6 +954,17 @@ pub const AT_SYMLINK_FOLLOW = 0x0400;
930954/// Remove directory instead of file
931955pub 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
933968/// Fail if not under dirfd
934969pub const AT_BENEATH = 0x1000;
935970