NetBSD/share/man/man3/ilog2.3

65 lines
2.1 KiB
Groff
Raw Normal View History

2010-06-21 01:57:59 +04:00
.\" $NetBSD: ilog2.3,v 1.3 2010/06/20 21:57:59 joerg Exp $ $
2010-06-08 12:51:08 +04:00
.\"
.\" 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 June 8, 2010
.Dt ILOG2 3
2010-06-21 01:57:59 +04:00
.Os
2010-06-08 12:51:08 +04:00
.Sh NAME
.Nm ilog2
.Nd integer logarithm
.Sh SYNOPSIS
.In sys/bitops.h
.Ft size
.Fn ilog2 "size x"
.Sh DESCRIPTION
The
.Fn ilog2
macro returns an integer (binary) logarithm of
.Fa x .
It is the logarithm for base 2; the binary logarithm of
.Fa x
is the power to which the number 2 must be raised to obtain the value
.Fa x .
.Pp
The type of the input parameter should be either
.Vt uint32_t
or
.Vt uint64_t .
.Sh ERRORS
A value \-1 is returned on error.
.Sh SEE ALSO
.Xr log2 3 ,
2010-06-08 13:00:51 +04:00
.Xr imax 9 ,
.Xr powerof2 9
2010-06-08 12:51:08 +04:00
.Sh HISTORY
The
.Fn ilog2
macro first appeared in
.Nx 5.0 .