Module: xenomai-gch
Branch: for-head
Commit: ecc2db3b21b6939d1bfa15b475e67975446d26a4
URL:    
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=ecc2db3b21b6939d1bfa15b475e67975446d26a4

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Tue Nov 24 07:58:02 2009 +0100

skins: move sigshadow to libxeno_common

---

 include/asm-generic/bits/sigshadow.h |   74 +--------------------------------
 src/skins/common/Makefile.am         |    2 +-
 src/skins/common/sigshadow.c         |   75 ++++++++++++++++++++++++++++++++++
 3 files changed, 79 insertions(+), 72 deletions(-)

diff --git a/include/asm-generic/bits/sigshadow.h 
b/include/asm-generic/bits/sigshadow.h
index c2fbfa2..5a32762 100644
--- a/include/asm-generic/bits/sigshadow.h
+++ b/include/asm-generic/bits/sigshadow.h
@@ -4,78 +4,10 @@
 #include <pthread.h>
 #include <signal.h>
 
-pthread_once_t __attribute__((weak))
-       xeno_sigshadow_installed = PTHREAD_ONCE_INIT;
-struct sigaction __attribute__((weak)) xeno_saved_sigshadow_action;
+extern pthread_once_t __attribute__((weak)) xeno_sigshadow_installed;
+extern struct sigaction __attribute__((weak)) xeno_saved_sigshadow_action;
 
