19428323dSchristos // 29428323dSchristos // bitfield.h - extract and set bit fields 39428323dSchristos // 49428323dSchristos // Written by Eryk Vershen 59428323dSchristos // 69428323dSchristos // Bitfields are not particularly transportable between big and little 79428323dSchristos // endian machines. Big endian machines lay out bitfields starting 89428323dSchristos // from the most significant bit of the (one, two or four byte) number, 99428323dSchristos // whereas little endian machines lay out bitfields starting from the 109428323dSchristos // least signifcant bit. 119428323dSchristos // 129428323dSchristos // These routines were written to support some bitfields in a disk 139428323dSchristos // data structure (partition map) whose original definition was on 149428323dSchristos // a big-endian machine. 159428323dSchristos // 169428323dSchristos // They only work on 32-bit values because I didn't need 16-bit support. 179428323dSchristos // The bits in the long word are numbered from 0 (least significant) to 189428323dSchristos // 31 (most significant). 199428323dSchristos // 209428323dSchristos 219428323dSchristos /* 229428323dSchristos * Copyright 1996,1998 by Apple Computer, Inc. 239428323dSchristos * All Rights Reserved 249428323dSchristos * 259428323dSchristos * Permission to use, copy, modify, and distribute this software and 269428323dSchristos * its documentation for any purpose and without fee is hereby granted, 279428323dSchristos * provided that the above copyright notice appears in all copies and 289428323dSchristos * that both the copyright notice and this permission notice appear in 299428323dSchristos * supporting documentation. 309428323dSchristos * 319428323dSchristos * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 329428323dSchristos * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 339428323dSchristos * FOR A PARTICULAR PURPOSE. 349428323dSchristos * 359428323dSchristos * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR 369428323dSchristos * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 379428323dSchristos * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, 389428323dSchristos * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 399428323dSchristos * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 409428323dSchristos */ 419428323dSchristos 429428323dSchristos #ifndef __bitfield__ 439428323dSchristos #define __bitfield__ 449428323dSchristos 459428323dSchristos 469428323dSchristos // 479428323dSchristos // Defines 489428323dSchristos // 499428323dSchristos 509428323dSchristos 519428323dSchristos // 529428323dSchristos // Types 539428323dSchristos // 549428323dSchristos 559428323dSchristos 569428323dSchristos // 579428323dSchristos // Global Constants 589428323dSchristos // 599428323dSchristos 609428323dSchristos 619428323dSchristos // 629428323dSchristos // Global Variables 639428323dSchristos // 649428323dSchristos 659428323dSchristos 669428323dSchristos // 679428323dSchristos // Forward declarations 689428323dSchristos // 69*48a628aeSchristos uint32_t bitfield_set(uint32_t *bf, int base, int length, uint32_t value); 70*48a628aeSchristos 71*48a628aeSchristos uint32_t bitfield_get(uint32_t bf, int base, int length); 729428323dSchristos 739428323dSchristos #endif /* __bitfield__ */ 74