1*63ec74c9Schristos.\" $NetBSD: mstohz.9,v 1.12 2019/09/28 15:11:19 christos Exp $ 299ff14deSbouyer.\" 399ff14deSbouyer.\" Copyright (c) 2002 Manuel Bouyer. 499ff14deSbouyer.\" 599ff14deSbouyer.\" Redistribution and use in source and binary forms, with or without 699ff14deSbouyer.\" modification, are permitted provided that the following conditions 799ff14deSbouyer.\" are met: 899ff14deSbouyer.\" 1. Redistributions of source code must retain the above copyright 999ff14deSbouyer.\" notice, this list of conditions and the following disclaimer. 1099ff14deSbouyer.\" 2. Redistributions in binary form must reproduce the above copyright 1199ff14deSbouyer.\" notice, this list of conditions and the following disclaimer in the 1299ff14deSbouyer.\" documentation and/or other materials provided with the distribution. 1399ff14deSbouyer.\" 1499ff14deSbouyer.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 1599ff14deSbouyer.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1699ff14deSbouyer.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1799ff14deSbouyer.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 1899ff14deSbouyer.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1999ff14deSbouyer.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2099ff14deSbouyer.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2199ff14deSbouyer.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2299ff14deSbouyer.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2399ff14deSbouyer.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2499ff14deSbouyer.\" SUCH DAMAGE. 2599ff14deSbouyer.\" 2699ff14deSbouyer.\" 27*63ec74c9Schristos.Dd September 28, 2019 2899ff14deSbouyer.Dt MSTOHZ 9 2999ff14deSbouyer.Os 3099ff14deSbouyer.Sh NAME 31a94ff8e2Sjruoho.Nm mstohz , 32a94ff8e2Sjruoho.Nm hztoms 33a866b2a0Sjruoho.Nd convert between milliseconds and system clock ticks 3499ff14deSbouyer.Sh SYNOPSIS 35472351e1Swiz.In sys/param.h 36*63ec74c9Schristos.Ft unsigned int 37*63ec74c9Schristos.Fn mstohz "unsigned int ms" 38*63ec74c9Schristos.Ft unsigned int 39*63ec74c9Schristos.Fn hztoms "unsigned int hz" 4099ff14deSbouyer.Sh DESCRIPTION 41a94ff8e2SjruohoThe 42a94ff8e2Sjruoho.Fn mstohz 43a94ff8e2Sjruohomacro can be used to convert time 44a94ff8e2Sjruohoin milliseconds to system clock ticks, as used 4599ff14deSbouyerby the 4699ff14deSbouyer.Xr callout 9 47d2c35cc4Swizfacility, in an integer-overflow safe way. 48a866b2a0SjruohoConversely, 49a866b2a0Sjruoho.Fn hztoms 50a866b2a0Sjruohoconverts system clock ticks to milliseconds. 5199ff14deSbouyer.Pp 52a866b2a0SjruohoThese macros are defined in the 539ec9f285Swiz.Aq Em sys/param.h 54d581afbdSwizheader. 55d581afbdSwizIndividual ports can have a processor-specific, more efficient 56d2c35cc4Swizversion implemented in their 579ec9f285Swiz.Aq Em machine/param.h 5899ff14deSbouyerheader as a define. 5999ff14deSbouyer.Sh RETURN VALUES 60a866b2a0SjruohoThe return value is either the number of clock ticks or milliseconds 61a866b2a0Sjruohofor the specified value. 6299ff14deSbouyer.Sh SEE ALSO 63bacb261aSjruoho.Xr param 3 , 641e1471bdSjruoho.Xr callout 9 , 651e1471bdSjruoho.Xr tvtohz 9 6699ff14deSbouyer.Sh BUGS 67a866b2a0SjruohoNeither 68d581afbdSwiz.Fn mstohz 69a866b2a0Sjruohonor 70a866b2a0Sjruoho.Fn hztoms 71a866b2a0Sjruohomake use of expensive 64-bit integer arithmetic. 72a866b2a0SjruohoThe result from 73a866b2a0Sjruoho.Fn mstohz 74a866b2a0Sjruohowill be rounded down to one second if the parameter is larger 7599ff14deSbouyerthan 131072 milliseconds. 76