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 {...@@ -893,6 +893,7 @@ const LinuxThreadImpl = struct {
893 };893 };
894894
895 fn spawn(config: SpawnConfig, comptime f: anytype, args: anytype) !Impl {895 fn spawn(config: SpawnConfig, comptime f: anytype, args: anytype) !Impl {
896 const page_size = std.mem.page_size;
896 const Args = @TypeOf(args);897 const Args = @TypeOf(args);
897 const Instance = struct {898 const Instance = struct {
898 fn_args: Args,899 fn_args: Args,
...@@ -915,11 +916,11 @@ const LinuxThreadImpl = struct {...@@ -915,11 +916,11 @@ const LinuxThreadImpl = struct {
915 var instance_offset: usize = undefined;916 var instance_offset: usize = undefined;
916917
917 const map_bytes = blk: {918 const map_bytes = blk: {
918 var bytes: usize = std.mem.page_size;919 var bytes: usize = page_size;
919 guard_offset = bytes;920 guard_offset = bytes;
920921
921 bytes += std.math.max(std.mem.page_size, config.stack_size);922 bytes += std.math.max(page_size, config.stack_size);
922 bytes = std.mem.alignForward(bytes, std.mem.page_size);923 bytes = std.mem.alignForward(bytes, page_size);
923 stack_offset = bytes;924 stack_offset = bytes;
924925
925 bytes = std.mem.alignForward(bytes, linux.tls.tls_image.alloc_align);926 bytes = std.mem.alignForward(bytes, linux.tls.tls_image.alloc_align);
...@@ -930,7 +931,7 @@ const LinuxThreadImpl = struct {...@@ -930,7 +931,7 @@ const LinuxThreadImpl = struct {
930 instance_offset = bytes;931 instance_offset = bytes;
931 bytes += @sizeOf(Instance);932 bytes += @sizeOf(Instance);
932933
933 bytes = std.mem.alignForward(bytes, std.mem.page_size);934 bytes = std.mem.alignForward(bytes, page_size);
934 break :blk bytes;935 break :blk bytes;
935 };936 };
936937
...@@ -954,7 +955,7 @@ const LinuxThreadImpl = struct {...@@ -954,7 +955,7 @@ const LinuxThreadImpl = struct {
954955
955 // map everything but the guard page as read/write956 // map everything but the guard page as read/write
956 os.mprotect(957 os.mprotect(
957 mapped[guard_offset..],958 @alignCast(page_size, mapped[guard_offset..]),
958 os.PROT.READ | os.PROT.WRITE,959 os.PROT.READ | os.PROT.WRITE,
959 ) catch |err| switch (err) {960 ) catch |err| switch (err) {
960 error.AccessDenied => unreachable,961 error.AccessDenied => unreachable,