Date: Sat, 13 Apr 2019 04:46:36 +0000 (UTC) From: Warner Losh <imp@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r346176 - head/sys/sys Message-ID: <201904130446.x3D4kabU042626@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: imp Date: Sat Apr 13 04:46:35 2019 New Revision: 346176 URL: https://svnweb.freebsd.org/changeset/base/346176 Log: Fix sbttons for values > 2s Add test against negative times. Add code to cope with larger values properly. Discussed with: bde@ (quite some time ago, for an earlier version) Modified: head/sys/sys/time.h Modified: head/sys/sys/time.h ============================================================================== --- head/sys/sys/time.h Sat Apr 13 04:42:17 2019 (r346175) +++ head/sys/sys/time.h Sat Apr 13 04:46:35 2019 (r346176) @@ -184,8 +184,18 @@ sbttobt(sbintime_t _sbt) static __inline int64_t sbttons(sbintime_t _sbt) { + uint64_t ns; - return ((1000000000 * _sbt) >> 32); +#ifdef KASSERT + KASSERT(_sbt >= 0, ("Negative values illegal for sbttons: %jx", _sbt)); +#endif + ns = _sbt; + if (ns >= SBT_1S) + ns = (ns >> 32) * 1000000000; + else + ns = 0; + + return (ns + (1000000000 * (_sbt & 0xffffffffu) >> 32)); } static __inline sbintime_t
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904130446.x3D4kabU042626>