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 | |
---|
12 | #if HAVE_CONFIG_H |
---|
13 | #include "config.h" |
---|
14 | #endif |
---|
15 | |
---|
16 | #define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ |
---|
17 | |
---|
18 | #if defined(RTEMS_NEWLIB) |
---|
19 | #include <sys/time.h> |
---|
20 | #include <errno.h> |
---|
21 | #include <rtems.h> |
---|
22 | #include <rtems/seterr.h> |
---|
23 | |
---|
24 | #if defined(RTEMS_NEWLIB) && !defined(HAVE_GETTIMEOFDAY) |
---|
25 | /* |
---|
26 | * NOTE: The solaris gettimeofday does not have a second parameter. |
---|
27 | */ |
---|
28 | int gettimeofday( |
---|
29 | struct timeval *tp, |
---|
30 | void * __tz __attribute__((unused)) |
---|
31 | ) |
---|
32 | { |
---|
33 | /* struct timezone* tzp = (struct timezone*) __tz; */ |
---|
34 | if ( !tp ) |
---|
35 | rtems_set_errno_and_return_minus_one( EFAULT ); |
---|
36 | |
---|
37 | /* |
---|
38 | * POSIX does not seem to allow for not having a TOD so we just |
---|
39 | * grab the time of day. |
---|
40 | */ |
---|
41 | _TOD_Get_timeval( tp ); |
---|
42 | |
---|
43 | /* |
---|
44 | * Timezone information ignored by the OS proper. Per email |
---|
45 | * with Eric Norum, this is how GNU/Linux, Solaris, and MacOS X |
---|
46 | * do it. This puts us in good company. |
---|
47 | */ |
---|
48 | |
---|
49 | return 0; |
---|
50 | } |
---|
51 | #endif |
---|
52 | |
---|
53 | #if defined(RTEMS_NEWLIB) && !defined(HAVE__GETTIMEOFDAY_R) |
---|
54 | |
---|
55 | #include <sys/reent.h> |
---|
56 | |
---|
57 | /* |
---|
58 | * "Reentrant" version |
---|
59 | */ |
---|
60 | int _gettimeofday_r( |
---|
61 | struct _reent *ignored_reentrancy_stuff __attribute__((unused)), |
---|
62 | struct timeval *tp, |
---|
63 | struct timezone *tzp |
---|
64 | ) |
---|
65 | { |
---|
66 | return gettimeofday( tp, tzp ); |
---|
67 | } |
---|
68 | #endif |
---|
69 | |
---|
70 | #if defined(RTEMS_NEWLIB) && !defined(HAVE__GETTIMEOFDAY) |
---|
71 | /* |
---|
72 | * "System call" version |
---|
73 | */ |
---|
74 | |
---|
75 | int _gettimeofday( |
---|
76 | struct timeval *tp, |
---|
77 | struct timezone *tzp |
---|
78 | ) |
---|
79 | { |
---|
80 | return gettimeofday( tp, tzp ); |
---|
81 | } |
---|
82 | #endif |
---|
83 | |
---|
84 | #endif /* defined(RTEMS_NEWLIB) */ |
---|