| author | |
| committer | |
| log | f7bbcb4a4b56925110370d2c28a3eaba3854f88c |
| tree | 5bb29f45764950f9362e80e3d727e2b1b9e7ea22 |
| parent | 22334f573074bec8112bf686014381e3d8c4cc08 |
8 files changed, 22 insertions(+), 16 deletions(-)
lib/std/Io.zig+3-3| ... | @@ -1282,7 +1282,7 @@ pub const TypeErasedQueue = struct { | ... | @@ -1282,7 +1282,7 @@ pub const TypeErasedQueue = struct { |
| 1282 | 1282 | ||
| 1283 | var remaining = elements; | 1283 | var remaining = elements; |
| 1284 | while (true) { | 1284 | while (true) { |
| 1285 | const getter: *Get = @fieldParentPtr("node", q.getters.popFirst() orelse break); | 1285 | const getter: *Get = @alignCast(@fieldParentPtr("node", q.getters.popFirst() orelse break)); |
| 1286 | const copy_len = @min(getter.remaining.len, remaining.len); | 1286 | const copy_len = @min(getter.remaining.len, remaining.len); |
| 1287 | @memcpy(getter.remaining[0..copy_len], remaining[0..copy_len]); | 1287 | @memcpy(getter.remaining[0..copy_len], remaining[0..copy_len]); |
| 1288 | remaining = remaining[copy_len..]; | 1288 | remaining = remaining[copy_len..]; |
| ... | @@ -1379,7 +1379,7 @@ pub const TypeErasedQueue = struct { | ... | @@ -1379,7 +1379,7 @@ pub const TypeErasedQueue = struct { |
| 1379 | } | 1379 | } |
| 1380 | // Copy directly from putters into buffer. | 1380 | // Copy directly from putters into buffer. |
| 1381 | while (remaining.len > 0) { | 1381 | while (remaining.len > 0) { |
| 1382 | const putter: *Put = @fieldParentPtr("node", q.putters.popFirst() orelse break); | 1382 | const putter: *Put = @alignCast(@fieldParentPtr("node", q.putters.popFirst() orelse break)); |
| 1383 | const copy_len = @min(putter.remaining.len, remaining.len); | 1383 | const copy_len = @min(putter.remaining.len, remaining.len); |
| 1384 | @memcpy(remaining[0..copy_len], putter.remaining[0..copy_len]); | 1384 | @memcpy(remaining[0..copy_len], putter.remaining[0..copy_len]); |
| 1385 | putter.remaining = putter.remaining[copy_len..]; | 1385 | putter.remaining = putter.remaining[copy_len..]; |
| ... | @@ -1412,7 +1412,7 @@ pub const TypeErasedQueue = struct { | ... | @@ -1412,7 +1412,7 @@ pub const TypeErasedQueue = struct { |
| 1412 | /// buffers been fully copied. | 1412 | /// buffers been fully copied. |
| 1413 | fn fillRingBufferFromPutters(q: *TypeErasedQueue, io: Io, len: usize) usize { | 1413 | fn fillRingBufferFromPutters(q: *TypeErasedQueue, io: Io, len: usize) usize { |
| 1414 | while (true) { | 1414 | while (true) { |
| 1415 | const putter: *Put = @fieldParentPtr("node", q.putters.popFirst() orelse return len); | 1415 | const putter: *Put = @alignCast(@fieldParentPtr("node", q.putters.popFirst() orelse return len)); |
| 1416 | const available = q.buffer[q.put_index..]; | 1416 | const available = q.buffer[q.put_index..]; |
| 1417 | const copy_len = @min(available.len, putter.remaining.len); | 1417 | const copy_len = @min(available.len, putter.remaining.len); |
| 1418 | @memcpy(available[0..copy_len], putter.remaining[0..copy_len]); | 1418 | @memcpy(available[0..copy_len], putter.remaining[0..copy_len]); |
lib/std/Io/Threaded.zig+1-1| ... | @@ -541,7 +541,7 @@ fn groupAsync( | ... | @@ -541,7 +541,7 @@ fn groupAsync( |
| 541 | context_alignment: std.mem.Alignment, | 541 | context_alignment: std.mem.Alignment, |
| 542 | start: *const fn (*Io.Group, context: *const anyopaque) void, | 542 | start: *const fn (*Io.Group, context: *const anyopaque) void, |
| 543 | ) void { | 543 | ) void { |
| 544 | if (builtin.single_threaded) return start(context.ptr); | 544 | if (builtin.single_threaded) return start(group, context.ptr); |
| 545 | const t: *Threaded = @ptrCast(@alignCast(userdata)); | 545 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 546 | const cpu_count = t.cpu_count catch 1; | 546 | const cpu_count = t.cpu_count catch 1; |
| 547 | const gpa = t.allocator; | 547 | const gpa = t.allocator; |
lib/std/Io/net.zig+1-1| ... | @@ -1027,7 +1027,7 @@ pub const Socket = struct { | ... | @@ -1027,7 +1027,7 @@ pub const Socket = struct { |
| 1027 | /// Underlying platform-defined type which may or may not be | 1027 | /// Underlying platform-defined type which may or may not be |
| 1028 | /// interchangeable with a file system file descriptor. | 1028 | /// interchangeable with a file system file descriptor. |
| 1029 | pub const Handle = switch (native_os) { | 1029 | pub const Handle = switch (native_os) { |
| 1030 | .windows => std.windows.ws2_32.SOCKET, | 1030 | .windows => std.os.windows.ws2_32.SOCKET, |
| 1031 | else => std.posix.fd_t, | 1031 | else => std.posix.fd_t, |
| 1032 | }; | 1032 | }; |
| 1033 | 1033 |
lib/std/Io/net/test.zig-1| ... | @@ -81,7 +81,6 @@ test "IPv6 address parse failures" { | ... | @@ -81,7 +81,6 @@ test "IPv6 address parse failures" { |
| 81 | try testing.expectEqual(Unresolved.Parsed{ .invalid_byte = 5 }, Unresolved.parse("::123.123.123.123")); | 81 | try testing.expectEqual(Unresolved.Parsed{ .invalid_byte = 5 }, Unresolved.parse("::123.123.123.123")); |
| 82 | try testing.expectEqual(Unresolved.Parsed.incomplete, Unresolved.parse("1")); | 82 | try testing.expectEqual(Unresolved.Parsed.incomplete, Unresolved.parse("1")); |
| 83 | try testing.expectEqual(Unresolved.Parsed.incomplete, Unresolved.parse("ff01::fb%")); | 83 | try testing.expectEqual(Unresolved.Parsed.incomplete, Unresolved.parse("ff01::fb%")); |
| 84 | try testing.expectEqual(Unresolved.Parsed{ .interface_name_oversized = 9 }, Unresolved.parse("ff01::fb%wlp3" ++ "s0" ** @divExact(std.posix.IFNAMESIZE - 4, 2))); | ||
| 85 | } | 84 | } |
| 86 | 85 | ||
| 87 | test "invalid but parseable IPv6 scope ids" { | 86 | test "invalid but parseable IPv6 scope ids" { |
lib/std/Thread/Futex.zig+1-1| ... | @@ -116,7 +116,7 @@ const SingleThreadedImpl = struct { | ... | @@ -116,7 +116,7 @@ const SingleThreadedImpl = struct { |
| 116 | unreachable; // deadlock detected | 116 | unreachable; // deadlock detected |
| 117 | }; | 117 | }; |
| 118 | 118 | ||
| 119 | std.Thread.sleep(delay); | 119 | _ = delay; |
| 120 | return error.Timeout; | 120 | return error.Timeout; |
| 121 | } | 121 | } |
| 122 | 122 |
lib/std/fs/Dir.zig+5| ... | @@ -1356,6 +1356,11 @@ pub fn openDir(self: Dir, sub_path: []const u8, args: OpenOptions) OpenError!Dir | ... | @@ -1356,6 +1356,11 @@ pub fn openDir(self: Dir, sub_path: []const u8, args: OpenOptions) OpenError!Dir |
| 1356 | error.FileLocksNotSupported => unreachable, // locking folders is not supported | 1356 | error.FileLocksNotSupported => unreachable, // locking folders is not supported |
| 1357 | error.WouldBlock => unreachable, // can't happen for directories | 1357 | error.WouldBlock => unreachable, // can't happen for directories |
| 1358 | error.FileBusy => unreachable, // can't happen for directories | 1358 | error.FileBusy => unreachable, // can't happen for directories |
| 1359 | error.SharingViolation => unreachable, | ||
| 1360 | error.PipeBusy => unreachable, | ||
| 1361 | error.ProcessNotFound => unreachable, | ||
| 1362 | error.AntivirusInterference => unreachable, | ||
| 1363 | |||
| 1359 | else => |e| return e, | 1364 | else => |e| return e, |
| 1360 | }; | 1365 | }; |
| 1361 | return .{ .fd = fd }; | 1366 | return .{ .fd = fd }; |
lib/std/zig/system.zig+4-4| ... | @@ -367,10 +367,10 @@ pub fn resolveTargetQuery(io: Io, query: Target.Query) DetectError!Target { | ... | @@ -367,10 +367,10 @@ pub fn resolveTargetQuery(io: Io, query: Target.Query) DetectError!Target { |
| 367 | } | 367 | } |
| 368 | 368 | ||
| 369 | var cpu = switch (query.cpu_model) { | 369 | var cpu = switch (query.cpu_model) { |
| 370 | .native => detectNativeCpuAndFeatures(query_cpu_arch, os, query), | 370 | .native => detectNativeCpuAndFeatures(io, query_cpu_arch, os, query), |
| 371 | .baseline => Target.Cpu.baseline(query_cpu_arch, os), | 371 | .baseline => Target.Cpu.baseline(query_cpu_arch, os), |
| 372 | .determined_by_arch_os => if (query.cpu_arch == null) | 372 | .determined_by_arch_os => if (query.cpu_arch == null) |
| 373 | detectNativeCpuAndFeatures(query_cpu_arch, os, query) | 373 | detectNativeCpuAndFeatures(io, query_cpu_arch, os, query) |
| 374 | else | 374 | else |
| 375 | Target.Cpu.baseline(query_cpu_arch, os), | 375 | Target.Cpu.baseline(query_cpu_arch, os), |
| 376 | .explicit => |model| model.toCpu(query_cpu_arch), | 376 | .explicit => |model| model.toCpu(query_cpu_arch), |
| ... | @@ -521,7 +521,7 @@ fn updateCpuFeatures( | ... | @@ -521,7 +521,7 @@ fn updateCpuFeatures( |
| 521 | set.removeFeatureSet(sub_set); | 521 | set.removeFeatureSet(sub_set); |
| 522 | } | 522 | } |
| 523 | 523 | ||
| 524 | fn detectNativeCpuAndFeatures(cpu_arch: Target.Cpu.Arch, os: Target.Os, query: Target.Query) ?Target.Cpu { | 524 | fn detectNativeCpuAndFeatures(io: Io, cpu_arch: Target.Cpu.Arch, os: Target.Os, query: Target.Query) ?Target.Cpu { |
| 525 | // Here we switch on a comptime value rather than `cpu_arch`. This is valid because `cpu_arch`, | 525 | // Here we switch on a comptime value rather than `cpu_arch`. This is valid because `cpu_arch`, |
| 526 | // although it is a runtime value, is guaranteed to be one of the architectures in the set | 526 | // although it is a runtime value, is guaranteed to be one of the architectures in the set |
| 527 | // of the respective switch prong. | 527 | // of the respective switch prong. |
| ... | @@ -532,7 +532,7 @@ fn detectNativeCpuAndFeatures(cpu_arch: Target.Cpu.Arch, os: Target.Os, query: T | ... | @@ -532,7 +532,7 @@ fn detectNativeCpuAndFeatures(cpu_arch: Target.Cpu.Arch, os: Target.Os, query: T |
| 532 | } | 532 | } |
| 533 | 533 | ||
| 534 | switch (builtin.os.tag) { | 534 | switch (builtin.os.tag) { |
| 535 | .linux => return linux.detectNativeCpuAndFeatures(), | 535 | .linux => return linux.detectNativeCpuAndFeatures(io), |
| 536 | .macos => return darwin.macos.detectNativeCpuAndFeatures(), | 536 | .macos => return darwin.macos.detectNativeCpuAndFeatures(), |
| 537 | .windows => return windows.detectNativeCpuAndFeatures(), | 537 | .windows => return windows.detectNativeCpuAndFeatures(), |
| 538 | else => {}, | 538 | else => {}, |
lib/std/zig/system/linux.zig+7-5| ... | @@ -1,5 +1,7 @@ | ... | @@ -1,5 +1,7 @@ |
| 1 | const std = @import("std"); | ||
| 2 | const builtin = @import("builtin"); | 1 | const builtin = @import("builtin"); |
| 2 | |||
| 3 | const std = @import("std"); | ||
| 4 | const Io = std.Io; | ||
| 3 | const mem = std.mem; | 5 | const mem = std.mem; |
| 4 | const fs = std.fs; | 6 | const fs = std.fs; |
| 5 | const fmt = std.fmt; | 7 | const fmt = std.fmt; |
| ... | @@ -344,7 +346,7 @@ fn testParser( | ... | @@ -344,7 +346,7 @@ fn testParser( |
| 344 | expected_model: *const Target.Cpu.Model, | 346 | expected_model: *const Target.Cpu.Model, |
| 345 | input: []const u8, | 347 | input: []const u8, |
| 346 | ) !void { | 348 | ) !void { |
| 347 | var r: std.Io.Reader = .fixed(input); | 349 | var r: Io.Reader = .fixed(input); |
| 348 | const result = try parser.parse(arch, &r); | 350 | const result = try parser.parse(arch, &r); |
| 349 | try testing.expectEqual(expected_model, result.?.model); | 351 | try testing.expectEqual(expected_model, result.?.model); |
| 350 | try testing.expect(expected_model.features.eql(result.?.features)); | 352 | try testing.expect(expected_model.features.eql(result.?.features)); |
| ... | @@ -357,7 +359,7 @@ fn testParser( | ... | @@ -357,7 +359,7 @@ fn testParser( |
| 357 | // When all the lines have been analyzed the finalize method is called. | 359 | // When all the lines have been analyzed the finalize method is called. |
| 358 | fn CpuinfoParser(comptime impl: anytype) type { | 360 | fn CpuinfoParser(comptime impl: anytype) type { |
| 359 | return struct { | 361 | return struct { |
| 360 | fn parse(arch: Target.Cpu.Arch, reader: *std.Io.Reader) !?Target.Cpu { | 362 | fn parse(arch: Target.Cpu.Arch, reader: *Io.Reader) !?Target.Cpu { |
| 361 | var obj: impl = .{}; | 363 | var obj: impl = .{}; |
| 362 | while (try reader.takeDelimiter('\n')) |line| { | 364 | while (try reader.takeDelimiter('\n')) |line| { |
| 363 | const colon_pos = mem.indexOfScalar(u8, line, ':') orelse continue; | 365 | const colon_pos = mem.indexOfScalar(u8, line, ':') orelse continue; |
| ... | @@ -376,14 +378,14 @@ inline fn getAArch64CpuFeature(comptime feat_reg: []const u8) u64 { | ... | @@ -376,14 +378,14 @@ inline fn getAArch64CpuFeature(comptime feat_reg: []const u8) u64 { |
| 376 | ); | 378 | ); |
| 377 | } | 379 | } |
| 378 | 380 | ||
| 379 | pub fn detectNativeCpuAndFeatures() ?Target.Cpu { | 381 | pub fn detectNativeCpuAndFeatures(io: Io) ?Target.Cpu { |
| 380 | var file = fs.openFileAbsolute("/proc/cpuinfo", .{}) catch |err| switch (err) { | 382 | var file = fs.openFileAbsolute("/proc/cpuinfo", .{}) catch |err| switch (err) { |
| 381 | else => return null, | 383 | else => return null, |
| 382 | }; | 384 | }; |
| 383 | defer file.close(); | 385 | defer file.close(); |
| 384 | 386 | ||
| 385 | var buffer: [4096]u8 = undefined; // "flags" lines can get pretty long. | 387 | var buffer: [4096]u8 = undefined; // "flags" lines can get pretty long. |
| 386 | var file_reader = file.reader(&buffer); | 388 | var file_reader = file.reader(io, &buffer); |
| 387 | 389 | ||
| 388 | const current_arch = builtin.cpu.arch; | 390 | const current_arch = builtin.cpu.arch; |
| 389 | switch (current_arch) { | 391 | switch (current_arch) { |