source: rtems/cpukit/libcsupport/src/__gettod.c @ c752e849

4.8
Last change on this file since c752e849 was c752e849, checked in by Ralf Corsepius <ralf.corsepius@…>, on 12/23/07 at 07:14:12

Make gettimeofday() POSIX-compliant.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*
2 *  gettimeofday() - SVR4 and BSD4.3 extension required by Newlib
3 *
4 *  COPYRIGHT (c) 1989-2007.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
19
20#include <rtems.h>
21
22#if !defined(RTEMS_UNIX)
23#ifdef RTEMS_NEWLIB
24#include <sys/reent.h>
25#endif
26
27#include <sys/time.h>
28#include <time.h>
29
30#include <errno.h>
31
32/*
33 *  NOTE:  The solaris gettimeofday does not have a second parameter.
34 */
35
36int gettimeofday(
37  struct timeval  *tp,
38  void * __tz
39)
40{
41  /* struct timezone* tzp = (struct timezone*) __tz; */
42  if ( !tp ) {
43    errno = EFAULT;
44    return -1;
45  }
46
47  /*
48   *  POSIX does not seem to allow for not having a TOD so we just
49   *  grab the time of day.
50   */
51
52  _TOD_Get_timeval( tp );
53
54  /*
55   *  Timezone information ignored by the OS proper.   Per email
56   *  with Eric Norum, this is how GNU/Linux, Solaris, and MacOS X
57   *  do it.  This puts us in good company.
58   */
59
60  return 0;
61}
62
63#if defined(RTEMS_NEWLIB)
64
65/*
66 *  "Reentrant" version
67 */
68
69int _gettimeofday_r(
70  struct _reent   *ignored_reentrancy_stuff,
71  struct timeval  *tp,
72  struct timezone *tzp
73)
74{
75  return gettimeofday( tp, tzp );
76}
77
78/*
79 *  "System call" version
80 */
81
82int _gettimeofday(
83  struct timeval  *tp,
84  struct timezone *tzp
85)
86{
87  return gettimeofday( tp, tzp );
88}
89
90#endif /* defined(RTEMS_NEWLIB) */
91
92#endif
Note: See TracBrowser for help on using the repository browser.