| author | |
| committer | |
| log | f2911948341e1ba1fc03ba2678eaf0a3c4508fa3 |
| tree | 7a32f0ddd22c822456ae360f73ff7f51dbe023df |
| parent | 676e416c86e2977f76b0cc1b9d3bc2b7ac6d7936 |
| parent | 7e30e8390044fbd396966b6e21d2de980d6f915f |
| signature |
zig fmt improvement and small miscellaneous fixes25 files changed, 251 insertions(+), 215 deletions(-)
lib/std/auto_reset_event.zig+6-8| ... | ... | @@ -30,10 +30,8 @@ pub const AutoResetEvent = struct { |
| 30 | 30 | // std.ResetEvent.wait() | |
| 31 | 31 | // | std.ResetEvent.set() |
| 32 | 32 | // | std.ResetEvent.set() |
| 33 | // std.ResetEvent.reset() | | |
| 33 | // std.ResetEvent.reset() | | |
| 34 | 34 | // std.ResetEvent.wait() | (missed the second .set() notification above) |
| 35 | ||
| 36 | ||
| 37 | 35 | state: usize = UNSET, |
| 38 | 36 | |
| 39 | 37 | const UNSET = 0; |
| ... | ... | @@ -70,7 +68,7 @@ pub const AutoResetEvent = struct { |
| 70 | 68 | if (state != UNSET) { |
| 71 | 69 | unreachable; // multiple waiting threads on the same AutoResetEvent |
| 72 | 70 | } |
| 73 | ||
| 71 | ||
| 74 | 72 | // lazily initialize the ResetEvent if it hasn't been already |
| 75 | 73 | if (!has_reset_event) { |
| 76 | 74 | has_reset_event = true; |
| ... | ... | @@ -78,7 +76,7 @@ pub const AutoResetEvent = struct { |
| 78 | 76 | } |
| 79 | 77 | |
| 80 | 78 | // 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 | |
| 82 | 80 | // for a set() call from another thread. |
| 83 | 81 | if (@cmpxchgWeak( |
| 84 | 82 | usize, |
| ... | ... | @@ -121,7 +119,7 @@ pub const AutoResetEvent = struct { |
| 121 | 119 | unreachable; // multiple waiting threads on the same AutoResetEvent observed when timing out |
| 122 | 120 | } |
| 123 | 121 | |
| 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. | |
| 125 | 123 | // We need to wait for it to wake up our ResetEvent before we can return and invalidate it. |
| 126 | 124 | // We don't return error.TimedOut here as it technically notified us while we were "timing out". |
| 127 | 125 | reset_event.wait(); |
| ... | ... | @@ -137,7 +135,7 @@ pub const AutoResetEvent = struct { |
| 137 | 135 | return; |
| 138 | 136 | } |
| 139 | 137 | |
| 140 | // If the AutoResetEvent isn't set, | |
| 138 | // If the AutoResetEvent isn't set, | |
| 141 | 139 | // then try to leave a notification for the wait() thread that we set() it. |
| 142 | 140 | if (state == UNSET) { |
| 143 | 141 | state = @cmpxchgWeak( |
| ... | ... | @@ -226,4 +224,4 @@ test "std.AutoResetEvent" { |
| 226 | 224 | |
| 227 | 225 | send_thread.wait(); |
| 228 | 226 | 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 { |
| 34 | 34 | }; |
| 35 | 35 | |
| 36 | 36 | pub 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 { |
| 316 | 316 | comptime { |
| 317 | 317 | @setEvalBranchQuota(100000); |
| 318 | 318 | |
| 319 | const len_lengths = // | |
| 319 | const len_lengths = | |
| 320 | 320 | [_]u16{8} ** 144 ++ |
| 321 | 321 | [_]u16{9} ** 112 ++ |
| 322 | 322 | [_]u16{7} ** 24 ++ |
lib/std/hash_map.zig+1-1| ... | ... | @@ -1127,7 +1127,7 @@ test "std.hash_map put" { |
| 1127 | 1127 | test "std.hash_map putAssumeCapacity" { |
| 1128 | 1128 | var map = AutoHashMap(u32, u32).init(std.testing.allocator); |
| 1129 | 1129 | defer map.deinit(); |
| 1130 | ||
| 1130 | ||
| 1131 | 1131 | try map.ensureCapacity(20); |
| 1132 | 1132 | var i: u32 = 0; |
| 1133 | 1133 | 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 { |
| 184 | 184 | const total_requested_bytes_init = if (config.enable_memory_limit) @as(usize, 0) else {}; |
| 185 | 185 | const requested_memory_limit_init = if (config.enable_memory_limit) @as(usize, math.maxInt(usize)) else {}; |
| 186 | 186 | |
| 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{}; | |
| 189 | 193 | |
| 190 | 194 | const stack_n = config.stack_trace_frames; |
| 191 | 195 | const one_trace_size = @sizeOf(usize) * stack_n; |
| ... | ... | @@ -865,9 +869,9 @@ test "realloc large object to small object" { |
| 865 | 869 | } |
| 866 | 870 | |
| 867 | 871 | test "overrideable mutexes" { |
| 868 | var gpa = GeneralPurposeAllocator(.{.MutexType = std.Mutex}){ | |
| 872 | var gpa = GeneralPurposeAllocator(.{ .MutexType = std.Mutex }){ | |
| 869 | 873 | .backing_allocator = std.testing.allocator, |
| 870 | .mutex = std.Mutex{} | |
| 874 | .mutex = std.Mutex{}, | |
| 871 | 875 | }; |
| 872 | 876 | defer std.testing.expect(!gpa.deinit()); |
| 873 | 877 | const allocator = &gpa.allocator; |
lib/std/macho.zig-1| ... | ... | @@ -42,7 +42,6 @@ pub const uuid_command = extern struct { |
| 42 | 42 | uuid: [16]u8, |
| 43 | 43 | }; |
| 44 | 44 | |
| 45 | ||
| 46 | 45 | /// The version_min_command contains the min OS version on which this |
| 47 | 46 | /// binary was built to run. |
| 48 | 47 | pub 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 { |
| 226 | 226 | switch (@typeInfo(T)) { |
| 227 | 227 | .Pointer => |info| switch (info.size) { |
| 228 | 228 | .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 = .{ | |
| 230 | 250 | .size = info.size, |
| 231 | 251 | .is_const = info.is_const, |
| 232 | 252 | .is_volatile = info.is_volatile, |
| 233 | 253 | .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, | |
| 239 | 255 | .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 | }), | |
| 253 | 259 | else => {}, |
| 254 | 260 | }, |
| 255 | 261 | .Optional => |info| switch (@typeInfo(info.child)) { |
| 256 | 262 | .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 | }), | |
| 266 | 278 | else => {}, |
| 267 | 279 | }, |
| 268 | 280 | else => {}, |
| ... | ... | @@ -296,17 +308,17 @@ pub fn assumeSentinel(p: anytype, comptime sentinel_val: Elem(@TypeOf(p))) Senti |
| 296 | 308 | } |
| 297 | 309 | |
| 298 | 310 | test "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))); | |
| 310 | 322 | } |
| 311 | 323 | |
| 312 | 324 | pub fn containerLayout(comptime T: type) TypeInfo.ContainerLayout { |
lib/std/mutex.zig+1-1| ... | ... | @@ -38,7 +38,7 @@ pub const Mutex = if (builtin.single_threaded) |
| 38 | 38 | else if (builtin.os.tag == .windows) |
| 39 | 39 | WindowsMutex |
| 40 | 40 | else 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 | |
| 42 | 42 | struct { |
| 43 | 43 | state: usize = 0, |
| 44 | 44 |
lib/std/os/linux.zig+1-1| ... | ... | @@ -50,7 +50,7 @@ pub fn getauxval(index: usize) usize { |
| 50 | 50 | |
| 51 | 51 | // Some architectures (and some syscalls) require 64bit parameters to be passed |
| 52 | 52 | // in a even-aligned register pair. |
| 53 | const require_aligned_register_pair = // | |
| 53 | const require_aligned_register_pair = | |
| 54 | 54 | std.Target.current.cpu.arch.isMIPS() or |
| 55 | 55 | std.Target.current.cpu.arch.isARM() or |
| 56 | 56 | std.Target.current.cpu.arch.isThumb(); |
lib/std/os/linux/io_uring.zig+77-79| ... | ... | @@ -31,7 +31,7 @@ pub const IO_Uring = struct { |
| 31 | 31 | pub fn init(entries: u12, flags: u32) !IO_Uring { |
| 32 | 32 | var params = mem.zeroInit(io_uring_params, .{ |
| 33 | 33 | .flags = flags, |
| 34 | .sq_thread_idle = 1000 | |
| 34 | .sq_thread_idle = 1000, | |
| 35 | 35 | }); |
| 36 | 36 | return try IO_Uring.init_params(entries, &params); |
| 37 | 37 | } |
| ... | ... | @@ -69,7 +69,7 @@ pub const IO_Uring = struct { |
| 69 | 69 | // or a container seccomp policy prohibits io_uring syscalls: |
| 70 | 70 | linux.EPERM => return error.PermissionDenied, |
| 71 | 71 | linux.ENOSYS => return error.SystemOutdated, |
| 72 | else => |errno| return os.unexpectedErrno(errno) | |
| 72 | else => |errno| return os.unexpectedErrno(errno), | |
| 73 | 73 | } |
| 74 | 74 | const fd = @intCast(os.fd_t, res); |
| 75 | 75 | assert(fd >= 0); |
| ... | ... | @@ -117,12 +117,12 @@ pub const IO_Uring = struct { |
| 117 | 117 | assert(cq.overflow.* == 0); |
| 118 | 118 | assert(cq.cqes.len == p.cq_entries); |
| 119 | 119 | |
| 120 | return IO_Uring { | |
| 120 | return IO_Uring{ | |
| 121 | 121 | .fd = fd, |
| 122 | 122 | .sq = sq, |
| 123 | 123 | .cq = cq, |
| 124 | 124 | .flags = p.flags, |
| 125 | .features = p.features | |
| 125 | .features = p.features, | |
| 126 | 126 | }; |
| 127 | 127 | } |
| 128 | 128 | |
| ... | ... | @@ -207,7 +207,7 @@ pub const IO_Uring = struct { |
| 207 | 207 | // The operation was interrupted by a delivery of a signal before it could complete. |
| 208 | 208 | // This can happen while waiting for events with IORING_ENTER_GETEVENTS: |
| 209 | 209 | linux.EINTR => return error.SignalInterrupt, |
| 210 | else => |errno| return os.unexpectedErrno(errno) | |
| 210 | else => |errno| return os.unexpectedErrno(errno), | |
| 211 | 211 | } |
| 212 | 212 | return @intCast(u32, res); |
| 213 | 213 | } |
| ... | ... | @@ -369,7 +369,7 @@ pub const IO_Uring = struct { |
| 369 | 369 | user_data: u64, |
| 370 | 370 | fd: os.fd_t, |
| 371 | 371 | buffer: []u8, |
| 372 | offset: u64 | |
| 372 | offset: u64, | |
| 373 | 373 | ) !*io_uring_sqe { |
| 374 | 374 | const sqe = try self.get_sqe(); |
| 375 | 375 | io_uring_prep_read(sqe, fd, buffer, offset); |
| ... | ... | @@ -384,7 +384,7 @@ pub const IO_Uring = struct { |
| 384 | 384 | user_data: u64, |
| 385 | 385 | fd: os.fd_t, |
| 386 | 386 | buffer: []const u8, |
| 387 | offset: u64 | |
| 387 | offset: u64, | |
| 388 | 388 | ) !*io_uring_sqe { |
| 389 | 389 | const sqe = try self.get_sqe(); |
| 390 | 390 | io_uring_prep_write(sqe, fd, buffer, offset); |
| ... | ... | @@ -401,7 +401,7 @@ pub const IO_Uring = struct { |
| 401 | 401 | user_data: u64, |
| 402 | 402 | fd: os.fd_t, |
| 403 | 403 | iovecs: []const os.iovec, |
| 404 | offset: u64 | |
| 404 | offset: u64, | |
| 405 | 405 | ) !*io_uring_sqe { |
| 406 | 406 | const sqe = try self.get_sqe(); |
| 407 | 407 | io_uring_prep_readv(sqe, fd, iovecs, offset); |
| ... | ... | @@ -418,7 +418,7 @@ pub const IO_Uring = struct { |
| 418 | 418 | user_data: u64, |
| 419 | 419 | fd: os.fd_t, |
| 420 | 420 | iovecs: []const os.iovec_const, |
| 421 | offset: u64 | |
| 421 | offset: u64, | |
| 422 | 422 | ) !*io_uring_sqe { |
| 423 | 423 | const sqe = try self.get_sqe(); |
| 424 | 424 | io_uring_prep_writev(sqe, fd, iovecs, offset); |
| ... | ... | @@ -434,7 +434,7 @@ pub const IO_Uring = struct { |
| 434 | 434 | fd: os.fd_t, |
| 435 | 435 | addr: *os.sockaddr, |
| 436 | 436 | addrlen: *os.socklen_t, |
| 437 | flags: u32 | |
| 437 | flags: u32, | |
| 438 | 438 | ) !*io_uring_sqe { |
| 439 | 439 | const sqe = try self.get_sqe(); |
| 440 | 440 | io_uring_prep_accept(sqe, fd, addr, addrlen, flags); |
| ... | ... | @@ -449,7 +449,7 @@ pub const IO_Uring = struct { |
| 449 | 449 | user_data: u64, |
| 450 | 450 | fd: os.fd_t, |
| 451 | 451 | addr: *const os.sockaddr, |
| 452 | addrlen: os.socklen_t | |
| 452 | addrlen: os.socklen_t, | |
| 453 | 453 | ) !*io_uring_sqe { |
| 454 | 454 | const sqe = try self.get_sqe(); |
| 455 | 455 | io_uring_prep_connect(sqe, fd, addr, addrlen); |
| ... | ... | @@ -464,7 +464,7 @@ pub const IO_Uring = struct { |
| 464 | 464 | user_data: u64, |
| 465 | 465 | fd: os.fd_t, |
| 466 | 466 | buffer: []u8, |
| 467 | flags: u32 | |
| 467 | flags: u32, | |
| 468 | 468 | ) !*io_uring_sqe { |
| 469 | 469 | const sqe = try self.get_sqe(); |
| 470 | 470 | io_uring_prep_recv(sqe, fd, buffer, flags); |
| ... | ... | @@ -479,7 +479,7 @@ pub const IO_Uring = struct { |
| 479 | 479 | user_data: u64, |
| 480 | 480 | fd: os.fd_t, |
| 481 | 481 | buffer: []const u8, |
| 482 | flags: u32 | |
| 482 | flags: u32, | |
| 483 | 483 | ) !*io_uring_sqe { |
| 484 | 484 | const sqe = try self.get_sqe(); |
| 485 | 485 | io_uring_prep_send(sqe, fd, buffer, flags); |
| ... | ... | @@ -495,7 +495,7 @@ pub const IO_Uring = struct { |
| 495 | 495 | fd: os.fd_t, |
| 496 | 496 | path: [*:0]const u8, |
| 497 | 497 | flags: u32, |
| 498 | mode: os.mode_t | |
| 498 | mode: os.mode_t, | |
| 499 | 499 | ) !*io_uring_sqe { |
| 500 | 500 | const sqe = try self.get_sqe(); |
| 501 | 501 | io_uring_prep_openat(sqe, fd, path, flags, mode); |
| ... | ... | @@ -529,7 +529,7 @@ pub const IO_Uring = struct { |
| 529 | 529 | self.fd, |
| 530 | 530 | .REGISTER_FILES, |
| 531 | 531 | @ptrCast(*const c_void, fds.ptr), |
| 532 | @intCast(u32, fds.len) | |
| 532 | @intCast(u32, fds.len), | |
| 533 | 533 | ); |
| 534 | 534 | switch (linux.getErrno(res)) { |
| 535 | 535 | 0 => {}, |
| ... | ... | @@ -548,7 +548,7 @@ pub const IO_Uring = struct { |
| 548 | 548 | linux.ENOMEM => return error.SystemResources, |
| 549 | 549 | // Attempt to register files on a ring already registering files or being torn down: |
| 550 | 550 | linux.ENXIO => return error.RingShuttingDownOrAlreadyRegisteringFiles, |
| 551 | else => |errno| return os.unexpectedErrno(errno) | |
| 551 | else => |errno| return os.unexpectedErrno(errno), | |
| 552 | 552 | } |
| 553 | 553 | } |
| 554 | 554 | |
| ... | ... | @@ -559,7 +559,7 @@ pub const IO_Uring = struct { |
| 559 | 559 | switch (linux.getErrno(res)) { |
| 560 | 560 | 0 => {}, |
| 561 | 561 | linux.ENXIO => return error.FilesNotRegistered, |
| 562 | else => |errno| return os.unexpectedErrno(errno) | |
| 562 | else => |errno| return os.unexpectedErrno(errno), | |
| 563 | 563 | } |
| 564 | 564 | } |
| 565 | 565 | }; |
| ... | ... | @@ -581,13 +581,13 @@ pub const SubmissionQueue = struct { |
| 581 | 581 | // This allows us to amortize the cost of the @atomicStore to `tail` across multiple SQEs. |
| 582 | 582 | sqe_head: u32 = 0, |
| 583 | 583 | sqe_tail: u32 = 0, |
| 584 | ||
| 584 | ||
| 585 | 585 | pub fn init(fd: os.fd_t, p: io_uring_params) !SubmissionQueue { |
| 586 | 586 | assert(fd >= 0); |
| 587 | 587 | assert((p.features & linux.IORING_FEAT_SINGLE_MMAP) != 0); |
| 588 | 588 | const size = std.math.max( |
| 589 | 589 | 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), | |
| 591 | 591 | ); |
| 592 | 592 | const mmap = try os.mmap( |
| 593 | 593 | null, |
| ... | ... | @@ -620,9 +620,9 @@ pub const SubmissionQueue = struct { |
| 620 | 620 | // see https://github.com/torvalds/linux/blob/v5.8/fs/io_uring.c#L7843-L7844. |
| 621 | 621 | assert( |
| 622 | 622 | 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])).*, | |
| 624 | 624 | ); |
| 625 | return SubmissionQueue { | |
| 625 | return SubmissionQueue{ | |
| 626 | 626 | .head = @ptrCast(*u32, @alignCast(@alignOf(u32), &mmap[p.sq_off.head])), |
| 627 | 627 | .tail = @ptrCast(*u32, @alignCast(@alignOf(u32), &mmap[p.sq_off.tail])), |
| 628 | 628 | .mask = @ptrCast(*u32, @alignCast(@alignOf(u32), &mmap[p.sq_off.ring_mask])).*, |
| ... | ... | @@ -631,7 +631,7 @@ pub const SubmissionQueue = struct { |
| 631 | 631 | .array = array[0..p.sq_entries], |
| 632 | 632 | .sqes = sqes[0..p.sq_entries], |
| 633 | 633 | .mmap = mmap, |
| 634 | .mmap_sqes = mmap_sqes | |
| 634 | .mmap_sqes = mmap_sqes, | |
| 635 | 635 | }; |
| 636 | 636 | } |
| 637 | 637 | |
| ... | ... | @@ -654,18 +654,16 @@ pub const CompletionQueue = struct { |
| 654 | 654 | const mmap = sq.mmap; |
| 655 | 655 | const cqes = @ptrCast( |
| 656 | 656 | [*]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]), | |
| 658 | 658 | ); |
| 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{ | |
| 664 | 662 | .head = @ptrCast(*u32, @alignCast(@alignOf(u32), &mmap[p.cq_off.head])), |
| 665 | 663 | .tail = @ptrCast(*u32, @alignCast(@alignOf(u32), &mmap[p.cq_off.tail])), |
| 666 | 664 | .mask = @ptrCast(*u32, @alignCast(@alignOf(u32), &mmap[p.cq_off.ring_mask])).*, |
| 667 | 665 | .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], | |
| 669 | 667 | }; |
| 670 | 668 | } |
| 671 | 669 | |
| ... | ... | @@ -689,7 +687,7 @@ pub fn io_uring_prep_nop(sqe: *io_uring_sqe) void { |
| 689 | 687 | .buf_index = 0, |
| 690 | 688 | .personality = 0, |
| 691 | 689 | .splice_fd_in = 0, |
| 692 | .__pad2 = [2]u64{ 0, 0 } | |
| 690 | .__pad2 = [2]u64{ 0, 0 }, | |
| 693 | 691 | }; |
| 694 | 692 | } |
| 695 | 693 | |
| ... | ... | @@ -707,7 +705,7 @@ pub fn io_uring_prep_fsync(sqe: *io_uring_sqe, fd: os.fd_t, flags: u32) void { |
| 707 | 705 | .buf_index = 0, |
| 708 | 706 | .personality = 0, |
| 709 | 707 | .splice_fd_in = 0, |
| 710 | .__pad2 = [2]u64{ 0, 0 } | |
| 708 | .__pad2 = [2]u64{ 0, 0 }, | |
| 711 | 709 | }; |
| 712 | 710 | } |
| 713 | 711 | |
| ... | ... | @@ -717,7 +715,7 @@ pub fn io_uring_prep_rw( |
| 717 | 715 | fd: os.fd_t, |
| 718 | 716 | addr: anytype, |
| 719 | 717 | len: usize, |
| 720 | offset: u64 | |
| 718 | offset: u64, | |
| 721 | 719 | ) void { |
| 722 | 720 | sqe.* = .{ |
| 723 | 721 | .opcode = op, |
| ... | ... | @@ -732,7 +730,7 @@ pub fn io_uring_prep_rw( |
| 732 | 730 | .buf_index = 0, |
| 733 | 731 | .personality = 0, |
| 734 | 732 | .splice_fd_in = 0, |
| 735 | .__pad2 = [2]u64{ 0, 0 } | |
| 733 | .__pad2 = [2]u64{ 0, 0 }, | |
| 736 | 734 | }; |
| 737 | 735 | } |
| 738 | 736 | |
| ... | ... | @@ -748,7 +746,7 @@ pub fn io_uring_prep_readv( |
| 748 | 746 | sqe: *io_uring_sqe, |
| 749 | 747 | fd: os.fd_t, |
| 750 | 748 | iovecs: []const os.iovec, |
| 751 | offset: u64 | |
| 749 | offset: u64, | |
| 752 | 750 | ) void { |
| 753 | 751 | io_uring_prep_rw(.READV, sqe, fd, iovecs.ptr, iovecs.len, offset); |
| 754 | 752 | } |
| ... | ... | @@ -757,7 +755,7 @@ pub fn io_uring_prep_writev( |
| 757 | 755 | sqe: *io_uring_sqe, |
| 758 | 756 | fd: os.fd_t, |
| 759 | 757 | iovecs: []const os.iovec_const, |
| 760 | offset: u64 | |
| 758 | offset: u64, | |
| 761 | 759 | ) void { |
| 762 | 760 | io_uring_prep_rw(.WRITEV, sqe, fd, iovecs.ptr, iovecs.len, offset); |
| 763 | 761 | } |
| ... | ... | @@ -767,7 +765,7 @@ pub fn io_uring_prep_accept( |
| 767 | 765 | fd: os.fd_t, |
| 768 | 766 | addr: *os.sockaddr, |
| 769 | 767 | addrlen: *os.socklen_t, |
| 770 | flags: u32 | |
| 768 | flags: u32, | |
| 771 | 769 | ) void { |
| 772 | 770 | // `addr` holds a pointer to `sockaddr`, and `addr2` holds a pointer to socklen_t`. |
| 773 | 771 | // `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( |
| 779 | 777 | sqe: *io_uring_sqe, |
| 780 | 778 | fd: os.fd_t, |
| 781 | 779 | addr: *const os.sockaddr, |
| 782 | addrlen: os.socklen_t | |
| 780 | addrlen: os.socklen_t, | |
| 783 | 781 | ) void { |
| 784 | 782 | // `addrlen` maps to `sqe.off` (u64) instead of `sqe.len` (which is only a u32). |
| 785 | 783 | io_uring_prep_rw(.CONNECT, sqe, fd, addr, 0, addrlen); |
| ... | ... | @@ -800,7 +798,7 @@ pub fn io_uring_prep_openat( |
| 800 | 798 | fd: os.fd_t, |
| 801 | 799 | path: [*:0]const u8, |
| 802 | 800 | flags: u32, |
| 803 | mode: os.mode_t | |
| 801 | mode: os.mode_t, | |
| 804 | 802 | ) void { |
| 805 | 803 | io_uring_prep_rw(.OPENAT, sqe, fd, path, mode, 0); |
| 806 | 804 | sqe.rw_flags = flags; |
| ... | ... | @@ -820,7 +818,7 @@ pub fn io_uring_prep_close(sqe: *io_uring_sqe, fd: os.fd_t) void { |
| 820 | 818 | .buf_index = 0, |
| 821 | 819 | .personality = 0, |
| 822 | 820 | .splice_fd_in = 0, |
| 823 | .__pad2 = [2]u64{ 0, 0 } | |
| 821 | .__pad2 = [2]u64{ 0, 0 }, | |
| 824 | 822 | }; |
| 825 | 823 | } |
| 826 | 824 | |
| ... | ... | @@ -845,7 +843,7 @@ test "nop" { |
| 845 | 843 | var ring = IO_Uring.init(1, 0) catch |err| switch (err) { |
| 846 | 844 | error.SystemOutdated => return error.SkipZigTest, |
| 847 | 845 | error.PermissionDenied => return error.SkipZigTest, |
| 848 | else => return err | |
| 846 | else => return err, | |
| 849 | 847 | }; |
| 850 | 848 | defer { |
| 851 | 849 | ring.deinit(); |
| ... | ... | @@ -853,7 +851,7 @@ test "nop" { |
| 853 | 851 | } |
| 854 | 852 | |
| 855 | 853 | const sqe = try ring.nop(0xaaaaaaaa); |
| 856 | testing.expectEqual(io_uring_sqe { | |
| 854 | testing.expectEqual(io_uring_sqe{ | |
| 857 | 855 | .opcode = .NOP, |
| 858 | 856 | .flags = 0, |
| 859 | 857 | .ioprio = 0, |
| ... | ... | @@ -866,7 +864,7 @@ test "nop" { |
| 866 | 864 | .buf_index = 0, |
| 867 | 865 | .personality = 0, |
| 868 | 866 | .splice_fd_in = 0, |
| 869 | .__pad2 = [2]u64{ 0, 0 } | |
| 867 | .__pad2 = [2]u64{ 0, 0 }, | |
| 870 | 868 | }, sqe.*); |
| 871 | 869 | |
| 872 | 870 | testing.expectEqual(@as(u32, 0), ring.sq.sqe_head); |
| ... | ... | @@ -883,10 +881,10 @@ test "nop" { |
| 883 | 881 | testing.expectEqual(@as(u32, 0), ring.cq.head.*); |
| 884 | 882 | testing.expectEqual(@as(u32, 0), ring.sq_ready()); |
| 885 | 883 | |
| 886 | testing.expectEqual(io_uring_cqe { | |
| 884 | testing.expectEqual(io_uring_cqe{ | |
| 887 | 885 | .user_data = 0xaaaaaaaa, |
| 888 | 886 | .res = 0, |
| 889 | .flags = 0 | |
| 887 | .flags = 0, | |
| 890 | 888 | }, try ring.copy_cqe()); |
| 891 | 889 | testing.expectEqual(@as(u32, 1), ring.cq.head.*); |
| 892 | 890 | testing.expectEqual(@as(u32, 0), ring.cq_ready()); |
| ... | ... | @@ -894,10 +892,10 @@ test "nop" { |
| 894 | 892 | const sqe_barrier = try ring.nop(0xbbbbbbbb); |
| 895 | 893 | sqe_barrier.flags |= linux.IOSQE_IO_DRAIN; |
| 896 | 894 | testing.expectEqual(@as(u32, 1), try ring.submit()); |
| 897 | testing.expectEqual(io_uring_cqe { | |
| 895 | testing.expectEqual(io_uring_cqe{ | |
| 898 | 896 | .user_data = 0xbbbbbbbb, |
| 899 | 897 | .res = 0, |
| 900 | .flags = 0 | |
| 898 | .flags = 0, | |
| 901 | 899 | }, try ring.copy_cqe()); |
| 902 | 900 | testing.expectEqual(@as(u32, 2), ring.sq.sqe_head); |
| 903 | 901 | testing.expectEqual(@as(u32, 2), ring.sq.sqe_tail); |
| ... | ... | @@ -911,7 +909,7 @@ test "readv" { |
| 911 | 909 | var ring = IO_Uring.init(1, 0) catch |err| switch (err) { |
| 912 | 910 | error.SystemOutdated => return error.SkipZigTest, |
| 913 | 911 | error.PermissionDenied => return error.SkipZigTest, |
| 914 | else => return err | |
| 912 | else => return err, | |
| 915 | 913 | }; |
| 916 | 914 | defer ring.deinit(); |
| 917 | 915 | |
| ... | ... | @@ -930,14 +928,14 @@ test "readv" { |
| 930 | 928 | try ring.register_files(registered_fds[0..]); |
| 931 | 929 | |
| 932 | 930 | 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 }}; | |
| 934 | 932 | const sqe = try ring.readv(0xcccccccc, fd_index, iovecs[0..], 0); |
| 935 | 933 | testing.expectEqual(linux.IORING_OP.READV, sqe.opcode); |
| 936 | 934 | sqe.flags |= linux.IOSQE_FIXED_FILE; |
| 937 | 935 | |
| 938 | 936 | testing.expectError(error.SubmissionQueueFull, ring.nop(0)); |
| 939 | 937 | testing.expectEqual(@as(u32, 1), try ring.submit()); |
| 940 | testing.expectEqual(linux.io_uring_cqe { | |
| 938 | testing.expectEqual(linux.io_uring_cqe{ | |
| 941 | 939 | .user_data = 0xcccccccc, |
| 942 | 940 | .res = buffer.len, |
| 943 | 941 | .flags = 0, |
| ... | ... | @@ -953,10 +951,10 @@ test "writev/fsync/readv" { |
| 953 | 951 | var ring = IO_Uring.init(4, 0) catch |err| switch (err) { |
| 954 | 952 | error.SystemOutdated => return error.SkipZigTest, |
| 955 | 953 | error.PermissionDenied => return error.SkipZigTest, |
| 956 | else => return err | |
| 954 | else => return err, | |
| 957 | 955 | }; |
| 958 | 956 | defer ring.deinit(); |
| 959 | ||
| 957 | ||
| 960 | 958 | const path = "test_io_uring_writev_fsync_readv"; |
| 961 | 959 | const file = try std.fs.cwd().createFile(path, .{ .read = true, .truncate = true }); |
| 962 | 960 | defer file.close(); |
| ... | ... | @@ -964,19 +962,19 @@ test "writev/fsync/readv" { |
| 964 | 962 | const fd = file.handle; |
| 965 | 963 | |
| 966 | 964 | 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 }, | |
| 969 | 967 | }; |
| 970 | 968 | 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 }, | |
| 973 | 971 | }; |
| 974 | 972 | |
| 975 | 973 | const sqe_writev = try ring.writev(0xdddddddd, fd, iovecs_write[0..], 17); |
| 976 | 974 | testing.expectEqual(linux.IORING_OP.WRITEV, sqe_writev.opcode); |
| 977 | 975 | testing.expectEqual(@as(u64, 17), sqe_writev.off); |
| 978 | 976 | sqe_writev.flags |= linux.IOSQE_IO_LINK; |
| 979 | ||
| 977 | ||
| 980 | 978 | const sqe_fsync = try ring.fsync(0xeeeeeeee, fd, 0); |
| 981 | 979 | testing.expectEqual(linux.IORING_OP.FSYNC, sqe_fsync.opcode); |
| 982 | 980 | testing.expectEqual(fd, sqe_fsync.fd); |
| ... | ... | @@ -991,21 +989,21 @@ test "writev/fsync/readv" { |
| 991 | 989 | testing.expectEqual(@as(u32, 0), ring.sq_ready()); |
| 992 | 990 | testing.expectEqual(@as(u32, 3), ring.cq_ready()); |
| 993 | 991 | |
| 994 | testing.expectEqual(linux.io_uring_cqe { | |
| 992 | testing.expectEqual(linux.io_uring_cqe{ | |
| 995 | 993 | .user_data = 0xdddddddd, |
| 996 | 994 | .res = buffer_write.len, |
| 997 | 995 | .flags = 0, |
| 998 | 996 | }, try ring.copy_cqe()); |
| 999 | 997 | testing.expectEqual(@as(u32, 2), ring.cq_ready()); |
| 1000 | ||
| 1001 | testing.expectEqual(linux.io_uring_cqe { | |
| 998 | ||
| 999 | testing.expectEqual(linux.io_uring_cqe{ | |
| 1002 | 1000 | .user_data = 0xeeeeeeee, |
| 1003 | 1001 | .res = 0, |
| 1004 | 1002 | .flags = 0, |
| 1005 | 1003 | }, try ring.copy_cqe()); |
| 1006 | 1004 | testing.expectEqual(@as(u32, 1), ring.cq_ready()); |
| 1007 | 1005 | |
| 1008 | testing.expectEqual(linux.io_uring_cqe { | |
| 1006 | testing.expectEqual(linux.io_uring_cqe{ | |
| 1009 | 1007 | .user_data = 0xffffffff, |
| 1010 | 1008 | .res = buffer_read.len, |
| 1011 | 1009 | .flags = 0, |
| ... | ... | @@ -1021,10 +1019,10 @@ test "write/read" { |
| 1021 | 1019 | var ring = IO_Uring.init(2, 0) catch |err| switch (err) { |
| 1022 | 1020 | error.SystemOutdated => return error.SkipZigTest, |
| 1023 | 1021 | error.PermissionDenied => return error.SkipZigTest, |
| 1024 | else => return err | |
| 1022 | else => return err, | |
| 1025 | 1023 | }; |
| 1026 | 1024 | defer ring.deinit(); |
| 1027 | ||
| 1025 | ||
| 1028 | 1026 | const path = "test_io_uring_write_read"; |
| 1029 | 1027 | const file = try std.fs.cwd().createFile(path, .{ .read = true, .truncate = true }); |
| 1030 | 1028 | defer file.close(); |
| ... | ... | @@ -1048,12 +1046,12 @@ test "write/read" { |
| 1048 | 1046 | // https://lwn.net/Articles/809820/ |
| 1049 | 1047 | if (cqe_write.res == -linux.EINVAL) return error.SkipZigTest; |
| 1050 | 1048 | if (cqe_read.res == -linux.EINVAL) return error.SkipZigTest; |
| 1051 | testing.expectEqual(linux.io_uring_cqe { | |
| 1049 | testing.expectEqual(linux.io_uring_cqe{ | |
| 1052 | 1050 | .user_data = 0x11111111, |
| 1053 | 1051 | .res = buffer_write.len, |
| 1054 | 1052 | .flags = 0, |
| 1055 | 1053 | }, cqe_write); |
| 1056 | testing.expectEqual(linux.io_uring_cqe { | |
| 1054 | testing.expectEqual(linux.io_uring_cqe{ | |
| 1057 | 1055 | .user_data = 0x22222222, |
| 1058 | 1056 | .res = buffer_read.len, |
| 1059 | 1057 | .flags = 0, |
| ... | ... | @@ -1067,7 +1065,7 @@ test "openat" { |
| 1067 | 1065 | var ring = IO_Uring.init(1, 0) catch |err| switch (err) { |
| 1068 | 1066 | error.SystemOutdated => return error.SkipZigTest, |
| 1069 | 1067 | error.PermissionDenied => return error.SkipZigTest, |
| 1070 | else => return err | |
| 1068 | else => return err, | |
| 1071 | 1069 | }; |
| 1072 | 1070 | defer ring.deinit(); |
| 1073 | 1071 | |
| ... | ... | @@ -1077,7 +1075,7 @@ test "openat" { |
| 1077 | 1075 | const flags: u32 = os.O_CLOEXEC | os.O_RDWR | os.O_CREAT; |
| 1078 | 1076 | const mode: os.mode_t = 0o666; |
| 1079 | 1077 | 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{ | |
| 1081 | 1079 | .opcode = .OPENAT, |
| 1082 | 1080 | .flags = 0, |
| 1083 | 1081 | .ioprio = 0, |
| ... | ... | @@ -1090,7 +1088,7 @@ test "openat" { |
| 1090 | 1088 | .buf_index = 0, |
| 1091 | 1089 | .personality = 0, |
| 1092 | 1090 | .splice_fd_in = 0, |
| 1093 | .__pad2 = [2]u64{ 0, 0 } | |
| 1091 | .__pad2 = [2]u64{ 0, 0 }, | |
| 1094 | 1092 | }, sqe_openat.*); |
| 1095 | 1093 | testing.expectEqual(@as(u32, 1), try ring.submit()); |
| 1096 | 1094 | |
| ... | ... | @@ -1103,7 +1101,7 @@ test "openat" { |
| 1103 | 1101 | if (cqe_openat.res == -linux.EBADF and (ring.features & linux.IORING_FEAT_RW_CUR_POS) == 0) { |
| 1104 | 1102 | return error.SkipZigTest; |
| 1105 | 1103 | } |
| 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}); | |
| 1107 | 1105 | testing.expect(cqe_openat.res > 0); |
| 1108 | 1106 | testing.expectEqual(@as(u32, 0), cqe_openat.flags); |
| 1109 | 1107 | |
| ... | ... | @@ -1112,14 +1110,14 @@ test "openat" { |
| 1112 | 1110 | |
| 1113 | 1111 | test "close" { |
| 1114 | 1112 | if (builtin.os.tag != .linux) return error.SkipZigTest; |
| 1115 | ||
| 1113 | ||
| 1116 | 1114 | var ring = IO_Uring.init(1, 0) catch |err| switch (err) { |
| 1117 | 1115 | error.SystemOutdated => return error.SkipZigTest, |
| 1118 | 1116 | error.PermissionDenied => return error.SkipZigTest, |
| 1119 | else => return err | |
| 1117 | else => return err, | |
| 1120 | 1118 | }; |
| 1121 | 1119 | defer ring.deinit(); |
| 1122 | ||
| 1120 | ||
| 1123 | 1121 | const path = "test_io_uring_close"; |
| 1124 | 1122 | const file = try std.fs.cwd().createFile(path, .{}); |
| 1125 | 1123 | errdefer file.close(); |
| ... | ... | @@ -1132,7 +1130,7 @@ test "close" { |
| 1132 | 1130 | |
| 1133 | 1131 | const cqe_close = try ring.copy_cqe(); |
| 1134 | 1132 | if (cqe_close.res == -linux.EINVAL) return error.SkipZigTest; |
| 1135 | testing.expectEqual(linux.io_uring_cqe { | |
| 1133 | testing.expectEqual(linux.io_uring_cqe{ | |
| 1136 | 1134 | .user_data = 0x44444444, |
| 1137 | 1135 | .res = 0, |
| 1138 | 1136 | .flags = 0, |
| ... | ... | @@ -1145,7 +1143,7 @@ test "accept/connect/send/recv" { |
| 1145 | 1143 | var ring = IO_Uring.init(16, 0) catch |err| switch (err) { |
| 1146 | 1144 | error.SystemOutdated => return error.SkipZigTest, |
| 1147 | 1145 | error.PermissionDenied => return error.SkipZigTest, |
| 1148 | else => return err | |
| 1146 | else => return err, | |
| 1149 | 1147 | }; |
| 1150 | 1148 | defer ring.deinit(); |
| 1151 | 1149 | |
| ... | ... | @@ -1157,8 +1155,8 @@ test "accept/connect/send/recv" { |
| 1157 | 1155 | try os.bind(server, &address.any, address.getOsSockLen()); |
| 1158 | 1156 | try os.listen(server, kernel_backlog); |
| 1159 | 1157 | |
| 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 }; | |
| 1162 | 1160 | |
| 1163 | 1161 | var accept_addr: os.sockaddr = undefined; |
| 1164 | 1162 | var accept_addr_len: os.socklen_t = @sizeOf(@TypeOf(accept_addr)); |
| ... | ... | @@ -1184,10 +1182,10 @@ test "accept/connect/send/recv" { |
| 1184 | 1182 | } |
| 1185 | 1183 | |
| 1186 | 1184 | 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}); | |
| 1188 | 1186 | testing.expect(cqe_accept.res > 0); |
| 1189 | 1187 | testing.expectEqual(@as(u32, 0), cqe_accept.flags); |
| 1190 | testing.expectEqual(linux.io_uring_cqe { | |
| 1188 | testing.expectEqual(linux.io_uring_cqe{ | |
| 1191 | 1189 | .user_data = 0xcccccccc, |
| 1192 | 1190 | .res = 0, |
| 1193 | 1191 | .flags = 0, |
| ... | ... | @@ -1200,7 +1198,7 @@ test "accept/connect/send/recv" { |
| 1200 | 1198 | |
| 1201 | 1199 | const cqe_send = try ring.copy_cqe(); |
| 1202 | 1200 | if (cqe_send.res == -linux.EINVAL) return error.SkipZigTest; |
| 1203 | testing.expectEqual(linux.io_uring_cqe { | |
| 1201 | testing.expectEqual(linux.io_uring_cqe{ | |
| 1204 | 1202 | .user_data = 0xeeeeeeee, |
| 1205 | 1203 | .res = buffer_send.len, |
| 1206 | 1204 | .flags = 0, |
| ... | ... | @@ -1208,7 +1206,7 @@ test "accept/connect/send/recv" { |
| 1208 | 1206 | |
| 1209 | 1207 | const cqe_recv = try ring.copy_cqe(); |
| 1210 | 1208 | if (cqe_recv.res == -linux.EINVAL) return error.SkipZigTest; |
| 1211 | testing.expectEqual(linux.io_uring_cqe { | |
| 1209 | testing.expectEqual(linux.io_uring_cqe{ | |
| 1212 | 1210 | .user_data = 0xffffffff, |
| 1213 | 1211 | .res = buffer_recv.len, |
| 1214 | 1212 | .flags = 0, |
lib/std/os/linux/test.zig+1-1| ... | ... | @@ -24,7 +24,7 @@ test "fallocate" { |
| 24 | 24 | 0 => {}, |
| 25 | 25 | linux.ENOSYS => return error.SkipZigTest, |
| 26 | 26 | linux.EOPNOTSUPP => return error.SkipZigTest, |
| 27 | else => |errno| std.debug.panic("unhandled errno: {}", .{ errno }), | |
| 27 | else => |errno| std.debug.panic("unhandled errno: {}", .{errno}), | |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | 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 |
| 570 | 570 | const path_len_bytes = math.cast(u16, path_name.len * 2) catch |err| switch (err) { |
| 571 | 571 | error.Overflow => return error.NameTooLong, |
| 572 | 572 | }; |
| 573 | ||
| 573 | ||
| 574 | 574 | var nt_name = UNICODE_STRING{ |
| 575 | 575 | .Length = path_len_bytes, |
| 576 | 576 | .MaximumLength = path_len_bytes, |
| 577 | 577 | .Buffer = @intToPtr([*]u16, @ptrToInt(path_name.ptr)), |
| 578 | 578 | }; |
| 579 | ||
| 579 | ||
| 580 | 580 | const rc = ntdll.RtlSetCurrentDirectory_U(&nt_name); |
| 581 | 581 | switch (rc) { |
| 582 | 582 | .SUCCESS => {}, |
lib/std/os/windows/ntdll.zig+1-3| ... | ... | @@ -112,6 +112,4 @@ pub extern "NtDll" fn NtWaitForKeyedEvent( |
| 112 | 112 | Timeout: ?*LARGE_INTEGER, |
| 113 | 113 | ) callconv(WINAPI) NTSTATUS; |
| 114 | 114 | |
| 115 | pub extern "NtDll" fn RtlSetCurrentDirectory_U( | |
| 116 | PathName: *UNICODE_STRING | |
| 117 | ) callconv(WINAPI) NTSTATUS; | |
| 115 | pub 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" { |
| 468 | 468 | expectEqual(@as(u32, 5), queue.remove()); |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | ||
| 472 | 471 | test "std.PriorityQueue: update same min heap" { |
| 473 | 472 | var queue = PQ.init(testing.allocator, lessThan); |
| 474 | 473 | defer queue.deinit(); |
| ... | ... | @@ -514,4 +513,4 @@ test "std.PriorityQueue: update same max heap" { |
| 514 | 513 | expectEqual(@as(u32, 4), queue.remove()); |
| 515 | 514 | expectEqual(@as(u32, 2), queue.remove()); |
| 516 | 515 | 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" { |
| 274 | 274 | }); |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | test "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 | ||
| 292 | test "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 | ||
| 277 | 322 | test "zig fmt: empty file" { |
| 278 | 323 | try testCanonical( |
| 279 | 324 | \\ |
| ... | ... | @@ -3224,7 +3269,8 @@ test "zig fmt: integer literals with underscore separators" { |
| 3224 | 3269 | \\ 1_234_567 |
| 3225 | 3270 | \\ +(0b0_1-0o7_0+0xff_FF ) + 0_0; |
| 3226 | 3271 | , |
| 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; | |
| 3228 | 3274 | \\ |
| 3229 | 3275 | ); |
| 3230 | 3276 | } |
lib/std/zig/render.zig+25-19| ... | ... | @@ -2209,10 +2209,10 @@ fn renderAsmOutput( |
| 2209 | 2209 | try ais.writer().writeAll(" ("); |
| 2210 | 2210 | |
| 2211 | 2211 | switch (asm_output.kind) { |
| 2212 | ast.Node.Asm.Output.Kind.Variable => |variable_name| { | |
| 2212 | .Variable => |variable_name| { | |
| 2213 | 2213 | try renderExpression(allocator, ais, tree, &variable_name.base, Space.None); |
| 2214 | 2214 | }, |
| 2215 | ast.Node.Asm.Output.Kind.Return => |return_type| { | |
| 2215 | .Return => |return_type| { | |
| 2216 | 2216 | try ais.writer().writeAll("-> "); |
| 2217 | 2217 | try renderExpression(allocator, ais, tree, return_type, Space.None); |
| 2218 | 2218 | }, |
| ... | ... | @@ -2304,8 +2304,17 @@ fn renderVarDecl( |
| 2304 | 2304 | } |
| 2305 | 2305 | |
| 2306 | 2306 | 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 | } | |
| 2309 | 2318 | ais.pushIndentOneShot(); |
| 2310 | 2319 | try renderExpression(allocator, ais, tree, init_node, Space.None); |
| 2311 | 2320 | } |
| ... | ... | @@ -2470,20 +2479,20 @@ fn renderTokenOffset( |
| 2470 | 2479 | |
| 2471 | 2480 | var loc = tree.tokenLocationLoc(token_loc.end, next_token_loc); |
| 2472 | 2481 | 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), " ")); | |
| 2474 | 2486 | offset = 2; |
| 2475 | 2487 | token_loc = next_token_loc; |
| 2476 | 2488 | next_token_loc = tree.token_locs[token_index + offset]; |
| 2477 | 2489 | next_token_id = tree.token_ids[token_index + offset]; |
| 2478 | 2490 | if (next_token_id != .LineComment) { |
| 2479 | 2491 | switch (space) { |
| 2480 | Space.None, Space.Space => { | |
| 2481 | try ais.insertNewline(); | |
| 2482 | }, | |
| 2483 | Space.SpaceOrOutdent => { | |
| 2492 | .None, .Space, .SpaceOrOutdent => { | |
| 2484 | 2493 | try ais.insertNewline(); |
| 2485 | 2494 | }, |
| 2486 | Space.Newline => { | |
| 2495 | .Newline => { | |
| 2487 | 2496 | if (next_token_id == .MultilineStringLiteralLine) { |
| 2488 | 2497 | return; |
| 2489 | 2498 | } else { |
| ... | ... | @@ -2491,8 +2500,8 @@ fn renderTokenOffset( |
| 2491 | 2500 | return; |
| 2492 | 2501 | } |
| 2493 | 2502 | }, |
| 2494 | Space.NoNewline => {}, | |
| 2495 | Space.NoComment, Space.Comma, Space.BlockStart => unreachable, | |
| 2503 | .NoNewline => {}, | |
| 2504 | .NoComment, .Comma, .BlockStart => unreachable, | |
| 2496 | 2505 | } |
| 2497 | 2506 | return; |
| 2498 | 2507 | } |
| ... | ... | @@ -2513,7 +2522,7 @@ fn renderTokenOffset( |
| 2513 | 2522 | next_token_id = tree.token_ids[token_index + offset]; |
| 2514 | 2523 | if (next_token_id != .LineComment) { |
| 2515 | 2524 | switch (space) { |
| 2516 | Space.Newline => { | |
| 2525 | .Newline => { | |
| 2517 | 2526 | if (next_token_id == .MultilineStringLiteralLine) { |
| 2518 | 2527 | return; |
| 2519 | 2528 | } else { |
| ... | ... | @@ -2521,14 +2530,11 @@ fn renderTokenOffset( |
| 2521 | 2530 | return; |
| 2522 | 2531 | } |
| 2523 | 2532 | }, |
| 2524 | Space.None, Space.Space => { | |
| 2525 | try ais.insertNewline(); | |
| 2526 | }, | |
| 2527 | Space.SpaceOrOutdent => { | |
| 2533 | .None, .Space, .SpaceOrOutdent => { | |
| 2528 | 2534 | try ais.insertNewline(); |
| 2529 | 2535 | }, |
| 2530 | Space.NoNewline => {}, | |
| 2531 | Space.NoComment, Space.Comma, Space.BlockStart => unreachable, | |
| 2536 | .NoNewline => {}, | |
| 2537 | .NoComment, .Comma, .BlockStart => unreachable, | |
| 2532 | 2538 | } |
| 2533 | 2539 | return; |
| 2534 | 2540 | } |
lib/std/zig/system.zig+2-2| ... | ... | @@ -212,7 +212,7 @@ pub const NativeTargetInfo = struct { |
| 212 | 212 | const uts = std.os.uname(); |
| 213 | 213 | const release = mem.spanZ(&uts.release); |
| 214 | 214 | // 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. | |
| 216 | 216 | if (std.builtin.Version.parse(release)) |ver| { |
| 217 | 217 | os.version_range.linux.range.min = ver; |
| 218 | 218 | os.version_range.linux.range.max = ver; |
| ... | ... | @@ -237,7 +237,7 @@ pub const NativeTargetInfo = struct { |
| 237 | 237 | // `---` `` ``--> Sub-version (Starting from Windows 10 onwards) |
| 238 | 238 | // \ `--> Service pack (Always zero in the constants defined) |
| 239 | 239 | // `--> OS version (Major & minor) |
| 240 | const os_ver: u16 = // | |
| 240 | const os_ver: u16 = | |
| 241 | 241 | @intCast(u16, version_info.dwMajorVersion & 0xff) << 8 | |
| 242 | 242 | @intCast(u16, version_info.dwMinorVersion & 0xff); |
| 243 | 243 | const sp_ver: u8 = 0; |
src/link.zig+2-2| ... | ... | @@ -572,11 +572,11 @@ pub const File = struct { |
| 572 | 572 | |
| 573 | 573 | if (!base.options.disable_lld_caching) { |
| 574 | 574 | 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)}); | |
| 576 | 576 | }; |
| 577 | 577 | |
| 578 | 578 | 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)}); | |
| 580 | 580 | }; |
| 581 | 581 | |
| 582 | 582 | base.lock = man.toOwnedLock(); |
src/link/Coff.zig+3-3| ... | ... | @@ -1205,7 +1205,7 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void { |
| 1205 | 1205 | } |
| 1206 | 1206 | |
| 1207 | 1207 | if (stderr.len != 0) { |
| 1208 | std.log.warn("unexpected LLD stderr:\n{s}", .{stderr}); | |
| 1208 | log.warn("unexpected LLD stderr:\n{s}", .{stderr}); | |
| 1209 | 1209 | } |
| 1210 | 1210 | } |
| 1211 | 1211 | } |
| ... | ... | @@ -1214,11 +1214,11 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void { |
| 1214 | 1214 | // Update the file with the digest. If it fails we can continue; it only |
| 1215 | 1215 | // means that the next invocation will have an unnecessary cache miss. |
| 1216 | 1216 | 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)}); | |
| 1218 | 1218 | }; |
| 1219 | 1219 | // Again failure here only means an unnecessary cache miss. |
| 1220 | 1220 | 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)}); | |
| 1222 | 1222 | }; |
| 1223 | 1223 | // We hang on to this lock so that the output file path can be used without |
| 1224 | 1224 | // other processes clobbering it. |
src/link/Elf.zig+3-3| ... | ... | @@ -1684,7 +1684,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { |
| 1684 | 1684 | } |
| 1685 | 1685 | |
| 1686 | 1686 | if (stderr.len != 0) { |
| 1687 | std.log.warn("unexpected LLD stderr:\n{s}", .{stderr}); | |
| 1687 | log.warn("unexpected LLD stderr:\n{s}", .{stderr}); | |
| 1688 | 1688 | } |
| 1689 | 1689 | } |
| 1690 | 1690 | |
| ... | ... | @@ -1692,11 +1692,11 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { |
| 1692 | 1692 | // Update the file with the digest. If it fails we can continue; it only |
| 1693 | 1693 | // means that the next invocation will have an unnecessary cache miss. |
| 1694 | 1694 | 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)}); | |
| 1696 | 1696 | }; |
| 1697 | 1697 | // Again failure here only means an unnecessary cache miss. |
| 1698 | 1698 | 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)}); | |
| 1700 | 1700 | }; |
| 1701 | 1701 | // We hang on to this lock so that the output file path can be used without |
| 1702 | 1702 | // other processes clobbering it. |
src/link/MachO.zig+10-10| ... | ... | @@ -673,15 +673,15 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { |
| 673 | 673 | self.base.allocator.free(result.stderr); |
| 674 | 674 | } |
| 675 | 675 | if (result.stdout.len != 0) { |
| 676 | std.log.warn("unexpected LD stdout: {}", .{result.stdout}); | |
| 676 | log.warn("unexpected LD stdout: {}", .{result.stdout}); | |
| 677 | 677 | } |
| 678 | 678 | if (result.stderr.len != 0) { |
| 679 | std.log.warn("unexpected LD stderr: {}", .{result.stderr}); | |
| 679 | log.warn("unexpected LD stderr: {}", .{result.stderr}); | |
| 680 | 680 | } |
| 681 | 681 | if (result.term != .Exited or result.term.Exited != 0) { |
| 682 | 682 | // TODO parse this output and surface with the Compilation API rather than |
| 683 | 683 | // directly outputting to stderr here. |
| 684 | std.log.err("{}", .{result.stderr}); | |
| 684 | log.err("{}", .{result.stderr}); | |
| 685 | 685 | return error.LDReportedFailure; |
| 686 | 686 | } |
| 687 | 687 | } else { |
| ... | ... | @@ -738,7 +738,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { |
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | if (stderr.len != 0) { |
| 741 | std.log.warn("unexpected LLD stderr:\n{s}", .{stderr}); | |
| 741 | log.warn("unexpected LLD stderr:\n{s}", .{stderr}); | |
| 742 | 742 | } |
| 743 | 743 | } |
| 744 | 744 | |
| ... | ... | @@ -757,10 +757,10 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { |
| 757 | 757 | // TODO We are in the position to be able to increase the padding by moving all sections |
| 758 | 758 | // by the required offset, but this requires a little bit more thinking and bookkeeping. |
| 759 | 759 | // 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}); | |
| 764 | 764 | return error.NotEnoughPadding; |
| 765 | 765 | } |
| 766 | 766 | const linkedit_segment = self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment; |
| ... | ... | @@ -792,11 +792,11 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { |
| 792 | 792 | // Update the file with the digest. If it fails we can continue; it only |
| 793 | 793 | // means that the next invocation will have an unnecessary cache miss. |
| 794 | 794 | 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)}); | |
| 796 | 796 | }; |
| 797 | 797 | // Again failure here only means an unnecessary cache miss. |
| 798 | 798 | 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)}); | |
| 800 | 800 | }; |
| 801 | 801 | // We hang on to this lock so that the output file path can be used without |
| 802 | 802 | // other processes clobbering it. |
src/link/Wasm.zig+3-3| ... | ... | @@ -455,7 +455,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | if (stderr.len != 0) { |
| 458 | std.log.warn("unexpected LLD stderr:\n{s}", .{stderr}); | |
| 458 | log.warn("unexpected LLD stderr:\n{s}", .{stderr}); | |
| 459 | 459 | } |
| 460 | 460 | } |
| 461 | 461 | |
| ... | ... | @@ -463,11 +463,11 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { |
| 463 | 463 | // Update the file with the digest. If it fails we can continue; it only |
| 464 | 464 | // means that the next invocation will have an unnecessary cache miss. |
| 465 | 465 | 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)}); | |
| 467 | 467 | }; |
| 468 | 468 | // Again failure here only means an unnecessary cache miss. |
| 469 | 469 | 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)}); | |
| 471 | 471 | }; |
| 472 | 472 | // We hang on to this lock so that the output file path can be used without |
| 473 | 473 | // other processes clobbering it. |
src/stage1/analyze.cpp+1-6| ... | ... | @@ -3936,12 +3936,6 @@ void update_compile_var(CodeGen *g, Buf *name, ZigValue *value) { |
| 3936 | 3936 | |
| 3937 | 3937 | void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) { |
| 3938 | 3938 | 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; | |
| 3945 | 3939 | case NodeTypeFnDef: |
| 3946 | 3940 | scan_decls(g, decls_scope, node->data.fn_def.fn_proto); |
| 3947 | 3941 | break; |
| ... | ... | @@ -3986,6 +3980,7 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) { |
| 3986 | 3980 | case NodeTypeCompTime: |
| 3987 | 3981 | preview_comptime_decl(g, node, decls_scope); |
| 3988 | 3982 | break; |
| 3983 | case NodeTypeContainerDecl: | |
| 3989 | 3984 | case NodeTypeNoSuspend: |
| 3990 | 3985 | case NodeTypeParamDecl: |
| 3991 | 3986 | case NodeTypeReturnExpr: |
src/stage1/ir.cpp-18| ... | ... | @@ -25310,24 +25310,6 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInst* source_instr, ZigVa |
| 25310 | 25310 | } |
| 25311 | 25311 | |
| 25312 | 25312 | 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 | ||
| 25331 | 25313 | break; |
| 25332 | 25314 | } |
| 25333 | 25315 | default: |
test/stage1/behavior/vector.zig+4-4| ... | ... | @@ -550,8 +550,8 @@ test "vector reduce operation" { |
| 550 | 550 | // LLVM 11 ERROR: Cannot select type |
| 551 | 551 | // https://github.com/ziglang/zig/issues/7138 |
| 552 | 552 | 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)); | |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | doTheTestReduce(.Min, [4]i128{ 1234567, -386, 0, 3 }, @as(i128, -386)); |
| ... | ... | @@ -568,8 +568,8 @@ test "vector reduce operation" { |
| 568 | 568 | // LLVM 11 ERROR: Cannot select type |
| 569 | 569 | // https://github.com/ziglang/zig/issues/7138 |
| 570 | 570 | 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)); | |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | doTheTestReduce(.Max, [4]i128{ 1234567, -386, 0, 3 }, @as(i128, 1234567)); |