From be7725f0fde6c1fb1c00dd7ff54ef874e069ebcd Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Fri, 9 Jun 2023 09:04:27 +0100 Subject: [PATCH] [Backtracing][Linux] Include declarations for gettid() and tgkill(). Older glibc doesn't include these. Nor does Musl, it seems. The previous fix put the gettid() declaration too far down the file. rdar://110417355 --- stdlib/public/runtime/CrashHandlerLinux.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/stdlib/public/runtime/CrashHandlerLinux.cpp b/stdlib/public/runtime/CrashHandlerLinux.cpp index 42f83ca616847..2913245b97566 100644 --- a/stdlib/public/runtime/CrashHandlerLinux.cpp +++ b/stdlib/public/runtime/CrashHandlerLinux.cpp @@ -183,6 +183,18 @@ _swift_installCrashHandler() namespace { +// Older glibc and musl don't have these two syscalls +pid_t +gettid() +{ + return (pid_t)syscall(SYS_gettid); +} + +int +tgkill(int tgid, int tid, int sig) { + return syscall(SYS_tgkill, tgid, tid, sig); +} + void reset_signal(int signum) { @@ -296,12 +308,6 @@ getdents(int fd, void *buf, size_t bufsiz) return syscall(SYS_getdents64, fd, buf, bufsiz); } -pid_t -gettid() -{ - return (pid_t)syscall(SYS_gettid); -} - /* Stop all other threads in this process; we do this by establishing a signal handler for SIGPROF, then iterating through the threads sending SIGPROF.