diff options
Diffstat (limited to '')
-rw-r--r-- | cpukit/posix/src/adjtime.c | 26 | ||||
-rw-r--r-- | cpukit/posix/src/alarm.c | 15 | ||||
-rw-r--r-- | cpukit/posix/src/clockgetres.c | 13 | ||||
-rw-r--r-- | cpukit/posix/src/condtimedwait.c | 34 | ||||
-rw-r--r-- | cpukit/posix/src/mqueuetimedreceive.c | 11 | ||||
-rw-r--r-- | cpukit/posix/src/mqueuetimedsend.c | 11 | ||||
-rw-r--r-- | cpukit/posix/src/mutextimedlock.c | 14 | ||||
-rw-r--r-- | cpukit/posix/src/nanosleep.c | 37 | ||||
-rw-r--r-- | cpukit/posix/src/posixtimespecabsolutetimeout.c | 39 | ||||
-rw-r--r-- | cpukit/posix/src/posixtimespecsubtract.c | 58 | ||||
-rw-r--r-- | cpukit/posix/src/posixtimespectointerval.c | 41 | ||||
-rw-r--r-- | cpukit/posix/src/pthread.c | 11 | ||||
-rw-r--r-- | cpukit/posix/src/pthreadcreate.c | 11 | ||||
-rw-r--r-- | cpukit/posix/src/pthreadsetschedparam.c | 9 | ||||
-rw-r--r-- | cpukit/posix/src/ptimer1.c | 21 | ||||
-rw-r--r-- | cpukit/posix/src/sched.c | 11 | ||||
-rw-r--r-- | cpukit/posix/src/semtimedwait.c | 27 | ||||
-rw-r--r-- | cpukit/posix/src/sigtimedwait.c | 15 | ||||
-rw-r--r-- | cpukit/posix/src/ualarm.c | 12 | ||||
-rw-r--r-- | cpukit/score/src/timespecfromticks.c (renamed from cpukit/posix/src/posixintervaltotimespec.c) | 25 |
20 files changed, 205 insertions, 236 deletions
diff --git a/cpukit/posix/src/adjtime.c b/cpukit/posix/src/adjtime.c index 1e06dab608..e8743181aa 100644 --- a/cpukit/posix/src/adjtime.c +++ b/cpukit/posix/src/adjtime.c @@ -1,8 +1,17 @@ /* - * adjustime() function - required by NTP + * adjime() function - required by NTP * * I am unaware of the history behind the definition of this service * and don't know if its behavior is covered by any standard. --joel + */ + +/* + * COPYRIGHT (c) 1989-2007. + * 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$ */ @@ -32,16 +41,19 @@ int adjtime ( struct timeval *delta, struct timeval *olddelta ) if ( !delta ) return -1; - __adjustment = (delta->tv_sec * TOD_MICROSECONDS_PER_SECOND) + delta->tv_usec; + /* convert delta to microseconds */ + __adjustment = (delta->tv_sec * TOD_MICROSECONDS_PER_SECOND); + __adjustment += delta->tv_usec; + /* too small to account for */ if ( __adjustment < _TOD_Microseconds_per_tick ) return 0; - clock_gettime( CLOCK_REALTIME, &ts ); + /* Grab the current TOD */ + _TOD_Get( &ts ); - ts.tv_sec += (__adjustment / TOD_MICROSECONDS_PER_SECOND); - ts.tv_nsec += (__adjustment % TOD_MICROSECONDS_PER_SECOND) * - TOD_NANOSECONDS_PER_MICROSECOND; + ts.tv_sec += delta->tv_sec; + ts.tv_nsec += delta->tv_usec * TOD_NANOSECONDS_PER_MICROSECOND; /* if adjustment is too much positive */ while ( ts.tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) { @@ -55,6 +67,6 @@ int adjtime ( struct timeval *delta, struct timeval *olddelta ) ts.tv_sec--; } - clock_settime( CLOCK_REALTIME, &ts ); + _TOD_Set( &ts ); return 0; } diff --git a/cpukit/posix/src/alarm.c b/cpukit/posix/src/alarm.c index 71097554c7..1f3151b919 100644 --- a/cpukit/posix/src/alarm.c +++ b/cpukit/posix/src/alarm.c @@ -1,7 +1,8 @@ /* * 3.4.1 Schedule Alarm, P1003.1b-1993, p. 79 - * - * COPYRIGHT (c) 1989-1999. + */ + +/* COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -16,7 +17,6 @@ #endif #include <pthread.h> -/* #include <errno.h> */ #include <rtems/system.h> #include <rtems/posix/pthread.h> @@ -69,12 +69,9 @@ unsigned int alarm( * this. */ - remaining = the_timer->initial; - remaining -= (the_timer->stop_time - the_timer->start_time); - - /* remaining is now in ticks */ - remaining *= _TOD_Microseconds_per_tick; - remaining /= TOD_MICROSECONDS_PER_SECOND; + remaining = the_timer->initial - + ((the_timer->stop_time - the_timer->start_time) / + TOD_TICKS_PER_SECOND); break; } } diff --git a/cpukit/posix/src/clockgetres.c b/cpukit/posix/src/clockgetres.c index 936e35ab74..9c5f1be925 100644 --- a/cpukit/posix/src/clockgetres.c +++ b/cpukit/posix/src/clockgetres.c @@ -2,6 +2,17 @@ * $Id$ */ +/* + * COPYRIGHT (c) 1989-2007. + * 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 @@ -42,7 +53,7 @@ int clock_getres( if ( res ) { res->tv_sec = _TOD_Microseconds_per_tick / 1000000; res->tv_nsec = _TOD_Microseconds_per_tick * 1000; - /* _POSIX_Interval_to_timespec( _TOD_Microseconds_per_tick, res ); */ + /* _TOD_From_ticks( _TOD_Microseconds_per_tick, res ); */ } break; diff --git a/cpukit/posix/src/condtimedwait.c b/cpukit/posix/src/condtimedwait.c index 32ce1d4a05..717851a8c8 100644 --- a/cpukit/posix/src/condtimedwait.c +++ b/cpukit/posix/src/condtimedwait.c @@ -2,6 +2,17 @@ * $Id$ */ +/* + * COPYRIGHT (c) 1989-2007. + * 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 @@ -33,24 +44,27 @@ int pthread_cond_timedwait( struct timespec difference; boolean already_timedout = FALSE; - if ( !abstime ) + if ( !_Timespec_Is_valid(abstime) ) return EINVAL; /* * The abstime is a walltime. We turn it into an interval. */ - (void) clock_gettime( CLOCK_REALTIME, ¤t_time ); + _TOD_Get( ¤t_time ); - /* XXX probably some error checking should go here */ - - _POSIX_Timespec_subtract( ¤t_time, abstime, &difference ); - - if ( ( difference.tv_sec < 0 ) || ( ( difference.tv_sec == 0 ) && - ( difference.tv_nsec < 0 ) ) ) + /* + * Make sure the timeout is in the future + */ + if ( _Timespec_Less_than( abstime, ¤t_time ) ) { already_timedout = TRUE; - - timeout = _POSIX_Timespec_to_interval( &difference ); + difference.tv_sec = 0; + difference.tv_nsec = 0; + timeout = 0; + } else { + _Timespec_Subtract( ¤t_time, abstime, &difference ); + timeout = _Timespec_To_ticks( &difference ); + } return _POSIX_Condition_variables_Wait_support( cond, diff --git a/cpukit/posix/src/mqueuetimedreceive.c b/cpukit/posix/src/mqueuetimedreceive.c index 2ad5f4c6d6..493ac7aa66 100644 --- a/cpukit/posix/src/mqueuetimedreceive.c +++ b/cpukit/posix/src/mqueuetimedreceive.c @@ -10,6 +10,15 @@ * * This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open * time. + */ + +/* + * COPYRIGHT (c) 1989-2007. + * 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$ */ @@ -52,6 +61,6 @@ ssize_t mq_timedreceive( msg_ptr, msg_len, msg_prio, - _POSIX_Timespec_to_interval( timeout ) + _Timespec_To_ticks( timeout ) ); } diff --git a/cpukit/posix/src/mqueuetimedsend.c b/cpukit/posix/src/mqueuetimedsend.c index 89569368be..262bf8baa9 100644 --- a/cpukit/posix/src/mqueuetimedsend.c +++ b/cpukit/posix/src/mqueuetimedsend.c @@ -10,6 +10,15 @@ * * This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open * time. + */ + +/* + * COPYRIGHT (c) 1989-2007. + * 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$ */ @@ -52,6 +61,6 @@ int mq_timedsend( msg_ptr, msg_len, msg_prio, - _POSIX_Timespec_to_interval( timeout ) + _Timespec_To_ticks( timeout ) ); } diff --git a/cpukit/posix/src/mutextimedlock.c b/cpukit/posix/src/mutextimedlock.c index e86c3040dd..85a1782114 100644 --- a/cpukit/posix/src/mutextimedlock.c +++ b/cpukit/posix/src/mutextimedlock.c @@ -1,4 +1,15 @@ /* + * Mutex Timed Lock + */ + +/* + * COPYRIGHT (c) 1989-2007. + * 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$ */ @@ -31,9 +42,10 @@ int pthread_mutex_timedlock( const struct timespec *timeout ) { + /* XXX does timeout need to be based on CLOCK_REALTIME and be TOD? */ return _POSIX_Mutex_Lock_support( mutex, TRUE, - _POSIX_Timespec_to_interval( timeout ) + _Timespec_To_ticks( timeout ) ); } diff --git a/cpukit/posix/src/nanosleep.c b/cpukit/posix/src/nanosleep.c index 47f7cbad0e..bca61ad709 100644 --- a/cpukit/posix/src/nanosleep.c +++ b/cpukit/posix/src/nanosleep.c @@ -1,4 +1,11 @@ /* + * COPYRIGHT (c) 1989-2007. + * 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$ */ @@ -28,41 +35,25 @@ int nanosleep( ) { Watchdog_Interval ticks; - struct timespec *the_rqtp; - if ( !rqtp ) + if ( !_Timespec_Is_valid( rqtp ) ) rtems_set_errno_and_return_minus_one( EINVAL ); - the_rqtp = (struct timespec *)rqtp; - /* - * Return EAGAIN if the delay interval is negative. + * Return EINVAL if the delay interval is negative. * * NOTE: This behavior is beyond the POSIX specification. - * FSU pthreads shares this behavior. + * FSU and GNU/Linux pthreads shares this behavior. */ - - if ( the_rqtp->tv_sec < 0 ) - the_rqtp->tv_sec = 0; - - if ( /* the_rqtp->tv_sec < 0 || */ the_rqtp->tv_nsec < 0 ) - rtems_set_errno_and_return_minus_one( EAGAIN ); - - if ( the_rqtp->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) + if ( rqtp->tv_sec < 0 || rqtp->tv_nsec < 0 ) rtems_set_errno_and_return_minus_one( EINVAL ); - ticks = _POSIX_Timespec_to_interval( the_rqtp ); - - /* - * Bump the ticks by one so the delay is at least the number of - * ticks requested - */ - ticks++; + ticks = _Timespec_To_ticks( rqtp ); /* * A nanosleep for zero time is implemented as a yield. * This behavior is also beyond the POSIX specification but is - * consistent with the RTEMS api and yields desirable behavior. + * consistent with the RTEMS API and yields desirable behavior. */ if ( !ticks ) { @@ -99,7 +90,7 @@ int nanosleep( ticks -= _Thread_Executing->Timer.stop_time - _Thread_Executing->Timer.start_time; - _POSIX_Interval_to_timespec( ticks, rmtp ); + _Timespec_From_ticks( ticks, rmtp ); /* * If there is time remaining, then we were interrupted by a signal. diff --git a/cpukit/posix/src/posixtimespecabsolutetimeout.c b/cpukit/posix/src/posixtimespecabsolutetimeout.c index df70c90533..52208e380b 100644 --- a/cpukit/posix/src/posixtimespecabsolutetimeout.c +++ b/cpukit/posix/src/posixtimespecabsolutetimeout.c @@ -1,5 +1,14 @@ /* * Convert abstime timeout to ticks + */ + +/* + * COPYRIGHT (c) 1989-2007. + * 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$ */ @@ -30,39 +39,23 @@ int _POSIX_Absolute_timeout_to_ticks( Watchdog_Interval *ticks_out ) { - struct timespec current_time; - struct timespec difference; - - if ( !abstime ) - return EINVAL; + struct timespec current_time; + struct timespec difference; - /* - * Error check the absolute time to timeout - */ -#if 0 - /* they are unsigned so this is impossible */ - if ( abstime->tv_sec < 0 || abstime->tv_nsec < 0 ) + if ( !_Timespec_Is_valid(abstime) ) return EINVAL; -#endif - if ( abstime->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) - return EINVAL; - - (void) clock_gettime( CLOCK_REALTIME, ¤t_time ); + _TOD_Get( ¤t_time ); /* * Make sure the abstime is in the future */ - if ( abstime->tv_sec < current_time.tv_sec ) - return EINVAL; - - if ( (abstime->tv_sec == current_time.tv_sec) && - (abstime->tv_nsec <= current_time.tv_nsec) ) + if ( _Timespec_Less_than( abstime, ¤t_time ) ) return EINVAL; - _POSIX_Timespec_subtract( ¤t_time, abstime, &difference ); + _Timespec_Subtract( ¤t_time, abstime, &difference ); - *ticks_out = _POSIX_Timespec_to_interval( &difference ); + *ticks_out = _Timespec_To_ticks( &difference ); return 0; } diff --git a/cpukit/posix/src/posixtimespecsubtract.c b/cpukit/posix/src/posixtimespecsubtract.c deleted file mode 100644 index a2cce2a332..0000000000 --- a/cpukit/posix/src/posixtimespecsubtract.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * $Id$ - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include <time.h> -#include <errno.h> - -#include <rtems/system.h> -#include <rtems/score/isr.h> -#include <rtems/score/thread.h> -#include <rtems/score/tod.h> - -#include <rtems/seterr.h> -#include <rtems/posix/time.h> - -/*PAGE - * - * _POSIX_Timespec_subtract - */ - -void _POSIX_Timespec_subtract( - const struct timespec *start, - const struct timespec *end, - struct timespec *result -) -{ -#if 0 - struct timespec start_struct = *the_start; - struct timespec *start = &start_struct; - uint32_t nsecs_per_sec = TOD_NANOSECONDS_PER_SECOND; - - if (end->tv_nsec < start->tv_nsec) { - int seconds = (start->tv_nsec - end->tv_nsec) / nsecs_per_sec + 1; - start->tv_nsec -= nsecs_per_sec * seconds; - start->tv_sec += seconds; - } - - if (end->tv_nsec - start->tv_nsec > nsecs_per_sec) { - int seconds = (start->tv_nsec - end->tv_nsec) / nsecs_per_sec; - start->tv_nsec += nsecs_per_sec * seconds; - start->tv_sec -= seconds; - } -#else - -#endif - - if (end->tv_nsec < start->tv_nsec) { - result->tv_sec = end->tv_sec - start->tv_sec - 1; - result->tv_nsec = (TOD_NANOSECONDS_PER_SECOND - start->tv_nsec) + end->tv_nsec; - } else { - result->tv_sec = end->tv_sec - start->tv_sec; - result->tv_nsec = end->tv_nsec - start->tv_nsec; - } -} diff --git a/cpukit/posix/src/posixtimespectointerval.c b/cpukit/posix/src/posixtimespectointerval.c deleted file mode 100644 index 92be3e508f..0000000000 --- a/cpukit/posix/src/posixtimespectointerval.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - * $Id$ - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include <time.h> -#include <errno.h> - -#include <rtems/system.h> -#include <rtems/score/isr.h> -#include <rtems/score/thread.h> -#include <rtems/score/tod.h> - -#include <rtems/seterr.h> -#include <rtems/posix/time.h> - -/*PAGE - * - * _POSIX_Timespec_to_interval - */ - -Watchdog_Interval _POSIX_Timespec_to_interval( - const struct timespec *time -) -{ - Watchdog_Interval ticks; - - ticks = time->tv_sec * - (TOD_MICROSECONDS_PER_SECOND / _TOD_Microseconds_per_tick); - - ticks += (time->tv_nsec / TOD_NANOSECONDS_PER_MICROSECOND) / - _TOD_Microseconds_per_tick; - - if (ticks) - return ticks; - - return 1; -} diff --git a/cpukit/posix/src/pthread.c b/cpukit/posix/src/pthread.c index bbd7a73a9e..9b04b5bfdf 100644 --- a/cpukit/posix/src/pthread.c +++ b/cpukit/posix/src/pthread.c @@ -1,4 +1,11 @@ /* + * COPYRIGHT (c) 1989-2007. + * 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$ */ @@ -70,7 +77,7 @@ void _POSIX_Threads_Sporadic_budget_TSR( api = the_thread->API_Extensions[ THREAD_API_POSIX ]; - ticks = _POSIX_Timespec_to_interval( &api->schedparam.ss_initial_budget ); + ticks = _Timespec_To_ticks( &api->schedparam.ss_initial_budget ); if ( !ticks ) ticks = 1; @@ -84,7 +91,7 @@ void _POSIX_Threads_Sporadic_budget_TSR( the_thread->current_priority > new_priority ) _Thread_Change_priority( the_thread, new_priority, TRUE ); - ticks = _POSIX_Timespec_to_interval( &api->schedparam.ss_replenish_period ); + ticks = _Timespec_To_ticks( &api->schedparam.ss_replenish_period ); if ( !ticks ) ticks = 1; diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c index 61a59c01f8..b2b1ed128b 100644 --- a/cpukit/posix/src/pthreadcreate.c +++ b/cpukit/posix/src/pthreadcreate.c @@ -1,7 +1,8 @@ /* * 16.1.2 Thread Creation, P1003.1c/Draft 10, p. 144 - * - * COPYRIGHT (c) 1989-1999. + */ + +/* COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -126,8 +127,8 @@ int pthread_create( budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_CALLOUT; budget_callout = _POSIX_Threads_Sporadic_budget_callout; - if ( _POSIX_Timespec_to_interval( &schedparam.ss_replenish_period ) < - _POSIX_Timespec_to_interval( &schedparam.ss_initial_budget ) ) + if ( _Timespec_To_ticks( &schedparam.ss_replenish_period ) < + _Timespec_To_ticks( &schedparam.ss_initial_budget ) ) return EINVAL; if ( !_POSIX_Priority_Is_valid( schedparam.ss_low_priority ) ) @@ -230,7 +231,7 @@ int pthread_create( if ( schedpolicy == SCHED_SPORADIC ) { _Watchdog_Insert_ticks( &api->Sporadic_timer, - _POSIX_Timespec_to_interval( &api->schedparam.ss_replenish_period ) + _Timespec_To_ticks( &api->schedparam.ss_replenish_period ) ); } diff --git a/cpukit/posix/src/pthreadsetschedparam.c b/cpukit/posix/src/pthreadsetschedparam.c index 3413dbfc74..63b45f8669 100644 --- a/cpukit/posix/src/pthreadsetschedparam.c +++ b/cpukit/posix/src/pthreadsetschedparam.c @@ -1,8 +1,9 @@ /* * 13.5.2 Dynamic Thread Scheduling Parameters Access, * P1003.1c/Draft 10, p. 124 - * - * COPYRIGHT (c) 1989-1999. + */ + +/* COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -66,8 +67,8 @@ int pthread_setschedparam( budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_CALLOUT; budget_callout = _POSIX_Threads_Sporadic_budget_callout; - if ( _POSIX_Timespec_to_interval( ¶m->ss_replenish_period ) < - _POSIX_Timespec_to_interval( ¶m->ss_initial_budget ) ) + if ( _Timespec_To_ticks( ¶m->ss_replenish_period ) < + _Timespec_To_ticks( ¶m->ss_initial_budget ) ) return EINVAL; if ( !_POSIX_Priority_Is_valid( param->ss_low_priority ) ) diff --git a/cpukit/posix/src/ptimer1.c b/cpukit/posix/src/ptimer1.c index 9a63441f52..2ee201ddda 100644 --- a/cpukit/posix/src/ptimer1.c +++ b/cpukit/posix/src/ptimer1.c @@ -1,5 +1,12 @@ /* - * ptimer.c,v 1.1 1996/06/03 16:29:58 joel Exp + * COPYRIGHT (c) 1989-2007. + * 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 @@ -344,7 +351,7 @@ int timer_settime( /* The fire time is relative: use "rtems_time_fire_after" */ case POSIX_TIMER_RELATIVE: /* First, convert from seconds and nanoseconds to ticks */ - ptimer->ticks = _POSIX_Timespec_to_interval( &value->it_value ); + ptimer->ticks = _Timespec_To_ticks( &value->it_value ); activated = _Watchdog_Insert_ticks_helper( &ptimer->Timer, @@ -422,11 +429,13 @@ int timer_gettime( /* Calculates the time left before the timer finishes */ - _POSIX_Timespec_subtract( - &ptimer->timer_data.it_value, ¤t_time, &value->it_value); + _Timespec_Subtract( + &ptimer->timer_data.it_value, + ¤t_time, + &value->it_value + ); - value->it_interval.tv_sec = ptimer->timer_data.it_interval.tv_sec; - value->it_interval.tv_nsec = ptimer->timer_data.it_interval.tv_nsec; + value->it_interval = ptimer->timer_data.it_interval; _Thread_Enable_dispatch(); return 0; diff --git a/cpukit/posix/src/sched.c b/cpukit/posix/src/sched.c index 825294e056..c298655dc7 100644 --- a/cpukit/posix/src/sched.c +++ b/cpukit/posix/src/sched.c @@ -1,4 +1,11 @@ /* + * COPYRIGHT (c) 1989-2007. + * 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$ */ @@ -126,8 +133,6 @@ int sched_rr_get_interval( struct timespec *interval ) { - /* XXX do we need to support different time quantums per thread */ - /* * Only supported for the "calling process" (i.e. this node). */ @@ -138,7 +143,7 @@ int sched_rr_get_interval( if ( !interval ) rtems_set_errno_and_return_minus_one( EINVAL ); - _POSIX_Interval_to_timespec( _Thread_Ticks_per_timeslice, interval ); + _Timespec_From_ticks( _Thread_Ticks_per_timeslice, interval ); return 0; } diff --git a/cpukit/posix/src/semtimedwait.c b/cpukit/posix/src/semtimedwait.c index 662845ecd9..6b93b9232b 100644 --- a/cpukit/posix/src/semtimedwait.c +++ b/cpukit/posix/src/semtimedwait.c @@ -1,4 +1,11 @@ /* + * COPYRIGHT (c) 1989-2007. + * 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$ */ @@ -43,26 +50,18 @@ int sem_timedwait( /* * Error check the absolute time to timeout */ -#if 0 - if ( /* abstime->tv_sec < 0 || */ abstime->tv_nsec ) /* tv_sec is unsigned */ + if ( !_Timespec_Is_valid( abstime ) ) { blocking = CORE_SEMAPHORE_BAD_TIMEOUT_VALUE; - else -#endif - if ( abstime->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) { - blocking = CORE_SEMAPHORE_BAD_TIMEOUT; } else { - clock_gettime( CLOCK_REALTIME, ¤t_time ); + _TOD_Get( ¤t_time ); /* * Make sure the abstime is in the future */ - if ( abstime->tv_sec < current_time.tv_sec ) - blocking = CORE_SEMAPHORE_BAD_TIMEOUT; - else if ( (abstime->tv_sec == current_time.tv_sec) && - (abstime->tv_nsec <= current_time.tv_nsec) ) + if ( _Timespec_Less_than( abstime, ¤t_time ) ) { blocking = CORE_SEMAPHORE_BAD_TIMEOUT; - else { - _POSIX_Timespec_subtract( ¤t_time, abstime, &difference ); - ticks = _POSIX_Timespec_to_interval( &difference ); + } else { + _Timespec_Subtract( ¤t_time, abstime, &difference ); + ticks = _Timespec_To_ticks( &difference ); blocking = CORE_SEMAPHORE_BLOCK_WITH_TIMEOUT; } } diff --git a/cpukit/posix/src/sigtimedwait.c b/cpukit/posix/src/sigtimedwait.c index 1486be3054..311e6cc90a 100644 --- a/cpukit/posix/src/sigtimedwait.c +++ b/cpukit/posix/src/sigtimedwait.c @@ -1,7 +1,7 @@ /* * 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 * - * COPYRIGHT (c) 1989-1999. + * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -68,12 +68,11 @@ int sigtimedwait( interval = 0; if ( timeout ) { - if ( timeout->tv_nsec < 0 || - timeout->tv_nsec >= TOD_NANOSECONDS_PER_SECOND) { + if ( !_Timespec_Is_valid( timeout ) ) { rtems_set_errno_and_return_minus_one( EINVAL ); } - interval = _POSIX_Timespec_to_interval( timeout ); + interval = _Timespec_To_ticks( timeout ); } /* @@ -96,7 +95,13 @@ int sigtimedwait( if ( *set & api->signals_pending ) { /* XXX real info later */ the_info->si_signo = _POSIX_signals_Get_highest( api->signals_pending ); - _POSIX_signals_Clear_signals( api, the_info->si_signo, the_info, FALSE, FALSE ); + _POSIX_signals_Clear_signals( + api, + the_info->si_signo, + the_info, + FALSE, + FALSE + ); _ISR_Enable( level ); the_info->si_code = SI_USER; diff --git a/cpukit/posix/src/ualarm.c b/cpukit/posix/src/ualarm.c index d2b524ef5b..a5a8ee926b 100644 --- a/cpukit/posix/src/ualarm.c +++ b/cpukit/posix/src/ualarm.c @@ -1,7 +1,7 @@ /* - * XXX 3.4.1 Schedule Alarm, P1003.1b-1993, p. 79 + * 3.4.1 Schedule Alarm, P1003.1b-1993, p. 79 * - * COPYRIGHT (c) 1989-2003. + * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -75,12 +75,9 @@ useconds_t ualarm( ticks = the_timer->initial; ticks -= (the_timer->stop_time - the_timer->start_time); - /* remaining is now in ticks */ - ticks *= _TOD_Microseconds_per_tick; - ticks /= TOD_MICROSECONDS_PER_SECOND; - _POSIX_Interval_to_timespec( ticks, &tp ); + _Timespec_From_ticks( ticks, &tp ); remaining = tp.tv_sec * TOD_MICROSECONDS_PER_SECOND; remaining += tp.tv_nsec / 1000; break; @@ -89,8 +86,7 @@ useconds_t ualarm( tp.tv_sec = useconds / TOD_MICROSECONDS_PER_SECOND; tp.tv_nsec = (useconds % TOD_MICROSECONDS_PER_SECOND) * 1000; - ticks = _POSIX_Timespec_to_interval( &tp ); - _Watchdog_Insert_ticks( the_timer, ticks ); + _Watchdog_Insert_ticks( the_timer, _Timespec_To_ticks( &tp ) ); return remaining; } diff --git a/cpukit/posix/src/posixintervaltotimespec.c b/cpukit/score/src/timespecfromticks.c index b507c56935..73dda79db9 100644 --- a/cpukit/posix/src/posixintervaltotimespec.c +++ b/cpukit/score/src/timespecfromticks.c @@ -1,4 +1,11 @@ /* + * COPYRIGHT (c) 1989-2007. + * 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$ */ @@ -7,24 +14,14 @@ #endif #include <time.h> -#include <errno.h> #include <rtems/system.h> -#include <rtems/score/isr.h> -#include <rtems/score/thread.h> +#include <rtems/score/timespec.h> #include <rtems/score/tod.h> -#include <rtems/seterr.h> -#include <rtems/posix/time.h> - -/*PAGE - * - * _POSIX_Interval_to_timespec - */ - -void _POSIX_Interval_to_timespec( - Watchdog_Interval ticks, - struct timespec *time +void _Timespec_From_ticks( + uint32_t ticks, + struct timespec *time ) { uint32_t usecs; |