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 .Dd July 14, 2017
   7 .Dt DDI_FFS 9F
   8 .Os
   9 .Sh NAME
  10 .Nm ddi_ffs, ddi_ffsll, ddi_fls, ddi_flsll
  11 .Nd find first (last) bit set in a long (long) integer
  12 .Sh SYNOPSIS
  13 .In sys/conf.h
  14 .In sys/ddi.h
  15 .In sys/sunddi.h
  16 .Ft int
  17 .Fo "ddi_ffs"
  18 .Fa "long mask"
  19 .Fc
  20 .Ft int
  21 .Fo "ddi_fls"
  22 .Fa "long mask"
  23 .Fc
  24 .Ft int
  25 .Fo "ddi_ffs"
  26 .Fa "long long mask"
  27 .Fc
  28 .Ft int
  29 .Fo "ddi_fls"
  30 .Fa "long long mask"
  31 .Fc
  32 .Sh INTERFACE LEVEL
  33 Solaris DDI specific (Solaris DDI).
  34 .Sh PARAMETERS
  35 .Bl -tag -width Va
  36 .It Fa mask
  37 A 32-bit or 64-bit argument value to search through.
  38 .El
  39 .Sh DESCRIPTION
  40 The functions
  41 .Fn ddi_ffs
  42 and
  43 .Fn ddi_ffsll
  44 take their argument and return the shift count that the first (least
  45 significant) bit set in the argument corresponds to.
  46 The functions
  47 .Fn ddi_fls
  48 and
  49 .Fn ddi_flsll
  50 do the same, only they returns the shift count for the last (most
  51 significant) bit set in the argument.
  52 .Fn ddi_ffs
  53 and
  54 .Fn ddi_fls
  55 operate on 32-bit values, while
  56 .Fn ddi_ffsll
  57 and
  58 .Fn ddi_flsll
  59 operate on 64-bit values.
  60 .Sh CONTEXT
  61 These functions can be called from user, interrupt, or kernel context.
  62 .Sh RETURN VALUES
  63 .Bl -tag -width Va
  64 .It 0
  65 No bits are set in mask.
  66 .It N
  67 Bit
  68 .Em N
  69 is the least significant
  70 .Po
  71 .Fn ddi_ffs ,
  72 .Fn ddi_ffsll
  73 .Pc
  74 or most significant
  75 .Po
  76 .Fn ddi_fls ,
  77 .Fn ddi_flsll
  78 .Pc
  79 bit set in
  80 .Fa mask .
  81 Bits are numbered from
  82 .Em 1
  83 to
  84 .Em 32
  85 or
  86 .Em 64 ,
  87 with bit
  88 .Em 1
  89 being the least significant bit position and bit
  90 .Em 32
  91 or
  92 .Em 64
  93 the most significant position, depending on the variant of the
  94 functions used.
  95 .El
  96 .Sh SEE ALSO
  97 \fIWriting Device Drivers\fR