mirror of
https://github.com/subhobhai943/SUB-OS.git
synced 2026-10-25 16:52:29 +00:00
Initial commit: SUB-OS 64-Bit Production Monolithic Operating System with LazyBox userland suite
This commit is contained in:
commit
cd9c786d14
88 files changed
+7132
No files matched your search
@@ -0,0 +1,26 @@
|
||||
#ifndef _LIB_BITMAP_H
|
||||
#define _LIB_BITMAP_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef uint64_t bitmap_word_t;
|
||||
#define BITS_PER_WORD (sizeof(bitmap_word_t) * 8)
|
||||
|
||||
static inline void bitmap_set(bitmap_word_t* map, size_t bit) {
|
||||
map[bit / BITS_PER_WORD] |= ((bitmap_word_t)1 << (bit % BITS_PER_WORD));
|
||||
}
|
||||
|
||||
static inline void bitmap_clear(bitmap_word_t* map, size_t bit) {
|
||||
map[bit / BITS_PER_WORD] &= ~((bitmap_word_t)1 << (bit % BITS_PER_WORD));
|
||||
}
|
||||
|
||||
static inline bool bitmap_test(const bitmap_word_t* map, size_t bit) {
|
||||
return (map[bit / BITS_PER_WORD] & ((bitmap_word_t)1 << (bit % BITS_PER_WORD))) != 0;
|
||||
}
|
||||
|
||||
int64_t bitmap_find_first_free(const bitmap_word_t* map, size_t total_bits);
|
||||
int64_t bitmap_find_contiguous_free(const bitmap_word_t* map, size_t total_bits, size_t count);
|
||||
|
||||
#endif // _LIB_BITMAP_H
|
||||
Reference in new issue
Block a user