summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src/__gettod.c
blob: 05db4ab9d0c4b69e329d5afce488d1d60e4edf74 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
 *  gettimeofday() - SVR4 and BSD4.3 extension required by Newlib
 *
 *  COPYRIGHT (c) 1989-2007.
 *  On-Line Applications Research Corporation (OAR).
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.com/license/LICENSE.
 *
 *  $Id$
 */

#if HAVE_CONFIG_H
#include "config.h"
#endif

#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__

#if defined(RTEMS_NEWLIB)
#include <sys/time.h>
#include <errno.h>
#include <rtems.h>
#include <rtems/seterr.h>

#if defined(RTEMS_NEWLIB) && !defined(HAVE_GETTIMEOFDAY)
/*
 *  NOTE:  The solaris gettimeofday does not have a second parameter.
 */
int gettimeofday(
  struct timeval  *tp,
  void * __tz __attribute__((unused))
)
{
  /* struct timezone* tzp = (struct timezone*) __tz; */
  if ( !tp )
    rtems_set_errno_and_return_minus_one( EFAULT );

  /*
   *  POSIX does not seem to allow for not having a TOD so we just
   *  grab the time of day.
   */
  _TOD_Get_timeval( tp );

  /*
   *  Timezone information ignored by the OS proper.   Per email
   *  with Eric Norum, this is how GNU/Linux, Solaris, and MacOS X
   *  do it.  This puts us in good company.
   */

  return 0;
}
#endif

#if defined(RTEMS_NEWLIB) && !defined(HAVE__GETTIMEOFDAY_R)

#include <sys/reent.h>

/*
 *  "Reentrant" version
 */
int _gettimeofday_r(
  struct _reent   *ignored_reentrancy_stuff __attribute__((unused)),
  struct timeval  *tp,
  struct timezone *tzp
)
{
  return gettimeofday( tp, tzp );
}
#endif

#if defined(RTEMS_NEWLIB) && !defined(HAVE__GETTIMEOFDAY)
/*
 *  "System call" version
 */

int _gettimeofday(
  struct timeval  *tp,
  struct timezone *tzp
)
{
  return gettimeofday( tp, tzp );
}
#endif

#endif /* defined(RTEMS_NEWLIB) */