1/* @title: Allocation Macros */
2#pragma once
3#define kfree_1(ptr) kfree_internal((ptr), ALLOC_BEHAVIOR_DEFAULT)
4#define kfree_2(ptr, bh) kfree_internal((ptr), (bh))
5
6#define kfree(...) _DISPATCH(kfree, PP_NARG(__VA_ARGS__))(__VA_ARGS__)
7
8#define kmalloc_1(sz) \
9 kmalloc_internal((sz), ALLOC_FLAGS_DEFAULT, ALLOC_BEHAVIOR_DEFAULT)
10#define kmalloc_2(sz, fl) kmalloc_internal((sz), (fl), ALLOC_BEHAVIOR_DEFAULT)
11#define kmalloc_3(sz, fl, bh) kmalloc_internal((sz), (fl), (bh))
12#define kmalloc(...) _DISPATCH(kmalloc, PP_NARG(__VA_ARGS__))(__VA_ARGS__)
13
14#define kmalloc_aligned_2(sz, al) \
15 kmalloc_aligned_internal((sz), (al), ALLOC_FLAGS_DEFAULT, \
16 ALLOC_BEHAVIOR_DEFAULT)
17#define kmalloc_aligned_3(sz, al, fl) \
18 kmalloc_aligned_internal((sz), (al), (fl), ALLOC_BEHAVIOR_DEFAULT)
19#define kmalloc_aligned_4(sz, al, fl, bh) \
20 kmalloc_aligned_internal((sz), (al), (fl), (bh))
21#define kmalloc_aligned(...) \
22 _DISPATCH(kmalloc_aligned, PP_NARG(__VA_ARGS__))(__VA_ARGS__)
23
24#define kfree_aligned_1(ptr) \
25 kfree_aligned_internal((ptr), ALLOC_BEHAVIOR_DEFAULT)
26#define kfree_aligned_2(ptr, bh) kfree_aligned_internal((ptr), (bh))
27#define kfree_aligned(...) \
28 _DISPATCH(kfree_aligned, PP_NARG(__VA_ARGS__))(__VA_ARGS__)
29
30#define krealloc_2(ptr, sz) \
31 krealloc_internal((ptr), (sz), ALLOC_FLAGS_DEFAULT, ALLOC_BEHAVIOR_DEFAULT)
32#define krealloc_3(ptr, sz, fl) \
33 krealloc_internal((ptr), (sz), (fl), ALLOC_BEHAVIOR_DEFAULT)
34#define krealloc_4(ptr, sz, fl, bh) krealloc_internal((ptr), (sz), (fl), (bh))
35#define krealloc(...) _DISPATCH(krealloc, PP_NARG(__VA_ARGS__))(__VA_ARGS__)
36
37#define knew(ptr, ...) ((ptr) = kmalloc(sizeof(*(ptr)), ##__VA_ARGS__))
38