summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/ptimer1.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/posix/src/ptimer1.c')
-rw-r--r--cpukit/posix/src/ptimer1.c186
1 files changed, 93 insertions, 93 deletions
diff --git a/cpukit/posix/src/ptimer1.c b/cpukit/posix/src/ptimer1.c
index 4758b68113..6f7ec2466f 100644
--- a/cpukit/posix/src/ptimer1.c
+++ b/cpukit/posix/src/ptimer1.c
@@ -5,7 +5,7 @@
#if HAVE_CONFIG_H
#include "config.h"
#endif
-
+
#include <assert.h>
#include <time.h>
#include <errno.h>
@@ -39,16 +39,16 @@
/* End of necessary includes */
/*****************************/
-/* ************
+/* ************
* Constants
- * ************/
+ * ************/
/*
#define DEBUG_MESSAGES
*/
/*
- * Data for the signals
+ * Data for the signals
*/
/***********************************
@@ -58,7 +58,7 @@
/* ***************************************************************************
* TIMER_INITIALIZE_S
*
- * Description: Initialize the data of a timer
+ * Description: Initialize the data of a timer
* ***************************************************************************/
extern void TIMER_INITIALIZE_S ( int timer_pos );
@@ -66,17 +66,17 @@ extern void TIMER_INITIALIZE_S ( int timer_pos );
/* ***************************************************************************
* _POSIX_Timer_Manager_initialization
*
- * Description: Initialize the internal structure in which the data of all
+ * Description: Initialize the internal structure in which the data of all
* the timers are stored
* ***************************************************************************/
/* split to reduce minimum size */
/* ***************************************************************************
- * FIRST_FREE_POSITION_F
+ * FIRST_FREE_POSITION_F
*
* Description: Returns the first free position in the table of timers.
- * If there is not a free position, it returns NO_MORE_TIMERS_C
+ * If there is not a free position, it returns NO_MORE_TIMERS_C
* ***************************************************************************/
int FIRST_FREE_POSITION_F ()
@@ -88,14 +88,14 @@ int FIRST_FREE_POSITION_F ()
return index;
}
}
-
+
/* The function reaches this point only if all the position are occupied */
return NO_MORE_TIMERS_C;
}
/* ***************************************************************************
- * TIMER_POSITION_F
+ * TIMER_POSITION_F
*
* Description: Returns the position in the table of timers in which the
* data of the timer are stored.
@@ -125,12 +125,12 @@ int TIMER_POSITION_F ( timer_t timer_id )
}
/* ***************************************************************************
- * COPY_ITIMERSPEC_S
+ * COPY_ITIMERSPEC_S
*
- * Description: Does a copy of a variable of type struct itimerspec
+ * Description: Does a copy of a variable of type struct itimerspec
* ***************************************************************************/
-void COPY_ITIMERSPEC_S ( const struct itimerspec *source,
+void COPY_ITIMERSPEC_S ( const struct itimerspec *source,
struct itimerspec *target )
{
@@ -142,19 +142,19 @@ void COPY_ITIMERSPEC_S ( const struct itimerspec *source,
}
/* ***************************************************************************
- * ITIMERSPEC_TO_RTEMS_TIME_OF_DAY_S
+ * ITIMERSPEC_TO_RTEMS_TIME_OF_DAY_S
*
- * Description: This function converts the data of a structure itimerspec
- * into structure rtems_time_of_day
+ * Description: This function converts the data of a structure itimerspec
+ * into structure rtems_time_of_day
* ***************************************************************************/
-void ITIMERSPEC_TO_RTEMS_TIME_OF_DAY_S
+void ITIMERSPEC_TO_RTEMS_TIME_OF_DAY_S
( const struct itimerspec *itimer, rtems_time_of_day *rtems_time )
{
unsigned long int seconds;
/* The leap years and the months with 28, 29 or 31 days have not been
- * considerated. It will be made in the future */
+ * considerated. It will be made in the future */
seconds = itimer->it_value.tv_sec;
@@ -182,23 +182,23 @@ void ITIMERSPEC_TO_RTEMS_TIME_OF_DAY_S
/* ***************************************************************************
- * FIRE_TIMER_S
+ * FIRE_TIMER_S
*
* Description: This is the operation that is ran when a timer expires
* ***************************************************************************/
-rtems_timer_service_routine FIRE_TIMER_S (rtems_id timer, void *data)
+rtems_timer_service_routine FIRE_TIMER_S (rtems_id timer, void *data)
{
- int timer_pos; /* Position in the table of the timer that
+ int timer_pos; /* Position in the table of the timer that
* has expirated */
rtems_status_code return_v; /* Return value of rtems_timer_fire_after */
int sig_number; /* Number of the signal to send */
-
- /* The position of the table of timers that contains the data of the
+
+ /* The position of the table of timers that contains the data of the
* 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 */
+ * expire if it has not been created or has been deleted */
timer_pos = TIMER_POSITION_F(timer);
@@ -211,27 +211,27 @@ rtems_timer_service_routine FIRE_TIMER_S (rtems_id timer, void *data)
/* The timer must be reprogrammed */
- return_v = rtems_timer_fire_after ( timer,
- timer_struct[timer_pos].ticks,
- FIRE_TIMER_S,
+ return_v = rtems_timer_fire_after ( timer,
+ timer_struct[timer_pos].ticks,
+ FIRE_TIMER_S,
NULL );
- /* Stores the time when the timer was started again */
+ /* Stores the time when the timer was started again */
timer_struct[timer_pos].time = _TOD_Current;
-
+
/* The state has not to be actualized, because nothing modifies it */
timer_struct[timer_pos].state = STATE_CREATE_RUN_C;
} else {
/* Indicates that the timer is stopped */
-
+
timer_struct[timer_pos].state = STATE_CREATE_STOP_C;
}
- /*
+ /*
* The sending of the signal to the process running the handling function
* specified for that signal is simulated
*/
@@ -241,7 +241,7 @@ 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 ) ) {
/* XXX error handling */
- }
+ }
/*
* After the signal handler returns, the count of expirations of the
@@ -252,7 +252,7 @@ rtems_timer_service_routine FIRE_TIMER_S (rtems_id timer, void *data)
}
-/* *********************************************************************
+/* *********************************************************************
* 14.2.2 Create a Per-Process Timer, P1003.1b-1993, p. 264
* ********************************************************************/
@@ -271,20 +271,20 @@ int timer_create(
rtems_id timer_id; /* created timer identifier */
int timer_pos; /* Position in the table of timers */
- /*
+ /*
* The data of the structure evp are checked in order to verify if they
- * are coherent.
+ * are coherent.
*/
if (evp != NULL) {
/* The structure has data */
- if ( ( evp->sigev_notify != SIGEV_NONE ) &&
+ if ( ( evp->sigev_notify != SIGEV_NONE ) &&
( evp->sigev_notify != SIGEV_SIGNAL ) ) {
/* The value of the field sigev_notify is not valid */
rtems_set_errno_and_return_minus_one( EINVAL );
}
}
-
+
/*
* A timer is created using the primitive rtems_timer_create
*/
@@ -292,18 +292,18 @@ int timer_create(
return_v = rtems_timer_create ( clock_id, &timer_id );
switch (return_v) {
- case RTEMS_SUCCESSFUL :
+ case RTEMS_SUCCESSFUL :
/*
* The timer has been created properly
*/
-
+
/* Obtains the first free position in the table of timers */
timer_pos = FIRST_FREE_POSITION_F();
if ( timer_pos == NO_MORE_TIMERS_C ) {
- /* There is not position for another timers in spite of RTEMS
+ /* There is not position for another timers in spite of RTEMS
* supports it. It will necessaty to increase the structure used */
rtems_set_errno_and_return_minus_one( EAGAIN );
@@ -319,7 +319,7 @@ int timer_create(
/* NEW VERSION*/
timer_struct[timer_pos].thread_id = pthread_self ();
-
+
if ( evp != NULL ) {
timer_struct[timer_pos].inf.sigev_notify = evp->sigev_notify;
timer_struct[timer_pos].inf.sigev_signo = evp->sigev_signo;
@@ -344,20 +344,20 @@ int timer_create(
/* There has been created too much timers for the same process */
rtems_set_errno_and_return_minus_one( EAGAIN );
-
+
default :
/*
* Does nothing. It only returns the error without assigning a value
* to errno. In theory, it can not happen because the call to
- * rtems_timer_create can not return other different value.
+ * rtems_timer_create can not return other different value.
*/
rtems_set_errno_and_return_minus_one( EINVAL );
}
- /*
- * The next sentence is used to avoid singular situations
+ /*
+ * The next sentence is used to avoid singular situations
*/
rtems_set_errno_and_return_minus_one( EINVAL );
@@ -371,13 +371,13 @@ int timer_delete(
timer_t timerid
)
{
-
+
/*
* IDEA: This function must probably stop the timer first and then delete it
*
* It will have to do a call to rtems_timer_cancel and then another
* call to rtems_timer_delete.
- * The call to rtems_timer_delete will be probably unnecessary,
+ * The call to rtems_timer_delete will be probably unnecessary,
* because rtems_timer_delete stops the timer before deleting it.
*/
@@ -429,7 +429,7 @@ int timer_settime(
rtems_status_code return_v; /* Return of the calls to RTEMS */
int timer_pos; /* Position of the timer in the table */
rtems_time_of_day rtems_time; /* Time in RTEMS */
-
+
/* First the position in the table of timers is obtained */
@@ -448,7 +448,7 @@ int timer_settime(
}
/* If the function reaches this point, then it will be necessary to do
- * something with the structure of times of the timer: to stop, start
+ * something with the structure of times of the timer: to stop, start
* or start it again */
/* First, it verifies if the timer must be stopped */
@@ -468,7 +468,7 @@ int timer_settime(
timer_struct[timer_pos].timer_data = *value;
/* Indicates that the timer is created and stopped */
-
+
timer_struct[timer_pos].state = STATE_CREATE_STOP_C;
/* Returns with success */
@@ -476,11 +476,11 @@ int timer_settime(
return 0;
}
- /*
+ /*
* If the function reaches this point, then the timer will have to be
- * initialized with new values: to start it or start it again
+ * initialized with new values: to start it or start it again
*/
-
+
/* First, it verifies if the structure "value" is correct */
if ( ( value->it_value.tv_nsec > MAX_NSEC_C ) ||
@@ -493,7 +493,7 @@ int timer_settime(
/* Then, "value" must be converted from seconds and nanoseconds to clock
* ticks, to use it in the calls to RTEMS */
- /* It is also necessary to take in account if the time is absolute
+ /* It is also necessary to take in account if the time is absolute
* or relative */
switch (flags) {
@@ -513,14 +513,14 @@ int timer_settime(
/* The timer has been started and is running */
- /* Actualizes the data of the structure and
+ /* Actualizes the data of the structure and
* returns the old ones in "ovalue" */
if ( ovalue )
*ovalue = timer_struct[timer_pos].timer_data;
timer_struct[timer_pos].timer_data = *value;
-
+
/* It indicates that the time is running */
timer_struct[timer_pos].state = STATE_CREATE_RUN_C;
@@ -549,9 +549,9 @@ int timer_settime(
default: break;
-
+
}
-
+
break;
case TIMER_RELATIVE_C:
@@ -561,23 +561,23 @@ int timer_settime(
/* First, it converts from seconds and nanoseconds to ticks */
- /* The form in which this operation is done can produce a lost
+ /* The form in which this operation is done can produce a lost
* of precision of 1 second */
-
+
/* This is the process to convert from nanoseconds to ticks
*
- * There is a tick every 10 miliseconds, then the nanoseconds are
+ * There is a tick every 10 miliseconds, then the nanoseconds are
* divided between 10**7. The result of this operation will be the
- * number of ticks
+ * number of ticks
*/
- timer_struct[timer_pos].ticks =
+ timer_struct[timer_pos].ticks =
( SEC_TO_TICKS_C * value->it_value.tv_sec ) +
( value->it_value.tv_nsec / (NSEC_PER_SEC_C / SEC_TO_TICKS_C));
- return_v = rtems_timer_fire_after ( timerid,
- timer_struct[timer_pos].ticks,
- FIRE_TIMER_S,
+ return_v = rtems_timer_fire_after ( timerid,
+ timer_struct[timer_pos].ticks,
+ FIRE_TIMER_S,
NULL );
switch (return_v) {
@@ -585,14 +585,14 @@ int timer_settime(
/* The timer has been started and is running */
- /* Actualizes the data of the structure and
+ /* Actualizes the data of the structure and
* returns the old ones in "ovalue" */
if ( ovalue )
*ovalue = timer_struct[timer_pos].timer_data;
timer_struct[timer_pos].timer_data = *value;
-
+
/* It indicates that the time is running */
timer_struct[timer_pos].state = STATE_CREATE_RUN_C;
@@ -600,15 +600,15 @@ int timer_settime(
/* Stores the time in which the timer was started again */
timer_struct[timer_pos].time = _TOD_Current;
-
+
return 0;
break;
case RTEMS_INVALID_ID:
- /* The timer identifier is not correct. In theory, this
- * situation can not occur, but the solution is easy */
+ /* The timer identifier is not correct. In theory, this
+ * situation can not occur, but the solution is easy */
rtems_set_errno_and_return_minus_one( EINVAL );
@@ -620,14 +620,14 @@ int timer_settime(
* are incorrect */
/*
- * I do not know if errno must be actualized
+ * I do not know if errno must be actualized
*
* errno = EINVAL;
*/
rtems_set_errno_and_return_minus_one( EINVAL );
break;
-
+
default: break;
}
@@ -635,7 +635,7 @@ int timer_settime(
default: break;
- /* It does nothing, although it will be probably necessary to
+ /* It does nothing, although it will be probably necessary to
* return an error */
}
@@ -658,18 +658,18 @@ int timer_gettime(
)
{
- /*
+ /*
* IDEA: This function does not use functions of RTEMS to the handle
* of timers. It uses some functions for managing the time.
*
* A possible form to do this is the following:
*
- * - When a timer is initialized, the value of the time in
+ * - When a timer is initialized, the value of the time in
* that moment is stored.
* - When this function is called, it returns the difference
* between the current time and the initialization time.
*/
-
+
rtems_time_of_day current_time;
int timer_pos;
uint32_t hours;
@@ -677,7 +677,7 @@ int timer_gettime(
uint32_t seconds;
uint32_t ticks;
uint32_t nanosec;
-
+
/* Reads the current time */
@@ -686,7 +686,7 @@ int timer_gettime(
timer_pos = TIMER_POSITION_F ( timerid );
if ( timer_pos == BAD_TIMER_C ) {
- /* The timer identifier is erroneus */
+ /* The timer identifier is erroneus */
rtems_set_errno_and_return_minus_one( EINVAL );
}
@@ -701,45 +701,45 @@ int timer_gettime(
} else {
minutes = current_time.minute - timer_struct[timer_pos].time.minute;
}
-
+
if ( current_time.second < timer_struct[timer_pos].time.second ) {
seconds = 60 - timer_struct[timer_pos].time.second + current_time.second;
minutes--;
} else {
- seconds = current_time.second - timer_struct[timer_pos].time.second;
+ seconds = current_time.second - timer_struct[timer_pos].time.second;
}
if ( current_time.ticks < timer_struct[timer_pos].time.ticks ) {
ticks = 100 - timer_struct[timer_pos].time.ticks + current_time.ticks;
seconds--;
} else {
- ticks = current_time.ticks - timer_struct[timer_pos].time.ticks;
+ ticks = current_time.ticks - timer_struct[timer_pos].time.ticks;
}
/* The time that the timer is running is calculated */
seconds = hours * 60 * 60 +
minutes * 60 +
- seconds;
+ seconds;
nanosec = ticks * 10 * /* msec */
1000 * /* microsec */
1000; /* nanosec */
-
+
/* Calculates the time left before the timer finishes */
-
- value->it_value.tv_sec =
+
+ value->it_value.tv_sec =
timer_struct[timer_pos].timer_data.it_value.tv_sec - seconds;
-
- value->it_value.tv_nsec =
+
+ value->it_value.tv_nsec =
timer_struct[timer_pos].timer_data.it_value.tv_nsec - nanosec;
- value->it_interval.tv_sec =
+ value->it_interval.tv_sec =
timer_struct[timer_pos].timer_data.it_interval.tv_sec;
- value->it_interval.tv_nsec =
+ value->it_interval.tv_nsec =
timer_struct[timer_pos].timer_data.it_interval.tv_nsec;
-
+
return 0;
@@ -760,9 +760,9 @@ int timer_getoverrun(
/*
* IDEA: This function must count the times the timer expires.
- *
+ *
* The expiration of a timer must increase by one a counter.
- * After the signal handler associated to the timer finishs
+ * After the signal handler associated to the timer finishs
* its execution, FIRE_TIMER_S will have to set this counter to 0.
*/