summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2013-07-22 09:15:04 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-07-22 16:57:25 +0200
commit47ac81f645aba2fba985fa991f532173e6dd5b78 (patch)
tree53b48f45318df093ce21aa79ceaaf4e797443511
parent918d5565b202270d930b6f819672404fa8fa32de (diff)
downloadrtems-47ac81f645aba2fba985fa991f532173e6dd5b78.tar.bz2
posix: Obtain _Thread_Executing in proper context
-rw-r--r--cpukit/posix/src/setcancelstate.c9
-rw-r--r--cpukit/posix/src/setcanceltype.c9
-rw-r--r--cpukit/posix/src/testcancel.c8
3 files changed, 17 insertions, 9 deletions
diff --git a/cpukit/posix/src/setcancelstate.c b/cpukit/posix/src/setcancelstate.c
index 0d85fe624c..e3c5349365 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 f97affa8fb..9398c22cea 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 f999fe54a9..876f62c768 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 );
}