source: trunk/include/win/bit_array.h@ 3830

Last change on this file since 3830 was 4, checked in by ktk, 26 years ago

Import

File size: 1.6 KB
Line 
1/* $Id: bit_array.h,v 1.1 1999-05-24 20:19:08 ktk Exp $ */
2
3/***************************************************************************
4 * Copyright 1995, Technion, Israel Institute of Technology
5 * Electrical Eng, Software Lab.
6 * Author: Michael Veksler.
7 ***************************************************************************
8 * File: bit_array.h
9 * Purpose : manipulate array of bits,
10 * Important: operations may be considered atomic.
11 *
12 ***************************************************************************
13 */
14#ifndef __WINE_BIT_ARRAY_H
15#define __WINE_BIT_ARRAY_H
16
17
18#define BITS_PER_BYTE (8)
19#define BITS_PER_INT (sizeof(int)*BITS_PER_BYTE) /* must be power of 2 */
20
21#define BYTE_LOG2 (3)
22#if defined(INT_LOG2)
23/* nothing to do, IN_LOG2 is ok */
24#elif defined(__i386__)
25# define INT_LOG2 (5)
26#else
27# error "Can't find log2 of BITS_PER_INT, please code it manualy"
28#endif
29
30
31typedef struct bit_array {
32 int bits; /* number of bits in the array */
33 unsigned int *array; /* Actual array data (Never NULL) */
34} bit_array ;
35
36bit_array *AssembleArray(bit_array *new_array, unsigned int *buff, int bits);
37int ResetArray(bit_array *bits);
38
39/* Return index of first free bit, or -1 on failure */
40int VacantBit(bit_array *bits);
41
42
43/* Return the value of bit 'i' */
44int SampleBit(bit_array *bits, int i);
45
46/* Assign 'val' to a bit no. 'i'. Return: old bit's value */
47int AssignBit(bit_array *bits, int i, int val);
48
49/*
50** Allocate a free bit (==0) and make it used (==1).
51** Return: allocated bit index, or -1 on failure.
52*/
53int AllocateBit(bit_array *bits);
54
55#endif /* __WINE_BIT_ARRAY_H */
Note: See TracBrowser for help on using the repository browser.