16#include <kernel/types.h>
21 __typeof__(_x) _max1 = (_x); \
22 __typeof__(_y) _max2 = (_y); \
23 _max1 > _max2 ? _max1 : _max2; \
29 __typeof__(_x) _max1 = (_x); \
30 __typeof__(_y) _max2 = (_y); \
31 _max1 < _max2 ? _max1 : _max2; \
37 __typeof__(_x) _tmp = (_x); \
38 _tmp < 0 ? -_tmp : _tmp; \
41#define __align_mask(_value, _power) ((__typeof__(_value))((_power)-1))
47#define align_up(_value, _power) \
48 ((((_value)-1) | __align_mask(_value, _power)) + 1)
54#define align_down(_value, _power) ((_value) & ~__align_mask(_value, _power))
57#define is_aligned(_value, _alignment) (!((_value) % (_alignment)))
59#define align_down_ptr(_ptr, _power) ((void *)align_down((vaddr_t)_ptr, _power))
60#define align_up_ptr(_ptr, _power) ((void *)align_up((vaddr_t)_ptr, _power))
61#define is_aligned_ptr(_ptr, _alignment) is_aligned((vaddr_t)_ptr, _alignment)
69static inline u32
round_up(u32 value, u32 alignment)
74 u32 offset = value % alignment;
76 value += alignment - offset;
90 return value - (value % alignment);
static u32 round_down(u32 value, u32 alignment)
Round value to the previous multiple of alignment.
Definition: math.h:85
static u32 round_up(u32 value, u32 alignment)
Round value to the next multiple of alignment.
Definition: math.h:69