Release 970525
[wine/multimedia.git] / include / bit_array.h
blobb07cdf66dd56e0585337f1548f2e52e05023ce42
1 /***************************************************************************
2 * Copyright 1995, Technion, Israel Institute of Technology
3 * Electrical Eng, Software Lab.
4 * Author: Michael Veksler.
5 ***************************************************************************
6 * File: bit_array.h
7 * Purpose : manipulate array of bits,
8 * Important: operations may be considered atomic.
10 ***************************************************************************
12 #ifndef __WINE_BIT_ARRAY_H
13 #define __WINE_BIT_ARRAY_H
16 #define BITS_PER_BYTE (8)
17 #define BITS_PER_INT (sizeof(int)*BITS_PER_BYTE) /* must be power of 2 */
19 #define BYTE_LOG2 (3)
20 #if defined(INT_LOG2)
21 /* nothing to do, IN_LOG2 is ok */
22 #elif defined(__i386__)
23 # define INT_LOG2 (5)
24 #else
25 # error "Can't find log2 of BITS_PER_INT, please code it manualy"
26 #endif
29 typedef struct bit_array {
30 int bits; /* number of bits in the array */
31 unsigned int *array; /* Actual array data (Never NULL) */
32 } bit_array ;
34 bit_array *AssembleArray(bit_array *new_array, unsigned int *buff, int bits);
35 int ResetArray(bit_array *bits);
37 /* Return index of first free bit, or -1 on failure */
38 int VacantBit(bit_array *bits);
41 /* Return the value of bit 'i' */
42 int SampleBit(bit_array *bits, int i);
44 /* Assign 'val' to a bit no. 'i'. Return: old bit's value */
45 int AssignBit(bit_array *bits, int i, int val);
48 ** Allocate a free bit (==0) and make it used (==1).
49 ** Return: allocated bit index, or -1 on failure.
51 int AllocateBit(bit_array *bits);
53 #endif /* __WINE_BIT_ARRAY_H */