2000-02-18 03:39:52 +08:00
|
|
|
/* time.h -- An implementation of the standard Unix <sys/time.h> file.
|
|
|
|
Written by Geoffrey Noer <noer@cygnus.com>
|
|
|
|
Public domain; no rights reserved. */
|
|
|
|
|
|
|
|
#ifndef _SYS_TIME_H_
|
|
|
|
#define _SYS_TIME_H_
|
|
|
|
|
|
|
|
#include <_ansi.h>
|
2015-01-29 05:03:41 +08:00
|
|
|
#include <sys/cdefs.h>
|
2000-02-18 03:39:52 +08:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-07-06 18:41:21 +08:00
|
|
|
#ifndef _TIMEVAL_DEFINED
|
2009-10-10 02:43:12 +08:00
|
|
|
#define _TIMEVAL_DEFINED
|
2000-02-18 03:39:52 +08:00
|
|
|
struct timeval {
|
2006-02-15 18:26:30 +08:00
|
|
|
time_t tv_sec;
|
|
|
|
suseconds_t tv_usec;
|
2000-02-18 03:39:52 +08:00
|
|
|
};
|
|
|
|
|
2000-12-05 02:40:53 +08:00
|
|
|
/* BSD time macros used by RTEMS code */
|
2001-04-21 11:22:47 +08:00
|
|
|
#if defined (__rtems__) || defined (__CYGWIN__)
|
2000-12-05 02:40:53 +08:00
|
|
|
|
|
|
|
/* Convenience macros for operations on timevals.
|
|
|
|
NOTE: `timercmp' does not work for >= or <=. */
|
|
|
|
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
|
|
|
|
#define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
|
|
|
|
#define timercmp(a, b, CMP) \
|
|
|
|
(((a)->tv_sec == (b)->tv_sec) ? \
|
|
|
|
((a)->tv_usec CMP (b)->tv_usec) : \
|
|
|
|
((a)->tv_sec CMP (b)->tv_sec))
|
|
|
|
#define timeradd(a, b, result) \
|
|
|
|
do { \
|
|
|
|
(result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
|
|
|
|
(result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
|
|
|
|
if ((result)->tv_usec >= 1000000) \
|
|
|
|
{ \
|
|
|
|
++(result)->tv_sec; \
|
|
|
|
(result)->tv_usec -= 1000000; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
#define timersub(a, b, result) \
|
|
|
|
do { \
|
|
|
|
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
|
|
|
|
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
|
|
|
|
if ((result)->tv_usec < 0) { \
|
|
|
|
--(result)->tv_sec; \
|
|
|
|
(result)->tv_usec += 1000000; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
2001-04-21 11:22:47 +08:00
|
|
|
#endif /* defined (__rtems__) || defined (__CYGWIN__) */
|
2012-11-12 23:57:35 +08:00
|
|
|
#endif /* !_TIMEVAL_DEFINED */
|
|
|
|
|
|
|
|
struct timezone {
|
|
|
|
int tz_minuteswest;
|
|
|
|
int tz_dsttime;
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef __CYGWIN__
|
|
|
|
#include <cygwin/sys_time.h>
|
|
|
|
#endif /* __CYGWIN__ */
|
|
|
|
|
|
|
|
#define ITIMER_REAL 0
|
|
|
|
#define ITIMER_VIRTUAL 1
|
|
|
|
#define ITIMER_PROF 2
|
|
|
|
|
|
|
|
struct itimerval {
|
|
|
|
struct timeval it_interval;
|
|
|
|
struct timeval it_value;
|
|
|
|
};
|
2000-12-05 02:40:53 +08:00
|
|
|
|
2012-08-08 19:04:18 +08:00
|
|
|
#ifdef _COMPILING_NEWLIB
|
|
|
|
int _EXFUN(_gettimeofday, (struct timeval *__p, void *__tz));
|
|
|
|
#endif
|
|
|
|
|
2013-11-23 09:25:47 +08:00
|
|
|
int _EXFUN(gettimeofday, (struct timeval *__restrict __p,
|
|
|
|
void *__restrict __tz));
|
2014-07-23 03:30:00 +08:00
|
|
|
#if __BSD_VISIBLE
|
2000-02-18 03:39:52 +08:00
|
|
|
int _EXFUN(settimeofday, (const struct timeval *, const struct timezone *));
|
2014-07-23 03:30:00 +08:00
|
|
|
int _EXFUN(adjtime, (const struct timeval *, struct timeval *));
|
|
|
|
#endif
|
2005-02-09 04:55:18 +08:00
|
|
|
int _EXFUN(utimes, (const char *__path, const struct timeval *__tvp));
|
2000-02-18 03:39:52 +08:00
|
|
|
int _EXFUN(getitimer, (int __which, struct itimerval *__value));
|
2013-11-23 09:25:47 +08:00
|
|
|
int _EXFUN(setitimer, (int __which, const struct itimerval *__restrict __value,
|
|
|
|
struct itimerval *__restrict __ovalue));
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* _SYS_TIME_H_ */
|