aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/cgo/gcc_libinit.c
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2025-02-25 21:35:32 -0800
committerGopher Robot <gobot@golang.org>2025-02-26 10:52:55 -0800
commit76c70282538bf4cccd6f98b5b26df7f5a7f2cebd (patch)
tree45c62de6fe96dd8de1fe4cf888db8dcd2d5d95b6 /src/runtime/cgo/gcc_libinit.c
parent194696f1d1f6e5609f96d0fb0192595e7e0f5b90 (diff)
downloadgo-76c70282538bf4cccd6f98b5b26df7f5a7f2cebd.tar.xz
runtime/cgo: avoid errors from -Wdeclaration-after-statement
It's used by the SWIG CI build, at least, and it's an easy fix. Fixes #71961 Change-Id: Id21071a5aef216b35ecf0e9cd3e05d08972d92fe Reviewed-on: https://go-review.googlesource.com/c/go/+/652181 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime/cgo/gcc_libinit.c')
-rw-r--r--src/runtime/cgo/gcc_libinit.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/runtime/cgo/gcc_libinit.c b/src/runtime/cgo/gcc_libinit.c
index 2fe76e4360..e9b0a3f769 100644
--- a/src/runtime/cgo/gcc_libinit.c
+++ b/src/runtime/cgo/gcc_libinit.c
@@ -39,10 +39,11 @@ void
x_cgo_sys_thread_create(void* (*func)(void*), void* arg) {
pthread_attr_t attr;
pthread_t p;
+ int err;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- int err = _cgo_try_pthread_create(&p, &attr, func, arg);
+ err = _cgo_try_pthread_create(&p, &attr, func, arg);
if (err != 0) {
fprintf(stderr, "pthread_create failed: %s", strerror(err));
abort();
@@ -52,9 +53,11 @@ x_cgo_sys_thread_create(void* (*func)(void*), void* arg) {
uintptr_t
_cgo_wait_runtime_init_done(void) {
void (*pfn)(struct context_arg*);
+ int done;
+
pfn = __atomic_load_n(&cgo_context_function, __ATOMIC_CONSUME);
- int done = 2;
+ done = 2;
if (__atomic_load_n(&runtime_init_done, __ATOMIC_CONSUME) != done) {
pthread_mutex_lock(&runtime_init_mu);
while (__atomic_load_n(&runtime_init_done, __ATOMIC_CONSUME) == 0) {