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