1
0
mirror of https://github.com/golang/go synced 2024-11-17 06:14:51 -07:00

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>
This commit is contained in:
Cherry Mui 2023-04-03 15:17:40 -04:00
parent ca26c98351
commit ad87a124be

View File

@ -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);