2 // bitfield.h - extract and set bit fields
4 // Written by Eryk Vershen
6 // Bitfields are not particularly transportable between big and little
7 // endian machines. Big endian machines lay out bitfields starting
8 // from the most significant bit of the (one, two or four byte) number,
9 // whereas little endian machines lay out bitfields starting from the
10 // least signifcant bit.
12 // These routines were written to support some bitfields in a disk
13 // data structure (partition map) whose original definition was on
14 // a big-endian machine.
16 // They only work on 32-bit values because I didn't need 16-bit support.
17 // The bits in the long word are numbered from 0 (least significant) to
18 // 31 (most significant).
22 * Copyright 1996,1998 by Apple Computer, Inc.
25 * Permission to use, copy, modify, and distribute this software and
26 * its documentation for any purpose and without fee is hereby granted,
27 * provided that the above copyright notice appears in all copies and
28 * that both the copyright notice and this permission notice appear in
29 * supporting documentation.
31 * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
32 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
33 * FOR A PARTICULAR PURPOSE.
35 * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
36 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
37 * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
38 * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
39 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
67 // Forward declarations
69 unsigned long bitfield_set(unsigned long *bf
, int base
, int length
, unsigned long value
);
70 unsigned long bitfield_get(unsigned long bf
, int base
, int length
);
72 #endif /* __bitfield__ */