New drag list control.
[wine] / include / bit_array.h
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.
9  *
10  ***************************************************************************
11  */
12 #ifndef __WINE_BIT_ARRAY_H
13 #define __WINE_BIT_ARRAY_H
14
15
16 #define BITS_PER_BYTE (8)
17 #define BITS_PER_INT (sizeof(int)*BITS_PER_BYTE) /* must be power of 2 */
18
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
27
28
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 ;
33
34 bit_array *AssembleArray(bit_array *new_array, unsigned int *buff, int bits);
35 int ResetArray(bit_array *bits);
36
37 /* Return index of first free bit, or -1 on failure */
38 int VacantBit(bit_array *bits);
39
40
41 /* Return the value of bit 'i' */
42 int SampleBit(bit_array *bits, int i);
43
44 /* Assign 'val' to a bit no. 'i'.      Return: old bit's value */
45 int AssignBit(bit_array *bits, int i, int val);
46
47 /*
48 ** Allocate a free bit (==0) and make it used (==1).
49 ** Return: allocated bit index, or -1 on failure.
50 */
51 int AllocateBit(bit_array *bits);
52
53 #endif /* __WINE_BIT_ARRAY_H */