[compiler-rt] [compiler-rt][Mips] Align definition of __sanitizer_sigaction with musl (PR #124494)
Jens Reidel via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 7 11:43:19 PST 2025
https://github.com/Gelbpunkt updated https://github.com/llvm/llvm-project/pull/124494
>From 3587cb6b2e3a956c699d8473e9604edb850d6943 Mon Sep 17 00:00:00 2001
From: Jens Reidel <adrian at travitia.xyz>
Date: Sun, 26 Jan 2025 22:30:27 +0100
Subject: [PATCH 1/2] [compiler-rt][Mips] Align definition of
__sanitizer_sigaction with musl
The definition of __sanitizer_sigaction for MIPS matches the one in
glibc [1]. musl however uses a single definition of sigaction for all
architectures [2] that is more similar to the other architectures supported
by glibc. Fix the conditional logic so that __sanitizer_sigaction
matches the musl definition on MIPS.
[1]: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/mips/bits/sigaction.h;h=f7e3ad88abbf3c497aaed44247bc1085efebe462;hb=dc650eb715df0a272ce43dfb55a209d5b018cc04
[2]: https://git.musl-libc.org/cgit/musl/tree/include/signal.h#n169
Signed-off-by: Jens Reidel <adrian at travitia.xyz>
---
.../lib/sanitizer_common/sanitizer_platform_limits_posix.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
index 1a7d9e64048ebe9..f5bb0e58f8fbf98 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -658,7 +658,7 @@ struct __sanitizer_sigaction {
};
#else // !SANITIZER_ANDROID
struct __sanitizer_sigaction {
-#if defined(__mips__) && !SANITIZER_FREEBSD
+#if defined(__mips__) && !SANITIZER_FREEBSD && !SANITIZER_MUSL
unsigned int sa_flags;
#endif
union {
@@ -674,7 +674,7 @@ struct __sanitizer_sigaction {
#else
__sanitizer_sigset_t sa_mask;
#endif
-#ifndef __mips__
+#if !defined(__mips__) || SANITIZER_MUSL
#if defined(__sparc__)
#if __GLIBC_PREREQ (2, 20)
// On sparc glibc 2.19 and earlier sa_flags was unsigned long.
@@ -695,7 +695,7 @@ struct __sanitizer_sigaction {
#if SANITIZER_LINUX
void (*sa_restorer)();
#endif
-#if defined(__mips__) && (SANITIZER_WORDSIZE == 32)
+#if defined(__mips__) && (SANITIZER_WORDSIZE == 32) && !SANITIZER_MUSL
int sa_resv[1];
#endif
#if defined(__s390x__)
>From 23417e3785865acac459368749eb947253540b7e Mon Sep 17 00:00:00 2001
From: Jens Reidel <adrian at travitia.xyz>
Date: Fri, 7 Feb 2025 20:42:57 +0100
Subject: [PATCH 2/2] [compiler-rt][NFC] clang-format changes
Signed-off-by: Jens Reidel <adrian at travitia.xyz>
---
.../sanitizer_platform_limits_posix.h | 48 +++++++++----------
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
index f5bb0e58f8fbf98..67f00ff6f9e7231 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -658,49 +658,49 @@ struct __sanitizer_sigaction {
};
#else // !SANITIZER_ANDROID
struct __sanitizer_sigaction {
-#if defined(__mips__) && !SANITIZER_FREEBSD && !SANITIZER_MUSL
+# if defined(__mips__) && !SANITIZER_FREEBSD && !SANITIZER_MUSL
unsigned int sa_flags;
-#endif
+# endif
union {
__sanitizer_sigactionhandler_ptr sigaction;
__sanitizer_sighandler_ptr handler;
};
-#if SANITIZER_FREEBSD
+# if SANITIZER_FREEBSD
int sa_flags;
__sanitizer_sigset_t sa_mask;
-#else
-#if defined(__s390x__)
+# else
+# if defined(__s390x__)
int sa_resv;
-#else
+# else
__sanitizer_sigset_t sa_mask;
-#endif
-#if !defined(__mips__) || SANITIZER_MUSL
-#if defined(__sparc__)
-#if __GLIBC_PREREQ (2, 20)
+# endif
+# if !defined(__mips__) || SANITIZER_MUSL
+# if defined(__sparc__)
+# if __GLIBC_PREREQ(2, 20)
// On sparc glibc 2.19 and earlier sa_flags was unsigned long.
-#if defined(__arch64__)
+# if defined(__arch64__)
// To maintain ABI compatibility on sparc64 when switching to an int,
// __glibc_reserved0 was added.
int __glibc_reserved0;
-#endif
+# endif
int sa_flags;
-#else
+# else
unsigned long sa_flags;
-#endif
-#else
+# endif
+# else
int sa_flags;
-#endif
-#endif
-#endif
-#if SANITIZER_LINUX
+# endif
+# endif
+# endif
+# if SANITIZER_LINUX
void (*sa_restorer)();
-#endif
-#if defined(__mips__) && (SANITIZER_WORDSIZE == 32) && !SANITIZER_MUSL
+# endif
+# if defined(__mips__) && (SANITIZER_WORDSIZE == 32) && !SANITIZER_MUSL
int sa_resv[1];
-#endif
-#if defined(__s390x__)
+# endif
+# if defined(__s390x__)
__sanitizer_sigset_t sa_mask;
-#endif
+# endif
};
#endif // !SANITIZER_ANDROID
More information about the llvm-commits
mailing list