From 0fafc8cc4409b35649c19af19f7c259ff570c0b5 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 17 May 2022 15:13:20 -0700 Subject: std.Thread: insert a missing `@alignCast` stage1 has a missing compile error for this situation. --- lib/std/Thread.zig | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig index 9e29c82672..06903a9e91 100644 --- a/lib/std/Thread.zig +++ b/lib/std/Thread.zig @@ -893,6 +893,7 @@ const LinuxThreadImpl = struct { }; fn spawn(config: SpawnConfig, comptime f: anytype, args: anytype) !Impl { + const page_size = std.mem.page_size; const Args = @TypeOf(args); const Instance = struct { fn_args: Args, @@ -915,11 +916,11 @@ const LinuxThreadImpl = struct { var instance_offset: usize = undefined; const map_bytes = blk: { - var bytes: usize = std.mem.page_size; + var bytes: usize = page_size; guard_offset = bytes; - bytes += std.math.max(std.mem.page_size, config.stack_size); - bytes = std.mem.alignForward(bytes, std.mem.page_size); + bytes += std.math.max(page_size, config.stack_size); + bytes = std.mem.alignForward(bytes, page_size); stack_offset = bytes; bytes = std.mem.alignForward(bytes, linux.tls.tls_image.alloc_align); @@ -930,7 +931,7 @@ const LinuxThreadImpl = struct { instance_offset = bytes; bytes += @sizeOf(Instance); - bytes = std.mem.alignForward(bytes, std.mem.page_size); + bytes = std.mem.alignForward(bytes, page_size); break :blk bytes; }; @@ -954,7 +955,7 @@ const LinuxThreadImpl = struct { // map everything but the guard page as read/write os.mprotect( - mapped[guard_offset..], + @alignCast(page_size, mapped[guard_offset..]), os.PROT.READ | os.PROT.WRITE, ) catch |err| switch (err) { error.AccessDenied => unreachable, -- cgit v1.2.3