2008-02-27 22:09:51 +03:00
|
|
|
#ifndef _SOLARIS_TIME_H
|
|
|
|
#define _SOLARIS_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-02-28 03:48:31 +03:00
|
|
|
#include "spl-types.h"
|
2008-02-26 23:36:04 +03:00
|
|
|
|
|
|
|
extern unsigned long long monotonic_clock(void);
|
|
|
|
typedef struct timespec timestruc_t; /* definition per SVr4 */
|
|
|
|
typedef longlong_t hrtime_t;
|
|
|
|
|
|
|
|
#define TIME32_MAX INT32_MAX
|
|
|
|
#define TIME32_MIN INT32_MIN
|
|
|
|
|
|
|
|
#define SEC 1
|
|
|
|
#define MILLISEC 1000
|
|
|
|
#define MICROSEC 1000000
|
|
|
|
#define NANOSEC 1000000000
|
|
|
|
|
|
|
|
#define hz \
|
|
|
|
({ \
|
|
|
|
BUG_ON(HZ < 100 || HZ > MICROSEC); \
|
|
|
|
HZ; \
|
|
|
|
})
|
|
|
|
|
|
|
|
#define gethrestime(ts) getnstimeofday((ts))
|
|
|
|
|
|
|
|
static __inline__ hrtime_t
|
|
|
|
gethrtime(void) {
|
|
|
|
/* BUG_ON(cur_timer == timer_none); */
|
|
|
|
|
|
|
|
/* Solaris expects a long long here but monotonic_clock() returns an
|
|
|
|
* unsigned long long. Note that monotonic_clock() returns the number
|
|
|
|
* of nanoseconds passed since kernel initialization. Even for a signed
|
|
|
|
* long long this will not "go negative" for ~292 years.
|
|
|
|
*/
|
|
|
|
return monotonic_clock();
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ time_t
|
|
|
|
gethrestime_sec(void)
|
|
|
|
{
|
|
|
|
timestruc_t now;
|
|
|
|
|
|
|
|
gethrestime(&now);
|
|
|
|
return (now.tv_sec);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-02-27 22:09:51 +03:00
|
|
|
#endif /* _SOLARIS_TIME_H */
|