align.h 552 B

123456789101112131415
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_ALIGN_H
  3. #define _LINUX_ALIGN_H
  4. #include "const.h"
  5. /* @a is a power of 2 value */
  6. #define ALIGN_UP(x, a) __ALIGN_KERNEL((x), (a))
  7. #define ALIGN_DOWN(x, a) __ALIGN_KERNEL((x) - ((a) - 1), (a))
  8. #define __ALIGN_MASK(x, mask) __ALIGN_KERNEL_MASK((x), (mask))
  9. #define PTR_ALIGN(p, a) ((typeof(p))ALIGN_UP((unsigned long)(p), (a)))
  10. #define PTR_ALIGN_DOWN(p, a) ((typeof(p))ALIGN_DOWN((unsigned long)(p), (a)))
  11. #define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
  12. #endif /* _LINUX_ALIGN_H */