summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/adjtime.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--cpukit/posix/src/adjtime.c26
1 files changed, 19 insertions, 7 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;
}