diff options
| author | David CARLIER <devnexen@gmail.com> | 2023-05-25 20:32:17 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-25 14:32:17 -0500 |
| commit | 41502c6aa53a3da31b276c23c4db74db7d04796b (patch) | |
| tree | b1118c8e6c6042ff6fddeaf01dd97b2e236b52c2 /lib/std | |
| parent | 230ea411f72303607a8c5c5467258eee61bd6939 (diff) | |
| download | zig-41502c6aa53a3da31b276c23c4db74db7d04796b.tar.gz zig-41502c6aa53a3da31b276c23c4db74db7d04796b.zip | |
std.Thread: refining stack size from platform minimum, changes more targetted towards platform like Linux/musl (#15791)
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/Thread.zig | 2 | ||||
| -rw-r--r-- | lib/std/c/darwin.zig | 6 | ||||
| -rw-r--r-- | lib/std/c/dragonfly.zig | 2 | ||||
| -rw-r--r-- | lib/std/c/emscripten.zig | 2 | ||||
| -rw-r--r-- | lib/std/c/freebsd.zig | 6 | ||||
| -rw-r--r-- | lib/std/c/haiku.zig | 3 | ||||
| -rw-r--r-- | lib/std/c/linux.zig | 12 | ||||
| -rw-r--r-- | lib/std/c/minix.zig | 2 | ||||
| -rw-r--r-- | lib/std/c/netbsd.zig | 3 | ||||
| -rw-r--r-- | lib/std/c/openbsd.zig | 7 | ||||
| -rw-r--r-- | lib/std/c/solaris.zig | 2 | ||||
| -rw-r--r-- | lib/std/c/wasi.zig | 2 |
12 files changed, 48 insertions, 1 deletions
diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig index d213b167dd..ed6a9383e3 100644 --- a/lib/std/Thread.zig +++ b/lib/std/Thread.zig @@ -690,7 +690,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 = std.math.max(config.stack_size, 16 * 1024); + const stack_size = std.math.max(config.stack_size, c.PTHREAD_STACK_MIN); assert(c.pthread_attr_setstacksize(&attr, stack_size) == .SUCCESS); assert(c.pthread_attr_setguardsize(&attr, std.mem.page_size) == .SUCCESS); diff --git a/lib/std/c/darwin.zig b/lib/std/c/darwin.zig index f0da52a86a..3a56d0108f 100644 --- a/lib/std/c/darwin.zig +++ b/lib/std/c/darwin.zig @@ -4155,3 +4155,9 @@ 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, +}; diff --git a/lib/std/c/dragonfly.zig b/lib/std/c/dragonfly.zig index c7561d558d..64a79710a4 100644 --- a/lib/std/c/dragonfly.zig +++ b/lib/std/c/dragonfly.zig @@ -1160,3 +1160,5 @@ pub const sigevent = extern struct { sigev_value: sigval, sigev_notify_function: ?*const fn (sigval) callconv(.C) void, }; + +pub const PTHREAD_STACK_MIN = 16 * 1024; diff --git a/lib/std/c/emscripten.zig b/lib/std/c/emscripten.zig index 0d78d4d73f..8b9fd8c2a2 100644 --- a/lib/std/c/emscripten.zig +++ b/lib/std/c/emscripten.zig @@ -9,3 +9,5 @@ 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; diff --git a/lib/std/c/freebsd.zig b/lib/std/c/freebsd.zig index 70dc4b039a..9dfa46c5b9 100644 --- a/lib/std/c/freebsd.zig +++ b/lib/std/c/freebsd.zig @@ -2818,3 +2818,9 @@ 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, +}; diff --git a/lib/std/c/haiku.zig b/lib/std/c/haiku.zig index b0fcb710af..53930cdca7 100644 --- a/lib/std/c/haiku.zig +++ b/lib/std/c/haiku.zig @@ -1068,3 +1068,6 @@ 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; diff --git a/lib/std/c/linux.zig b/lib/std/c/linux.zig index eb31248683..17ce6eb3bd 100644 --- a/lib/std/c/linux.zig +++ b/lib/std/c/linux.zig @@ -350,6 +350,18 @@ 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; diff --git a/lib/std/c/minix.zig b/lib/std/c/minix.zig index 62cefc14fb..672f36ca86 100644 --- a/lib/std/c/minix.zig +++ b/lib/std/c/minix.zig @@ -16,3 +16,5 @@ const __SIZEOF_PTHREAD_MUTEX_T = switch (builtin.abi) { }, else => unreachable, }; + +pub const PTHREAD_STACK_MIN = 16 * 1024; diff --git a/lib/std/c/netbsd.zig b/lib/std/c/netbsd.zig index 87e9b45c5f..67ed0f6ed9 100644 --- a/lib/std/c/netbsd.zig +++ b/lib/std/c/netbsd.zig @@ -1720,3 +1720,6 @@ 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; diff --git a/lib/std/c/openbsd.zig b/lib/std/c/openbsd.zig index 07a8237311..dc5f8a14c9 100644 --- a/lib/std/c/openbsd.zig +++ b/lib/std/c/openbsd.zig @@ -1631,3 +1631,10 @@ pub const HW_ALLOWPOWERDOWN = 22; pub const HW_PERFPOLICY = 23; pub const HW_SMT = 24; pub const HW_NCPUONLINE = 25; + +/// TODO refines if necessary +pub const PTHREAD_STACK_MIN = switch (builtin.cpu.arch) { + .sparc64 => 1 << 13, + .mips64 => 1 << 14, + else => 1 << 12, +}; diff --git a/lib/std/c/solaris.zig b/lib/std/c/solaris.zig index b2225c6d00..4aeae190d0 100644 --- a/lib/std/c/solaris.zig +++ b/lib/std/c/solaris.zig @@ -1946,3 +1946,5 @@ 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; diff --git a/lib/std/c/wasi.zig b/lib/std/c/wasi.zig index e1940054b6..2cb0a32b06 100644 --- a/lib/std/c/wasi.zig +++ b/lib/std/c/wasi.zig @@ -119,3 +119,5 @@ pub const POLL = struct { pub const HUP = 0x2000; pub const NVAL = 0x4000; }; + +pub const PTHREAD_STACK_MIN = 16 * 1024; |
