blob: 048cf9123a8048d7a792b8f0cda9b54d26a02ea8 [file] [log] [blame]
The Android Open Source Project52d4c302009-03-03 19:29:09 -08001/*
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 */
15typedef 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 */
22BitVector* wsAllocBitVector(int startBits, int isExpandable);
23void 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 */
31int wsAllocBit(BitVector* pBits);
32void wsFreeBit(BitVector* pBits, int num);
33
34#endif /*_WRAPSIM_BITVECTOR_H*/