mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
Check for isDarwin() instead of linked libc
This commit is contained in:
parent
66fe5bb0d8
commit
c992164dc7
@ -650,7 +650,7 @@ fn if_nametoindex(name: []const u8) !u32 {
|
|||||||
return @bitCast(u32, ifr.ifru.ivalue);
|
return @bitCast(u32, ifr.ifru.ivalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (builtin.link_libc) {
|
if (comptime builtin.target.os.tag.isDarwin()) {
|
||||||
if (name.len >= os.IFNAMESIZE)
|
if (name.len >= os.IFNAMESIZE)
|
||||||
return error.NameTooLong;
|
return error.NameTooLong;
|
||||||
|
|
||||||
|
|||||||
@ -49,7 +49,7 @@ test "parse and render IPv6 addresses" {
|
|||||||
try testing.expectError(error.Incomplete, net.Address.parseIp6("FF01:", 0));
|
try testing.expectError(error.Incomplete, net.Address.parseIp6("FF01:", 0));
|
||||||
try testing.expectError(error.InvalidIpv4Mapping, net.Address.parseIp6("::123.123.123.123", 0));
|
try testing.expectError(error.InvalidIpv4Mapping, net.Address.parseIp6("::123.123.123.123", 0));
|
||||||
// TODO Make this test pass on other operating systems.
|
// TODO Make this test pass on other operating systems.
|
||||||
if (builtin.os.tag == .linux or builtin.link_libc) {
|
if (builtin.os.tag == .linux or comptime builtin.os.tag.isDarwin()) {
|
||||||
try testing.expectError(error.Incomplete, net.Address.resolveIp6("ff01::fb%", 0));
|
try testing.expectError(error.Incomplete, net.Address.resolveIp6("ff01::fb%", 0));
|
||||||
try testing.expectError(error.Overflow, net.Address.resolveIp6("ff01::fb%wlp3s0s0s0s0s0s0s0s0", 0));
|
try testing.expectError(error.Overflow, net.Address.resolveIp6("ff01::fb%wlp3s0s0s0s0s0s0s0s0", 0));
|
||||||
try testing.expectError(error.Overflow, net.Address.resolveIp6("ff01::fb%12345678901234", 0));
|
try testing.expectError(error.Overflow, net.Address.resolveIp6("ff01::fb%12345678901234", 0));
|
||||||
@ -57,7 +57,7 @@ test "parse and render IPv6 addresses" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "invalid but parseable IPv6 scope ids" {
|
test "invalid but parseable IPv6 scope ids" {
|
||||||
if (builtin.os.tag != .linux or !builtin.link_libc) {
|
if (builtin.os.tag != .linux or comptime !builtin.os.tag.isDarwin()) {
|
||||||
// Currently, resolveIp6 with alphanumerical scope IDs only works on Linux.
|
// Currently, resolveIp6 with alphanumerical scope IDs only works on Linux.
|
||||||
// TODO Make this test pass on other operating systems.
|
// TODO Make this test pass on other operating systems.
|
||||||
return error.SkipZigTest;
|
return error.SkipZigTest;
|
||||||
|
|||||||
@ -16,7 +16,7 @@ pub fn resolveScopeId(name: []const u8) !u32 {
|
|||||||
if (have_ifnamesize) {
|
if (have_ifnamesize) {
|
||||||
if (name.len >= os.IFNAMESIZE) return error.NameTooLong;
|
if (name.len >= os.IFNAMESIZE) return error.NameTooLong;
|
||||||
|
|
||||||
if (native_os.tag == .windows or builtin.link_libc) {
|
if (native_os.tag == .windows or comptime native_os.tag.isDarwin()) {
|
||||||
var interface_name: [os.IFNAMESIZE:0]u8 = undefined;
|
var interface_name: [os.IFNAMESIZE:0]u8 = undefined;
|
||||||
mem.copy(u8, &interface_name, name);
|
mem.copy(u8, &interface_name, name);
|
||||||
interface_name[name.len] = 0;
|
interface_name[name.len] = 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user