| ... | @@ -893,6 +893,7 @@ const LinuxThreadImpl = struct { | ... | @@ -893,6 +893,7 @@ const LinuxThreadImpl = struct { |
| 893 | }; | 893 | }; |
| 894 | | 894 | |
| 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; |
| 916 | | 917 | |
| 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; |
| 920 | | 921 | |
| 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; |
| 924 | | 925 | |
| 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); |
| 932 | | 933 | |
| 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 | }; |
| 936 | | 937 | |
| ... | @@ -954,7 +955,7 @@ const LinuxThreadImpl = struct { | ... | @@ -954,7 +955,7 @@ const LinuxThreadImpl = struct { |
| 954 | | 955 | |
| 955 | // map everything but the guard page as read/write | 956 | // 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, |