OSDN Git Service

Take into account MEMORY regions when creating a segment map.
[pf3gnuchains/pf3gnuchains3x.git] / newlib / libc / reent / gettimeofdayr.c
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 ANSI_SYNOPSIS
39         #include <reent.h>
40         #include <time.h>
41         int _gettimeofday_r(struct _reent *<[ptr]>,
42                 struct timeval *<[ptimeval]>,
43                 struct timezone *<[ptimezone]>);
44
45 TRAD_SYNOPSIS
46         #include <reent.h>
47         #include <time.h>
48         int _gettimeofday_r(<[ptr]>, <[ptimeval]>, <[ptimezone]>)
49         struct _reent *<[ptr]>;
50         struct timeval *<[ptimeval]>;
51         struct timezone *<[ptimezone]>;
52
53 DESCRIPTION
54         This is a reentrant version of <<gettimeofday>>.  It
55         takes a pointer to the global data block, which holds
56         <<errno>>.
57
58         This function is only available for a few targets.
59         Check libc.a to see if its available on yours.
60 */
61
62 int
63 _DEFUN (_gettimeofday_r, (ptr, ptimeval, ptimezone),
64      struct _reent *ptr _AND
65      struct timeval *ptimeval _AND
66      struct timezone *ptimezone)
67 {
68   int ret;
69
70   errno = 0;
71   if ((ret = _gettimeofday (ptimeval, ptimezone)) == -1 && errno != 0)
72     ptr->_errno = errno;
73   return ret;
74 }
75
76 #endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */