memalign.h 469 B

12345678910111213141516171819202122232425
  1. /*
  2. * Copyright (c) 2015 Google, Inc
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef __ALIGNMEM_H
  7. #define __ALIGNMEM_H
  8. /*
  9. * ARCH_DMA_MINALIGN is defined in asm/cache.h for each architecture. It
  10. * is used to align DMA buffers.
  11. */
  12. #ifndef __ASSEMBLY__
  13. #include <asm/cache.h>
  14. #include <malloc.h>
  15. static inline void *malloc_cache_aligned(size_t size)
  16. {
  17. return memalign(ARCH_DMA_MINALIGN, ALIGN(size, ARCH_DMA_MINALIGN));
  18. }
  19. #endif
  20. #endif /* __ALIGNMEM_H */