From ad87a124be4879f40a01f622dd03b40d3e6dd559 Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Mon, 3 Apr 2023 15:17:40 -0400 Subject: [PATCH] runtime/cgo: use pthread_attr_get_np on Illumos While Solaris supports pthread_getattr_np, Illumos doesn't... Instead, Illumos supports pthread_attr_get_np. Updates #59294. Change-Id: I2c66dad79b8bf3d510352875bf21d04415f23eeb Reviewed-on: https://go-review.googlesource.com/c/go/+/481795 TryBot-Bypass: Cherry Mui Run-TryBot: Cherry Mui Reviewed-by: Michael Knyszek --- src/runtime/cgo/gcc_stack_unix.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/runtime/cgo/gcc_stack_unix.c b/src/runtime/cgo/gcc_stack_unix.c index 5ca6a94429..71ac36ff1e 100644 --- a/src/runtime/cgo/gcc_stack_unix.c +++ b/src/runtime/cgo/gcc_stack_unix.c @@ -18,9 +18,16 @@ x_cgo_getstackbound(G *g) void *addr; size_t size; -#if defined(__GLIBC__) || defined(__sun) +#if defined(__GLIBC__) || (defined(__sun) && !defined(__illumos__)) + // pthread_getattr_np is a GNU extension supported in glibc. + // Solaris is not glibc but does support pthread_getattr_np + // (and the fallback doesn't work...). Illumos does not. pthread_getattr_np(pthread_self(), &attr); // GNU extension pthread_attr_getstack(&attr, &addr, &size); // low address +#elif defined(__illumos__) + pthread_attr_init(&attr); + pthread_attr_get_np(pthread_self(), &attr); + pthread_attr_getstack(&attr, &addr, &size); // low address #else pthread_attr_init(&attr); pthread_attr_getstacksize(&attr, &size); -- 2.50.0