]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/cgo: use pthread_attr_get_np on Illumos
authorCherry Mui <cherryyz@google.com>
Mon, 3 Apr 2023 19:17:40 +0000 (15:17 -0400)
committerCherry Mui <cherryyz@google.com>
Tue, 4 Apr 2023 03:37:07 +0000 (03:37 +0000)
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>
src/runtime/cgo/gcc_stack_unix.c

index 5ca6a944298204d614d9190668693cc9cef1cccf..71ac36ff1e2e4c81f7ae04de63f49223901ea289 100644 (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);