2007-02-22 03:22:33 +08:00
|
|
|
/* Reentrant version of gettimeofday system call
|
2000-02-18 03:39:52 +08:00
|
|
|
This implementation just calls the times/gettimeofday system calls.
|
|
|
|
Gettimeofday may not be available on all targets. It's presence
|
|
|
|
here is dubious. Consider it for internal use only. */
|
|
|
|
|
|
|
|
#include <reent.h>
|
|
|
|
#include <time.h>
|
2000-08-25 02:51:09 +08:00
|
|
|
#include <sys/time.h>
|
2000-02-18 03:39:52 +08:00
|
|
|
#include <sys/times.h>
|
|
|
|
#include <_syslist.h>
|
|
|
|
|
|
|
|
/* Some targets provides their own versions of these functions. Those
|
|
|
|
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
|
|
|
|
|
|
|
|
#ifdef _REENT_ONLY
|
|
|
|
#ifndef REENTRANT_SYSCALLS_PROVIDED
|
|
|
|
#define REENTRANT_SYSCALLS_PROVIDED
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef REENTRANT_SYSCALLS_PROVIDED
|
|
|
|
|
2007-02-22 03:22:33 +08:00
|
|
|
int _dummy_gettimeofday_syscalls = 1;
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
/* We use the errno variable used by the system dependent layer. */
|
|
|
|
#undef errno
|
|
|
|
extern int errno;
|
|
|
|
|
|
|
|
/*
|
|
|
|
FUNCTION
|
|
|
|
<<_gettimeofday_r>>---Reentrant version of gettimeofday
|
2007-02-22 03:22:33 +08:00
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
INDEX
|
|
|
|
_gettimeofday_r
|
|
|
|
|
2017-11-30 15:41:14 +08:00
|
|
|
SYNOPSIS
|
2000-02-18 03:39:52 +08:00
|
|
|
#include <reent.h>
|
|
|
|
#include <time.h>
|
|
|
|
int _gettimeofday_r(struct _reent *<[ptr]>,
|
|
|
|
struct timeval *<[ptimeval]>,
|
2007-07-07 00:56:30 +08:00
|
|
|
void *<[ptimezone]>);
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
This is a reentrant version of <<gettimeofday>>. It
|
|
|
|
takes a pointer to the global data block, which holds
|
|
|
|
<<errno>>.
|
|
|
|
|
|
|
|
This function is only available for a few targets.
|
|
|
|
Check libc.a to see if its available on yours.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
2017-12-04 11:43:30 +08:00
|
|
|
_gettimeofday_r (struct _reent *ptr,
|
2017-12-04 09:31:41 +08:00
|
|
|
struct timeval *ptimeval,
|
2007-07-07 00:56:30 +08:00
|
|
|
void *ptimezone)
|
2000-02-18 03:39:52 +08:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
if ((ret = _gettimeofday (ptimeval, ptimezone)) == -1 && errno != 0)
|
2022-01-18 17:13:04 +08:00
|
|
|
_REENT_ERRNO(ptr) = errno;
|
2000-02-18 03:39:52 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
|