zig icon indicating copy to clipboard operation
zig copied to clipboard

std.c: adding glibc's pthread_get_minstack useful for thread stack wh…

Open devnexen opened this issue 1 year ago • 1 comments

…en there is thread local storage involved

devnexen avatar May 30 '23 22:05 devnexen

  • Reasoning comes from here.
  • Tested with the following `const std = @import("std"); const c = std.c; const os = std.os;

fn task() u8 { return 0; }

pub fn main() !void { var attr: c.pthread_attr_t = undefined; _ = c.pthread_attr_init(&attr); const stack_size = try c.pthread_get_minstack(&attr); std.debug.assert(stack_size >= std.c.PTHREAD_STACK_MIN); const th = try std.Thread.spawn(.{.stack_size = stack_size}, task, .{}); th.join(); _ = c.pthread_attr_destroy(&attr); }`

devnexen avatar Jun 20 '23 21:06 devnexen