[PATCH 5/5] posix: Add signal post switch extension on the fly

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Dec 3 11:54:11 UTC 2012


---
 cpukit/posix/include/rtems/posix/psignalimpl.h |   10 +++++++---
 cpukit/posix/src/killinfo.c                    |    2 ++
 cpukit/posix/src/psignal.c                     |    6 +++++-
 cpukit/posix/src/pthread.c                     |    5 -----
 cpukit/posix/src/pthreadkill.c                 |    2 ++
 5 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/cpukit/posix/include/rtems/posix/psignalimpl.h b/cpukit/posix/include/rtems/posix/psignalimpl.h
index e61fe3f..6c46f3c 100644
--- a/cpukit/posix/include/rtems/posix/psignalimpl.h
+++ b/cpukit/posix/include/rtems/posix/psignalimpl.h
@@ -19,6 +19,7 @@
 #include <rtems/posix/psignal.h>
 #include <rtems/posix/pthread.h>
 #include <rtems/posix/sigset.h>
+#include <rtems/score/apiext.h>
 
 #define _States_Is_interruptible_signal( _states ) \
   ( ((_states) & \
@@ -56,15 +57,18 @@ extern Chain_Control _POSIX_signals_Inactive_siginfo;
 
 extern Chain_Control _POSIX_signals_Siginfo[ SIG_ARRAY_MAX ];
 
+extern API_extensions_Post_switch_control _POSIX_signals_Post_switch;
+
 /*
  *  Internal routines
  */
 
 void _POSIX_signals_Manager_Initialization(void);
 
-void _POSIX_signals_Post_switch_extension(
-  Thread_Control  *the_thread
-);
+static inline void _POSIX_signals_Add_post_switch_extension(void)
+{
+  _API_extensions_Add_post_switch( &_POSIX_signals_Post_switch );
+}
 
 bool _POSIX_signals_Unblock_thread(
   Thread_Control  *the_thread,
diff --git a/cpukit/posix/src/killinfo.c b/cpukit/posix/src/killinfo.c
index 59329ee..95a2459 100644
--- a/cpukit/posix/src/killinfo.c
+++ b/cpukit/posix/src/killinfo.c
@@ -114,6 +114,8 @@ int killinfo(
 
   _Thread_Disable_dispatch();
 
+  _POSIX_signals_Add_post_switch_extension();
+
   /*
    *  Is the currently executing thread interested?  If so then it will
    *  get it an execute it as soon as the dispatcher executes.
diff --git a/cpukit/posix/src/psignal.c b/cpukit/posix/src/psignal.c
index aa76d0d..7623920 100644
--- a/cpukit/posix/src/psignal.c
+++ b/cpukit/posix/src/psignal.c
@@ -103,7 +103,7 @@ Watchdog_Control _POSIX_signals_Ualarm_timer;
  *  _POSIX_signals_Post_switch_extension
  */
 
-void _POSIX_signals_Post_switch_extension(
+static void _POSIX_signals_Post_switch_hook(
   Thread_Control  *the_thread
 )
 {
@@ -158,6 +158,10 @@ void _POSIX_signals_Post_switch_extension(
   _Thread_Executing->Wait.return_code = hold_errno;
 }
 
+API_extensions_Post_switch_control _POSIX_signals_Post_switch = {
+  .hook = _POSIX_signals_Post_switch_hook
+};
+
 /*
  *  _POSIX_signals_Manager_Initialization
  */
diff --git a/cpukit/posix/src/pthread.c b/cpukit/posix/src/pthread.c
index 8923aeb..1773c24 100644
--- a/cpukit/posix/src/pthread.c
+++ b/cpukit/posix/src/pthread.c
@@ -311,10 +311,6 @@ API_extensions_Control _POSIX_Threads_API_extensions = {
   .postdriver_hook = _POSIX_Threads_Initialize_user_threads
 };
 
-API_extensions_Post_switch_control _POSIX_Threads_API_extensions_post_switch = {
-  .hook = _POSIX_signals_Post_switch_extension
-};
-
 User_extensions_Control _POSIX_Threads_User_extensions = {
   { NULL, NULL },
   { { NULL, NULL }, NULL },
@@ -359,7 +355,6 @@ void _POSIX_Threads_Manager_initialization(void)
   _User_extensions_Add_API_set( &_POSIX_Threads_User_extensions );
 
   _API_extensions_Add( &_POSIX_Threads_API_extensions );
-  _API_extensions_Add_post_switch( &_POSIX_Threads_API_extensions_post_switch );
 
   /*
    *  If we supported MP, then here we would ...
diff --git a/cpukit/posix/src/pthreadkill.c b/cpukit/posix/src/pthreadkill.c
index 0caaa2a..67ef0c7 100644
--- a/cpukit/posix/src/pthreadkill.c
+++ b/cpukit/posix/src/pthreadkill.c
@@ -46,6 +46,8 @@ int pthread_kill(
        *  If sig == 0 then just validate arguments
        */
 
+      _POSIX_signals_Add_post_switch_extension();
+
       api = the_thread->API_Extensions[ THREAD_API_POSIX ];
 
       if ( sig ) {
-- 
1.7.7




More information about the devel mailing list