-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e156f89
commit bb62d45
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef ALLOCX_ALIGNMENT_H | ||
#define ALLOCX_ALIGNMENT_H | ||
|
||
#include "allocx_core_types.h" | ||
|
||
// Alignment macros | ||
#define ALIGN_UP(value, alignment) (((value) + ((alignment)-1)) & ~((alignment)-1)) | ||
#define ALIGN_DOWN(value, alignment) ((value) & ~((alignment)-1)) | ||
#define IS_ALIGNED(value, alignment) (((value) & ((alignment)-1)) == 0) | ||
|
||
// Alignment types | ||
typedef u8 align8_t __attribute__((aligned(8))); | ||
typedef u16 align16_t __attribute__((aligned(16))); | ||
typedef u32 align32_t __attribute__((aligned(32))); | ||
typedef u64 align64_t __attribute__((aligned(64))); | ||
|
||
#endif // ALLOCX_ALIGNMENT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef ALLOCX_UTILITIES_H | ||
#define ALLOCX_UTILITIES_H | ||
|
||
#include "allocx_alignment.h" | ||
|
||
// Array size | ||
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) | ||
|
||
// Range | ||
#define IN_RANGE(value, min, max) ((value) >= (min) && (value) <= (max)) | ||
#define CLAMP(value, min, max) (allocx_min(allocx_max((value), (min)), (max))) | ||
|
||
#endif // ALLOCX_UTILITIES_H |