[Android] jni: use a static array to store the minitored crash signals
Adrien Maglo
git at videolan.org
Thu May 8 09:35:47 CEST 2014
vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Thu May 8 09:35:41 2014 +0200| [c7cc1ed5704b9f4a93f68d9c5e0cfec41a958622] | committer: Adrien Maglo
jni: use a static array to store the minitored crash signals
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=c7cc1ed5704b9f4a93f68d9c5e0cfec41a958622
---
vlc-android/jni/native_crash_handler.c | 38 ++++++++++++++++++--------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/vlc-android/jni/native_crash_handler.c b/vlc-android/jni/native_crash_handler.c
index cde180d..47c7150 100644
--- a/vlc-android/jni/native_crash_handler.c
+++ b/vlc-android/jni/native_crash_handler.c
@@ -25,10 +25,20 @@
static struct sigaction old_actions[NSIG];
static jobject j_libVLC;
-
/** Unique Java VM instance, as defined in libvlcjni.c */
extern JavaVM *myVm;
+// Monitored signals.
+static const int monitored_signals[] = {
+ SIGILL,
+ SIGABRT,
+ SIGBUS,
+ SIGFPE,
+ SIGSEGV,
+ SIGSTKFLT,
+ SIGPIPE
+};
+
/**
* Callback called when a monitored signal is triggered.
@@ -61,28 +71,22 @@ void init_native_crash_handler(JNIEnv *env, jobject j_libVLC_local)
handler.sa_flags = SA_RESETHAND;
// Install the signal handlers and save their old actions.
- #define CATCHSIG(X) sigaction(X, &handler, &old_actions[X])
- CATCHSIG(SIGILL);
- CATCHSIG(SIGABRT);
- CATCHSIG(SIGBUS);
- CATCHSIG(SIGFPE);
- CATCHSIG(SIGSEGV);
- CATCHSIG(SIGSTKFLT);
- CATCHSIG(SIGPIPE);
+ for (unsigned i = 0; i < sizeof(monitored_signals) / sizeof(int); ++i)
+ {
+ const int s = monitored_signals[i];
+ sigaction(s, &handler, &old_actions[s]);
+ }
}
void destroy_native_crash_handler(JNIEnv *env)
{
// Uninstall the signal handlers and restore their old actions.
- #define REMOVESIG(X) sigaction(X, &old_actions[X], NULL)
- REMOVESIG(SIGILL);
- REMOVESIG(SIGABRT);
- REMOVESIG(SIGBUS);
- REMOVESIG(SIGFPE);
- REMOVESIG(SIGSEGV);
- REMOVESIG(SIGSTKFLT);
- REMOVESIG(SIGPIPE);
+ for (unsigned i = 0; i < sizeof(monitored_signals) / sizeof(int); ++i)
+ {
+ const int s = monitored_signals[i];
+ sigaction(s, &old_actions[s], NULL);
+ }
(*env)->DeleteGlobalRef(env, j_libVLC);
}
More information about the Android
mailing list