authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-12-09 14:29:15-05:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-12-09 14:29:15-05:00
logf2911948341e1ba1fc03ba2678eaf0a3c4508fa3
tree7a32f0ddd22c822456ae360f73ff7f51dbe023df
parent676e416c86e2977f76b0cc1b9d3bc2b7ac6d7936
parent7e30e8390044fbd396966b6e21d2de980d6f915f
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #7362 from Vexu/std

zig fmt improvement and small miscellaneous fixes

25 files changed, 251 insertions(+), 215 deletions(-)

lib/std/auto_reset_event.zig+6-8
......@@ -30,10 +30,8 @@ pub const AutoResetEvent = struct {
3030 // std.ResetEvent.wait() |
3131 // | std.ResetEvent.set()
3232 // | std.ResetEvent.set()
33 // std.ResetEvent.reset() |
33 // std.ResetEvent.reset() |
3434 // std.ResetEvent.wait() | (missed the second .set() notification above)
35
36
3735 state: usize = UNSET,
3836
3937 const UNSET = 0;
......@@ -70,7 +68,7 @@ pub const AutoResetEvent = struct {
7068 if (state != UNSET) {
7169 unreachable; // multiple waiting threads on the same AutoResetEvent
7270 }
73
71
7472 // lazily initialize the ResetEvent if it hasn't been already
7573 if (!has_reset_event) {
7674 has_reset_event = true;
......@@ -78,7 +76,7 @@ pub const AutoResetEvent = struct {
7876 }
7977
8078 // Since the AutoResetEvent currently isnt set,
81 // try to register our ResetEvent on it to wait
79 // try to register our ResetEvent on it to wait
8280 // for a set() call from another thread.
8381 if (@cmpxchgWeak(
8482 usize,
......@@ -121,7 +119,7 @@ pub const AutoResetEvent = struct {
121119 unreachable; // multiple waiting threads on the same AutoResetEvent observed when timing out
122120 }
123121
124 // This menas a set() thread saw our ResetEvent pointer, acquired it, and is trying to wake it up.
122 // This menas a set() thread saw our ResetEvent pointer, acquired it, and is trying to wake it up.
125123 // We need to wait for it to wake up our ResetEvent before we can return and invalidate it.
126124 // We don't return error.TimedOut here as it technically notified us while we were "timing out".
127125 reset_event.wait();
......@@ -137,7 +135,7 @@ pub const AutoResetEvent = struct {
137135 return;
138136 }
139137
140 // If the AutoResetEvent isn't set,
138 // If the AutoResetEvent isn't set,
141139 // then try to leave a notification for the wait() thread that we set() it.
142140 if (state == UNSET) {
143141 state = @cmpxchgWeak(
......@@ -226,4 +224,4 @@ test "std.AutoResetEvent" {
226224
227225 send_thread.wait();
228226 recv_thread.wait();
229}
\ No newline at end of file
227}
lib/std/c/openbsd.zig-1
......@@ -34,4 +34,3 @@ pub const pthread_attr_t = extern struct {
3434};
3535
3636pub extern "c" fn posix_memalign(memptr: *?*c_void, alignment: usize, size: usize) c_int;
37
lib/std/compress/deflate.zig+1-1
......@@ -316,7 +316,7 @@ pub fn InflateStream(comptime ReaderType: type) type {
316316 comptime {
317317 @setEvalBranchQuota(100000);
318318
319 const len_lengths = //
319 const len_lengths =
320320 [_]u16{8} ** 144 ++
321321 [_]u16{9} ** 112 ++
322322 [_]u16{7} ** 24 ++
lib/std/hash_map.zig+1-1
......@@ -1127,7 +1127,7 @@ test "std.hash_map put" {
11271127test "std.hash_map putAssumeCapacity" {
11281128 var map = AutoHashMap(u32, u32).init(std.testing.allocator);
11291129 defer map.deinit();
1130
1130
11311131 try map.ensureCapacity(20);
11321132 var i: u32 = 0;
11331133 while (i < 20) : (i += 1) {
lib/std/heap/general_purpose_allocator.zig+8-4
......@@ -184,8 +184,12 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type {
184184 const total_requested_bytes_init = if (config.enable_memory_limit) @as(usize, 0) else {};
185185 const requested_memory_limit_init = if (config.enable_memory_limit) @as(usize, math.maxInt(usize)) else {};
186186
187 const mutex_init = if (config.MutexType) |T| T{} else
188 if (config.thread_safe) std.Mutex{} else std.mutex.Dummy{};
187 const mutex_init = if (config.MutexType) |T|
188 T{}
189 else if (config.thread_safe)
190 std.Mutex{}
191 else
192 std.mutex.Dummy{};
189193
190194 const stack_n = config.stack_trace_frames;
191195 const one_trace_size = @sizeOf(usize) * stack_n;
......@@ -865,9 +869,9 @@ test "realloc large object to small object" {
865869}
866870
867871test "overrideable mutexes" {
868 var gpa = GeneralPurposeAllocator(.{.MutexType = std.Mutex}){
872 var gpa = GeneralPurposeAllocator(.{ .MutexType = std.Mutex }){
869873 .backing_allocator = std.testing.allocator,
870 .mutex = std.Mutex{}
874 .mutex = std.Mutex{},
871875 };
872876 defer std.testing.expect(!gpa.deinit());
873877 const allocator = &gpa.allocator;
lib/std/macho.zig-1
......@@ -42,7 +42,6 @@ pub const uuid_command = extern struct {
4242 uuid: [16]u8,
4343};
4444
45
4645/// The version_min_command contains the min OS version on which this
4746/// binary was built to run.
4847pub const version_min_command = extern struct {
lib/std/meta.zig+51-39
......@@ -226,43 +226,55 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
226226 switch (@typeInfo(T)) {
227227 .Pointer => |info| switch (info.size) {
228228 .One => switch (@typeInfo(info.child)) {
229 .Array => |array_info| return @Type(.{ .Pointer = .{
229 .Array => |array_info| return @Type(.{
230 .Pointer = .{
231 .size = info.size,
232 .is_const = info.is_const,
233 .is_volatile = info.is_volatile,
234 .alignment = info.alignment,
235 .child = @Type(.{
236 .Array = .{
237 .len = array_info.len,
238 .child = array_info.child,
239 .sentinel = sentinel_val,
240 },
241 }),
242 .is_allowzero = info.is_allowzero,
243 .sentinel = info.sentinel,
244 },
245 }),
246 else => {},
247 },
248 .Many, .Slice => return @Type(.{
249 .Pointer = .{
230250 .size = info.size,
231251 .is_const = info.is_const,
232252 .is_volatile = info.is_volatile,
233253 .alignment = info.alignment,
234 .child = @Type(.{ .Array = .{
235 .len = array_info.len,
236 .child = array_info.child,
237 .sentinel = sentinel_val,
238 }}),
254 .child = info.child,
239255 .is_allowzero = info.is_allowzero,
240 .sentinel = info.sentinel,
241 }}),
242 else => {},
243 },
244 .Many, .Slice => return @Type(.{ .Pointer = .{
245 .size = info.size,
246 .is_const = info.is_const,
247 .is_volatile = info.is_volatile,
248 .alignment = info.alignment,
249 .child = info.child,
250 .is_allowzero = info.is_allowzero,
251 .sentinel = sentinel_val,
252 }}),
256 .sentinel = sentinel_val,
257 },
258 }),
253259 else => {},
254260 },
255261 .Optional => |info| switch (@typeInfo(info.child)) {
256262 .Pointer => |ptr_info| switch (ptr_info.size) {
257 .Many => return @Type(.{ .Optional = .{ .child = @Type(.{ .Pointer = .{
258 .size = ptr_info.size,
259 .is_const = ptr_info.is_const,
260 .is_volatile = ptr_info.is_volatile,
261 .alignment = ptr_info.alignment,
262 .child = ptr_info.child,
263 .is_allowzero = ptr_info.is_allowzero,
264 .sentinel = sentinel_val,
265 }})}}),
263 .Many => return @Type(.{
264 .Optional = .{
265 .child = @Type(.{
266 .Pointer = .{
267 .size = ptr_info.size,
268 .is_const = ptr_info.is_const,
269 .is_volatile = ptr_info.is_volatile,
270 .alignment = ptr_info.alignment,
271 .child = ptr_info.child,
272 .is_allowzero = ptr_info.is_allowzero,
273 .sentinel = sentinel_val,
274 },
275 }),
276 },
277 }),
266278 else => {},
267279 },
268280 else => {},
......@@ -296,17 +308,17 @@ pub fn assumeSentinel(p: anytype, comptime sentinel_val: Elem(@TypeOf(p))) Senti
296308}
297309
298310test "std.meta.assumeSentinel" {
299 testing.expect([*:0]u8 == @TypeOf(assumeSentinel(@as([*]u8 , undefined), 0)));
300 testing.expect([:0]u8 == @TypeOf(assumeSentinel(@as([]u8 , undefined), 0)));
301 testing.expect([*:0]const u8 == @TypeOf(assumeSentinel(@as([*]const u8, undefined), 0)));
302 testing.expect([:0]const u8 == @TypeOf(assumeSentinel(@as([]const u8 , undefined), 0)));
303 testing.expect([*:0]u16 == @TypeOf(assumeSentinel(@as([*]u16 , undefined), 0)));
304 testing.expect([:0]const u16 == @TypeOf(assumeSentinel(@as([]const u16, undefined), 0)));
305 testing.expect([*:3]u8 == @TypeOf(assumeSentinel(@as([*:1]u8 , undefined), 3)));
306 testing.expect([:null]?[*]u8 == @TypeOf(assumeSentinel(@as([]?[*]u8 , undefined), null)));
307 testing.expect([*:null]?[*]u8 == @TypeOf(assumeSentinel(@as([*]?[*]u8 , undefined), null)));
308 testing.expect(*[10:0]u8 == @TypeOf(assumeSentinel(@as(*[10]u8 , undefined), 0)));
309 testing.expect(?[*:0]u8 == @TypeOf(assumeSentinel(@as(?[*]u8 , undefined), 0)));
311 testing.expect([*:0]u8 == @TypeOf(assumeSentinel(@as([*]u8, undefined), 0)));
312 testing.expect([:0]u8 == @TypeOf(assumeSentinel(@as([]u8, undefined), 0)));
313 testing.expect([*:0]const u8 == @TypeOf(assumeSentinel(@as([*]const u8, undefined), 0)));
314 testing.expect([:0]const u8 == @TypeOf(assumeSentinel(@as([]const u8, undefined), 0)));
315 testing.expect([*:0]u16 == @TypeOf(assumeSentinel(@as([*]u16, undefined), 0)));
316 testing.expect([:0]const u16 == @TypeOf(assumeSentinel(@as([]const u16, undefined), 0)));
317 testing.expect([*:3]u8 == @TypeOf(assumeSentinel(@as([*:1]u8, undefined), 3)));
318 testing.expect([:null]?[*]u8 == @TypeOf(assumeSentinel(@as([]?[*]u8, undefined), null)));
319 testing.expect([*:null]?[*]u8 == @TypeOf(assumeSentinel(@as([*]?[*]u8, undefined), null)));
320 testing.expect(*[10:0]u8 == @TypeOf(assumeSentinel(@as(*[10]u8, undefined), 0)));
321 testing.expect(?[*:0]u8 == @TypeOf(assumeSentinel(@as(?[*]u8, undefined), 0)));
310322}
311323
312324pub fn containerLayout(comptime T: type) TypeInfo.ContainerLayout {
lib/std/mutex.zig+1-1
......@@ -38,7 +38,7 @@ pub const Mutex = if (builtin.single_threaded)
3838else if (builtin.os.tag == .windows)
3939 WindowsMutex
4040else if (builtin.link_libc or builtin.os.tag == .linux)
41// stack-based version of https://github.com/Amanieu/parking_lot/blob/master/core/src/word_lock.rs
41 // stack-based version of https://github.com/Amanieu/parking_lot/blob/master/core/src/word_lock.rs
4242 struct {
4343 state: usize = 0,
4444
lib/std/os/linux.zig+1-1
......@@ -50,7 +50,7 @@ pub fn getauxval(index: usize) usize {
5050
5151// Some architectures (and some syscalls) require 64bit parameters to be passed
5252// in a even-aligned register pair.
53const require_aligned_register_pair = //
53const require_aligned_register_pair =
5454 std.Target.current.cpu.arch.isMIPS() or
5555 std.Target.current.cpu.arch.isARM() or
5656 std.Target.current.cpu.arch.isThumb();
lib/std/os/linux/io_uring.zig+77-79
......@@ -31,7 +31,7 @@ pub const IO_Uring = struct {
3131 pub fn init(entries: u12, flags: u32) !IO_Uring {
3232 var params = mem.zeroInit(io_uring_params, .{
3333 .flags = flags,
34 .sq_thread_idle = 1000
34 .sq_thread_idle = 1000,
3535 });
3636 return try IO_Uring.init_params(entries, &params);
3737 }
......@@ -69,7 +69,7 @@ pub const IO_Uring = struct {
6969 // or a container seccomp policy prohibits io_uring syscalls:
7070 linux.EPERM => return error.PermissionDenied,
7171 linux.ENOSYS => return error.SystemOutdated,
72 else => |errno| return os.unexpectedErrno(errno)
72 else => |errno| return os.unexpectedErrno(errno),
7373 }
7474 const fd = @intCast(os.fd_t, res);
7575 assert(fd >= 0);
......@@ -117,12 +117,12 @@ pub const IO_Uring = struct {
117117 assert(cq.overflow.* == 0);
118118 assert(cq.cqes.len == p.cq_entries);
119119
120 return IO_Uring {
120 return IO_Uring{
121121 .fd = fd,
122122 .sq = sq,
123123 .cq = cq,
124124 .flags = p.flags,
125 .features = p.features
125 .features = p.features,
126126 };
127127 }
128128
......@@ -207,7 +207,7 @@ pub const IO_Uring = struct {
207207 // The operation was interrupted by a delivery of a signal before it could complete.
208208 // This can happen while waiting for events with IORING_ENTER_GETEVENTS:
209209 linux.EINTR => return error.SignalInterrupt,
210 else => |errno| return os.unexpectedErrno(errno)
210 else => |errno| return os.unexpectedErrno(errno),
211211 }
212212 return @intCast(u32, res);
213213 }
......@@ -369,7 +369,7 @@ pub const IO_Uring = struct {
369369 user_data: u64,
370370 fd: os.fd_t,
371371 buffer: []u8,
372 offset: u64
372 offset: u64,
373373 ) !*io_uring_sqe {
374374 const sqe = try self.get_sqe();
375375 io_uring_prep_read(sqe, fd, buffer, offset);
......@@ -384,7 +384,7 @@ pub const IO_Uring = struct {
384384 user_data: u64,
385385 fd: os.fd_t,
386386 buffer: []const u8,
387 offset: u64
387 offset: u64,
388388 ) !*io_uring_sqe {
389389 const sqe = try self.get_sqe();
390390 io_uring_prep_write(sqe, fd, buffer, offset);
......@@ -401,7 +401,7 @@ pub const IO_Uring = struct {
401401 user_data: u64,
402402 fd: os.fd_t,
403403 iovecs: []const os.iovec,
404 offset: u64
404 offset: u64,
405405 ) !*io_uring_sqe {
406406 const sqe = try self.get_sqe();
407407 io_uring_prep_readv(sqe, fd, iovecs, offset);
......@@ -418,7 +418,7 @@ pub const IO_Uring = struct {
418418 user_data: u64,
419419 fd: os.fd_t,
420420 iovecs: []const os.iovec_const,
421 offset: u64
421 offset: u64,
422422 ) !*io_uring_sqe {
423423 const sqe = try self.get_sqe();
424424 io_uring_prep_writev(sqe, fd, iovecs, offset);
......@@ -434,7 +434,7 @@ pub const IO_Uring = struct {
434434 fd: os.fd_t,
435435 addr: *os.sockaddr,
436436 addrlen: *os.socklen_t,
437 flags: u32
437 flags: u32,
438438 ) !*io_uring_sqe {
439439 const sqe = try self.get_sqe();
440440 io_uring_prep_accept(sqe, fd, addr, addrlen, flags);
......@@ -449,7 +449,7 @@ pub const IO_Uring = struct {
449449 user_data: u64,
450450 fd: os.fd_t,
451451 addr: *const os.sockaddr,
452 addrlen: os.socklen_t
452 addrlen: os.socklen_t,
453453 ) !*io_uring_sqe {
454454 const sqe = try self.get_sqe();
455455 io_uring_prep_connect(sqe, fd, addr, addrlen);
......@@ -464,7 +464,7 @@ pub const IO_Uring = struct {
464464 user_data: u64,
465465 fd: os.fd_t,
466466 buffer: []u8,
467 flags: u32
467 flags: u32,
468468 ) !*io_uring_sqe {
469469 const sqe = try self.get_sqe();
470470 io_uring_prep_recv(sqe, fd, buffer, flags);
......@@ -479,7 +479,7 @@ pub const IO_Uring = struct {
479479 user_data: u64,
480480 fd: os.fd_t,
481481 buffer: []const u8,
482 flags: u32
482 flags: u32,
483483 ) !*io_uring_sqe {
484484 const sqe = try self.get_sqe();
485485 io_uring_prep_send(sqe, fd, buffer, flags);
......@@ -495,7 +495,7 @@ pub const IO_Uring = struct {
495495 fd: os.fd_t,
496496 path: [*:0]const u8,
497497 flags: u32,
498 mode: os.mode_t
498 mode: os.mode_t,
499499 ) !*io_uring_sqe {
500500 const sqe = try self.get_sqe();
501501 io_uring_prep_openat(sqe, fd, path, flags, mode);
......@@ -529,7 +529,7 @@ pub const IO_Uring = struct {
529529 self.fd,
530530 .REGISTER_FILES,
531531 @ptrCast(*const c_void, fds.ptr),
532 @intCast(u32, fds.len)
532 @intCast(u32, fds.len),
533533 );
534534 switch (linux.getErrno(res)) {
535535 0 => {},
......@@ -548,7 +548,7 @@ pub const IO_Uring = struct {
548548 linux.ENOMEM => return error.SystemResources,
549549 // Attempt to register files on a ring already registering files or being torn down:
550550 linux.ENXIO => return error.RingShuttingDownOrAlreadyRegisteringFiles,
551 else => |errno| return os.unexpectedErrno(errno)
551 else => |errno| return os.unexpectedErrno(errno),
552552 }
553553 }
554554
......@@ -559,7 +559,7 @@ pub const IO_Uring = struct {
559559 switch (linux.getErrno(res)) {
560560 0 => {},
561561 linux.ENXIO => return error.FilesNotRegistered,
562 else => |errno| return os.unexpectedErrno(errno)
562 else => |errno| return os.unexpectedErrno(errno),
563563 }
564564 }
565565};
......@@ -581,13 +581,13 @@ pub const SubmissionQueue = struct {
581581 // This allows us to amortize the cost of the @atomicStore to `tail` across multiple SQEs.
582582 sqe_head: u32 = 0,
583583 sqe_tail: u32 = 0,
584
584
585585 pub fn init(fd: os.fd_t, p: io_uring_params) !SubmissionQueue {
586586 assert(fd >= 0);
587587 assert((p.features & linux.IORING_FEAT_SINGLE_MMAP) != 0);
588588 const size = std.math.max(
589589 p.sq_off.array + p.sq_entries * @sizeOf(u32),
590 p.cq_off.cqes + p.cq_entries * @sizeOf(io_uring_cqe)
590 p.cq_off.cqes + p.cq_entries * @sizeOf(io_uring_cqe),
591591 );
592592 const mmap = try os.mmap(
593593 null,
......@@ -620,9 +620,9 @@ pub const SubmissionQueue = struct {
620620 // see https://github.com/torvalds/linux/blob/v5.8/fs/io_uring.c#L7843-L7844.
621621 assert(
622622 p.sq_entries ==
623 @ptrCast(*u32, @alignCast(@alignOf(u32), &mmap[p.sq_off.ring_entries])).*
623 @ptrCast(*u32, @alignCast(@alignOf(u32), &mmap[p.sq_off.ring_entries])).*,
624624 );
625 return SubmissionQueue {
625 return SubmissionQueue{
626626 .head = @ptrCast(*u32, @alignCast(@alignOf(u32), &mmap[p.sq_off.head])),
627627 .tail = @ptrCast(*u32, @alignCast(@alignOf(u32), &mmap[p.sq_off.tail])),
628628 .mask = @ptrCast(*u32, @alignCast(@alignOf(u32), &mmap[p.sq_off.ring_mask])).*,
......@@ -631,7 +631,7 @@ pub const SubmissionQueue = struct {
631631 .array = array[0..p.sq_entries],
632632 .sqes = sqes[0..p.sq_entries],
633633 .mmap = mmap,
634 .mmap_sqes = mmap_sqes
634 .mmap_sqes = mmap_sqes,
635635 };
636636 }
637637
......@@ -654,18 +654,16 @@ pub const CompletionQueue = struct {
654654 const mmap = sq.mmap;
655655 const cqes = @ptrCast(
656656 [*]io_uring_cqe,
657 @alignCast(@alignOf(io_uring_cqe), &mmap[p.cq_off.cqes])
657 @alignCast(@alignOf(io_uring_cqe), &mmap[p.cq_off.cqes]),
658658 );
659 assert(
660 p.cq_entries ==
661 @ptrCast(*u32, @alignCast(@alignOf(u32), &mmap[p.cq_off.ring_entries])).*
662 );
663 return CompletionQueue {
659 assert(p.cq_entries ==
660 @ptrCast(*u32, @alignCast(@alignOf(u32), &mmap[p.cq_off.ring_entries])).*);
661 return CompletionQueue{
664662 .head = @ptrCast(*u32, @alignCast(@alignOf(u32), &mmap[p.cq_off.head])),
665663 .tail = @ptrCast(*u32, @alignCast(@alignOf(u32), &mmap[p.cq_off.tail])),
666664 .mask = @ptrCast(*u32, @alignCast(@alignOf(u32), &mmap[p.cq_off.ring_mask])).*,
667665 .overflow = @ptrCast(*u32, @alignCast(@alignOf(u32), &mmap[p.cq_off.overflow])),
668 .cqes = cqes[0..p.cq_entries]
666 .cqes = cqes[0..p.cq_entries],
669667 };
670668 }
671669
......@@ -689,7 +687,7 @@ pub fn io_uring_prep_nop(sqe: *io_uring_sqe) void {
689687 .buf_index = 0,
690688 .personality = 0,
691689 .splice_fd_in = 0,
692 .__pad2 = [2]u64{ 0, 0 }
690 .__pad2 = [2]u64{ 0, 0 },
693691 };
694692}
695693
......@@ -707,7 +705,7 @@ pub fn io_uring_prep_fsync(sqe: *io_uring_sqe, fd: os.fd_t, flags: u32) void {
707705 .buf_index = 0,
708706 .personality = 0,
709707 .splice_fd_in = 0,
710 .__pad2 = [2]u64{ 0, 0 }
708 .__pad2 = [2]u64{ 0, 0 },
711709 };
712710}
713711
......@@ -717,7 +715,7 @@ pub fn io_uring_prep_rw(
717715 fd: os.fd_t,
718716 addr: anytype,
719717 len: usize,
720 offset: u64
718 offset: u64,
721719) void {
722720 sqe.* = .{
723721 .opcode = op,
......@@ -732,7 +730,7 @@ pub fn io_uring_prep_rw(
732730 .buf_index = 0,
733731 .personality = 0,
734732 .splice_fd_in = 0,
735 .__pad2 = [2]u64{ 0, 0 }
733 .__pad2 = [2]u64{ 0, 0 },
736734 };
737735}
738736
......@@ -748,7 +746,7 @@ pub fn io_uring_prep_readv(
748746 sqe: *io_uring_sqe,
749747 fd: os.fd_t,
750748 iovecs: []const os.iovec,
751 offset: u64
749 offset: u64,
752750) void {
753751 io_uring_prep_rw(.READV, sqe, fd, iovecs.ptr, iovecs.len, offset);
754752}
......@@ -757,7 +755,7 @@ pub fn io_uring_prep_writev(
757755 sqe: *io_uring_sqe,
758756 fd: os.fd_t,
759757 iovecs: []const os.iovec_const,
760 offset: u64
758 offset: u64,
761759) void {
762760 io_uring_prep_rw(.WRITEV, sqe, fd, iovecs.ptr, iovecs.len, offset);
763761}
......@@ -767,7 +765,7 @@ pub fn io_uring_prep_accept(
767765 fd: os.fd_t,
768766 addr: *os.sockaddr,
769767 addrlen: *os.socklen_t,
770 flags: u32
768 flags: u32,
771769) void {
772770 // `addr` holds a pointer to `sockaddr`, and `addr2` holds a pointer to socklen_t`.
773771 // `addr2` maps to `sqe.off` (u64) instead of `sqe.len` (which is only a u32).
......@@ -779,7 +777,7 @@ pub fn io_uring_prep_connect(
779777 sqe: *io_uring_sqe,
780778 fd: os.fd_t,
781779 addr: *const os.sockaddr,
782 addrlen: os.socklen_t
780 addrlen: os.socklen_t,
783781) void {
784782 // `addrlen` maps to `sqe.off` (u64) instead of `sqe.len` (which is only a u32).
785783 io_uring_prep_rw(.CONNECT, sqe, fd, addr, 0, addrlen);
......@@ -800,7 +798,7 @@ pub fn io_uring_prep_openat(
800798 fd: os.fd_t,
801799 path: [*:0]const u8,
802800 flags: u32,
803 mode: os.mode_t
801 mode: os.mode_t,
804802) void {
805803 io_uring_prep_rw(.OPENAT, sqe, fd, path, mode, 0);
806804 sqe.rw_flags = flags;
......@@ -820,7 +818,7 @@ pub fn io_uring_prep_close(sqe: *io_uring_sqe, fd: os.fd_t) void {
820818 .buf_index = 0,
821819 .personality = 0,
822820 .splice_fd_in = 0,
823 .__pad2 = [2]u64{ 0, 0 }
821 .__pad2 = [2]u64{ 0, 0 },
824822 };
825823}
826824
......@@ -845,7 +843,7 @@ test "nop" {
845843 var ring = IO_Uring.init(1, 0) catch |err| switch (err) {
846844 error.SystemOutdated => return error.SkipZigTest,
847845 error.PermissionDenied => return error.SkipZigTest,
848 else => return err
846 else => return err,
849847 };
850848 defer {
851849 ring.deinit();
......@@ -853,7 +851,7 @@ test "nop" {
853851 }
854852
855853 const sqe = try ring.nop(0xaaaaaaaa);
856 testing.expectEqual(io_uring_sqe {
854 testing.expectEqual(io_uring_sqe{
857855 .opcode = .NOP,
858856 .flags = 0,
859857 .ioprio = 0,
......@@ -866,7 +864,7 @@ test "nop" {
866864 .buf_index = 0,
867865 .personality = 0,
868866 .splice_fd_in = 0,
869 .__pad2 = [2]u64{ 0, 0 }
867 .__pad2 = [2]u64{ 0, 0 },
870868 }, sqe.*);
871869
872870 testing.expectEqual(@as(u32, 0), ring.sq.sqe_head);
......@@ -883,10 +881,10 @@ test "nop" {
883881 testing.expectEqual(@as(u32, 0), ring.cq.head.*);
884882 testing.expectEqual(@as(u32, 0), ring.sq_ready());
885883
886 testing.expectEqual(io_uring_cqe {
884 testing.expectEqual(io_uring_cqe{
887885 .user_data = 0xaaaaaaaa,
888886 .res = 0,
889 .flags = 0
887 .flags = 0,
890888 }, try ring.copy_cqe());
891889 testing.expectEqual(@as(u32, 1), ring.cq.head.*);
892890 testing.expectEqual(@as(u32, 0), ring.cq_ready());
......@@ -894,10 +892,10 @@ test "nop" {
894892 const sqe_barrier = try ring.nop(0xbbbbbbbb);
895893 sqe_barrier.flags |= linux.IOSQE_IO_DRAIN;
896894 testing.expectEqual(@as(u32, 1), try ring.submit());
897 testing.expectEqual(io_uring_cqe {
895 testing.expectEqual(io_uring_cqe{
898896 .user_data = 0xbbbbbbbb,
899897 .res = 0,
900 .flags = 0
898 .flags = 0,
901899 }, try ring.copy_cqe());
902900 testing.expectEqual(@as(u32, 2), ring.sq.sqe_head);
903901 testing.expectEqual(@as(u32, 2), ring.sq.sqe_tail);
......@@ -911,7 +909,7 @@ test "readv" {
911909 var ring = IO_Uring.init(1, 0) catch |err| switch (err) {
912910 error.SystemOutdated => return error.SkipZigTest,
913911 error.PermissionDenied => return error.SkipZigTest,
914 else => return err
912 else => return err,
915913 };
916914 defer ring.deinit();
917915
......@@ -930,14 +928,14 @@ test "readv" {
930928 try ring.register_files(registered_fds[0..]);
931929
932930 var buffer = [_]u8{42} ** 128;
933 var iovecs = [_]os.iovec{ os.iovec { .iov_base = &buffer, .iov_len = buffer.len } };
931 var iovecs = [_]os.iovec{os.iovec{ .iov_base = &buffer, .iov_len = buffer.len }};
934932 const sqe = try ring.readv(0xcccccccc, fd_index, iovecs[0..], 0);
935933 testing.expectEqual(linux.IORING_OP.READV, sqe.opcode);
936934 sqe.flags |= linux.IOSQE_FIXED_FILE;
937935
938936 testing.expectError(error.SubmissionQueueFull, ring.nop(0));
939937 testing.expectEqual(@as(u32, 1), try ring.submit());
940 testing.expectEqual(linux.io_uring_cqe {
938 testing.expectEqual(linux.io_uring_cqe{
941939 .user_data = 0xcccccccc,
942940 .res = buffer.len,
943941 .flags = 0,
......@@ -953,10 +951,10 @@ test "writev/fsync/readv" {
953951 var ring = IO_Uring.init(4, 0) catch |err| switch (err) {
954952 error.SystemOutdated => return error.SkipZigTest,
955953 error.PermissionDenied => return error.SkipZigTest,
956 else => return err
954 else => return err,
957955 };
958956 defer ring.deinit();
959
957
960958 const path = "test_io_uring_writev_fsync_readv";
961959 const file = try std.fs.cwd().createFile(path, .{ .read = true, .truncate = true });
962960 defer file.close();
......@@ -964,19 +962,19 @@ test "writev/fsync/readv" {
964962 const fd = file.handle;
965963
966964 const buffer_write = [_]u8{42} ** 128;
967 const iovecs_write = [_]os.iovec_const {
968 os.iovec_const { .iov_base = &buffer_write, .iov_len = buffer_write.len }
965 const iovecs_write = [_]os.iovec_const{
966 os.iovec_const{ .iov_base = &buffer_write, .iov_len = buffer_write.len },
969967 };
970968 var buffer_read = [_]u8{0} ** 128;
971 var iovecs_read = [_]os.iovec {
972 os.iovec { .iov_base = &buffer_read, .iov_len = buffer_read.len }
969 var iovecs_read = [_]os.iovec{
970 os.iovec{ .iov_base = &buffer_read, .iov_len = buffer_read.len },
973971 };
974972
975973 const sqe_writev = try ring.writev(0xdddddddd, fd, iovecs_write[0..], 17);
976974 testing.expectEqual(linux.IORING_OP.WRITEV, sqe_writev.opcode);
977975 testing.expectEqual(@as(u64, 17), sqe_writev.off);
978976 sqe_writev.flags |= linux.IOSQE_IO_LINK;
979
977
980978 const sqe_fsync = try ring.fsync(0xeeeeeeee, fd, 0);
981979 testing.expectEqual(linux.IORING_OP.FSYNC, sqe_fsync.opcode);
982980 testing.expectEqual(fd, sqe_fsync.fd);
......@@ -991,21 +989,21 @@ test "writev/fsync/readv" {
991989 testing.expectEqual(@as(u32, 0), ring.sq_ready());
992990 testing.expectEqual(@as(u32, 3), ring.cq_ready());
993991
994 testing.expectEqual(linux.io_uring_cqe {
992 testing.expectEqual(linux.io_uring_cqe{
995993 .user_data = 0xdddddddd,
996994 .res = buffer_write.len,
997995 .flags = 0,
998996 }, try ring.copy_cqe());
999997 testing.expectEqual(@as(u32, 2), ring.cq_ready());
1000
1001 testing.expectEqual(linux.io_uring_cqe {
998
999 testing.expectEqual(linux.io_uring_cqe{
10021000 .user_data = 0xeeeeeeee,
10031001 .res = 0,
10041002 .flags = 0,
10051003 }, try ring.copy_cqe());
10061004 testing.expectEqual(@as(u32, 1), ring.cq_ready());
10071005
1008 testing.expectEqual(linux.io_uring_cqe {
1006 testing.expectEqual(linux.io_uring_cqe{
10091007 .user_data = 0xffffffff,
10101008 .res = buffer_read.len,
10111009 .flags = 0,
......@@ -1021,10 +1019,10 @@ test "write/read" {
10211019 var ring = IO_Uring.init(2, 0) catch |err| switch (err) {
10221020 error.SystemOutdated => return error.SkipZigTest,
10231021 error.PermissionDenied => return error.SkipZigTest,
1024 else => return err
1022 else => return err,
10251023 };
10261024 defer ring.deinit();
1027
1025
10281026 const path = "test_io_uring_write_read";
10291027 const file = try std.fs.cwd().createFile(path, .{ .read = true, .truncate = true });
10301028 defer file.close();
......@@ -1048,12 +1046,12 @@ test "write/read" {
10481046 // https://lwn.net/Articles/809820/
10491047 if (cqe_write.res == -linux.EINVAL) return error.SkipZigTest;
10501048 if (cqe_read.res == -linux.EINVAL) return error.SkipZigTest;
1051 testing.expectEqual(linux.io_uring_cqe {
1049 testing.expectEqual(linux.io_uring_cqe{
10521050 .user_data = 0x11111111,
10531051 .res = buffer_write.len,
10541052 .flags = 0,
10551053 }, cqe_write);
1056 testing.expectEqual(linux.io_uring_cqe {
1054 testing.expectEqual(linux.io_uring_cqe{
10571055 .user_data = 0x22222222,
10581056 .res = buffer_read.len,
10591057 .flags = 0,
......@@ -1067,7 +1065,7 @@ test "openat" {
10671065 var ring = IO_Uring.init(1, 0) catch |err| switch (err) {
10681066 error.SystemOutdated => return error.SkipZigTest,
10691067 error.PermissionDenied => return error.SkipZigTest,
1070 else => return err
1068 else => return err,
10711069 };
10721070 defer ring.deinit();
10731071
......@@ -1077,7 +1075,7 @@ test "openat" {
10771075 const flags: u32 = os.O_CLOEXEC | os.O_RDWR | os.O_CREAT;
10781076 const mode: os.mode_t = 0o666;
10791077 const sqe_openat = try ring.openat(0x33333333, linux.AT_FDCWD, path, flags, mode);
1080 testing.expectEqual(io_uring_sqe {
1078 testing.expectEqual(io_uring_sqe{
10811079 .opcode = .OPENAT,
10821080 .flags = 0,
10831081 .ioprio = 0,
......@@ -1090,7 +1088,7 @@ test "openat" {
10901088 .buf_index = 0,
10911089 .personality = 0,
10921090 .splice_fd_in = 0,
1093 .__pad2 = [2]u64{ 0, 0 }
1091 .__pad2 = [2]u64{ 0, 0 },
10941092 }, sqe_openat.*);
10951093 testing.expectEqual(@as(u32, 1), try ring.submit());
10961094
......@@ -1103,7 +1101,7 @@ test "openat" {
11031101 if (cqe_openat.res == -linux.EBADF and (ring.features & linux.IORING_FEAT_RW_CUR_POS) == 0) {
11041102 return error.SkipZigTest;
11051103 }
1106 if (cqe_openat.res <= 0) std.debug.print("\ncqe_openat.res={}\n", .{ cqe_openat.res });
1104 if (cqe_openat.res <= 0) std.debug.print("\ncqe_openat.res={}\n", .{cqe_openat.res});
11071105 testing.expect(cqe_openat.res > 0);
11081106 testing.expectEqual(@as(u32, 0), cqe_openat.flags);
11091107
......@@ -1112,14 +1110,14 @@ test "openat" {
11121110
11131111test "close" {
11141112 if (builtin.os.tag != .linux) return error.SkipZigTest;
1115
1113
11161114 var ring = IO_Uring.init(1, 0) catch |err| switch (err) {
11171115 error.SystemOutdated => return error.SkipZigTest,
11181116 error.PermissionDenied => return error.SkipZigTest,
1119 else => return err
1117 else => return err,
11201118 };
11211119 defer ring.deinit();
1122
1120
11231121 const path = "test_io_uring_close";
11241122 const file = try std.fs.cwd().createFile(path, .{});
11251123 errdefer file.close();
......@@ -1132,7 +1130,7 @@ test "close" {
11321130
11331131 const cqe_close = try ring.copy_cqe();
11341132 if (cqe_close.res == -linux.EINVAL) return error.SkipZigTest;
1135 testing.expectEqual(linux.io_uring_cqe {
1133 testing.expectEqual(linux.io_uring_cqe{
11361134 .user_data = 0x44444444,
11371135 .res = 0,
11381136 .flags = 0,
......@@ -1145,7 +1143,7 @@ test "accept/connect/send/recv" {
11451143 var ring = IO_Uring.init(16, 0) catch |err| switch (err) {
11461144 error.SystemOutdated => return error.SkipZigTest,
11471145 error.PermissionDenied => return error.SkipZigTest,
1148 else => return err
1146 else => return err,
11491147 };
11501148 defer ring.deinit();
11511149
......@@ -1157,8 +1155,8 @@ test "accept/connect/send/recv" {
11571155 try os.bind(server, &address.any, address.getOsSockLen());
11581156 try os.listen(server, kernel_backlog);
11591157
1160 const buffer_send = [_]u8{ 1,0,1,0,1,0,1,0,1,0 };
1161 var buffer_recv = [_]u8{ 0,1,0,1,0 };
1158 const buffer_send = [_]u8{ 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 };
1159 var buffer_recv = [_]u8{ 0, 1, 0, 1, 0 };
11621160
11631161 var accept_addr: os.sockaddr = undefined;
11641162 var accept_addr_len: os.socklen_t = @sizeOf(@TypeOf(accept_addr));
......@@ -1184,10 +1182,10 @@ test "accept/connect/send/recv" {
11841182 }
11851183
11861184 testing.expectEqual(@as(u64, 0xaaaaaaaa), cqe_accept.user_data);
1187 if (cqe_accept.res <= 0) std.debug.print("\ncqe_accept.res={}\n", .{ cqe_accept.res });
1185 if (cqe_accept.res <= 0) std.debug.print("\ncqe_accept.res={}\n", .{cqe_accept.res});
11881186 testing.expect(cqe_accept.res > 0);
11891187 testing.expectEqual(@as(u32, 0), cqe_accept.flags);
1190 testing.expectEqual(linux.io_uring_cqe {
1188 testing.expectEqual(linux.io_uring_cqe{
11911189 .user_data = 0xcccccccc,
11921190 .res = 0,
11931191 .flags = 0,
......@@ -1200,7 +1198,7 @@ test "accept/connect/send/recv" {
12001198
12011199 const cqe_send = try ring.copy_cqe();
12021200 if (cqe_send.res == -linux.EINVAL) return error.SkipZigTest;
1203 testing.expectEqual(linux.io_uring_cqe {
1201 testing.expectEqual(linux.io_uring_cqe{
12041202 .user_data = 0xeeeeeeee,
12051203 .res = buffer_send.len,
12061204 .flags = 0,
......@@ -1208,7 +1206,7 @@ test "accept/connect/send/recv" {
12081206
12091207 const cqe_recv = try ring.copy_cqe();
12101208 if (cqe_recv.res == -linux.EINVAL) return error.SkipZigTest;
1211 testing.expectEqual(linux.io_uring_cqe {
1209 testing.expectEqual(linux.io_uring_cqe{
12121210 .user_data = 0xffffffff,
12131211 .res = buffer_recv.len,
12141212 .flags = 0,
lib/std/os/linux/test.zig+1-1
......@@ -24,7 +24,7 @@ test "fallocate" {
2424 0 => {},
2525 linux.ENOSYS => return error.SkipZigTest,
2626 linux.EOPNOTSUPP => return error.SkipZigTest,
27 else => |errno| std.debug.panic("unhandled errno: {}", .{ errno }),
27 else => |errno| std.debug.panic("unhandled errno: {}", .{errno}),
2828 }
2929
3030 expect((try file.stat()).size == len);
lib/std/os/windows.zig+2-2
......@@ -570,13 +570,13 @@ pub fn SetCurrentDirectory(path_name: []const u16) SetCurrentDirectoryError!void
570570 const path_len_bytes = math.cast(u16, path_name.len * 2) catch |err| switch (err) {
571571 error.Overflow => return error.NameTooLong,
572572 };
573
573
574574 var nt_name = UNICODE_STRING{
575575 .Length = path_len_bytes,
576576 .MaximumLength = path_len_bytes,
577577 .Buffer = @intToPtr([*]u16, @ptrToInt(path_name.ptr)),
578578 };
579
579
580580 const rc = ntdll.RtlSetCurrentDirectory_U(&nt_name);
581581 switch (rc) {
582582 .SUCCESS => {},
lib/std/os/windows/ntdll.zig+1-3
......@@ -112,6 +112,4 @@ pub extern "NtDll" fn NtWaitForKeyedEvent(
112112 Timeout: ?*LARGE_INTEGER,
113113) callconv(WINAPI) NTSTATUS;
114114
115pub extern "NtDll" fn RtlSetCurrentDirectory_U(
116 PathName: *UNICODE_STRING
117) callconv(WINAPI) NTSTATUS;
115pub extern "NtDll" fn RtlSetCurrentDirectory_U(PathName: *UNICODE_STRING) callconv(WINAPI) NTSTATUS;
lib/std/priority_queue.zig+1-2
......@@ -468,7 +468,6 @@ test "std.PriorityQueue: update min heap" {
468468 expectEqual(@as(u32, 5), queue.remove());
469469}
470470
471
472471test "std.PriorityQueue: update same min heap" {
473472 var queue = PQ.init(testing.allocator, lessThan);
474473 defer queue.deinit();
......@@ -514,4 +513,4 @@ test "std.PriorityQueue: update same max heap" {
514513 expectEqual(@as(u32, 4), queue.remove());
515514 expectEqual(@as(u32, 2), queue.remove());
516515 expectEqual(@as(u32, 1), queue.remove());
517}
\ No newline at end of file
516}
lib/std/zig/parser_test.zig+47-1
......@@ -274,6 +274,51 @@ test "recovery: missing block after for/while loops" {
274274 });
275275}
276276
277test "zig fmt: respect line breaks after var declarations" {
278 try testCanonical(
279 \\const crc =
280 \\ lookup_tables[0][p[7]] ^
281 \\ lookup_tables[1][p[6]] ^
282 \\ lookup_tables[2][p[5]] ^
283 \\ lookup_tables[3][p[4]] ^
284 \\ lookup_tables[4][@truncate(u8, self.crc >> 24)] ^
285 \\ lookup_tables[5][@truncate(u8, self.crc >> 16)] ^
286 \\ lookup_tables[6][@truncate(u8, self.crc >> 8)] ^
287 \\ lookup_tables[7][@truncate(u8, self.crc >> 0)];
288 \\
289 );
290}
291
292test "zig fmt: multiline string mixed with comments" {
293 try testCanonical(
294 \\const s1 =
295 \\ //\\one
296 \\ \\two)
297 \\ \\three
298 \\;
299 \\const s2 =
300 \\ \\one
301 \\ \\two)
302 \\ //\\three
303 \\;
304 \\const s3 =
305 \\ \\one
306 \\ //\\two)
307 \\ \\three
308 \\;
309 \\const s4 =
310 \\ \\one
311 \\ //\\two
312 \\ \\three
313 \\ //\\four
314 \\ \\five
315 \\;
316 \\const a =
317 \\ 1;
318 \\
319 );
320}
321
277322test "zig fmt: empty file" {
278323 try testCanonical(
279324 \\
......@@ -3224,7 +3269,8 @@ test "zig fmt: integer literals with underscore separators" {
32243269 \\ 1_234_567
32253270 \\ +(0b0_1-0o7_0+0xff_FF ) + 0_0;
32263271 ,
3227 \\const x = 1_234_567 + (0b0_1 - 0o7_0 + 0xff_FF) + 0_0;
3272 \\const x =
3273 \\ 1_234_567 + (0b0_1 - 0o7_0 + 0xff_FF) + 0_0;
32283274 \\
32293275 );
32303276}
lib/std/zig/render.zig+25-19
......@@ -2209,10 +2209,10 @@ fn renderAsmOutput(
22092209 try ais.writer().writeAll(" (");
22102210
22112211 switch (asm_output.kind) {
2212 ast.Node.Asm.Output.Kind.Variable => |variable_name| {
2212 .Variable => |variable_name| {
22132213 try renderExpression(allocator, ais, tree, &variable_name.base, Space.None);
22142214 },
2215 ast.Node.Asm.Output.Kind.Return => |return_type| {
2215 .Return => |return_type| {
22162216 try ais.writer().writeAll("-> ");
22172217 try renderExpression(allocator, ais, tree, return_type, Space.None);
22182218 },
......@@ -2304,8 +2304,17 @@ fn renderVarDecl(
23042304 }
23052305
23062306 if (var_decl.getInitNode()) |init_node| {
2307 const s = if (init_node.tag == .MultilineStringLiteral) Space.None else Space.Space;
2308 try renderToken(tree, ais, var_decl.getEqToken().?, s); // =
2307 const eq_token = var_decl.getEqToken().?;
2308 const eq_space = blk: {
2309 const loc = tree.tokenLocation(tree.token_locs[eq_token].end, tree.nextToken(eq_token));
2310 break :blk if (loc.line == 0) Space.Space else Space.Newline;
2311 };
2312
2313 {
2314 ais.pushIndent();
2315 defer ais.popIndent();
2316 try renderToken(tree, ais, eq_token, eq_space); // =
2317 }
23092318 ais.pushIndentOneShot();
23102319 try renderExpression(allocator, ais, tree, init_node, Space.None);
23112320 }
......@@ -2470,20 +2479,20 @@ fn renderTokenOffset(
24702479
24712480 var loc = tree.tokenLocationLoc(token_loc.end, next_token_loc);
24722481 if (loc.line == 0) {
2473 try ais.writer().print(" {}", .{mem.trimRight(u8, tree.tokenSliceLoc(next_token_loc), " ")});
2482 if (tree.token_ids[token_index] != .MultilineStringLiteralLine) {
2483 try ais.writer().writeByte(' ');
2484 }
2485 try ais.writer().writeAll(mem.trimRight(u8, tree.tokenSliceLoc(next_token_loc), " "));
24742486 offset = 2;
24752487 token_loc = next_token_loc;
24762488 next_token_loc = tree.token_locs[token_index + offset];
24772489 next_token_id = tree.token_ids[token_index + offset];
24782490 if (next_token_id != .LineComment) {
24792491 switch (space) {
2480 Space.None, Space.Space => {
2481 try ais.insertNewline();
2482 },
2483 Space.SpaceOrOutdent => {
2492 .None, .Space, .SpaceOrOutdent => {
24842493 try ais.insertNewline();
24852494 },
2486 Space.Newline => {
2495 .Newline => {
24872496 if (next_token_id == .MultilineStringLiteralLine) {
24882497 return;
24892498 } else {
......@@ -2491,8 +2500,8 @@ fn renderTokenOffset(
24912500 return;
24922501 }
24932502 },
2494 Space.NoNewline => {},
2495 Space.NoComment, Space.Comma, Space.BlockStart => unreachable,
2503 .NoNewline => {},
2504 .NoComment, .Comma, .BlockStart => unreachable,
24962505 }
24972506 return;
24982507 }
......@@ -2513,7 +2522,7 @@ fn renderTokenOffset(
25132522 next_token_id = tree.token_ids[token_index + offset];
25142523 if (next_token_id != .LineComment) {
25152524 switch (space) {
2516 Space.Newline => {
2525 .Newline => {
25172526 if (next_token_id == .MultilineStringLiteralLine) {
25182527 return;
25192528 } else {
......@@ -2521,14 +2530,11 @@ fn renderTokenOffset(
25212530 return;
25222531 }
25232532 },
2524 Space.None, Space.Space => {
2525 try ais.insertNewline();
2526 },
2527 Space.SpaceOrOutdent => {
2533 .None, .Space, .SpaceOrOutdent => {
25282534 try ais.insertNewline();
25292535 },
2530 Space.NoNewline => {},
2531 Space.NoComment, Space.Comma, Space.BlockStart => unreachable,
2536 .NoNewline => {},
2537 .NoComment, .Comma, .BlockStart => unreachable,
25322538 }
25332539 return;
25342540 }
lib/std/zig/system.zig+2-2
......@@ -212,7 +212,7 @@ pub const NativeTargetInfo = struct {
212212 const uts = std.os.uname();
213213 const release = mem.spanZ(&uts.release);
214214 // The release field sometimes has a weird format,
215 // `Version.parse` will attempt to find some meaningful interpretation.
215 // `Version.parse` will attempt to find some meaningful interpretation.
216216 if (std.builtin.Version.parse(release)) |ver| {
217217 os.version_range.linux.range.min = ver;
218218 os.version_range.linux.range.max = ver;
......@@ -237,7 +237,7 @@ pub const NativeTargetInfo = struct {
237237 // `---` `` ``--> Sub-version (Starting from Windows 10 onwards)
238238 // \ `--> Service pack (Always zero in the constants defined)
239239 // `--> OS version (Major & minor)
240 const os_ver: u16 = //
240 const os_ver: u16 =
241241 @intCast(u16, version_info.dwMajorVersion & 0xff) << 8 |
242242 @intCast(u16, version_info.dwMinorVersion & 0xff);
243243 const sp_ver: u8 = 0;
src/link.zig+2-2
......@@ -572,11 +572,11 @@ pub const File = struct {
572572
573573 if (!base.options.disable_lld_caching) {
574574 Cache.writeSmallFile(directory.handle, id_symlink_basename, &digest) catch |err| {
575 std.log.warn("failed to save archive hash digest file: {}", .{@errorName(err)});
575 log.warn("failed to save archive hash digest file: {}", .{@errorName(err)});
576576 };
577577
578578 man.writeManifest() catch |err| {
579 std.log.warn("failed to write cache manifest when archiving: {}", .{@errorName(err)});
579 log.warn("failed to write cache manifest when archiving: {}", .{@errorName(err)});
580580 };
581581
582582 base.lock = man.toOwnedLock();
src/link/Coff.zig+3-3
......@@ -1205,7 +1205,7 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void {
12051205 }
12061206
12071207 if (stderr.len != 0) {
1208 std.log.warn("unexpected LLD stderr:\n{s}", .{stderr});
1208 log.warn("unexpected LLD stderr:\n{s}", .{stderr});
12091209 }
12101210 }
12111211 }
......@@ -1214,11 +1214,11 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void {
12141214 // Update the file with the digest. If it fails we can continue; it only
12151215 // means that the next invocation will have an unnecessary cache miss.
12161216 Cache.writeSmallFile(directory.handle, id_symlink_basename, &digest) catch |err| {
1217 std.log.warn("failed to save linking hash digest file: {}", .{@errorName(err)});
1217 log.warn("failed to save linking hash digest file: {}", .{@errorName(err)});
12181218 };
12191219 // Again failure here only means an unnecessary cache miss.
12201220 man.writeManifest() catch |err| {
1221 std.log.warn("failed to write cache manifest when linking: {}", .{@errorName(err)});
1221 log.warn("failed to write cache manifest when linking: {}", .{@errorName(err)});
12221222 };
12231223 // We hang on to this lock so that the output file path can be used without
12241224 // other processes clobbering it.
src/link/Elf.zig+3-3
......@@ -1684,7 +1684,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
16841684 }
16851685
16861686 if (stderr.len != 0) {
1687 std.log.warn("unexpected LLD stderr:\n{s}", .{stderr});
1687 log.warn("unexpected LLD stderr:\n{s}", .{stderr});
16881688 }
16891689 }
16901690
......@@ -1692,11 +1692,11 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
16921692 // Update the file with the digest. If it fails we can continue; it only
16931693 // means that the next invocation will have an unnecessary cache miss.
16941694 Cache.writeSmallFile(directory.handle, id_symlink_basename, &digest) catch |err| {
1695 std.log.warn("failed to save linking hash digest file: {}", .{@errorName(err)});
1695 log.warn("failed to save linking hash digest file: {}", .{@errorName(err)});
16961696 };
16971697 // Again failure here only means an unnecessary cache miss.
16981698 man.writeManifest() catch |err| {
1699 std.log.warn("failed to write cache manifest when linking: {}", .{@errorName(err)});
1699 log.warn("failed to write cache manifest when linking: {}", .{@errorName(err)});
17001700 };
17011701 // We hang on to this lock so that the output file path can be used without
17021702 // other processes clobbering it.
src/link/MachO.zig+10-10
......@@ -673,15 +673,15 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
673673 self.base.allocator.free(result.stderr);
674674 }
675675 if (result.stdout.len != 0) {
676 std.log.warn("unexpected LD stdout: {}", .{result.stdout});
676 log.warn("unexpected LD stdout: {}", .{result.stdout});
677677 }
678678 if (result.stderr.len != 0) {
679 std.log.warn("unexpected LD stderr: {}", .{result.stderr});
679 log.warn("unexpected LD stderr: {}", .{result.stderr});
680680 }
681681 if (result.term != .Exited or result.term.Exited != 0) {
682682 // TODO parse this output and surface with the Compilation API rather than
683683 // directly outputting to stderr here.
684 std.log.err("{}", .{result.stderr});
684 log.err("{}", .{result.stderr});
685685 return error.LDReportedFailure;
686686 }
687687 } else {
......@@ -738,7 +738,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
738738 }
739739
740740 if (stderr.len != 0) {
741 std.log.warn("unexpected LLD stderr:\n{s}", .{stderr});
741 log.warn("unexpected LLD stderr:\n{s}", .{stderr});
742742 }
743743 }
744744
......@@ -757,10 +757,10 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
757757 // TODO We are in the position to be able to increase the padding by moving all sections
758758 // by the required offset, but this requires a little bit more thinking and bookkeeping.
759759 // For now, return an error informing the user of the problem.
760 std.log.err("Not enough padding between load commands and start of __text section:\n", .{});
761 std.log.err("Offset after last load command: 0x{x}\n", .{after_last_cmd_offset});
762 std.log.err("Beginning of __text section: 0x{x}\n", .{text_section.offset});
763 std.log.err("Needed size: 0x{x}\n", .{needed_size});
760 log.err("Not enough padding between load commands and start of __text section:\n", .{});
761 log.err("Offset after last load command: 0x{x}\n", .{after_last_cmd_offset});
762 log.err("Beginning of __text section: 0x{x}\n", .{text_section.offset});
763 log.err("Needed size: 0x{x}\n", .{needed_size});
764764 return error.NotEnoughPadding;
765765 }
766766 const linkedit_segment = self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
......@@ -792,11 +792,11 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
792792 // Update the file with the digest. If it fails we can continue; it only
793793 // means that the next invocation will have an unnecessary cache miss.
794794 Cache.writeSmallFile(directory.handle, id_symlink_basename, &digest) catch |err| {
795 std.log.warn("failed to save linking hash digest file: {}", .{@errorName(err)});
795 log.warn("failed to save linking hash digest file: {}", .{@errorName(err)});
796796 };
797797 // Again failure here only means an unnecessary cache miss.
798798 man.writeManifest() catch |err| {
799 std.log.warn("failed to write cache manifest when linking: {}", .{@errorName(err)});
799 log.warn("failed to write cache manifest when linking: {}", .{@errorName(err)});
800800 };
801801 // We hang on to this lock so that the output file path can be used without
802802 // other processes clobbering it.
src/link/Wasm.zig+3-3
......@@ -455,7 +455,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void {
455455 }
456456
457457 if (stderr.len != 0) {
458 std.log.warn("unexpected LLD stderr:\n{s}", .{stderr});
458 log.warn("unexpected LLD stderr:\n{s}", .{stderr});
459459 }
460460 }
461461
......@@ -463,11 +463,11 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void {
463463 // Update the file with the digest. If it fails we can continue; it only
464464 // means that the next invocation will have an unnecessary cache miss.
465465 Cache.writeSmallFile(directory.handle, id_symlink_basename, &digest) catch |err| {
466 std.log.warn("failed to save linking hash digest symlink: {}", .{@errorName(err)});
466 log.warn("failed to save linking hash digest symlink: {}", .{@errorName(err)});
467467 };
468468 // Again failure here only means an unnecessary cache miss.
469469 man.writeManifest() catch |err| {
470 std.log.warn("failed to write cache manifest when linking: {}", .{@errorName(err)});
470 log.warn("failed to write cache manifest when linking: {}", .{@errorName(err)});
471471 };
472472 // We hang on to this lock so that the output file path can be used without
473473 // other processes clobbering it.
src/stage1/analyze.cpp+1-6
......@@ -3936,12 +3936,6 @@ void update_compile_var(CodeGen *g, Buf *name, ZigValue *value) {
39363936
39373937void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) {
39383938 switch (node->type) {
3939 case NodeTypeContainerDecl:
3940 for (size_t i = 0; i < node->data.container_decl.decls.length; i += 1) {
3941 AstNode *child = node->data.container_decl.decls.at(i);
3942 scan_decls(g, decls_scope, child);
3943 }
3944 break;
39453939 case NodeTypeFnDef:
39463940 scan_decls(g, decls_scope, node->data.fn_def.fn_proto);
39473941 break;
......@@ -3986,6 +3980,7 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) {
39863980 case NodeTypeCompTime:
39873981 preview_comptime_decl(g, node, decls_scope);
39883982 break;
3983 case NodeTypeContainerDecl:
39893984 case NodeTypeNoSuspend:
39903985 case NodeTypeParamDecl:
39913986 case NodeTypeReturnExpr:
src/stage1/ir.cpp-18
......@@ -25310,24 +25310,6 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInst* source_instr, ZigVa
2531025310 }
2531125311
2531225312 inner_fields[2]->data.x_union.payload = fn_decl_val;
25313 break;
25314 }
25315 case TldIdContainer:
25316 {
25317 ZigType *type_entry = ((TldContainer *)curr_entry->value)->type_entry;
25318 if ((err = type_resolve(ira->codegen, type_entry, ResolveStatusSizeKnown)))
25319 return ErrorSemanticAnalyzeFail;
25320
25321 // This is a type.
25322 bigint_init_unsigned(&inner_fields[2]->data.x_union.tag, 0);
25323
25324 ZigValue *payload = ira->codegen->pass1_arena->create<ZigValue>();
25325 payload->special = ConstValSpecialStatic;
25326 payload->type = ira->codegen->builtin_types.entry_type;
25327 payload->data.x_type = type_entry;
25328
25329 inner_fields[2]->data.x_union.payload = payload;
25330
2533125313 break;
2533225314 }
2533325315 default:
test/stage1/behavior/vector.zig+4-4
......@@ -550,8 +550,8 @@ test "vector reduce operation" {
550550 // LLVM 11 ERROR: Cannot select type
551551 // https://github.com/ziglang/zig/issues/7138
552552 if (std.builtin.arch != .aarch64) {
553 doTheTestReduce(.Min, [4]i64{ 1234567, -386, 0, 3 }, @as(i64, -386));
554 doTheTestReduce(.Min, [4]u64{ 99, 9999, 9, 99999 }, @as(u64, 9));
553 doTheTestReduce(.Min, [4]i64{ 1234567, -386, 0, 3 }, @as(i64, -386));
554 doTheTestReduce(.Min, [4]u64{ 99, 9999, 9, 99999 }, @as(u64, 9));
555555 }
556556
557557 doTheTestReduce(.Min, [4]i128{ 1234567, -386, 0, 3 }, @as(i128, -386));
......@@ -568,8 +568,8 @@ test "vector reduce operation" {
568568 // LLVM 11 ERROR: Cannot select type
569569 // https://github.com/ziglang/zig/issues/7138
570570 if (std.builtin.arch != .aarch64) {
571 doTheTestReduce(.Max, [4]i64{ 1234567, -386, 0, 3 }, @as(i64, 1234567));
572 doTheTestReduce(.Max, [4]u64{ 99, 9999, 9, 99999 }, @as(u64, 99999));
571 doTheTestReduce(.Max, [4]i64{ 1234567, -386, 0, 3 }, @as(i64, 1234567));
572 doTheTestReduce(.Max, [4]u64{ 99, 9999, 9, 99999 }, @as(u64, 99999));
573573 }
574574
575575 doTheTestReduce(.Max, [4]i128{ 1234567, -386, 0, 3 }, @as(i128, 1234567));