aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2022-09-26 15:03:53 -0400
committerIan Lance Taylor <iant@golang.org>2022-09-27 09:30:23 -0700
commite73d9fcafbd07bc3714fbaf8a82db71d50015c92 (patch)
tree44d8382e7696a4aa4ecbc6e116b2654775215402 /libgo/runtime
parentf38162977e2b7efaa75233a0cba2a30a2b7f5132 (diff)
downloadgcc-e73d9fcafbd07bc3714fbaf8a82db71d50015c92.zip
gcc-e73d9fcafbd07bc3714fbaf8a82db71d50015c92.tar.gz
gcc-e73d9fcafbd07bc3714fbaf8a82db71d50015c92.tar.bz2
runtime: portable access to sigev_notify_thread_id
Previously, libgo relied on the _sigev_un implementation-specific field in struct sigevent, which is only available on glibc. This patch uses the sigev_notify_thread_id macro instead which is mandated by timer_create(2). In theory, this should work with any libc implementation for Linux. Unfortunately, there is an open glibc bug as glibc does not define this macro. For this reason, a glibc-specific workaround is required. Other libcs (such as musl) define the macro and don't require the workaround. See https://sourceware.org/bugzilla/show_bug.cgi?id=27417 This makes libgo compatible with musl libc. Based on patch by Sören Tempel. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/434755
Diffstat (limited to 'libgo/runtime')
-rw-r--r--libgo/runtime/go-signal.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/libgo/runtime/go-signal.c b/libgo/runtime/go-signal.c
index 528d9b6..aa1b630 100644
--- a/libgo/runtime/go-signal.c
+++ b/libgo/runtime/go-signal.c
@@ -183,6 +183,24 @@ setSigactionHandler(struct sigaction* sa, uintptr handler)
sa->sa_sigaction = (void*)(handler);
}
+#ifdef __linux__
+
+// Workaround for https://sourceware.org/bugzilla/show_bug.cgi?id=27417
+#ifndef sigev_notify_thread_id
+ #define sigev_notify_thread_id _sigev_un._tid
+#endif
+
+void setSigeventTID(struct sigevent*, int32_t)
+ __asm__ (GOSYM_PREFIX "runtime.setSigeventTID");
+
+void
+setSigeventTID(struct sigevent *sev, int32_t v)
+{
+ sev->sigev_notify_thread_id = v;
+}
+
+#endif // defined(__linux__)
+
// C code to fetch values from the siginfo_t and ucontext_t pointers
// passed to a signal handler.