[rtems commit] posix: Obtain _Thread_Executing in proper context
Sebastian Huber
sebh at rtems.org
Mon Jul 22 14:51:44 UTC 2013
Module: rtems
Branch: master
Commit: 47ac81f645aba2fba985fa991f532173e6dd5b78
Changeset: http://git.rtems.org/rtems/commit/?id=47ac81f645aba2fba985fa991f532173e6dd5b78
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Mon Jul 22 09:15:04 2013 +0200
posix: Obtain _Thread_Executing in proper context
---
cpukit/posix/src/setcancelstate.c | 9 ++++++---
cpukit/posix/src/setcanceltype.c | 9 ++++++---
cpukit/posix/src/testcancel.c | 8 +++++---
3 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/cpukit/posix/src/setcancelstate.c b/cpukit/posix/src/setcancelstate.c
index 0d85fe6..e3c5349 100644
--- a/cpukit/posix/src/setcancelstate.c
+++ b/cpukit/posix/src/setcancelstate.c
@@ -39,6 +39,7 @@ int pthread_setcancelstate(
)
{
POSIX_API_Control *thread_support;
+ Thread_Control *executing;
/*
* Don't even think about deleting a resource from an ISR.
@@ -55,13 +56,15 @@ int pthread_setcancelstate(
if ( state != PTHREAD_CANCEL_ENABLE && state != PTHREAD_CANCEL_DISABLE )
return EINVAL;
- thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];
-
_Thread_Disable_dispatch();
+
+ executing = _Thread_Executing;
+ thread_support = executing ->API_Extensions[ THREAD_API_POSIX ];
+
*oldstate = thread_support->cancelability_state;
thread_support->cancelability_state = state;
- _POSIX_Thread_Evaluate_cancellation_and_enable_dispatch(_Thread_Executing);
+ _POSIX_Thread_Evaluate_cancellation_and_enable_dispatch( executing );
/*
* _Thread_Enable_dispatch is invoked by above call.
diff --git a/cpukit/posix/src/setcanceltype.c b/cpukit/posix/src/setcanceltype.c
index f97affa..9398c22 100644
--- a/cpukit/posix/src/setcanceltype.c
+++ b/cpukit/posix/src/setcanceltype.c
@@ -39,6 +39,7 @@ int pthread_setcanceltype(
)
{
POSIX_API_Control *thread_support;
+ Thread_Control *executing;
/*
* Don't even think about deleting a resource from an ISR.
@@ -55,13 +56,15 @@ int pthread_setcanceltype(
if ( type != PTHREAD_CANCEL_DEFERRED && type != PTHREAD_CANCEL_ASYNCHRONOUS )
return EINVAL;
- thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];
-
_Thread_Disable_dispatch();
+
+ executing = _Thread_Executing;
+ thread_support = executing ->API_Extensions[ THREAD_API_POSIX ];
+
*oldtype = thread_support->cancelability_type;
thread_support->cancelability_type = type;
- _POSIX_Thread_Evaluate_cancellation_and_enable_dispatch(_Thread_Executing);
+ _POSIX_Thread_Evaluate_cancellation_and_enable_dispatch( executing );
/*
* _Thread_Enable_dispatch is invoked by above call.
diff --git a/cpukit/posix/src/testcancel.c b/cpukit/posix/src/testcancel.c
index f999fe5..876f62c 100644
--- a/cpukit/posix/src/testcancel.c
+++ b/cpukit/posix/src/testcancel.c
@@ -37,6 +37,7 @@
void pthread_testcancel( void )
{
POSIX_API_Control *thread_support;
+ Thread_Control *executing;
bool cancel = false;
/*
@@ -48,14 +49,15 @@ void pthread_testcancel( void )
if ( _ISR_Is_in_progress() )
return;
- thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];
-
_Thread_Disable_dispatch();
+ executing = _Thread_Executing;
+ thread_support = executing->API_Extensions[ THREAD_API_POSIX ];
+
if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&
thread_support->cancelation_requested )
cancel = true;
_Thread_Enable_dispatch();
if ( cancel )
- _POSIX_Thread_Exit( _Thread_Executing, PTHREAD_CANCELED );
+ _POSIX_Thread_Exit( executing, PTHREAD_CANCELED );
}
More information about the vc
mailing list