aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/cgo/gcc_libinit.c
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2023-08-15 17:29:40 -0700
committerGopher Robot <gobot@golang.org>2023-08-22 22:06:46 +0000
commit52e17c2e4df91b295b23b8d7a2b669123b0da880 (patch)
tree0306d620cffe16ff7c78c8e6cb94f0612db47847 /src/runtime/cgo/gcc_libinit.c
parent21293b6b87c67bc98c56b33509ae390a3352da71 (diff)
downloadgo-52e17c2e4df91b295b23b8d7a2b669123b0da880.tar.xz
runtime/cgo: get getstackbound for set_stacklo
Change-Id: Ia63a4604449b5e460e6f54c962fb7d6db2bc6a43 Reviewed-on: https://go-review.googlesource.com/c/go/+/519457 Run-TryBot: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/runtime/cgo/gcc_libinit.c')
-rw-r--r--src/runtime/cgo/gcc_libinit.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/runtime/cgo/gcc_libinit.c b/src/runtime/cgo/gcc_libinit.c
index f6c930209e..68f4a02379 100644
--- a/src/runtime/cgo/gcc_libinit.c
+++ b/src/runtime/cgo/gcc_libinit.c
@@ -85,20 +85,18 @@ _cgo_wait_runtime_init_done(void) {
// _cgo_set_stacklo sets g->stacklo based on the stack size.
// This is common code called from x_cgo_init, which is itself
// called by rt0_go in the runtime package.
-void _cgo_set_stacklo(G *g, pthread_attr_t *pattr)
+void _cgo_set_stacklo(G *g, uintptr *pbounds)
{
- pthread_attr_t attr;
- size_t size;
+ uintptr bounds[2];
- // pattr can be passed in by the caller; see gcc_linux_amd64.c.
- if (pattr == NULL) {
- pattr = &attr;
+ // pbounds can be passed in by the caller; see gcc_linux_amd64.c.
+ if (pbounds == NULL) {
+ pbounds = &bounds[0];
}
- pthread_attr_init(pattr);
- pthread_attr_getstacksize(pattr, &size);
+ x_cgo_getstackbound(pbounds);
- g->stacklo = (uintptr)(__builtin_frame_address(0)) - size + 4096;
+ g->stacklo = *pbounds;
// Sanity check the results now, rather than getting a
// morestack on g0 crash.
@@ -106,8 +104,6 @@ void _cgo_set_stacklo(G *g, pthread_attr_t *pattr)
fprintf(stderr, "runtime/cgo: bad stack bounds: lo=%p hi=%p\n", (void*)(g->stacklo), (void*)(g->stackhi));
abort();
}
-
- pthread_attr_destroy(pattr);
}
// Store the g into a thread-specific value associated with the pthread key pthread_g.