authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-05-17 15:13:20-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-05-17 23:50:38-07:00
log0fafc8cc4409b35649c19af19f7c259ff570c0b5
tree1f122e8af15f634b6b392eedb22553db9758eb1a
parentb6798c26efc4689cf35c5f4ac0436b4510a1f813

std.Thread: insert a missing `@alignCast`

stage1 has a missing compile error for this situation.

1 files changed, 6 insertions(+), 5 deletions(-)

lib/std/Thread.zig+6-5
......@@ -893,6 +893,7 @@ const LinuxThreadImpl = struct {
893893 };
894894
895895 fn spawn(config: SpawnConfig, comptime f: anytype, args: anytype) !Impl {
896 const page_size = std.mem.page_size;
896897 const Args = @TypeOf(args);
897898 const Instance = struct {
898899 fn_args: Args,
......@@ -915,11 +916,11 @@ const LinuxThreadImpl = struct {
915916 var instance_offset: usize = undefined;
916917
917918 const map_bytes = blk: {
918 var bytes: usize = std.mem.page_size;
919 var bytes: usize = page_size;
919920 guard_offset = bytes;
920921
921 bytes += std.math.max(std.mem.page_size, config.stack_size);
922 bytes = std.mem.alignForward(bytes, std.mem.page_size);
922 bytes += std.math.max(page_size, config.stack_size);
923 bytes = std.mem.alignForward(bytes, page_size);
923924 stack_offset = bytes;
924925
925926 bytes = std.mem.alignForward(bytes, linux.tls.tls_image.alloc_align);
......@@ -930,7 +931,7 @@ const LinuxThreadImpl = struct {
930931 instance_offset = bytes;
931932 bytes += @sizeOf(Instance);
932933
933 bytes = std.mem.alignForward(bytes, std.mem.page_size);
934 bytes = std.mem.alignForward(bytes, page_size);
934935 break :blk bytes;
935936 };
936937
......@@ -954,7 +955,7 @@ const LinuxThreadImpl = struct {
954955
955956 // map everything but the guard page as read/write
956957 os.mprotect(
957 mapped[guard_offset..],
958 @alignCast(page_size, mapped[guard_offset..]),
958959 os.PROT.READ | os.PROT.WRITE,
959960 ) catch |err| switch (err) {
960961 error.AccessDenied => unreachable,