1 '\" te 2 .\" Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. 3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. 4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. 5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] 6 .TH DDI_FFS 9F "Jan 16, 2006" 7 .SH NAME 8 ddi_ffs, ddi_fls \- find first (last) bit set in a long integer 9 .SH SYNOPSIS 10 .LP 11 .nf 12 #include <sys/conf.h> 13 #include <sys/ddi.h> 14 #include <sys/sunddi.h> 15 16 17 18 \fBint\fR\fBddi_ffs\fR(\fBlong\fR \fImask\fR); 19 .fi 20 21 .LP 22 .nf 23 \fBint\fR \fBddi_fls\fR(\fBlong\fR \fImask\fR); 24 .fi 25 26 .SH INTERFACE LEVEL 27 .sp 28 .LP 29 Solaris DDI specific (Solaris DDI). 30 .SH PARAMETERS 31 .sp 32 .ne 2 33 .na 34 \fB\fImask\fR\fR 35 .ad 36 .RS 8n 37 A 32-bit argument value to search through. 38 .RE 39 40 .SH DESCRIPTION 41 .sp 42 .LP 43 The function \fBddi_ffs()\fR takes its argument and returns the shift count 44 that the first (least significant) bit set in the argument corresponds to. The 45 function \fBddi_fls()\fR does the same, only it returns the shift count for the 46 last (most significant) bit set in the argument. 47 .SH RETURN VALUES 48 .sp 49 .ne 2 50 .na 51 \fB\fB0\fR\fR 52 .ad 53 .RS 5n 54 No bits are set in mask. 55 .RE 56 57 .sp 58 .ne 2 59 .na 60 \fB\fIN\fR\fR 61 .ad 62 .RS 5n 63 Bit \fIN\fR is the least significant (\fBddi_ffs\fR) or most significant 64 (\fBddi_fls\fR) bit set in mask. Bits are numbered from \fB1\fR to \fB32\fR, 65 with bit \fB1\fR being the least significant bit position and bit \fB32\fR the 66 most significant position. 67 .RE 68 69 .SH CONTEXT 70 .sp 71 .LP 72 This function can be called from user, interrupt, or kernel context. 73 .SH SEE ALSO 74 .sp 75 .LP 76 \fIWriting Device Drivers\fR