source: rtems/c/src/exec/libcsupport/src/__gettod.c @ f331481c

4.104.114.84.95
Last change on this file since f331481c was 60b791ad, checked in by Joel Sherrill <joel.sherrill@…>, on 02/17/98 at 23:46:28

updated copyright to 1998

  • Property mode set to 100644
File size: 1.8 KB
Line 
1#if !defined(RTEMS_UNIX)
2/*
3 *  RTEMS gettimeofday Implementation
4 *
5 *
6 *  COPYRIGHT (c) 1989-1998.
7 *  On-Line Applications Research Corporation (OAR).
8 *  Copyright assigned to U.S. Government, 1994.
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.OARcorp.com/rtems/license.html.
13 *
14 *  $Id$
15 */
16
17#include <rtems.h>
18
19#ifdef RTEMS_NEWLIB
20#include <sys/reent.h>
21#endif
22
23#include <sys/time.h>
24#include <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 0
62  if ( tzp ) {
63    tzp->tz_minuteswest = 0;  /* at UTC */
64    tzp->tz_dsttime = 0;      /* no daylight savings */
65  tzp->minuteswest = timezone / 60; /* from seconds to minutes */
66  tzp->dsttime = daylight;
67  }
68#endif
69  return 0;
70}
71
72#if defined(RTEMS_NEWLIB)
73
74/*
75 *  "Reentrant" version
76 */
77
78int _gettimeofday_r(
79  struct _reent   *ignored_reentrancy_stuff,
80  struct timeval  *tp,
81  struct timezone *tzp
82)
83{
84  return gettimeofday( tp, tzp );
85}
86
87/*
88 *  "System call" version
89 */
90
91int _gettimeofday(
92  struct timeval  *tp,
93  struct timezone *tzp
94)
95{
96  return gettimeofday( tp, tzp );
97}
98
99#endif /* defined(RTEMS_NEWLIB) */
100
101#endif
Note: See TracBrowser for help on using the repository browser.