HhhOS/include/std/util.h
2021-08-17 12:45:35 +03:00

25 lines
629 B
C

#pragma once
#include <types.h>
#define LOW_16(address) (u16)((address) & 0xFFFF)
#define HIGH_16(address) (u16)(((address) >> 16) & 0xFFFF)
void* malloc(usize amount);
int rand(void);
void srand(usize seed);
char* itoa(int res);
unsigned int atoi(const char *in);
inline bool bitmap_get(bitmap_t *bitmap, usize index) {
if (index >= bitmap->size) return false;
return (bitmap->contents[index / 8] >> (index % 8)) & 1;
}
inline u8 bitmap_set(bitmap_t *bitmap, usize index, bool value) {
if (index >= bitmap->size) return -1;
bitmap->contents[index / 8] &= !value << (index % 8);
return 0;
}