From b7d5a30f85bc5f4056eee1cf825ce7c78a5c5cc1 Mon Sep 17 00:00:00 2001 From: wangmingrong1 Date: Sat, 14 Sep 2024 11:29:03 +0800 Subject: [PATCH] include/nuttx.h: add common align definitions for nuttx Signed-off-by: Bowen Wang --- include/nuttx/nuttx.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/nuttx/nuttx.h b/include/nuttx/nuttx.h index 1c67a705e8..adeaf94fce 100644 --- a/include/nuttx/nuttx.h +++ b/include/nuttx/nuttx.h @@ -33,6 +33,28 @@ * Pre-processor Definitions ****************************************************************************/ +/* Align definitions */ + +#ifndef ALIGN_MASK +# define ALIGN_MASK(s) ((1 << (s)) - 1) +#endif + +#ifndef ALIGN_UP +# define ALIGN_UP(x,a) (((x) + ((a) - 1)) & ~((a) - 1)) +#endif + +#ifndef ALIGN_UP_MASK +# define ALIGN_UP_MASK(x,m) (((x) + (m)) & ~(m)) +#endif + +#ifndef ALIGN_DOWN +# define ALIGN_DOWN(x,a) ((x) & (~((a) - 1))) +#endif + +#ifndef ALIGN_DOWN_MASK +# define ALIGN_DOWN_MASK(x,m) ((x) & ~(m)) +#endif + /* Name: container_of * * Description: