diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-05-17 16:08:09 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-05-17 16:08:09 -0700 |
| commit | 83677074f95930d0fcb95a4eed276637d52afde7 (patch) | |
| tree | 9ca5af3f5723a9f721b3bc558ecbe5520740d83c /lib/std/net.zig | |
| parent | 8cfa231104cc99c3a6c85a2ff691d89e6c856e89 (diff) | |
| download | zig-83677074f95930d0fcb95a4eed276637d52afde7.tar.gz zig-83677074f95930d0fcb95a4eed276637d52afde7.zip | |
std: update regarding std.builtin reorganization
There are also some regressed std.fmt tests here and I haven't figured
out what's wrong yet.
Diffstat (limited to 'lib/std/net.zig')
| -rw-r--r-- | lib/std/net.zig | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/std/net.zig b/lib/std/net.zig index 03fa48086c..ff0e299a7e 100644 --- a/lib/std/net.zig +++ b/lib/std/net.zig @@ -4,18 +4,19 @@ // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. const std = @import("std.zig"); -const builtin = std.builtin; +const builtin = @import("builtin"); const assert = std.debug.assert; const net = @This(); const mem = std.mem; const os = std.os; const fs = std.fs; const io = std.io; +const native_endian = builtin.target.cpu.arch.endian(); // Windows 10 added support for unix sockets in build 17063, redstone 4 is the // first release to support them. pub const has_unix_sockets = @hasDecl(os, "sockaddr_un") and - (builtin.os.tag != .windows or + (builtin.target.os.tag != .windows or std.Target.current.os.version_range.windows.isAtLeast(.win10_rs4) orelse false); pub const Address = extern union { @@ -567,7 +568,7 @@ pub const Ip6Address = extern struct { return; } const big_endian_parts = @ptrCast(*align(1) const [8]u16, &self.sa.addr); - const native_endian_parts = switch (builtin.endian) { + const native_endian_parts = switch (native_endian) { .Big => big_endian_parts.*, .Little => blk: { var buf: [8]u16 = undefined; @@ -673,7 +674,7 @@ pub fn tcpConnectToHost(allocator: *mem.Allocator, name: []const u8, port: u16) pub fn tcpConnectToAddress(address: Address) !Stream { const nonblock = if (std.io.is_async) os.SOCK_NONBLOCK else 0; const sock_flags = os.SOCK_STREAM | nonblock | - (if (builtin.os.tag == .windows) 0 else os.SOCK_CLOEXEC); + (if (builtin.target.os.tag == .windows) 0 else os.SOCK_CLOEXEC); const sockfd = try os.socket(address.any.family, sock_flags, os.IPPROTO_TCP); errdefer os.closeSocket(sockfd); @@ -704,14 +705,14 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !* const arena = &result.arena.allocator; errdefer result.arena.deinit(); - if (builtin.os.tag == .windows or builtin.link_libc) { + if (builtin.target.os.tag == .windows or builtin.link_libc) { const name_c = try std.cstr.addNullByte(allocator, name); defer allocator.free(name_c); const port_c = try std.fmt.allocPrint(allocator, "{}\x00", .{port}); defer allocator.free(port_c); - const sys = if (builtin.os.tag == .windows) os.windows.ws2_32 else os.system; + const sys = if (builtin.target.os.tag == .windows) os.windows.ws2_32 else os.system; const hints = os.addrinfo{ .flags = sys.AI_NUMERICSERV, .family = os.AF_UNSPEC, @@ -724,7 +725,7 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !* }; var res: *os.addrinfo = undefined; const rc = sys.getaddrinfo(name_c.ptr, std.meta.assumeSentinel(port_c.ptr, 0), &hints, &res); - if (builtin.os.tag == .windows) switch (@intToEnum(os.windows.ws2_32.WinsockError, @intCast(u16, rc))) { + if (builtin.target.os.tag == .windows) switch (@intToEnum(os.windows.ws2_32.WinsockError, @intCast(u16, rc))) { @intToEnum(os.windows.ws2_32.WinsockError, 0) => {}, .WSATRY_AGAIN => return error.TemporaryNameServerFailure, .WSANO_RECOVERY => return error.NameServerFailure, @@ -782,7 +783,7 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !* return result; } - if (builtin.os.tag == .linux) { + if (builtin.target.os.tag == .linux) { const flags = std.c.AI_NUMERICSERV; const family = os.AF_UNSPEC; var lookup_addrs = std.ArrayList(LookupAddr).init(allocator); |
