85 lines
2.7 KiB
Groff
85 lines
2.7 KiB
Groff
.\" $NetBSD: ctod.9,v 1.4 2011/04/08 07:55:04 jruoho Exp $
|
|
.\"
|
|
.\" Copyright (c) 2010 The NetBSD Foundation, Inc.
|
|
.\" All rights reserved.
|
|
.\"
|
|
.\" This code is derived from software contributed to The NetBSD Foundation
|
|
.\" by Jukka Ruohonen.
|
|
.\"
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
.\" modification, are permitted provided that the following conditions
|
|
.\" are met:
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
.\"
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
|
.\"
|
|
.Dd April 8, 2011
|
|
.Dt CTOD 9
|
|
.Os
|
|
.Sh NAME
|
|
.Nm ctod
|
|
.Nd macros related to bytes, pages, and disk blocks
|
|
.Sh SYNOPSIS
|
|
.In sys/param.h
|
|
.Ft size
|
|
.Fn ctod "size x"
|
|
.Ft size
|
|
.Fn dtoc "size x"
|
|
.Ft size
|
|
.Fn ctob "size x"
|
|
.Ft size
|
|
.Fn btoc "size x"
|
|
.Ft size
|
|
.Fn dbtob "size x"
|
|
.Ft size
|
|
.Fn btodb "size x"
|
|
.Sh DESCRIPTION
|
|
The
|
|
.Nm
|
|
family of macros can be used to convert between bytes, pages
|
|
.Pq Dq clicks ,
|
|
and disk blocks.
|
|
.Pp
|
|
The following table lists the possible conversions:
|
|
.Bl -column -offset indent "disk blocks " "disk blocks " "disk blocks "
|
|
.It Sy Macro Ta Sy From Ta Sy To
|
|
.It Fn ctod Ta pages Ta disk blocks
|
|
.It Fn dtoc Ta disk blocks Ta pages
|
|
.It Fn ctob Ta pages Ta bytes
|
|
.It Fn btoc Ta bytes Ta pages
|
|
.It Fn dbtob Ta disk blocks Ta bytes
|
|
.It Fn btodb Ta bytes Ta disk blocks
|
|
.El
|
|
.Pp
|
|
These are typical macros that may appear
|
|
with different names in other operating systems.
|
|
Examples include
|
|
.Fn btop
|
|
and
|
|
.Fn btopr
|
|
in Solaris.
|
|
.Sh SEE ALSO
|
|
.Xr param 3
|
|
.Sh HISTORY
|
|
Some of these macros appeared in
|
|
.At v7 .
|
|
.Sh CAVEATS
|
|
The described macros make no assumptions
|
|
about the type of the input parameter.
|
|
A caller should ensure that neither
|
|
integer overflow nor integer underflow are possible.
|