BSD 4_3_Net_2 release
[unix-history] / usr / src / share / man / man3 / bitstring.3
index fb2bcd8..94dcb5b 100644 (file)
-.\" Copyright (c) 1989 The Regents of the University of California.
+.\" Copyright (c) 1989, 1991 The Regents of the University of California.
 .\" All rights reserved.
 .\"
 .\" This code is derived from software contributed to Berkeley by
 .\" Paul Vixie.
 .\" All rights reserved.
 .\"
 .\" This code is derived from software contributed to Berkeley by
 .\" Paul Vixie.
+.\" 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.
+.\" 3. All advertising materials mentioning features or use of this software
+.\"    must display the following acknowledgement:
+.\"    This product includes software developed by the University of
+.\"    California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
 .\"
 .\"
-.\" Redistribution and use in source and binary forms are permitted provided
-.\" that: (1) source distributions retain this entire copyright notice and
-.\" comment, and (2) distributions including binaries display the following
-.\" acknowledgement:  ``This product includes software developed by the
-.\" University of California, Berkeley and its contributors'' in the
-.\" documentation or other materials provided with the distribution and in
-.\" all advertising materials mentioning features or use of this software.
-.\" Neither the name of the University nor the names of its contributors may
-.\" be used to endorse or promote products derived from this software without
-.\" specific prior written permission.
-.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
-.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
 .\"
 .\"
-.\"    @(#)bitstring.3 5.3 (Berkeley) 6/23/90
+.\"     @(#)bitstring.3        5.4 (Berkeley) 4/19/91
 .\"
 .\"
-.TH BITSTRING 3  "June 23, 1990"
-.UC 4
-.SH NAME
-bit_alloc, bit_clear, bit_decl, bit_ffs, bit_nclear, bit_nset,
-bit_set, bitstr_size, bit_test \- bit-string manipulation macros
-.SH SYNOPSIS
-.ft B
-.nf
-#include <bitstring.h>
-
-name = bit_alloc(nbits)
-bitstr_t *name;
-int nbits;
-
-bit_decl(name, nbits)
-bitstr_t name;
-int nbits;
-
-bit_clear(name, bit)
-bitstr_t name;
-int bit;
-
-bit_ffc(name, nbits, value)
-bitstr_t name;
-int nbits, *value;
-
-bit_ffs(name, nbits, value)
-bitstr_t name;
-int nbits, *value;
-
-bit_nclear(name, start, stop)
-bitstr_t name;
-int start, stop;
-
-bit_nset(name, start, stop)
-bitstr_t name;
-int start, stop;
-
-bit_set(name, bit)
-bitstr_t name;
-int bit;
-
-bitstr_size(nbits)
-int nbits;
-
-bit_test(name, bit)
-bitstr_t name;
-int bit;
-.fi
-.ft R
-.SH DESCRIPTION
+.Dd April 19, 1991
+.Dt BITSTRING 3
+.Os BSD 4
+.Sh NAME
+.Nm bit_alloc ,
+.Nm bit_clear ,
+.Nm bit_decl ,
+.Nm bit_ffs ,
+.Nm bit_nclear ,
+.Nm bit_nset,
+.Nm bit_set ,
+.Nm bitstr_size ,
+.Nm bit_test
+.Nd bit-string manipulation macros
+.Sh SYNOPSIS
+.Fd #include <bitstring.h>
+.Ft bitstr_t *
+.Fn bit_alloc "int nbits"
+.Fn bit_decl "bit_str name" "int nbits"
+.Fn bit_clear "bit_str name" "int bit"
+.Fn bit_ffc "bit_str name" "int nbits" "int *value"
+.Fn bit_ffs "bit_str name" "int nbits" "int *value"
+.Fn bit_nclear "bit_str name" "int start" "int stop"
+.Fn bit_nset "bit_str name" "int start" "int stop"
+.Fn bit_set "bit_str name" "int bit"
+.Fn bitstr_size "int nbits"
+.Fn bit_test "bit_str name" "int bit"
+.Sh DESCRIPTION
 These macros operate on strings of bits.
 These macros operate on strings of bits.
