aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2023-04-03 15:17:40 -0400
committerCherry Mui <cherryyz@google.com>2023-04-04 03:37:07 +0000
commitad87a124be4879f40a01f622dd03b40d3e6dd559 (patch)
treee9f4115bfdc11831c7aae4adf202e235280a4ea2
parentca26c9835109f8f3e72bbc069a6361bdf24e271d (diff)
downloadgo-ad87a124be4879f40a01f622dd03b40d3e6dd559.tar.gz
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 <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
-rw-r--r--src/runtime/cgo/gcc_stack_unix.c9
1 files changed, 8 insertions, 1 deletions
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);