opensolaris compat / zfs: avoid early overflow in ddi_get_lbolt*

Reported by:	David P. Discher <dpd@bitgravity.com>
Tested by:	will
Reviewed by:	art
Discussed with:	dwhite
MFC after:	2 weeks
This commit is contained in:
Andriy Gapon 2011-06-04 07:02:06 +00:00
parent 7e5eb44d14
commit 2386e135da
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=222670
2 changed files with 18 additions and 2 deletions

View File

@ -40,6 +40,7 @@
cpu_core_t cpu_core[MAXCPU];
kmutex_t cpu_lock;
solaris_cpu_t solaris_cpu[MAXCPU];
int nsec_per_tick;
/*
* OpenSolaris subsystem initialisation.
@ -60,6 +61,8 @@ opensolaris_load(void *dummy)
}
mutex_init(&cpu_lock, "OpenSolaris CPU lock", MUTEX_DEFAULT, NULL);
nsec_per_tick = NANOSEC / hz;
}
SYSINIT(opensolaris_register, SI_SUB_OPENSOLARIS, SI_ORDER_FIRST, opensolaris_load, NULL);

View File

@ -62,8 +62,21 @@ gethrtime(void) {
#define gethrestime(ts) getnanotime(ts)
#define gethrtime_waitfree() gethrtime()
#define ddi_get_lbolt() ((gethrtime() * hz) / NANOSEC)
#define ddi_get_lbolt64() (int64_t)((gethrtime() * hz) / NANOSEC)
extern int nsec_per_tick; /* nanoseconds per clock tick */
static __inline int64_t
ddi_get_lbolt64(void)
{
return (gethrtime() / nsec_per_tick);
}
static __inline clock_t
ddi_get_lbolt(void)
{
return (ddi_get_lbolt64());
}
#else