-.PP
-.I Bit_alloc
+.Pp
+The macro
+.Fn bit_alloc
 returns a pointer of type
 returns a pointer of type
-.I bitstr_t\ *
+.Dq Fa "bitstr_t *"
 to sufficient space to store
 to sufficient space to store
-.I nbits
-bits, or NULL if no space is available.
-.PP
-.I Bit_decl
-is a macro for allocating sufficient space to store
-.I nbits
+.Fa nbits
+bits, or
+.Dv NULL
+if no space is available.
+.Pp
+The macro
+.Fn bit_decl
+allocates sufficient space to store
+.Fa nbits
 bits on the stack.
 bits on the stack.
-.PP
-.I Bitstr_size
+.Pp
+The macro
+.Fn bitstr_size
 returns the number of elements of type
 returns the number of elements of type
-.I bitstr_t
+.Fa bitstr_t
 necessary to store
 necessary to store
-.I nbits
+.Fa nbits
 bits.
 This is useful for copying bit strings.
 bits.
 This is useful for copying bit strings.
-.PP
-.I Bit_clear
+.Pp
+The macros
+.Fn bit_clear
 and
 and
-.I bit_set
+.Fn bit_set
 clear or set the zero-based numbered bit
 clear or set the zero-based numbered bit
-.IR bit ,
+.Fa bit ,
 in the bit string
 in the bit string
-.IR name .
-.PP
-.I Bit_nset
+.Ar name .
+.Pp
+The
+.Fn bit_nset
 and
 and
-.I bit_nclear
+.Fn bit_nclear
+macros
 set or clear the zero-based numbered bits from
 set or clear the zero-based numbered bits from
-.I start
+.Fa start
 to
 to
-.I stop
+.Fa stop
 in the bit string
 in the bit string
-.IR name .
-.PP
-.I Bit_test
+.Ar name .
+.Pp
+The
+.Fn bit_test
+macro
 evaluates to zero if the zero-based numbered bit
 evaluates to zero if the zero-based numbered bit
-.I bit
+.Fa bit
 of bit string
 of bit string
-.I name
+.Fa name
 is set, and non-zero otherwise.
 is set, and non-zero otherwise.
-.PP
-.I Bit_ffs
+.Pp
+The
+.Fn bit_ffs
+macro
 stores in the location referenced by
 stores in the location referenced by
-.I value
+.Fa value
 the zero-based number of the first bit set in the array of
 the zero-based number of the first bit set in the array of
-.I nbits
+.Fa nbits
 bits referenced by
 bits referenced by
-.IR name .
+.Fa name .
 If no bits are set, the location referenced by
 If no bits are set, the location referenced by
-.I value
-is set to -1.
-.PP
-.I Bit_ffc
+.Fa value
+is set to \-1.
+.Pp
+The macro
+.Fn bit_ffc
 stores in the location referenced by
 stores in the location referenced by
-.I value
+.Fa value
 the zero-based number of the first bit not set in the array of
 the zero-based number of the first bit not set in the array of
-.I nbits
+.Fa nbits
 bits referenced by
 bits referenced by
-.IR name .
+.Fa name .
 If all bits are set, the location referenced by
 If all bits are set, the location referenced by
-.I value
-is set to -1.
-.PP
+.Fa value
+is set to \-1.
+.Pp
 The arguments to these macros are evaluated only once and may safely
 have side effects.
 The arguments to these macros are evaluated only once and may safely
 have side effects.
-.SH EXAMPLE
-.nf
-.in +5
+.Sh EXAMPLE
+.Bd -literal -offset indent
 #include <limits.h>
 #include <bitstring.h>
 
 #include <limits.h>
 #include <bitstring.h>
 
@@ -168,6 +170,11 @@ make_lpr_available()
                bit_set(bitlist, LPR_AVAILABLE_BIT);
        }
 }
                bit_set(bitlist, LPR_AVAILABLE_BIT);
        }
 }
-.fi
-.SH "SEE ALSO"
-malloc(3)
+.Ed
+.Sh SEE ALSO
+.Xr malloc 3
+.Sh HISTORY
+The
+.Nm
+functions are
+.Ud .