diff options
| author | Carlos Maiolino <[email protected]> | 2025-08-25 08:30:50 +0200 |
|---|---|---|
| committer | Carlos Maiolino <[email protected]> | 2025-08-25 08:30:50 +0200 |
| commit | 74c5f1825f7ab0ab42656919032fe907c0aaeb8d (patch) | |
| tree | 6ddd507b3e4d157499865708b1729a7e53a0c730 /src/include | |
| parent | 7b988e680727beed1d75ff4f0e48158f4465f122 (diff) | |
Add math lib
So far I just need a roundup routine to implement a basic heap manager
Signed-off-by: Carlos Maiolino <[email protected]>
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/toxic/math.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/include/toxic/math.h b/src/include/toxic/math.h new file mode 100644 index 0000000..acae3fe --- /dev/null +++ b/src/include/toxic/math.h @@ -0,0 +1,14 @@ +#ifndef MATH_H +#define MATH_H + +#include <stdint.h> + +/* This should check for overflow */ +static inline uint32_t +roundup32(uint32_t n, uint32_t alignment) +{ + return (n % alignment == 0) ? n : + (n + (alignment - ( n % alignment))); +} + +#endif /* MATH_H */ |
