[PATCH] D39824: [msan] Extract signal_impl and sigaction_impl
Vitaly Buka via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 8 16:57:55 PST 2017
vitalybuka updated this revision to Diff 122181.
vitalybuka added a comment.
less moving
https://reviews.llvm.org/D39824
Files:
compiler-rt/lib/msan/msan_interceptors.cc
Index: compiler-rt/lib/msan/msan_interceptors.cc
===================================================================
--- compiler-rt/lib/msan/msan_interceptors.cc
+++ compiler-rt/lib/msan/msan_interceptors.cc
@@ -1006,8 +1006,22 @@
CHECK_UNPOISONED(&act->sa_mask, sizeof(act->sa_mask));
}
-INTERCEPTOR(int, sigaction, int signo, const __sanitizer_sigaction *act,
+static int sigaction_impl(int signum, const __sanitizer_sigaction *act,
+ __sanitizer_sigaction *oldact);
+static void *signal_impl(int signum, void *handler);
+
+INTERCEPTOR(int, sigaction, int signum, const __sanitizer_sigaction *act,
__sanitizer_sigaction *oldact) {
+ return sigaction_impl(signum, act, oldact);
+}
+
+INTERCEPTOR(int, signal, int signum, void *handler) {
+ handler = signal_impl(signum, handler);
+ return REAL(signal)(signum, handler);
+}
+
+static int sigaction_impl(int signo, const __sanitizer_sigaction *act,
+ __sanitizer_sigaction *oldact) {
ENSURE_MSAN_INITED();
if (act) read_sigaction(act);
int res;
@@ -1045,19 +1059,18 @@
return res;
}
-INTERCEPTOR(int, signal, int signo, uptr cb) {
+static void *signal_impl(int signo, void *handler) {
ENSURE_MSAN_INITED();
if (flags()->wrap_signals) {
CHECK_LT(signo, kMaxSignals);
SpinMutexLock lock(&sigactions_mu);
+ uptr cb = (uptr)handler;
if (cb != __sanitizer::sig_ign && cb != __sanitizer::sig_dfl) {
atomic_store(&sigactions[signo], cb, memory_order_relaxed);
- cb = (uptr) SignalHandler;
+ return (void *)&SignalHandler;
}
- return REAL(signal)(signo, cb);
- } else {
- return REAL(signal)(signo, cb);
}
+ return handler;
}
extern "C" int pthread_attr_init(void *attr);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39824.122181.patch
Type: text/x-patch
Size: 1762 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171109/f47d65bd/attachment.bin>
More information about the llvm-commits
mailing list