mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-22 12:18:21 +08:00
2009-07-21 Santosh G Vattam <vattam.santosh@gmail.com>
* posix/Makefile.am, posix/include/rtems/posix/cancel.h, posix/src/cancel.c, posix/src/setcancelstate.c, posix/src/setcanceltype.c: Add _POSIX_Thread_Evaluate_cancellation_and_enable_dispatch method to avoid duplication of code and ease coverage analysis. * posix/src/canceleval.c: New file.
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
2009-07-21 Santosh G Vattam <vattam.santosh@gmail.com>
|
||||
|
||||
* posix/Makefile.am, posix/include/rtems/posix/cancel.h,
|
||||
posix/src/cancel.c, posix/src/setcancelstate.c,
|
||||
posix/src/setcanceltype.c: Add
|
||||
_POSIX_Thread_Evaluate_cancellation_and_enable_dispatch method to
|
||||
avoid duplication of code and ease coverage analysis.
|
||||
* posix/src/canceleval.c: New file.
|
||||
|
||||
2009-07-20 Joel Sherrill <joel.sherrill@OARcorp.com>
|
||||
|
||||
* score/src/corebarrierwait.c: Reverse order of tests to increase test
|
||||
|
||||
@@ -69,9 +69,9 @@ libposix_a_SOURCES += src/barrierattrdestroy.c src/barrierattrgetpshared.c \
|
||||
src/pbarriertranslatereturncode.c src/pbarrierwait.c
|
||||
|
||||
## CANCEL_C_FILES
|
||||
libposix_a_SOURCES += src/cancel.c src/cancelrun.c src/cleanuppop.c \
|
||||
src/cleanuppush.c src/setcancelstate.c src/setcanceltype.c \
|
||||
src/testcancel.c
|
||||
libposix_a_SOURCES += src/cancel.c src/canceleval.c src/cancelrun.c \
|
||||
src/cleanuppop.c src/cleanuppush.c src/setcancelstate.c \
|
||||
src/setcanceltype.c src/testcancel.c
|
||||
|
||||
## CONDITION_VARIABLE_C_FILES
|
||||
libposix_a_SOURCES += src/cond.c src/condattrdestroy.c \
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2007.
|
||||
* COPYRIGHT (c) 1989-2009.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
@@ -16,6 +16,8 @@
|
||||
#ifndef _RTEMS_POSIX_CANCEL_H
|
||||
#define _RTEMS_POSIX_CANCEL_H
|
||||
|
||||
#include <rtems/posix/threadsup.h>
|
||||
|
||||
typedef struct {
|
||||
Chain_Node Node;
|
||||
void (*routine)( void * );
|
||||
@@ -35,5 +37,18 @@ void _POSIX_Threads_cancel_run(
|
||||
Thread_Control *the_thread
|
||||
);
|
||||
|
||||
/*
|
||||
* _POSIX_Thread_Evaluate_cancellation_and_enable_dispatch
|
||||
*
|
||||
* DESCRIPTION:
|
||||
*
|
||||
* This routine separates a piece of code that existed as part of
|
||||
* another routine, but had to be separated to improve coverage.
|
||||
*/
|
||||
|
||||
void _POSIX_Thread_Evaluate_cancellation_and_enable_dispatch (
|
||||
POSIX_API_Control *thread_support
|
||||
);
|
||||
|
||||
#endif
|
||||
/* end of include file */
|
||||
|
||||
@@ -25,8 +25,7 @@
|
||||
#include <rtems/posix/pthread.h>
|
||||
#include <rtems/posix/threadsup.h>
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
/*
|
||||
* 18.2.1 Canceling Execution of a Thread, P1003.1c/Draft 10, p. 181
|
||||
*/
|
||||
|
||||
@@ -37,7 +36,6 @@ int pthread_cancel(
|
||||
Thread_Control *the_thread;
|
||||
POSIX_API_Control *thread_support;
|
||||
Objects_Locations location;
|
||||
bool cancel = false;
|
||||
|
||||
/*
|
||||
* Don't even think about deleting a resource from an ISR.
|
||||
@@ -54,13 +52,7 @@ int pthread_cancel(
|
||||
|
||||
thread_support->cancelation_requested = 1;
|
||||
|
||||
if (thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&
|
||||
thread_support->cancelability_type == PTHREAD_CANCEL_ASYNCHRONOUS)
|
||||
cancel = true;
|
||||
|
||||
_Thread_Enable_dispatch();
|
||||
if ( cancel )
|
||||
_POSIX_Thread_Exit( the_thread, PTHREAD_CANCELED );
|
||||
_POSIX_Thread_Evaluate_cancellation_and_enable_dispatch( thread_support );
|
||||
return 0;
|
||||
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2009.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <pthread.h>
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/thread.h>
|
||||
#include <rtems/posix/cancel.h>
|
||||
#include <rtems/posix/pthread.h>
|
||||
|
||||
void _POSIX_Thread_Evaluate_cancellation_and_enable_dispatch(
|
||||
POSIX_API_Control *thread_support
|
||||
)
|
||||
{
|
||||
bool cancel = false;
|
||||
|
||||
if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&
|
||||
thread_support->cancelability_type == PTHREAD_CANCEL_ASYNCHRONOUS &&
|
||||
thread_support->cancelation_requested )
|
||||
cancel = true;
|
||||
|
||||
_Thread_Enable_dispatch();
|
||||
|
||||
if ( cancel )
|
||||
_POSIX_Thread_Exit( _Thread_Executing, PTHREAD_CANCELED );
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2008.
|
||||
* COPYRIGHT (c) 1989-2009.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
@@ -20,13 +20,11 @@
|
||||
#include <rtems/score/chain.h>
|
||||
#include <rtems/score/isr.h>
|
||||
#include <rtems/score/thread.h>
|
||||
#include <rtems/score/wkspace.h>
|
||||
#include <rtems/posix/cancel.h>
|
||||
#include <rtems/posix/pthread.h>
|
||||
#include <rtems/posix/threadsup.h>
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
/*
|
||||
* 18.2.2 Setting Cancelability State, P1003.1c/Draft 10, p. 183
|
||||
*/
|
||||
|
||||
@@ -36,7 +34,6 @@ int pthread_setcancelstate(
|
||||
)
|
||||
{
|
||||
POSIX_API_Control *thread_support;
|
||||
bool cancel = false;
|
||||
|
||||
/*
|
||||
* Don't even think about deleting a resource from an ISR.
|
||||
@@ -59,13 +56,11 @@ int pthread_setcancelstate(
|
||||
*oldstate = thread_support->cancelability_state;
|
||||
thread_support->cancelability_state = state;
|
||||
|
||||
if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&
|
||||
thread_support->cancelability_type == PTHREAD_CANCEL_ASYNCHRONOUS &&
|
||||
thread_support->cancelation_requested )
|
||||
cancel = true;
|
||||
_POSIX_Thread_Evaluate_cancellation_and_enable_dispatch( thread_support );
|
||||
|
||||
/*
|
||||
* _Thread_Enable_dispatch is invoked by above call.
|
||||
*/
|
||||
|
||||
_Thread_Enable_dispatch();
|
||||
if ( cancel )
|
||||
_POSIX_Thread_Exit( _Thread_Executing, PTHREAD_CANCELED );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2008.
|
||||
* COPYRIGHT (c) 1989-2009.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
@@ -20,13 +20,11 @@
|
||||
#include <rtems/score/chain.h>
|
||||
#include <rtems/score/isr.h>
|
||||
#include <rtems/score/thread.h>
|
||||
#include <rtems/score/wkspace.h>
|
||||
#include <rtems/posix/cancel.h>
|
||||
#include <rtems/posix/pthread.h>
|
||||
#include <rtems/posix/threadsup.h>
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
/*
|
||||
* 18.2.2 Setting Cancelability State, P1003.1c/Draft 10, p. 183
|
||||
*/
|
||||
|
||||
@@ -36,7 +34,6 @@ int pthread_setcanceltype(
|
||||
)
|
||||
{
|
||||
POSIX_API_Control *thread_support;
|
||||
bool cancel = false;
|
||||
|
||||
/*
|
||||
* Don't even think about deleting a resource from an ISR.
|
||||
@@ -59,13 +56,10 @@ int pthread_setcanceltype(
|
||||
*oldtype = thread_support->cancelability_type;
|
||||
thread_support->cancelability_type = type;
|
||||
|
||||
if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&
|
||||
thread_support->cancelability_type == PTHREAD_CANCEL_ASYNCHRONOUS &&
|
||||
thread_support->cancelation_requested )
|
||||
cancel = true;
|
||||
_Thread_Enable_dispatch();
|
||||
if ( cancel )
|
||||
_POSIX_Thread_Exit( _Thread_Executing, PTHREAD_CANCELED );
|
||||
|
||||
_POSIX_Thread_Evaluate_cancellation_and_enable_dispatch( thread_support );
|
||||
|
||||
/*
|
||||
* _Thread_Enable_dispatch is invoked by above call.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user