kernel: add header files
This commit is contained in:
35
include/kernel/bitmap.h
Normal file
35
include/kernel/bitmap.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef KERNEL_BITMAP_H_
|
||||
#define KERNEL_BITMAP_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BITS_PER_WORD (8 * sizeof(unsigned long))
|
||||
#define __DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
|
||||
#define BITMAP_WORDS(nbits) __DIV_ROUND_UP(nbits, BITS_PER_WORD)
|
||||
#define BITMAP_NPOS ((unsigned int)-1)
|
||||
|
||||
#define DECLARE_BITMAP(name, nbits) unsigned long name[BITMAP_WORDS(nbits)]
|
||||
|
||||
extern void bitmap_zero(unsigned long *map, unsigned long nbits);
|
||||
extern void bitmap_fill(unsigned long *map, unsigned long nbits);
|
||||
extern void bitmap_set(unsigned long *map, unsigned long bit);
|
||||
extern void bitmap_clear(unsigned long *map, unsigned long bit);
|
||||
extern bool bitmap_check(unsigned long *map, unsigned long bit);
|
||||
|
||||
extern unsigned int bitmap_count_set(unsigned long *map, unsigned long nbits);
|
||||
extern unsigned int bitmap_count_clear(unsigned long *map, unsigned long nbits);
|
||||
|
||||
extern unsigned int bitmap_highest_set(unsigned long *map, unsigned long nbits);
|
||||
extern unsigned int bitmap_highest_clear(unsigned long *map, unsigned long nbits);
|
||||
extern unsigned int bitmap_lowest_set(unsigned long *map, unsigned long nbits);
|
||||
extern unsigned int bitmap_lowest_clear(unsigned long *map, unsigned long nbits);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user