Module Name: src Committed By: jruoho Date: Wed Apr 28 07:35:31 UTC 2010
Modified Files: src/distrib/sets/lists/comp: mi src/share/man/man3: Makefile Added Files: src/share/man/man3: ffs32.3 Log Message: Document ffs32(), ffs64(), fls32(), and fls64() from <sys/bitops.h>. To generate a diff of this commit: cvs rdiff -u -r1.1436 -r1.1437 src/distrib/sets/lists/comp/mi cvs rdiff -u -r1.49 -r1.50 src/share/man/man3/Makefile cvs rdiff -u -r0 -r1.1 src/share/man/man3/ffs32.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/comp/mi diff -u src/distrib/sets/lists/comp/mi:1.1436 src/distrib/sets/lists/comp/mi:1.1437 --- src/distrib/sets/lists/comp/mi:1.1436 Sun Apr 25 00:54:44 2010 +++ src/distrib/sets/lists/comp/mi Wed Apr 28 07:35:30 2010 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1436 2010/04/25 00:54:44 joerg Exp $ +# $NetBSD: mi,v 1.1437 2010/04/28 07:35:30 jruoho Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -5746,6 +5746,8 @@ ./usr/share/man/cat3/fetch.0 comp-c-catman .cat ./usr/share/man/cat3/fflush.0 comp-c-catman .cat ./usr/share/man/cat3/ffs.0 comp-c-catman .cat +./usr/share/man/cat3/ffs32.0 comp-c-catman .cat +./usr/share/man/cat3/ffs64.0 comp-c-catman .cat ./usr/share/man/cat3/fgetc.0 comp-c-catman .cat ./usr/share/man/cat3/fgetln.0 comp-c-catman .cat ./usr/share/man/cat3/fgetpos.0 comp-c-catman .cat @@ -5779,6 +5781,8 @@ ./usr/share/man/cat3/flockfile.0 comp-c-catman .cat ./usr/share/man/cat3/floor.0 comp-c-catman .cat ./usr/share/man/cat3/floorf.0 comp-c-catman .cat +./usr/share/man/cat3/fls32.0 comp-c-catman .cat +./usr/share/man/cat3/fls64.0 comp-c-catman .cat ./usr/share/man/cat3/flushinp.0 comp-c-catman .cat ./usr/share/man/cat3/flushok.0 comp-c-catman .cat ./usr/share/man/cat3/fmax.0 comp-c-catman .cat @@ -11569,6 +11573,8 @@ ./usr/share/man/html3/fetch.html comp-c-htmlman html ./usr/share/man/html3/fflush.html comp-c-htmlman html ./usr/share/man/html3/ffs.html comp-c-htmlman html +./usr/share/man/html3/ffs32.html comp-c-htmlman html +./usr/share/man/html3/ffs64.html comp-c-htmlman html ./usr/share/man/html3/fgetc.html comp-c-htmlman html ./usr/share/man/html3/fgetln.html comp-c-htmlman html ./usr/share/man/html3/fgetpos.html comp-c-htmlman html @@ -11601,6 +11607,8 @@ ./usr/share/man/html3/flockfile.html comp-c-htmlman html ./usr/share/man/html3/floor.html comp-c-htmlman html ./usr/share/man/html3/floorf.html comp-c-htmlman html +./usr/share/man/html3/fls32.html comp-c-htmlman html +./usr/share/man/html3/fls64.html comp-c-htmlman html ./usr/share/man/html3/flushinp.html comp-c-htmlman html ./usr/share/man/html3/flushok.html comp-c-htmlman html ./usr/share/man/html3/fmax.html comp-c-htmlman html @@ -17302,6 +17310,8 @@ ./usr/share/man/man3/fetch.3 comp-c-man .man ./usr/share/man/man3/fflush.3 comp-c-man .man ./usr/share/man/man3/ffs.3 comp-c-man .man +./usr/share/man/man3/ffs32.3 comp-c-man .man +./usr/share/man/man3/ffs64.3 comp-c-man .man ./usr/share/man/man3/fgetc.3 comp-c-man .man ./usr/share/man/man3/fgetln.3 comp-c-man .man ./usr/share/man/man3/fgetpos.3 comp-c-man .man @@ -17335,6 +17345,8 @@ ./usr/share/man/man3/flockfile.3 comp-c-man .man ./usr/share/man/man3/floor.3 comp-c-man .man ./usr/share/man/man3/floorf.3 comp-c-man .man +./usr/share/man/man3/fls32.3 comp-c-man .man +./usr/share/man/man3/fls64.3 comp-c-man .man ./usr/share/man/man3/flushinp.3 comp-c-man .man ./usr/share/man/man3/flushok.3 comp-c-man .man ./usr/share/man/man3/fmax.3 comp-c-man .man Index: src/share/man/man3/Makefile diff -u src/share/man/man3/Makefile:1.49 src/share/man/man3/Makefile:1.50 --- src/share/man/man3/Makefile:1.49 Thu Apr 22 06:48:29 2010 +++ src/share/man/man3/Makefile Wed Apr 28 07:35:30 2010 @@ -1,10 +1,10 @@ -# $NetBSD: Makefile,v 1.49 2010/04/22 06:48:29 jruoho Exp $ +# $NetBSD: Makefile,v 1.50 2010/04/28 07:35:30 jruoho Exp $ # @(#)Makefile 8.2 (Berkeley) 12/13/93 MAN= _DIAGASSERT.3 __CONCAT.3 __UNCONST.3 CMSG_DATA.3 \ __arraycount.3 assert.3 bits.3 bitstring.3 dlfcn.3 end.3 \ - fast_divide32.3 gcq.3 intro.3 inttypes.3 iso646.3 offsetof.3 queue.3 \ - rb.3 stdarg.3 stdbool.3 stddef.3 stdint.3 stdlib.3 sysexits.3 \ + fast_divide32.3 ffs32.3 gcq.3 intro.3 inttypes.3 iso646.3 offsetof.3 \ + queue.3 rb.3 stdarg.3 stdbool.3 stddef.3 stdint.3 stdlib.3 sysexits.3 \ tgmath.3 timeradd.3 tree.3 types.3 varargs.3 USETBL= # used by queue.3 @@ -29,6 +29,9 @@ MLINKS+=end.3 edata.3 end.3 etext.3 MLINKS+=fast_divide32.3 fast_divide32_prepare.3 \ fast_divide32.3 fast_remainder32.3 +MLINKS+=ffs32.3 ffs64.3 \ + ffs32.3 fls32.3 \ + ffs32.3 fls64.3 MLINKS+=gcq.3 GCQ_INIT.3 \ gcq.3 GCQ_INIT_HEAD.3 \ gcq.3 gcq_init.3 \ Added files: Index: src/share/man/man3/ffs32.3 diff -u /dev/null src/share/man/man3/ffs32.3:1.1 --- /dev/null Wed Apr 28 07:35:31 2010 +++ src/share/man/man3/ffs32.3 Wed Apr 28 07:35:30 2010 @@ -0,0 +1,102 @@ +.\" $NetBSD: ffs32.3,v 1.1 2010/04/28 07:35:30 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 28, 2010 +.Os +.Dt FFS32 3 +.Sh NAME +.Nm ffs32 , +.Nm ffs64 , +.Nm fls32 , +.Nm fls64 +.Nd find first or last bit set +.Sh SYNOPSIS +.In sys/bitops.h +.Ft int +.Fn ffs32 "uint32_t n" +.Ft int +.Fn ffs64 "uint64_t n" +.Ft int +.Fn fls32 "uint32_t n" +.Ft int +.Fn fls64 "uint64_t n" +.Sh DESCRIPTION +The +.Fn ffs32 +and +.Fn ffs64 +functions find the first bit set from +.Fa n +and return the index of that bit. +Conversely, +the +.Fn fls32 +and +.Fn fls64 +functions return the last bit set in +.Fa n , +returning the index of the bit. +.Pp +The search always starts from the bit 1 (the least significant bit). +If the argument +.Fa n +is zero, each function returns zero. +.Sh IMPLEMENTATION NOTES +The described functions are implemented as +.Em static inline +functions in the +.In sys/bitops.h +header. +The standard C library includes a more portable +.Xr ffs 3 +for user applications. +.\" +.\" XXX: It is noted in the CVS history of <sys/bitops.h> that MD-optimized +.\" <machine/bitops.h> is a TODO. If those start appear, note it here. +.\" +.Sh EXAMPLES +In the following example +.Va f = 3 +and +.Va l = 7 : +.Bd -literal -offset indent +uint32_t n = 0x44; /* 01000100 */ +int f, l; + +f = ffs32(n); +l = fls32(n); +.Ed +.Sh SEE ALSO +.Xr bits 3 , +.Xr bitstring 3 , +.Xr ffs 3 , +.Xr setbit 9 +.Sh HISTORY +These functions first appeared in +.Nx 5.0 .