#ifndef _SYS_TIME_H
#define _SYS_TIME_H 1
#include
#include
#define __need_time_t
#include
#define __need_timeval
#include
#include
#ifndef __suseconds_t_defined
typedef __suseconds_t suseconds_t;
# define __suseconds_t_defined
#endif
__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_BSD
struct timezone
{
int tz_minuteswest;
int tz_dsttime;
};
typedef struct timezone *__restrict __timezone_ptr_t;
#else
typedef void *__restrict __timezone_ptr_t;
#endif
extern int gettimeofday (struct timeval *__restrict __tv,
__timezone_ptr_t __tz) __THROW;
#ifdef __USE_BSD
extern int settimeofday (__const struct timeval *__tv,
__const struct timezone *__tz) __THROW;
extern int adjtime (__const struct timeval *__delta,
struct timeval *__olddelta) __THROW;
#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
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;
#ifdef __USE_BSD
extern int lutimes (__const char *__file, __const struct timeval __tvp[2])
__THROW;
extern int futimes (int __fd, __const struct timeval __tvp[2]) __THROW;
#endif
#ifdef __USE_BSD
# 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
__END_DECLS
#endif
|