From b602c298a90eaee590ab46d0b6fc4b298f6ce967 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 25 Aug 2000 17:15:44 +0000 Subject: 2000-08-25 Joel Sherrill * inline/rtems/posix/timer.inl, include/rtems/posix/timer.h, inline/rtems/posix/Makefile.am, src/ptimer1.c: Redid the style of src/ptimer1.c. Continued effort to make the POSIX Timer implementation match that of other managers. Added data structures required to use SuperCore Object Handler. --- c/src/exec/posix/ChangeLog | 8 +++ c/src/exec/posix/include/rtems/posix/timer.h | 14 ++++ c/src/exec/posix/inline/rtems/posix/Makefile.am | 2 +- c/src/exec/posix/inline/rtems/posix/timer.inl | 90 +++++++++++++++++++++++++ c/src/exec/posix/src/ptimer1.c | 48 ++----------- 5 files changed, 118 insertions(+), 44 deletions(-) create mode 100644 c/src/exec/posix/inline/rtems/posix/timer.inl (limited to 'c') diff --git a/c/src/exec/posix/ChangeLog b/c/src/exec/posix/ChangeLog index 89d247b8f0..f2ae5c1ccb 100644 --- a/c/src/exec/posix/ChangeLog +++ b/c/src/exec/posix/ChangeLog @@ -1,3 +1,11 @@ +2000-08-25 Joel Sherrill + + * inline/rtems/posix/timer.inl, include/rtems/posix/timer.h, + inline/rtems/posix/Makefile.am, src/ptimer1.c: Redid the + style of src/ptimer1.c. Continued effort to make the + POSIX Timer implementation match that of other managers. + Added data structures required to use SuperCore Object Handler. + 2000-08-15 Joel Sherrill * src/ptimer1.c: Minor formatting fixes. diff --git a/c/src/exec/posix/include/rtems/posix/timer.h b/c/src/exec/posix/include/rtems/posix/timer.h index 8b11a18e65..ba0745b8b3 100644 --- a/c/src/exec/posix/include/rtems/posix/timer.h +++ b/c/src/exec/posix/include/rtems/posix/timer.h @@ -35,6 +35,9 @@ */ typedef struct { + Objects_Control Object; + Watchdog_Control Ticker; + pthread_t thread_id; /* Thread identifier */ char state; /* State of the timer */ struct sigevent inf; /* Information associated to the timer */ @@ -52,6 +55,17 @@ typedef struct { extern int timer_max; extern POSIX_Timer_Control *timer_struct; +/* + * The following defines the information control block used to manage + * this class of objects. + */ + +RTEMS_EXTERN Objects_Information _POSIX_Timer_Information; + +#ifndef __RTEMS_APPLICATION__ +#include +#endif + #endif /* end of include file */ diff --git a/c/src/exec/posix/inline/rtems/posix/Makefile.am b/c/src/exec/posix/inline/rtems/posix/Makefile.am index a38f1fa8f1..a479cf611b 100644 --- a/c/src/exec/posix/inline/rtems/posix/Makefile.am +++ b/c/src/exec/posix/inline/rtems/posix/Makefile.am @@ -6,7 +6,7 @@ AUTOMAKE_OPTIONS = foreign 1.4 #I_FILES= intr.inl I_FILES = cond.inl key.inl mqueue.inl mutex.inl pthread.inl priority.inl \ - semaphore.inl + semaphore.inl timer.inl noinst_HEADERS = $(I_FILES) diff --git a/c/src/exec/posix/inline/rtems/posix/timer.inl b/c/src/exec/posix/inline/rtems/posix/timer.inl new file mode 100644 index 0000000000..96bd86f677 --- /dev/null +++ b/c/src/exec/posix/inline/rtems/posix/timer.inl @@ -0,0 +1,90 @@ +/* timer.inl + * + * This file contains the static inline implementation of the inlined routines + * from the POSIX Timer Manager. + * + * COPYRIGHT (c) 1989-1999. + * 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.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#ifndef __POSIX_TIMER_inl +#define __POSIX_TIMER_inl + +/*PAGE + * + * _POSIX_Timer_Allocate + * + * DESCRIPTION: + * + * This function allocates a timer control block from + * the inactive chain of free timer control blocks. + */ + +RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Allocate( void ) +{ + return (POSIX_Timer_Control *) _Objects_Allocate( &_POSIX_Timer_Information ); +} + +/*PAGE + * + * _POSIX_Timer_Free + * + * DESCRIPTION: + * + * This routine frees a timer control block to the + * inactive chain of free timer control blocks. + */ + +RTEMS_INLINE_ROUTINE void _POSIX_Timer_Free ( + POSIX_Timer_Control *the_timer +) +{ + _Objects_Free( &_POSIX_Timer_Information, &the_timer->Object ); +} + +/*PAGE + * + * _POSIX_Timer_Get + * + * DESCRIPTION: + * + * This function maps timer IDs to timer control blocks. + * If ID corresponds to a local timer, then it returns + * the timer control pointer which maps to ID and location + * is set to OBJECTS_LOCAL. Otherwise, location is set + * to OBJECTS_ERROR and the returned value is undefined. + */ + +RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Get ( + Objects_Id id, + Objects_Locations *location +) +{ + return (POSIX_Timer_Control *) + _Objects_Get( &_POSIX_Timer_Information, id, location ); +} + +/*PAGE + * + * _POSIX_Timer_Is_null + * + * DESCRIPTION: + * + * This function returns TRUE if the_timer is NULL and FALSE otherwise. + */ + +RTEMS_INLINE_ROUTINE boolean _POSIX_Timer_Is_null ( + Timer_Control *the_timer +) +{ + return (the_timer == NULL); +} + +#endif +/* end of include file */ diff --git a/c/src/exec/posix/src/ptimer1.c b/c/src/exec/posix/src/ptimer1.c index 13eaa2b213..4e5f67b585 100644 --- a/c/src/exec/posix/src/ptimer1.c +++ b/c/src/exec/posix/src/ptimer1.c @@ -47,29 +47,10 @@ * Data for the signals */ -struct sigaction signal_inf[SIGRTMAX]; - /*********************************** * Definition of Internal Functions ***********************************/ -/* *************************************************************************** - * PRINT_MSG_S - * - * Description: This function write a message in the display. - * It is used for debugging and all the calls must be deleted - * when the tests finish - * ***************************************************************************/ - -static void PRINT_MSG_S ( char *msg ) -{ - -#ifdef DEBUG_MESSAGES - printf("%s\n", msg); -#endif - -} - /* *************************************************************************** * TIMER_INITIALIZE_S * @@ -215,8 +196,6 @@ rtems_timer_service_routine FIRE_TIMER_S (rtems_id timer, void *data) * expired timer will be stored in "timer_pos". In theory a timer can not * expire if it has not been created or has been deleted */ - PRINT_MSG_S ("FIRE_TIMER_S"); - timer_pos = TIMER_POSITION_F(timer); /* Increases the number of expiration of the timer in one unit. */ @@ -257,10 +236,8 @@ rtems_timer_service_routine FIRE_TIMER_S (rtems_id timer, void *data) if( pthread_kill ( timer_struct[timer_pos].thread_id , timer_struct[timer_pos].inf.sigev_signo ) ) { - PRINT_MSG_S ("ERROR_PTHREAD_KILL"); - } else { - PRINT_MSG_S ("SUCCESS_PTHREAD_KILL"); - } + /* XXX error handling */ + } /* * After the signal handler returns, the count of expirations of the @@ -313,8 +290,6 @@ int timer_create( switch (return_v) { case RTEMS_SUCCESSFUL : - PRINT_MSG_S("SUCCESS: rtems create timer RTEMS_SUCCESSFUL"); - /* * The timer has been created properly */ @@ -359,13 +334,11 @@ int timer_create( case RTEMS_INVALID_NAME : /* The assigned name is not valid */ - PRINT_MSG_S ("ERROR: rtems create timer RTEMS_INVALID_NAME"); set_errno_and_return_minus_one( EINVAL ); case RTEMS_TOO_MANY : /* There has been created too much timers for the same process */ - PRINT_MSG_S ("ERROR: rtems create timer RTEMS_TOO_MANY "); set_errno_and_return_minus_one( EAGAIN ); default : @@ -534,8 +507,6 @@ int timer_settime( switch ( return_v ) { case RTEMS_SUCCESSFUL: - PRINT_MSG_S ("SUCCESS: timer_settime RTEMS_SUCCESSFUL"); - /* The timer has been started and is running */ /* Actualizes the data of the structure and @@ -559,17 +530,17 @@ int timer_settime( case RTEMS_INVALID_ID: - PRINT_MSG_S ("ERROR: timer_settime RTEMS_INVALID_ID"); + /* XXX error handling */ break; case RTEMS_NOT_DEFINED: - PRINT_MSG_S ("ERROR: timer_settime RTEMS_NOT_DEFINED"); + /* XXX error handling */ break; case RTEMS_INVALID_CLOCK: - PRINT_MSG_S ("ERROR: timer_settime RTEMS_INVALID_CLOCK"); + /* XXX error handling */ break; default: @@ -608,8 +579,6 @@ int timer_settime( switch (return_v) { case RTEMS_SUCCESSFUL: - PRINT_MSG_S ( "SUCCESS: timer_settime RTEMS_SUCCESSFUL"); - /* The timer has been started and is running */ /* Actualizes the data of the structure and @@ -634,8 +603,6 @@ int timer_settime( case RTEMS_INVALID_ID: - PRINT_MSG_S ( "ERROR: timer_settime RTEMS_INVALID_ID"); - /* The timer identifier is not correct. In theory, this * situation can not occur, but the solution is easy */ @@ -645,8 +612,6 @@ int timer_settime( case RTEMS_INVALID_NUMBER: - PRINT_MSG_S ( "ERROR: timer_settime RTEMS_INVALID_NUMBER"); - /* In this case, RTEMS fails because the values of timing * are incorrect */ @@ -668,13 +633,10 @@ int timer_settime( /* It does nothing, although it will be probably necessary to * return an error */ - } /* To avoid problems */ - return 0; - } -- cgit v1.2.3