• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2007 The Android Open Source Project
3  *
4  * Simple bit vector.
5  */
6 #ifndef _WRAPSIM_BITVECTOR_H
7 #define _WRAPSIM_BITVECTOR_H
8 
9 #include <stdint.h>
10 
11 /*
12  * Expanding bitmap, used for tracking resources.  Bits are numbered starting
13  * from zero.
14  */
15 typedef struct BitVector {
16     int         isExpandable;   /* expand bitmap if we run out? */
17     int         storageSize;    /* current size, in 32-bit words */
18     uint32_t*   storage;
19 } BitVector;
20 
21 /* allocate a bit vector with enough space to hold "startBits" bits */
22 BitVector* wsAllocBitVector(int startBits, int isExpandable);
23 void wsFreeBitVector(BitVector* pBits);
24 
25 /*
26  * Set/clear a single bit; assumes external synchronization.
27  *
28  * We always allocate the first possible bit.  If we run out of space in
29  * the bitmap, and it's not marked expandable, dvmAllocBit returns -1.
30  */
31 int wsAllocBit(BitVector* pBits);
32 void wsFreeBit(BitVector* pBits, int num);
33 
34 #endif /*_WRAPSIM_BITVECTOR_H*/
35