Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / reent / gettimeofdayr.c
blobaa60e5e3ac72887a31013394b3bec1d15b679095
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. */
6 #include <reent.h>
7 #include <time.h>
8 #include <sys/time.h>
9 #include <sys/times.h>
10 #include <_syslist.h>
12 /* Some targets provides their own versions of these functions. Those
13 targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
15 #ifdef _REENT_ONLY
16 #ifndef REENTRANT_SYSCALLS_PROVIDED
17 #define REENTRANT_SYSCALLS_PROVIDED
18 #endif
19 #endif
21 #ifdef REENTRANT_SYSCALLS_PROVIDED
23 int _dummy_gettimeofday_syscalls = 1;
25 #else
27 /* We use the errno variable used by the system dependent layer. */
28 #undef errno
29 extern int errno;
32 FUNCTION
33 <<_gettimeofday_r>>---Reentrant version of gettimeofday
35 INDEX
36 _gettimeofday_r
38 SYNOPSIS
39 #include <reent.h>
40 #include <time.h>
41 int _gettimeofday_r(struct _reent *<[ptr]>,
42 struct timeval *<[ptimeval]>,
43 void *<[ptimezone]>);
45 DESCRIPTION
46 This is a reentrant version of <<gettimeofday>>. It
47 takes a pointer to the global data block, which holds
48 <<errno>>.
50 This function is only available for a few targets.
51 Check libc.a to see if its available on yours.
54 int
55 _gettimeofday_r (struct _reent *ptr,
56 struct timeval *ptimeval,
57 void *ptimezone)
59 int ret;
61 errno = 0;
62 if ((ret = _gettimeofday (ptimeval, ptimezone)) == -1 && errno != 0)
63 _REENT_ERRNO(ptr) = errno;
64 return ret;
67 #endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */