28 lines
654 B
C
28 lines
654 B
C
|
/* NEW CODE for optimised bit array.
|
||
|
* Copyright (C) 2024 Zak Fenton
|
||
|
* NO WARRANTY USE AT YOUR OWN RISK etc. under terms of UNLICENSE or MIT license
|
||
|
*/
|
||
|
|
||
|
#ifndef _BITARRAY_H
|
||
|
#define _BITARRAY_H
|
||
|
|
||
|
struct bitarray {
|
||
|
sched_spinlock_t lock;
|
||
|
int size;
|
||
|
int pad;
|
||
|
uint64 data[64];
|
||
|
};
|
||
|
|
||
|
struct bitarray* bitarrayalloc(int nbits);
|
||
|
|
||
|
int bitarray_get(struct bitarray* a, int index);
|
||
|
int bitarray_getnolock(struct bitarray* a, int index);
|
||
|
int bitarray_findlowest(struct bitarray* a, int startidx);
|
||
|
int bitarray_poplowest(struct bitarray* a, int startidx);
|
||
|
void bitarray_set(struct bitarray* a, int index, int val);
|
||
|
|
||
|
|
||
|
/* From ifndef at top of file: */
|
||
|
#endif
|
||
|
|