2008-02-28 03:52:31 +03:00
|
|
|
#ifndef _SPL_TIME_H
|
|
|
|
#define _SPL_TIME_H
|
2008-02-26 23:36:04 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Structure returned by gettimeofday(2) system call,
|
|
|
|
* and used in other calls.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2008-02-27 22:09:51 +03:00
|
|
|
#include <linux/module.h>
|
2008-02-26 23:36:04 +03:00
|
|
|
#include <linux/time.h>
|
2008-03-01 03:45:59 +03:00
|
|
|
#include <sys/types.h>
|
2008-02-26 23:36:04 +03:00
|
|
|
|
2008-03-11 00:38:39 +03:00
|
|
|
#define TIME32_MAX INT32_MAX
|
|
|
|
#define TIME32_MIN INT32_MIN
|
|
|
|
|
|
|
|
#define SEC 1
|
|
|
|
#define MILLISEC 1000
|
|
|
|
#define MICROSEC 1000000
|
|
|
|
#define NANOSEC 1000000000
|
2008-02-26 23:36:04 +03:00
|
|
|
|
2008-03-14 22:04:41 +03:00
|
|
|
/* Already defined in include/linux/time.h */
|
|
|
|
#undef CLOCK_THREAD_CPUTIME_ID
|
|
|
|
#undef CLOCK_REALTIME
|
|
|
|
#undef CLOCK_MONOTONIC
|
|
|
|
#undef CLOCK_PROCESS_CPUTIME_ID
|
|
|
|
|
|
|
|
typedef enum clock_type {
|
|
|
|
__CLOCK_REALTIME0 = 0, /* obsolete; same as CLOCK_REALTIME */
|
|
|
|
CLOCK_VIRTUAL = 1, /* thread's user-level CPU clock */
|
|
|
|
CLOCK_THREAD_CPUTIME_ID = 2, /* thread's user+system CPU clock */
|
|
|
|
CLOCK_REALTIME = 3, /* wall clock */
|
|
|
|
CLOCK_MONOTONIC = 4, /* high resolution monotonic clock */
|
|
|
|
CLOCK_PROCESS_CPUTIME_ID = 5, /* process's user+system CPU clock */
|
|
|
|
CLOCK_HIGHRES = CLOCK_MONOTONIC, /* alternate name */
|
|
|
|
CLOCK_PROF = CLOCK_THREAD_CPUTIME_ID,/* alternate name */
|
|
|
|
} clock_type_t;
|
|
|
|
|
2008-02-26 23:36:04 +03:00
|
|
|
#define hz \
|
|
|
|
({ \
|
2008-04-21 21:29:47 +04:00
|
|
|
ASSERT(HZ >= 100 && HZ <= MICROSEC); \
|
2008-02-26 23:36:04 +03:00
|
|
|
HZ; \
|
|
|
|
})
|
|
|
|
|
2008-03-14 22:04:41 +03:00
|
|
|
extern void __gethrestime(timestruc_t *);
|
|
|
|
extern int __clock_gettime(clock_type_t, timespec_t *);
|
|
|
|
extern hrtime_t __gethrtime(void);
|
|
|
|
|
|
|
|
#define gethrestime(ts) __gethrestime(ts)
|
|
|
|
#define clock_gettime(fl, tp) __clock_gettime(fl, tp)
|
|
|
|
#define gethrtime() __gethrtime()
|
|
|
|
|
2008-03-11 00:38:39 +03:00
|
|
|
static __inline__ time_t
|
|
|
|
gethrestime_sec(void)
|
|
|
|
{
|
|
|
|
timestruc_t now;
|
|
|
|
|
|
|
|
__gethrestime(&now);
|
|
|
|
return now.tv_sec;
|
|
|
|
}
|
2008-02-26 23:36:04 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-02-28 03:52:31 +03:00
|
|
|
#endif /* _SPL_TIME_H */
|