Date: Wed, 22 Jun 2011 07:15:57 +0000 (UTC) From: Andriy Gapon <avg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r223412 - in stable/8/sys/cddl/compat/opensolaris: kern sys Message-ID: <201106220715.p5M7Fvc8036946@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: avg Date: Wed Jun 22 07:15:57 2011 New Revision: 223412 URL: http://svn.freebsd.org/changeset/base/223412 Log: MFC r222670: opensolaris compat / zfs: avoid early overflow in ddi_get_lbolt* Modified: stable/8/sys/cddl/compat/opensolaris/kern/opensolaris.c stable/8/sys/cddl/compat/opensolaris/sys/time.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/cddl/compat/opensolaris/kern/opensolaris.c ============================================================================== --- stable/8/sys/cddl/compat/opensolaris/kern/opensolaris.c Wed Jun 22 07:08:44 2011 (r223411) +++ stable/8/sys/cddl/compat/opensolaris/kern/opensolaris.c Wed Jun 22 07:15:57 2011 (r223412) @@ -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); Modified: stable/8/sys/cddl/compat/opensolaris/sys/time.h ============================================================================== --- stable/8/sys/cddl/compat/opensolaris/sys/time.h Wed Jun 22 07:08:44 2011 (r223411) +++ stable/8/sys/cddl/compat/opensolaris/sys/time.h Wed Jun 22 07:15:57 2011 (r223412) @@ -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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201106220715.p5M7Fvc8036946>