Bump version to 0.9.1.
[python/dscho.git] / Include / bitset.h
blobe3ef1a18f3aae4b6d0a5aee6e36b0c2c0e7341f7
1 /***********************************************************
2 Copyright (c) 2000, BeOpen.com.
3 Copyright (c) 1995-2000, Corporation for National Research Initiatives.
4 Copyright (c) 1990-1995, Stichting Mathematisch Centrum.
5 All rights reserved.
7 See the file "Misc/COPYRIGHT" for information on usage and
8 redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
9 ******************************************************************/
11 #ifndef Py_BITSET_H
12 #define Py_BITSET_H
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
17 /* Bitset interface */
19 #define BYTE char
21 typedef BYTE *bitset;
23 bitset newbitset(int nbits);
24 void delbitset(bitset bs);
25 #define testbit(ss, ibit) (((ss)[BIT2BYTE(ibit)] & BIT2MASK(ibit)) != 0)
26 int addbit(bitset bs, int ibit); /* Returns 0 if already set */
27 int samebitset(bitset bs1, bitset bs2, int nbits);
28 void mergebitset(bitset bs1, bitset bs2, int nbits);
30 #define BITSPERBYTE (8*sizeof(BYTE))
31 #define NBYTES(nbits) (((nbits) + BITSPERBYTE - 1) / BITSPERBYTE)
33 #define BIT2BYTE(ibit) ((ibit) / BITSPERBYTE)
34 #define BIT2SHIFT(ibit) ((ibit) % BITSPERBYTE)
35 #define BIT2MASK(ibit) (1 << BIT2SHIFT(ibit))
36 #define BYTE2BIT(ibyte) ((ibyte) * BITSPERBYTE)
38 #ifdef __cplusplus
40 #endif
41 #endif /* !Py_BITSET_H */