source: rtems/c/src/lib/libc/__gettod.c @ 55951bc

4.104.114.84.95
Last change on this file since 55951bc was 3973e40, checked in by Joel Sherrill <joel.sherrill@…>, on 03/27/98 at 16:34:25

Should have included <rtems.h> before checking for ifdef RTEMS_UNIX.
Bug report from Olivier Hainque <hainque@…> on SPARC Solaris 2.6.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1#include <rtems.h>
2
3#if !defined(RTEMS_UNIX)
4/*
5 *  RTEMS gettimeofday Implementation
6 *
7 *
8 *  COPYRIGHT (c) 1989-1998.
9 *  On-Line Applications Research Corporation (OAR).
10 *  Copyright assigned to U.S. Government, 1994.
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.OARcorp.com/rtems/license.html.
15 *
16 *  $Id$
17 */
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.