shithub: femtolisp

ref: c1b99838564a31cba20b227c1f4a9ffa51d5c74e
dir: /bitvector.h/

View raw version
uint32_t *bitvector_resize(uint32_t *b, uint64_t oldsz, uint64_t newsz, int initzero);

#define bitvector_new(n, initzero) bitvector_resize(nil, 0, (n), (initzero))
#define bitvector_nwords(nbits) (((uint64_t)(nbits)+31)>>5)
#define bitvector_get(b, n) (b[(n)>>5] & (1U<<((n)&31)))
#define bitvector_set(b, n) do{ \
		b[(n)>>5] |= 1U<<((n)&31); \
	}while(0)
#define bitvector_reset(b, n) do{ \
		b[(n)>>5] &= ~(1U<<((n)&31)); \
	}while(0)