| ... | @@ -1478,6 +1478,10 @@ pub const libc = struct { | ... | @@ -1478,6 +1478,10 @@ pub const libc = struct { |
| 1478 | /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fsync.html | 1478 | /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/fsync.html |
| 1479 | pub extern fn fsync(fd: c_int) c_int; | 1479 | pub extern fn fsync(fd: c_int) c_int; |
| 1480 | | 1480 | |
| | 1481 | /// int getaddrinfo(const char *restrict nodename, const char *restrict servname, const struct addrinfo *restrict hints, struct addrinfo **restrict res); |
| | 1482 | /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getaddrinfo.html |
| | 1483 | pub extern fn getaddrinfo(noalias nodename: ?[*:0]const u8, noalias servname: ?[*:0]const u8, noalias req: ?*const struct_addrinfo, noalias pai: **const struct_addrinfo) c_int; |
| | 1484 | |
| 1481 | /// int getchar(void); | 1485 | /// int getchar(void); |
| 1482 | /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getchar.html | 1486 | /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getchar.html |
| 1483 | pub extern fn getchar() c_int; | 1487 | pub extern fn getchar() c_int; |
| ... | @@ -3089,3 +3093,11 @@ pub fn recv(socketfd: c_uint, buffer: []u8, flags: c_int) errno.Error!usize { | ... | @@ -3089,3 +3093,11 @@ pub fn recv(socketfd: c_uint, buffer: []u8, flags: c_int) errno.Error!usize { |
| 3089 | std.debug.assert(rc >= 0); | 3093 | std.debug.assert(rc >= 0); |
| 3090 | return @intCast(rc); | 3094 | return @intCast(rc); |
| 3091 | } | 3095 | } |
| | 3096 | pub fn getaddrinfo(noalias nodename: ?[*:0]const u8, noalias servname: ?[*:0]const u8, noalias req: ?*const struct_addrinfo) eai.Error!*const struct_addrinfo { |
| | 3097 | var pai: *const struct_addrinfo = undefined; |
| | 3098 | var hints = std.mem.zeroes(struct_addrinfo); |
| | 3099 | const rc = libc.getaddrinfo(nodename, servname, req orelse &hints, &pai); |
| | 3100 | if (rc < 0) return eai.fromInt(rc); |
| | 3101 | std.debug.assert(rc == 0); |
| | 3102 | return pai; |
| | 3103 | } |