source: rtems/cpukit/libcsupport/src/__gettod.c @ 217d2e7

4.104.114.84.95
Last change on this file since 217d2e7 was 88d594a, checked in by Joel Sherrill <joel.sherrill@…>, on May 24, 1995 at 9:39:42 PM

Fully tested on all in-house targets

  • Property mode set to 100644
File size: 1.9 KB
Line 
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 *  __gettod.c,v 1.2 1995/05/09 20:24:31 joel Exp
15 */
16
17#include <rtems.h>
18
19#ifdef RTEMS_NEWLIB
20#include <sys/reent.h>
21#endif
22
23#include <time.h>
24#include <sys/time.h>
25
26#include <errno.h>
27#include <assert.h>
28
29/*
30 *  NOTE:  The solaris gettimeofday does not have a second parameter.
31 */
32
33int gettimeofday(
34  struct timeval  *tp,
35  struct timezone *tzp
36)
37{
38  rtems_status_code      status;
39  rtems_clock_time_value time;
40
41  if ( !tp ) {
42    errno = EFAULT;
43    return -1;
44  }
45
46  /* "POSIX" does not seem to allow for not having a TOD */
47  status = rtems_clock_get( RTEMS_CLOCK_GET_TIME_VALUE, &time );
48  if ( status != RTEMS_SUCCESSFUL ) {
49    assert( 0 );
50    return -1;
51  }
52
53  tp->tv_sec  = time.seconds;
54  tp->tv_usec = time.microseconds;
55
56  /*
57   * newlib does not have timezone and daylight savings time
58   * yet.  When it does this needs to be fixed.
59   */
60
61  if ( tzp ) {
62    tzp->tz_minuteswest = 0;  /* at UTC */
63    tzp->tz_dsttime = 0;      /* no daylight savings */
64#if 0
65  tzp->minuteswest = timezone / 60; /* from seconds to minutes */
66  tzp->dsttime = daylight;
67#endif
68  }
69  return 0;
70}
71
72#if defined(RTEMS_NEWLIB)
73
74#if 0
75/*
76 *  "Reentrant" version
77 */
78
79int _gettimeofday_r(
80  struct _reent   *ignored_reentrancy_stuff,
81  struct timeval  *tp,
82  struct timezone *tzp
83)
84{
85  return gettimeofday( tp, tzp );
86}
87#endif
88
89/*
90 *  "System call" version
91 */
92
93int _gettimeofday(
94  struct timeval  *tp,
95  struct timezone *tzp
96)
97{
98  return gettimeofday( tp, tzp );
99}
100
101#endif /* defined(RTEMS_NEWLIB) */
102
103#endif
Note: See TracBrowser for help on using the repository browser.