forked from Imagelibrary/rtems
* psx02/init.c, psx02/task.c, psx03/init.c, psx04/init.c, psx04/task1.c, psx04/task2.c, psx04/task3.c, psx05/init.c, psx05/task.c, psx05/task2.c, psx05/task3.c, psx06/init.c, psx06/task.c, psx06/task2.c, psx07/init.c, psx08/init.c, psx08/task2.c, psx08/task3.c, psx09/init.c, psx10/init.c, psx10/task.c, psx10/task2.c, psx10/task3.c, psx11/init.c, psx11/task.c, psx12/init.c, psxalarm01/init.c, psxbarrier01/test.c, psxcancel01/init.c, psxchroot01/test.c, psxitimer/init.c, psxkey01/task.c, psxkey02/init.c, psxkey03/init.c, psxmount/test.c, psxmsgq01/init.c, psxmsgq03/init.c, psxmsgq04/init.c, psxrwlock01/test.c, psxsem01/init.c, psxsignal01/init.c, psxsignal01/task1.c, psxsignal02/init.c, psxsignal03/init.c, psxsignal05/init.c, psxspin01/test.c, psxspin02/test.c, psxstack01/init.c, psxstack02/init.c, psxualarm/init.c: Eliminate double space after parenthesis on rtems_test_assert().
120 lines
2.6 KiB
C
120 lines
2.6 KiB
C
/*
|
|
* 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$
|
|
*/
|
|
|
|
#include <pmacros.h>
|
|
#include <errno.h>
|
|
|
|
volatile int TSR_occurred;
|
|
volatile int TSR_status;
|
|
|
|
rtems_id timer_id;
|
|
|
|
rtems_timer_service_routine Cancel_duringISR_TSR(
|
|
rtems_id ignored_id,
|
|
void *ignored_address
|
|
)
|
|
{
|
|
TSR_status = pthread_cancel( pthread_self() );
|
|
TSR_occurred = 1;
|
|
}
|
|
|
|
rtems_timer_service_routine SetState_duringISR_TSR(
|
|
rtems_id ignored_id,
|
|
void *ignored_address
|
|
)
|
|
{
|
|
int oldstate;
|
|
|
|
TSR_status = pthread_setcancelstate( 0, &oldstate );
|
|
TSR_occurred = 1;
|
|
}
|
|
|
|
rtems_timer_service_routine SetType_duringISR_TSR(
|
|
rtems_id ignored_id,
|
|
void *ignored_address
|
|
)
|
|
{
|
|
int oldtype;
|
|
|
|
TSR_status = pthread_setcanceltype( 0, &oldtype );
|
|
TSR_occurred = 1;
|
|
}
|
|
|
|
void doit(
|
|
rtems_timer_service_routine (*TSR)(rtems_id, void *),
|
|
const char *method
|
|
)
|
|
{
|
|
rtems_interval start;
|
|
rtems_interval end;
|
|
rtems_status_code status;
|
|
|
|
printf( "Init: schedule %s from a TSR\n", method );
|
|
|
|
TSR_occurred = 0;
|
|
TSR_status = 0;
|
|
|
|
status = rtems_timer_fire_after( timer_id, 10, TSR, NULL );
|
|
rtems_test_assert( !status );
|
|
|
|
start = rtems_clock_get_ticks_since_boot();
|
|
do {
|
|
end = rtems_clock_get_ticks_since_boot();
|
|
} while ( !TSR_occurred && ((end - start) <= 800));
|
|
|
|
if ( !TSR_occurred ) {
|
|
printf( "%s did not occur\n", method );
|
|
rtems_test_exit(0);
|
|
}
|
|
if ( TSR_status != EPROTO ) {
|
|
printf( "%s returned %s\n", method, strerror(TSR_status) );
|
|
rtems_test_exit(0);
|
|
}
|
|
printf( "%s - from ISR returns EPROTO - OK\n", method );
|
|
|
|
}
|
|
|
|
void *POSIX_Init(
|
|
void *argument
|
|
)
|
|
{
|
|
rtems_status_code status;
|
|
|
|
puts( "\n\n*** POSIX TEST CANCEL 01 ***" );
|
|
|
|
status = rtems_timer_create(
|
|
rtems_build_name( 'T', 'M', '1', ' ' ),
|
|
&timer_id
|
|
);
|
|
rtems_test_assert( !status );
|
|
|
|
doit( Cancel_duringISR_TSR, "pthread_cancel" );
|
|
doit( SetState_duringISR_TSR, "pthread_setcancelstate" );
|
|
doit( SetType_duringISR_TSR, "pthread_setcanceltype" );
|
|
|
|
puts( "*** END OF POSIX TEST CANCEL 01 ***" );
|
|
rtems_test_exit(0);
|
|
return NULL; /* just so the compiler thinks we returned something */
|
|
}
|
|
|
|
/* configuration information */
|
|
|
|
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
|
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
|
|
|
#define CONFIGURE_MAXIMUM_TIMERS 1
|
|
|
|
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
|
|
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
|
|
|
|
#define CONFIGURE_INIT
|
|
#include <rtems/confdefs.h>
|