1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Get the Date and Time |
---|
5 | * @ingroup libcsupport |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2007. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
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.rtems.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ |
---|
22 | |
---|
23 | #if defined(RTEMS_NEWLIB) |
---|
24 | #include <sys/time.h> |
---|
25 | #include <errno.h> |
---|
26 | #include <rtems.h> |
---|
27 | #include <rtems/seterr.h> |
---|
28 | |
---|
29 | #if defined(RTEMS_NEWLIB) && !defined(HAVE_GETTIMEOFDAY) |
---|
30 | |
---|
31 | /** |
---|
32 | * SVR4 and BSD4.3 extension required by Newlib |
---|
33 | * |
---|
34 | * @note The solaris gettimeofday does not have a second parameter. |
---|
35 | */ |
---|
36 | int gettimeofday( |
---|
37 | struct timeval *tp, |
---|
38 | void * __tz __attribute__((unused)) |
---|
39 | ) |
---|
40 | { |
---|
41 | /* struct timezone* tzp = (struct timezone*) __tz; */ |
---|
42 | if ( !tp ) |
---|
43 | rtems_set_errno_and_return_minus_one( EFAULT ); |
---|
44 | |
---|
45 | /* |
---|
46 | * POSIX does not seem to allow for not having a TOD so we just |
---|
47 | * grab the time of day. |
---|
48 | */ |
---|
49 | _TOD_Get_timeval( tp ); |
---|
50 | |
---|
51 | /* |
---|
52 | * Timezone information ignored by the OS proper. Per email |
---|
53 | * with Eric Norum, this is how GNU/Linux, Solaris, and MacOS X |
---|
54 | * do it. This puts us in good company. |
---|
55 | */ |
---|
56 | |
---|
57 | return 0; |
---|
58 | } |
---|
59 | #endif |
---|
60 | |
---|
61 | #if defined(RTEMS_NEWLIB) && !defined(HAVE__GETTIMEOFDAY_R) |
---|
62 | |
---|
63 | #include <sys/reent.h> |
---|
64 | |
---|
65 | /** |
---|
66 | * "Reentrant" version |
---|
67 | */ |
---|
68 | int _gettimeofday_r( |
---|
69 | struct _reent *ignored_reentrancy_stuff __attribute__((unused)), |
---|
70 | struct timeval *tp, |
---|
71 | struct timezone *tzp |
---|
72 | ) |
---|
73 | { |
---|
74 | return gettimeofday( tp, tzp ); |
---|
75 | } |
---|
76 | #endif |
---|
77 | |
---|
78 | #if defined(RTEMS_NEWLIB) && !defined(HAVE__GETTIMEOFDAY) |
---|
79 | |
---|
80 | /** |
---|
81 | * "System call" version |
---|
82 | */ |
---|
83 | int _gettimeofday( |
---|
84 | struct timeval *tp, |
---|
85 | struct timezone *tzp |
---|
86 | ) |
---|
87 | { |
---|
88 | return gettimeofday( tp, tzp ); |
---|
89 | } |
---|
90 | #endif |
---|
91 | |
---|
92 | #endif /* defined(RTEMS_NEWLIB) */ |
---|