#ifndef _SYS_TIME_H
#define _SYS_TIME_H 1
#include <features.h>
#include <bits/types.h>
#include <bits/types/time_t.h>
#include <bits/types/struct_timeval.h>
#ifndef __suseconds_t_defined
typedef __suseconds_t suseconds_t;
# define __suseconds_t_defined
#endif
#include <sys/select.h>
__BEGIN_DECLS
#ifdef __USE_GNU
# define TIMEVAL_TO_TIMESPEC(tv, ts) { \
(ts)->tv_sec = (tv)->tv_sec; \
(ts)->tv_nsec = (tv)->tv_usec * 1000; \
}
# define TIMESPEC_TO_TIMEVAL(tv, ts) { \
(tv)->tv_sec = (ts)->tv_sec; \
(tv)->tv_usec = (ts)->tv_nsec / 1000; \
}
#endif
#ifdef __USE_MISC
struct timezone
{
int tz_minuteswest;
int tz_dsttime;
};
#endif
#ifndef __USE_TIME_BITS64
extern int gettimeofday (struct timeval *__restrict __tv,
void *__restrict __tz) __THROW __nonnull ((1));
#else
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (gettimeofday, (struct timeval *__restrict __tv,
void *__restrict __tz),
__gettimeofday64) __nonnull ((1));
# else
# define gettimeofday __gettimeofday64
# endif
#endif
#ifdef __USE_MISC
# ifndef __USE_TIME_BITS64
extern int settimeofday (const struct timeval *__tv,
const struct timezone *__tz)
__THROW;
extern int adjtime (const struct timeval *__delta,
struct timeval *__olddelta) __THROW;
# else
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (settimeofday, (const struct timeval *__tv,
const struct timezone *__tz),
__settimeofday64);
extern int __REDIRECT_NTH (adjtime, (const struct timeval *__delta,
struct timeval *__olddelta),
__adjtime64);
# else
# define settimeofday __settimeofday64
# define adjtime __adjtime64
# endif
# endif
#endif
enum __itimer_which
{
ITIMER_REAL = 0,
#define ITIMER_REAL ITIMER_REAL
ITIMER_VIRTUAL = 1,
#define ITIMER_VIRTUAL ITIMER_VIRTUAL
ITIMER_PROF = 2
#define ITIMER_PROF ITIMER_PROF
};
struct itimerval
{
struct timeval it_interval;
struct timeval it_value;
};
#if defined __USE_GNU && !defined __cplusplus
typedef enum __itimer_which __itimer_which_t;
#else
typedef int __itimer_which_t;
#endif
#ifndef __USE_TIME_BITS64
extern int getitimer (__itimer_which_t __which,
struct itimerval *__value) __THROW;
extern int setitimer (__itimer_which_t __which,
const struct itimerval *__restrict __new,
struct itimerval *__restrict __old) __THROW;
extern int utimes (const char *__file, const struct timeval __tvp[2])
__THROW __nonnull ((1));
#else
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (getitimer, (__itimer_which_t __which,
struct itimerval *__value),
__getitimer64);
extern int __REDIRECT_NTH (setitimer, (__itimer_which_t __which,
const struct itimerval *__restrict __new,
struct itimerval *__restrict __old),
__setitimer64);
extern int __REDIRECT_NTH (utimes, (const char *__file,
const struct timeval __tvp[2]),
__utimes64) __nonnull ((1));
# else
# define getitimer __getitimer64
# define setitimer __setitimer64
# define utimes __utimes64
# endif
#endif
#ifdef __USE_MISC
# ifndef __USE_TIME_BITS64
extern int lutimes (const char *__file, const struct timeval __tvp[2])
__THROW __nonnull ((1));
extern int futimes (int __fd, const struct timeval __tvp[2]) __THROW;
# else
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (lutimes, (const char *__file,
const struct timeval __tvp[2]),
__lutimes64) __nonnull ((1));
extern int __REDIRECT_NTH (futimes, (int __fd, const struct timeval __tvp[2]),
__futimes64);
# else
# define lutimes __lutimes64
# define futimes __futimes64
# endif
# endif
#endif
#ifdef __USE_GNU
# ifndef __USE_TIME_BITS64
extern int futimesat (int __fd, const char *__file,
const struct timeval __tvp[2]) __THROW;
# else
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (futimesat, (int __fd, const char *__file,
const struct timeval __tvp[2]),
__futimesat64);
# else
# define futimesat __futimesat64
# endif
# endif
#endif
#ifdef __USE_MISC
# 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)
#endif /* Misc. */
__END_DECLS
#endif /* sys/time.h */