Commit 1b9ffa0824

Andrew Kelley <andrew@ziglang.org>
2023-07-31 19:54:35
Revert "std.Thread: refining stack size from platform minimum, changes more targetted towards platform like Linux/musl (#15791)"
This reverts commit 41502c6aa53a3da31b276c23c4db74db7d04796b.
1 parent ba3b352
lib/std/c/darwin.zig
@@ -4153,9 +4153,3 @@ pub const vm_extmod_statistics_t = *vm_extmod_statistics;
 pub const vm_extmod_statistics_data_t = vm_extmod_statistics;
 
 pub extern "c" fn vm_stats(info: ?*anyopaque, count: *c_uint) kern_return_t;
-
-/// TODO refines if necessary
-pub const PTHREAD_STACK_MIN = switch (builtin.cpu.arch) {
-    .arm, .aarch64 => 16 * 1024,
-    else => 8 * 1024,
-};
lib/std/c/dragonfly.zig
@@ -1160,5 +1160,3 @@ pub const sigevent = extern struct {
     sigev_value: sigval,
     sigev_notify_function: ?*const fn (sigval) callconv(.C) void,
 };
-
-pub const PTHREAD_STACK_MIN = 16 * 1024;
lib/std/c/emscripten.zig
@@ -9,5 +9,3 @@ pub const pthread_rwlock_t = extern struct {
 };
 const __SIZEOF_PTHREAD_COND_T = 48;
 const __SIZEOF_PTHREAD_MUTEX_T = 28;
-
-pub const PTHREAD_STACK_MIN = 2048;
lib/std/c/freebsd.zig
@@ -2818,9 +2818,3 @@ pub const ptrace_cs_remote = extern struct {
 };
 
 pub extern "c" fn ptrace(request: c_int, pid: pid_t, addr: [*:0]u8, data: c_int) c_int;
-
-/// TODO refines if necessary
-pub const PTHREAD_STACK_MIN = switch (builtin.cpu.arch) {
-    .x86, .powerpc => 4 * 512,
-    else => 4 * 1024,
-};
lib/std/c/haiku.zig
@@ -1068,6 +1068,3 @@ pub const sigevent = extern struct {
     sigev_notify_function: ?*const fn (sigval) callconv(.C) void,
     sigev_notify_attributes: ?*pthread_attr_t,
 };
-
-/// TODO refines if necessary
-pub const PTHREAD_STACK_MIN = 2 * 4096;
lib/std/c/linux.zig
@@ -350,18 +350,6 @@ const __SIZEOF_PTHREAD_MUTEX_T = switch (native_abi) {
 };
 const __SIZEOF_SEM_T = 4 * @sizeOf(usize);
 
-/// TODO refines if necessary
-pub const PTHREAD_STACK_MIN = switch (native_abi) {
-    .musl, .musleabi, .musleabihf => 2048,
-    .gnu, .gnuabin32, .gnuabi64, .gnueabi, .gnueabihf, .gnux32 => switch (native_arch) {
-        .aarch64, .arm, .armeb, .powerpc, .powerpc64, .powerpc64le, .loongarch32, .loongarch64 => 131072,
-        .sparc64 => 24576,
-        else => 16 * 1024,
-    },
-    .android => if (@sizeOf(usize) == 8) 16 * 1024 else 8 * 1024,
-    else => 16 * 1024,
-};
-
 pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8) E;
 pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E;
 
lib/std/c/minix.zig
@@ -16,5 +16,3 @@ const __SIZEOF_PTHREAD_MUTEX_T = switch (builtin.abi) {
     },
     else => unreachable,
 };
-
-pub const PTHREAD_STACK_MIN = 16 * 1024;
lib/std/c/netbsd.zig
@@ -1720,6 +1720,3 @@ pub const PIOD = struct {
 };
 
 pub extern "c" fn ptrace(request: c_int, pid: pid_t, addr: ?*anyopaque, data: c_int) c_int;
-
-/// TODO refines if necessary
-pub const PTHREAD_STACK_MIN = 16 * 1024;
lib/std/c/openbsd.zig
@@ -1634,10 +1634,3 @@ pub const HW = struct {
     pub const NCPUONLINE = 25;
     pub const POWER = 26;
 };
-
-/// TODO refines if necessary
-pub const PTHREAD_STACK_MIN = switch (builtin.cpu.arch) {
-    .sparc64 => 1 << 13,
-    .mips64 => 1 << 14,
-    else => 1 << 12,
-};
lib/std/c/solaris.zig
@@ -1946,5 +1946,3 @@ pub const sigevent = extern struct {
     sigev_notify_function: ?*const fn (sigval) callconv(.C) void,
     sigev_notify_attributes: ?*pthread_attr_t,
 };
-
-pub const PTHREAD_STACK_MIN = if (@sizeOf(usize) == 8) 8 * 1024 else 4 * 1024;
lib/std/c/wasi.zig
@@ -119,5 +119,3 @@ pub const POLL = struct {
     pub const HUP = 0x2000;
     pub const NVAL = 0x4000;
 };
-
-pub const PTHREAD_STACK_MIN = 16 * 1024;
lib/std/Thread.zig
@@ -695,7 +695,7 @@ const PosixThreadImpl = struct {
         defer assert(c.pthread_attr_destroy(&attr) == .SUCCESS);
 
         // Use the same set of parameters used by the libc-less impl.
-        const stack_size = @max(config.stack_size, c.PTHREAD_STACK_MIN);
+        const stack_size = @max(config.stack_size, 16 * 1024);
         assert(c.pthread_attr_setstacksize(&attr, stack_size) == .SUCCESS);
         assert(c.pthread_attr_setguardsize(&attr, std.mem.page_size) == .SUCCESS);