1 | /* Reentrant version of gettimeofday system call |
---|
2 | This implementation just calls the times/gettimeofday system calls. |
---|
3 | Gettimeofday may not be available on all targets. It's presence |
---|
4 | here is dubious. Consider it for internal use only. */ |
---|
5 | |
---|
6 | #include <reent.h> |
---|
7 | #include <time.h> |
---|
8 | #include <sys/time.h> |
---|
9 | #include <sys/times.h> |
---|
10 | #include <_syslist.h> |
---|
11 | |
---|
12 | /* Some targets provides their own versions of these functions. Those |
---|
13 | targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */ |
---|
14 | |
---|
15 | #ifdef _REENT_ONLY |
---|
16 | #ifndef REENTRANT_SYSCALLS_PROVIDED |
---|
17 | #define REENTRANT_SYSCALLS_PROVIDED |
---|
18 | #endif |
---|
19 | #endif |
---|
20 | |
---|
21 | #ifdef REENTRANT_SYSCALLS_PROVIDED |
---|
22 | |
---|
23 | int _dummy_gettimeofday_syscalls = 1; |
---|
24 | |
---|
25 | #else |
---|
26 | |
---|
27 | /* We use the errno variable used by the system dependent layer. */ |
---|
28 | #undef errno |
---|
29 | extern int errno; |
---|
30 | |
---|
31 | /* |
---|
32 | FUNCTION |
---|
33 | <<_gettimeofday_r>>---Reentrant version of gettimeofday |
---|
34 | |
---|
35 | INDEX |
---|
36 | _gettimeofday_r |
---|
37 | |
---|
38 | SYNOPSIS |
---|
39 | #include <reent.h> |
---|
40 | #include <time.h> |
---|
41 | int _gettimeofday_r(struct _reent *<[ptr]>, |
---|
42 | struct timeval *<[ptimeval]>, |
---|
43 | void *<[ptimezone]>); |
---|
44 | |
---|
45 | DESCRIPTION |
---|
46 | This is a reentrant version of <<gettimeofday>>. It |
---|
47 | takes a pointer to the global data block, which holds |
---|
48 | <<errno>>. |
---|
49 | |
---|
50 | This function is only available for a few targets. |
---|
51 | Check libc.a to see if its available on yours. |
---|
52 | */ |
---|
53 | |
---|
54 | int |
---|
55 | _gettimeofday_r (struct _reent *ptr, |
---|
56 | struct timeval *ptimeval, |
---|
57 | void *ptimezone) |
---|
58 | { |
---|
59 | int ret; |
---|
60 | |
---|
61 | errno = 0; |
---|
62 | if ((ret = _gettimeofday (ptimeval, ptimezone)) == -1 && errno != 0) |
---|
63 | ptr->_errno = errno; |
---|
64 | return ret; |
---|
65 | } |
---|
66 | |
---|
67 | #endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */ |
---|