2 /* Bitset primitives used by the parser generator */
4 #include "pgenheaders.h"
10 int nbytes
= NBYTES(nbits
);
11 bitset ss
= (char *)PyObject_MALLOC(sizeof(BYTE
) * nbytes
);
14 Py_FatalError("no mem for bitset");
29 addbit(bitset ss
, int ibit
)
31 int ibyte
= BIT2BYTE(ibit
);
32 BYTE mask
= BIT2MASK(ibit
);
35 return 0; /* Bit already set */
40 #if 0 /* Now a macro */
42 testbit(bitset ss
, int ibit
)
44 return (ss
[BIT2BYTE(ibit
)] & BIT2MASK(ibit
)) != 0;
49 samebitset(bitset ss1
, bitset ss2
, int nbits
)
53 for (i
= NBYTES(nbits
); --i
>= 0; )
60 mergebitset(bitset ss1
, bitset ss2
, int nbits
)
64 for (i
= NBYTES(nbits
); --i
>= 0; )