-int __attribute__((weak))
-xeno_sigwinch_handler(int sig, siginfo_t *si, void *ctxt)
-{
-       int action;
-
-       if (si->si_code != SI_QUEUE)
-               return 0;
-
-       action = sigshadow_action(si->si_int);
-
-       switch(action) {
-       case SIGSHADOW_ACTION_HARDEN:
-               XENOMAI_SYSCALL1(__xn_sys_migrate, XENOMAI_XENO_DOMAIN);
-               break;
-
-       case SIGSHADOW_ACTION_RENICE: {
-               struct sched_param param;
-               int policy;
-
-               param.sched_priority = sigshadow_arg(si->si_int);
-               policy = param.sched_priority > 0 ? SCHED_FIFO: SCHED_OTHER;
-               pthread_setschedparam(pthread_self(), policy, &param);
-               break;
-       }
-
-       default:
-               return 0;
-       }
-
-       return 1;
-}
-
-void __attribute__((weak))
-xeno_sigshadow_handler(int sig, siginfo_t *si, void *ctxt)
-{
-       const struct sigaction *const sa = &xeno_saved_sigshadow_action;
-       sigset_t saved_sigset;
-
-       if (xeno_sigwinch_handler(sig, si, ctxt))
-               return;
-
-       /* Not a signal sent by Xenomai nucleus */
-       if ((!(sa->sa_flags & SA_SIGINFO) && !sa->sa_handler)
-           || ((sa->sa_flags & SA_SIGINFO) && !sa->sa_sigaction))
-               return;
-
-       pthread_sigmask(SIG_SETMASK, &sa->sa_mask, &saved_sigset);
-       if (!(sa->sa_flags & SA_SIGINFO))
-               sa->sa_handler(sig);
-       else
-               sa->sa_sigaction(sig, si, ctxt);
-       pthread_sigmask(SIG_SETMASK, &saved_sigset, NULL);
-       return;
-}
-
-void __attribute__((weak)) xeno_sigshadow_install(void)
-{
-       struct sigaction new_sigshadow_action;
-
-       new_sigshadow_action.sa_flags = SA_SIGINFO | SA_RESTART;
-       new_sigshadow_action.sa_sigaction = xeno_sigshadow_handler;
-       sigemptyset(&new_sigshadow_action.sa_mask);
-
-       sigaction(SIGSHADOW,
-                 &new_sigshadow_action, &xeno_saved_sigshadow_action);
-       if (!(xeno_saved_sigshadow_action.sa_flags & SA_NODEFER))
-               sigaddset(&xeno_saved_sigshadow_action.sa_mask, SIGSHADOW);
-}
+void __attribute__((weak)) xeno_sigshadow_install(void);
 
 static inline void sigshadow_install_once(void)
 {
diff --git a/src/skins/common/Makefile.am b/src/skins/common/Makefile.am
index f846c61..4a785d5 100644
--- a/src/skins/common/Makefile.am
+++ b/src/skins/common/Makefile.am
@@ -1,7 +1,7 @@
 noinst_LTLIBRARIES = libxeno_common.la
 noinst_HEADERS = sem_heap.h
 
-libxeno_common_la_SOURCES = bind.c current.c
+libxeno_common_la_SOURCES = bind.c current.c sigshadow.c
 
 if CONFIG_XENO_FASTSYNCH
 libxeno_common_la_SOURCES += sem_heap.c
diff --git a/src/skins/common/sigshadow.c b/src/skins/common/sigshadow.c
new file mode 100644
index 0000000..c1de323
--- /dev/null
+++ b/src/skins/common/sigshadow.c
@@ -0,0 +1,75 @@
+#include <asm/xenomai/syscall.h>
+#include <asm-generic/xenomai/bits/sigshadow.h>
+
+pthread_once_t __attribute__((weak))
+       xeno_sigshadow_installed = PTHREAD_ONCE_INIT;
+struct sigaction __attribute__((weak)) xeno_saved_sigshadow_action;
+
+int __attribute__((weak))
+xeno_sigwinch_handler(int sig, siginfo_t *si, void *ctxt)
+{
+       int action;
+
+       if (si->si_code != SI_QUEUE)
+               return 0;
+
+       action = sigshadow_action(si->si_int);
+
+       switch(action) {
+       case SIGSHADOW_ACTION_HARDEN:
+               XENOMAI_SYSCALL1(__xn_sys_migrate, XENOMAI_XENO_DOMAIN);
+               break;
+
+       case SIGSHADOW_ACTION_RENICE: {
+               struct sched_param param;
+               int policy;
+
+               param.sched_priority = sigshadow_arg(si->si_int);
+               policy = param.sched_priority > 0 ? SCHED_FIFO: SCHED_OTHER;
+               pthread_setschedparam(pthread_self(), policy, &param);
+               break;
+       }
+
+       default:
+               return 0;
+       }
+
+       return 1;
+}
+
+void __attribute__((weak))
+xeno_sigshadow_handler(int sig, siginfo_t *si, void *ctxt)
+{
+       const struct sigaction *const sa = &xeno_saved_sigshadow_action;
+       sigset_t saved_sigset;
+
+       if (xeno_sigwinch_handler(sig, si, ctxt))
+               return;
+
+       /* Not a signal sent by Xenomai nucleus */
+       if ((!(sa->sa_flags & SA_SIGINFO) && !sa->sa_handler)
+           || ((sa->sa_flags & SA_SIGINFO) && !sa->sa_sigaction))
+               return;
+
+       pthread_sigmask(SIG_SETMASK, &sa->sa_mask, &saved_sigset);
+       if (!(sa->sa_flags & SA_SIGINFO))
+               sa->sa_handler(sig);
+       else
+               sa->sa_sigaction(sig, si, ctxt);
+       pthread_sigmask(SIG_SETMASK, &saved_sigset, NULL);
+       return;
+}
+
+void __attribute__((weak)) xeno_sigshadow_install(void)
+{
+       struct sigaction new_sigshadow_action;
+
+       new_sigshadow_action.sa_flags = SA_SIGINFO | SA_RESTART;
+       new_sigshadow_action.sa_sigaction = xeno_sigshadow_handler;
+       sigemptyset(&new_sigshadow_action.sa_mask);
+
+       sigaction(SIGSHADOW,
+                 &new_sigshadow_action, &xeno_saved_sigshadow_action);
+       if (!(xeno_saved_sigshadow_action.sa_flags & SA_NODEFER))
+               sigaddset(&xeno_saved_sigshadow_action.sa_mask, SIGSHADOW);
+}


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to