| author | |
| committer | |
| log | 72ec4456779839d3df4b41055fbaf47a57b69ac8 |
| tree | c25be280bd8dd99e4623532490d001a913040df1 |
| parent | 9e6e1e58bb163868db51832e54c323a9ab893329 |
5 files changed, 102 insertions(+), 89 deletions(-)
lib/std/c.zig+3-3| ... | ... | @@ -185,7 +185,7 @@ pub extern "c" fn getaddrinfo( |
| 185 | 185 | noalias service: [*:0]const u8, |
| 186 | 186 | noalias hints: *const addrinfo, |
| 187 | 187 | noalias res: **addrinfo, |
| 188 | ) c_int; | |
| 188 | ) EAI; | |
| 189 | 189 | |
| 190 | 190 | pub extern "c" fn freeaddrinfo(res: *addrinfo) void; |
| 191 | 191 | |
| ... | ... | @@ -197,9 +197,9 @@ pub extern "c" fn getnameinfo( |
| 197 | 197 | noalias serv: [*]u8, |
| 198 | 198 | servlen: socklen_t, |
| 199 | 199 | flags: u32, |
| 200 | ) c_int; | |
| 200 | ) EAI; | |
| 201 | 201 | |
| 202 | pub extern "c" fn gai_strerror(errcode: c_int) [*:0]const u8; | |
| 202 | pub extern "c" fn gai_strerror(errcode: EAI) [*:0]const u8; | |
| 203 | 203 | |
| 204 | 204 | pub extern "c" fn poll(fds: [*]pollfd, nfds: nfds_t, timeout: c_int) c_int; |
| 205 | 205 |
lib/std/c/darwin.zig+33-28| ... | ... | @@ -70,47 +70,52 @@ pub const AI_NUMERICHOST = 0x00000004; |
| 70 | 70 | /// prevent service name resolution |
| 71 | 71 | pub const AI_NUMERICSERV = 0x00001000; |
| 72 | 72 | |
| 73 | /// address family for hostname not supported | |
| 74 | pub const EAI_ADDRFAMILY = 1; | |
| 73 | pub const EAI = extern enum(c_int) { | |
| 74 | /// address family for hostname not supported | |
| 75 | ADDRFAMILY = 1, | |
| 75 | 76 | |
| 76 | /// temporary failure in name resolution | |
| 77 | pub const EAI_AGAIN = 2; | |
| 77 | /// temporary failure in name resolution | |
| 78 | AGAIN = 2, | |
| 78 | 79 | |
| 79 | /// invalid value for ai_flags | |
| 80 | pub const EAI_BADFLAGS = 3; | |
| 80 | /// invalid value for ai_flags | |
| 81 | BADFLAGS = 3, | |
| 81 | 82 | |
| 82 | /// non-recoverable failure in name resolution | |
| 83 | pub const EAI_FAIL = 4; | |
| 83 | /// non-recoverable failure in name resolution | |
| 84 | FAIL = 4, | |
| 84 | 85 | |
| 85 | /// ai_family not supported | |
| 86 | pub const EAI_FAMILY = 5; | |
| 86 | /// ai_family not supported | |
| 87 | FAMILY = 5, | |
| 87 | 88 | |
| 88 | /// memory allocation failure | |
| 89 | pub const EAI_MEMORY = 6; | |
| 89 | /// memory allocation failure | |
| 90 | MEMORY = 6, | |
| 90 | 91 | |
| 91 | /// no address associated with hostname | |
| 92 | pub const EAI_NODATA = 7; | |
| 92 | /// no address associated with hostname | |
| 93 | NODATA = 7, | |
| 93 | 94 | |
| 94 | /// hostname nor servname provided, or not known | |
| 95 | pub const EAI_NONAME = 8; | |
| 95 | /// hostname nor servname provided, or not known | |
| 96 | NONAME = 8, | |
| 96 | 97 | |
| 97 | /// servname not supported for ai_socktype | |
| 98 | pub const EAI_SERVICE = 9; | |
| 98 | /// servname not supported for ai_socktype | |
| 99 | SERVICE = 9, | |
| 99 | 100 | |
| 100 | /// ai_socktype not supported | |
| 101 | pub const EAI_SOCKTYPE = 10; | |
| 101 | /// ai_socktype not supported | |
| 102 | SOCKTYPE = 10, | |
| 102 | 103 | |
| 103 | /// system error returned in errno | |
| 104 | pub const EAI_SYSTEM = 11; | |
| 104 | /// system error returned in errno | |
| 105 | SYSTEM = 11, | |
| 105 | 106 | |
| 106 | /// invalid value for hints | |
| 107 | pub const EAI_BADHINTS = 12; | |
| 107 | /// invalid value for hints | |
| 108 | BADHINTS = 12, | |
| 108 | 109 | |
| 109 | /// resolved protocol is unknown | |
| 110 | pub const EAI_PROTOCOL = 13; | |
| 110 | /// resolved protocol is unknown | |
| 111 | PROTOCOL = 13, | |
| 112 | ||
| 113 | /// argument buffer overflow | |
| 114 | OVERFLOW = 14, | |
| 115 | ||
| 116 | _, | |
| 117 | }; | |
| 111 | 118 | |
| 112 | /// argument buffer overflow | |
| 113 | pub const EAI_OVERFLOW = 14; | |
| 114 | 119 | pub const EAI_MAX = 15; |
| 115 | 120 | |
| 116 | 121 | pub const pthread_mutex_t = extern struct { |
lib/std/c/freebsd.zig+32-28| ... | ... | @@ -23,47 +23,51 @@ pub const pthread_attr_t = extern struct { |
| 23 | 23 | __align: c_long, |
| 24 | 24 | }; |
| 25 | 25 | |
| 26 | /// address family for hostname not supported | |
| 27 | pub const EAI_ADDRFAMILY = 1; | |
| 26 | pub const EAI = extern enum(c_int) { | |
| 27 | /// address family for hostname not supported | |
| 28 | ADDRFAMILY = 1, | |
| 28 | 29 | |
| 29 | /// name could not be resolved at this time | |
| 30 | pub const EAI_AGAIN = 2; | |
| 30 | /// name could not be resolved at this time | |
| 31 | AGAIN = 2, | |
| 31 | 32 | |
| 32 | /// flags parameter had an invalid value | |
| 33 | pub const EAI_BADFLAGS = 3; | |
| 33 | /// flags parameter had an invalid value | |
| 34 | BADFLAGS = 3, | |
| 34 | 35 | |
| 35 | /// non-recoverable failure in name resolution | |
| 36 | pub const EAI_FAIL = 4; | |
| 36 | /// non-recoverable failure in name resolution | |
| 37 | FAIL = 4, | |
| 37 | 38 | |
| 38 | /// address family not recognized | |
| 39 | pub const EAI_FAMILY = 5; | |
| 39 | /// address family not recognized | |
| 40 | FAMILY = 5, | |
| 40 | 41 | |
| 41 | /// memory allocation failure | |
| 42 | pub const EAI_MEMORY = 6; | |
| 42 | /// memory allocation failure | |
| 43 | MEMORY = 6, | |
| 43 | 44 | |
| 44 | /// no address associated with hostname | |
| 45 | pub const EAI_NODATA = 7; | |
| 45 | /// no address associated with hostname | |
| 46 | NODATA = 7, | |
| 46 | 47 | |
| 47 | /// name does not resolve | |
| 48 | pub const EAI_NONAME = 8; | |
| 48 | /// name does not resolve | |
| 49 | NONAME = 8, | |
| 49 | 50 | |
| 50 | /// service not recognized for socket type | |
| 51 | pub const EAI_SERVICE = 9; | |
| 51 | /// service not recognized for socket type | |
| 52 | SERVICE = 9, | |
| 52 | 53 | |
| 53 | /// intended socket type was not recognized | |
| 54 | pub const EAI_SOCKTYPE = 10; | |
| 54 | /// intended socket type was not recognized | |
| 55 | SOCKTYPE = 10, | |
| 55 | 56 | |
| 56 | /// system error returned in errno | |
| 57 | pub const EAI_SYSTEM = 11; | |
| 57 | /// system error returned in errno | |
| 58 | SYSTEM = 11, | |
| 58 | 59 | |
| 59 | /// invalid value for hints | |
| 60 | pub const EAI_BADHINTS = 12; | |
| 60 | /// invalid value for hints | |
| 61 | BADHINTS = 12, | |
| 61 | 62 | |
| 62 | /// resolved protocol is unknown | |
| 63 | pub const EAI_PROTOCOL = 13; | |
| 63 | /// resolved protocol is unknown | |
| 64 | PROTOCOL = 13, | |
| 64 | 65 | |
| 65 | /// argument buffer overflow | |
| 66 | pub const EAI_OVERFLOW = 14; | |
| 66 | /// argument buffer overflow | |
| 67 | OVERFLOW = 14, | |
| 68 | ||
| 69 | _, | |
| 70 | }; | |
| 67 | 71 | |
| 68 | 72 | pub const EAI_MAX = 15; |
| 69 | 73 |
lib/std/c/linux.zig+22-18| ... | ... | @@ -32,25 +32,29 @@ pub const NI_NAMEREQD = 0x08; |
| 32 | 32 | pub const NI_DGRAM = 0x10; |
| 33 | 33 | pub const NI_NUMERICSCOPE = 0x100; |
| 34 | 34 | |
| 35 | pub const EAI_BADFLAGS = -1; | |
| 36 | pub const EAI_NONAME = -2; | |
| 37 | pub const EAI_AGAIN = -3; | |
| 38 | pub const EAI_FAIL = -4; | |
| 39 | pub const EAI_FAMILY = -6; | |
| 40 | pub const EAI_SOCKTYPE = -7; | |
| 41 | pub const EAI_SERVICE = -8; | |
| 42 | pub const EAI_MEMORY = -10; | |
| 43 | pub const EAI_SYSTEM = -11; | |
| 44 | pub const EAI_OVERFLOW = -12; | |
| 35 | pub const EAI = extern enum(c_int) { | |
| 36 | BADFLAGS = -1, | |
| 37 | NONAME = -2, | |
| 38 | AGAIN = -3, | |
| 39 | FAIL = -4, | |
| 40 | FAMILY = -6, | |
| 41 | SOCKTYPE = -7, | |
| 42 | SERVICE = -8, | |
| 43 | MEMORY = -10, | |
| 44 | SYSTEM = -11, | |
| 45 | OVERFLOW = -12, | |
| 45 | 46 | |
| 46 | pub const EAI_NODATA = -5; | |
| 47 | pub const EAI_ADDRFAMILY = -9; | |
| 48 | pub const EAI_INPROGRESS = -100; | |
| 49 | pub const EAI_CANCELED = -101; | |
| 50 | pub const EAI_NOTCANCELED = -102; | |
| 51 | pub const EAI_ALLDONE = -103; | |
| 52 | pub const EAI_INTR = -104; | |
| 53 | pub const EAI_IDN_ENCODE = -105; | |
| 47 | NODATA = -5, | |
| 48 | ADDRFAMILY = -9, | |
| 49 | INPROGRESS = -100, | |
| 50 | CANCELED = -101, | |
| 51 | NOTCANCELED = -102, | |
| 52 | ALLDONE = -103, | |
| 53 | INTR = -104, | |
| 54 | IDN_ENCODE = -105, | |
| 55 | ||
| 56 | _, | |
| 57 | }; | |
| 54 | 58 | |
| 55 | 59 | pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize; |
| 56 | 60 | pub extern "c" fn sched_getaffinity(pid: c_int, size: usize, set: *cpu_set_t) c_int; |
lib/std/net.zig+12-12| ... | ... | @@ -452,18 +452,18 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !* |
| 452 | 452 | }; |
| 453 | 453 | var res: *os.addrinfo = undefined; |
| 454 | 454 | switch (os.system.getaddrinfo(name_c.ptr, @ptrCast([*:0]const u8, port_c.ptr), &hints, &res)) { |
| 455 | 0 => {}, | |
| 456 | c.EAI_ADDRFAMILY => return error.HostLacksNetworkAddresses, | |
| 457 | c.EAI_AGAIN => return error.TemporaryNameServerFailure, | |
| 458 | c.EAI_BADFLAGS => unreachable, // Invalid hints | |
| 459 | c.EAI_FAIL => return error.NameServerFailure, | |
| 460 | c.EAI_FAMILY => return error.AddressFamilyNotSupported, | |
| 461 | c.EAI_MEMORY => return error.OutOfMemory, | |
| 462 | c.EAI_NODATA => return error.HostLacksNetworkAddresses, | |
| 463 | c.EAI_NONAME => return error.UnknownHostName, | |
| 464 | c.EAI_SERVICE => return error.ServiceUnavailable, | |
| 465 | c.EAI_SOCKTYPE => unreachable, // Invalid socket type requested in hints | |
| 466 | c.EAI_SYSTEM => switch (os.errno(-1)) { | |
| 455 | @intToEnum(os.system.EAI, 0) => {}, | |
| 456 | .ADDRFAMILY => return error.HostLacksNetworkAddresses, | |
| 457 | .AGAIN => return error.TemporaryNameServerFailure, | |
| 458 | .BADFLAGS => unreachable, // Invalid hints | |
| 459 | .FAIL => return error.NameServerFailure, | |
| 460 | .FAMILY => return error.AddressFamilyNotSupported, | |
| 461 | .MEMORY => return error.OutOfMemory, | |
| 462 | .NODATA => return error.HostLacksNetworkAddresses, | |
| 463 | .NONAME => return error.UnknownHostName, | |
| 464 | .SERVICE => return error.ServiceUnavailable, | |
| 465 | .SOCKTYPE => unreachable, // Invalid socket type requested in hints | |
| 466 | .SYSTEM => switch (os.errno(-1)) { | |
| 467 | 467 | else => |e| return os.unexpectedErrno(e), |
| 468 | 468 | }, |
| 469 | 469 | else => unreachable, |