[ac7d5ef0] | 1 | #if !defined(RTEMS_UNIX) |
---|
| 2 | /* |
---|
| 3 | * RTEMS gettimeofday Implementation |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
| 7 | * On-Line Applications Research Corporation (OAR). |
---|
| 8 | * All rights assigned to U.S. Government, 1994. |
---|
| 9 | * |
---|
| 10 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
| 11 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
| 12 | * notice must appear in all copies of this file and its derivatives. |
---|
| 13 | * |
---|
| 14 | * $Id$ |
---|
| 15 | */ |
---|
| 16 | |
---|
| 17 | #include <rtems.h> |
---|
| 18 | |
---|
| 19 | #ifdef RTEMS_NEWLIB |
---|
| 20 | #include <sys/reent.h> |
---|
| 21 | #endif |
---|
| 22 | #include <time.h> |
---|
| 23 | #include <sys/time.h> |
---|
| 24 | #include <errno.h> |
---|
| 25 | #include <assert.h> |
---|
| 26 | |
---|
| 27 | /* |
---|
| 28 | * NOTE: The solaris gettimeofday does not have a second parameter. |
---|
| 29 | */ |
---|
| 30 | |
---|
| 31 | int gettimeofday( |
---|
| 32 | struct timeval *tp, |
---|
| 33 | struct timezone *tzp |
---|
| 34 | ) |
---|
| 35 | { |
---|
| 36 | rtems_status_code status; |
---|
| 37 | rtems_clock_time_value time; |
---|
| 38 | |
---|
| 39 | if ( !tp || !tzp ) { |
---|
| 40 | errno = EFAULT; |
---|
| 41 | return -1; |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | /* "POSIX" does not seem to allow for not having a TOD */ |
---|
| 45 | status = rtems_clock_get( RTEMS_CLOCK_GET_TIME_VALUE, &time ); |
---|
| 46 | if ( status != RTEMS_SUCCESSFUL ) { |
---|
| 47 | assert( 0 ); |
---|
| 48 | return -1; |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | tp->tv_sec = time.seconds; |
---|
| 52 | tp->tv_usec = time.microseconds; |
---|
| 53 | |
---|
| 54 | #if 0 |
---|
| 55 | tzp->minuteswest = timezone / 60; /* from seconds to minutes */ |
---|
| 56 | tzp->dsttime = daylight; |
---|
| 57 | #endif |
---|
| 58 | |
---|
| 59 | /* |
---|
| 60 | * newlib does not have timezone and daylight savings time |
---|
| 61 | * yet. When it does this needs to be fixed. |
---|
| 62 | */ |
---|
| 63 | |
---|
| 64 | tzp->tz_minuteswest = 0; /* at UTC */ |
---|
| 65 | tzp->tz_dsttime = 0; /* no daylight savings */ |
---|
| 66 | return 0; |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | /* |
---|
| 70 | * "Reentrant" versions of the above routines implemented above. |
---|
| 71 | */ |
---|
| 72 | |
---|
| 73 | #if 0 |
---|
| 74 | int _gettimeofday_r( |
---|
| 75 | struct _reent *ignored_reentrancy_stuff, |
---|
| 76 | struct timeval *tp, |
---|
| 77 | struct timezone *tzp |
---|
| 78 | ) |
---|
| 79 | { |
---|
| 80 | return gettimeofday( tp, tzp ); |
---|
| 81 | } |
---|
| 82 | #endif |
---|
| 83 | |
---|
| 84 | #endif |
---|