Annotation of 43BSDReno/usr.bin/make/bit.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
        !             3:  * Copyright (c) 1988, 1989 by Adam de Boor
        !             4:  * Copyright (c) 1989 by Berkeley Softworks
        !             5:  * All rights reserved.
        !             6:  *
        !             7:  * This code is derived from software contributed to Berkeley by
        !             8:  * Adam de Boor.
        !             9:  *
        !            10:  * Redistribution and use in source and binary forms are permitted
        !            11:  * provided that: (1) source distributions retain this entire copyright
        !            12:  * notice and comment, and (2) distributions including binaries display
        !            13:  * the following acknowledgement:  ``This product includes software
        !            14:  * developed by the University of California, Berkeley and its contributors''
        !            15:  * in the documentation or other materials provided with the distribution
        !            16:  * and in all advertising materials mentioning features or use of this
        !            17:  * software. Neither the name of the University nor the names of its
        !            18:  * contributors may be used to endorse or promote products derived
        !            19:  * from this software without specific prior written permission.
        !            20:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
        !            21:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
        !            22:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            23:  *
        !            24:  *     @(#)bit.h       5.3 (Berkeley) 6/1/90
        !            25:  */
        !            26: 
        !            27: /*
        !            28:  * bit.h --
        !            29:  *
        !            30:  *     Definition of macros for setting and clearing bits in an array
        !            31:  *     of integers.
        !            32:  *
        !            33:  *     It is assumed that "int" is 32 bits wide.
        !            34:  */
        !            35: 
        !            36: #ifndef _BIT
        !            37: #define _BIT
        !            38: 
        !            39: #include "sprite.h"
        !            40: 
        !            41: #define BIT_NUM_BITS_PER_INT   32
        !            42: #define BIT_NUM_BITS_PER_BYTE  8
        !            43: 
        !            44: #define Bit_NumInts(numBits)   \
        !            45:        (((numBits)+BIT_NUM_BITS_PER_INT -1)/BIT_NUM_BITS_PER_INT)
        !            46: 
        !            47: #define Bit_NumBytes(numBits)  \
        !            48:        (Bit_NumInts(numBits) * sizeof(int))
        !            49: 
        !            50: #define Bit_Alloc(numBits, bitArrayPtr)        \
        !            51:         bitArrayPtr = (int *)malloc((unsigned)Bit_NumBytes(numBits)); \
        !            52:         Bit_Zero((numBits), (bitArrayPtr))
        !            53: 
        !            54: #define Bit_Free(bitArrayPtr)  \
        !            55:         free((char *)bitArrayPtr)
        !            56: 
        !            57: #define Bit_Set(numBits, bitArrayPtr) \
        !            58:        ((bitArrayPtr)[(numBits)/BIT_NUM_BITS_PER_INT] |= \
        !            59:                                (1 << ((numBits) % BIT_NUM_BITS_PER_INT)))
        !            60: 
        !            61: #define Bit_IsSet(numBits, bitArrayPtr) \
        !            62:        ((bitArrayPtr)[(numBits)/BIT_NUM_BITS_PER_INT] & \
        !            63:                                (1 << ((numBits) % BIT_NUM_BITS_PER_INT)))
        !            64: 
        !            65: #define Bit_Clear(numBits, bitArrayPtr) \
        !            66:        ((bitArrayPtr)[(numBits)/BIT_NUM_BITS_PER_INT] &= \
        !            67:                                ~(1 << ((numBits) % BIT_NUM_BITS_PER_INT)))
        !            68: 
        !            69: #define Bit_IsClear(numBits, bitArrayPtr) \
        !            70:        (!(Bit_IsSet((numBits), (bitArrayPtr))))
        !            71: 
        !            72: #define Bit_Copy(numBits, srcArrayPtr, destArrayPtr) \
        !            73:        bcopy((char *)(srcArrayPtr), (char *)(destArrayPtr), \
        !            74:                Bit_NumBytes(numBits))
        !            75: 
        !            76: #define Bit_Zero(numBits, bitArrayPtr) \
        !            77:        bzero((char *)(bitArrayPtr), Bit_NumBytes(numBits))
        !            78: 
        !            79: extern int       Bit_FindFirstSet();
        !            80: extern int       Bit_FindFirstClear();
        !            81: extern Boolean   Bit_Intersect();
        !            82: extern Boolean           Bit_Union();
        !            83: extern Boolean           Bit_AnySet();
        !            84: extern int       *Bit_Expand();
        !            85:         
        !            86: #endif _BIT

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.