This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 9beb600e5e2 arch: use stack alignment macros instead of open-coded bit
operations
9beb600e5e2 is described below
commit 9beb600e5e2c8b2efa81cfb3a5dd4d46c55f33a7
Author: hujun5 <[email protected]>
AuthorDate: Fri Feb 6 14:49:56 2026 +0800
arch: use stack alignment macros instead of open-coded bit operations
Replace open-coded bitwise alignment checks and operations with the
STACK_ISALIGNED, STACKFRAME_ISALIGNED, and STACKFRAME_ALIGN_DOWN macros
across all architecture usestack, cpuidlestack and internal header files.
This improves readability and ensures consistent use of the common
stack alignment macros defined in include/nuttx/irq.h.
Signed-off-by: hujun5 <[email protected]>
---
arch/arm/src/common/arm_internal.h | 2 +-
arch/arm/src/common/arm_usestack.c | 2 +-
arch/arm64/src/common/arm64_internal.h | 2 +-
arch/arm64/src/common/arm64_usestack.c | 2 +-
arch/avr/src/avr/avr_usestack.c | 2 +-
arch/avr/src/avr32/avr_usestack.c | 2 +-
arch/ceva/src/common/ceva_usestack.c | 2 +-
arch/hc/src/common/hc_usestack.c | 2 +-
arch/mips/src/common/mips_usestack.c | 2 +-
arch/misoc/src/lm32/lm32_usestack.c | 2 +-
arch/misoc/src/minerva/minerva_usestack.c | 2 +-
arch/or1k/src/common/or1k_usestack.c | 2 +-
arch/renesas/src/common/renesas_usestack.c | 2 +-
arch/risc-v/src/common/riscv_usestack.c | 2 +-
arch/sim/src/sim/sim_usestack.c | 2 +-
arch/sparc/src/common/sparc_internal.h | 2 +-
arch/sparc/src/common/sparc_usestack.c | 2 +-
arch/tricore/src/common/tricore_internal.h | 2 +-
arch/tricore/src/common/tricore_usestack.c | 2 +-
arch/x86/src/i486/i486_usestack.c | 2 +-
arch/x86_64/src/intel64/intel64_usestack.c | 2 +-
arch/xtensa/src/common/xtensa_usestack.c | 2 +-
arch/z16/src/common/z16_usestack.c | 2 +-
arch/z80/src/common/z80_usestack.c | 2 +-
24 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/arch/arm/src/common/arm_internal.h
b/arch/arm/src/common/arm_internal.h
index f00b5d17acd..bf7eb0efd9e 100644
--- a/arch/arm/src/common/arm_internal.h
+++ b/arch/arm/src/common/arm_internal.h
@@ -89,7 +89,7 @@
# define CONFIG_ARCH_INTERRUPTSTACK 0
#endif
-#define INTSTACK_SIZE (CONFIG_ARCH_INTERRUPTSTACK & ~STACKFRAME_ALIGN_MASK)
+#define INTSTACK_SIZE STACKFRAME_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK)
/* Toolchain dependent, linker defined section addresses */
diff --git a/arch/arm/src/common/arm_usestack.c
b/arch/arm/src/common/arm_usestack.c
index c78518a6dcb..652e69f50d7 100644
--- a/arch/arm/src/common/arm_usestack.c
+++ b/arch/arm/src/common/arm_usestack.c
@@ -90,7 +90,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t
stack_size)
/* Make certain that the user provided stack is properly aligned */
- DEBUGASSERT(((uintptr_t)stack & STACK_ALIGN_MASK) == 0);
+ DEBUGASSERT(STACK_IS_ALIGNED(stack));
/* Is there already a stack allocated? */
diff --git a/arch/arm64/src/common/arm64_internal.h
b/arch/arm64/src/common/arm64_internal.h
index 628ca632042..dd19f528882 100644
--- a/arch/arm64/src/common/arm64_internal.h
+++ b/arch/arm64/src/common/arm64_internal.h
@@ -149,7 +149,7 @@ extern "C"
#define STACK_PTR_TO_FRAME(type, ptr) \
(type *)STACKFRAME_ALIGN_DOWN((uintptr_t)(ptr) - sizeof(type))
-#define INTSTACK_SIZE (CONFIG_ARCH_INTERRUPTSTACK &
~STACKFRAME_ALIGN_MASK)
+#define INTSTACK_SIZE STACKFRAME_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK)
#ifdef CONFIG_SMP
diff --git a/arch/arm64/src/common/arm64_usestack.c
b/arch/arm64/src/common/arm64_usestack.c
index 5bd2099cdf2..a061fd2e4b4 100644
--- a/arch/arm64/src/common/arm64_usestack.c
+++ b/arch/arm64/src/common/arm64_usestack.c
@@ -102,7 +102,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t
stack_size)
/* Make certain that the user provided stack is properly aligned */
- DEBUGASSERT(((uintptr_t)stack & STACK_ALIGN_MASK) == 0);
+ DEBUGASSERT(STACK_IS_ALIGNED(stack));
/* Is there already a stack allocated? */
diff --git a/arch/avr/src/avr/avr_usestack.c b/arch/avr/src/avr/avr_usestack.c
index d7d90eafdc5..3fa60acb145 100644
--- a/arch/avr/src/avr/avr_usestack.c
+++ b/arch/avr/src/avr/avr_usestack.c
@@ -87,7 +87,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t
stack_size)
/* Make certain that the user provided stack is properly aligned */
- DEBUGASSERT(((uintptr_t)stack & STACK_ALIGN_MASK) == 0);
+ DEBUGASSERT(STACK_IS_ALIGNED(stack));
/* Is there already a stack allocated? */
diff --git a/arch/avr/src/avr32/avr_usestack.c
b/arch/avr/src/avr32/avr_usestack.c
index 4c075687521..4c96332f553 100644
--- a/arch/avr/src/avr32/avr_usestack.c
+++ b/arch/avr/src/avr32/avr_usestack.c
@@ -89,7 +89,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t
stack_size)
/* Make certain that the user provided stack is properly aligned */
- DEBUGASSERT(((uintptr_t)stack & STACK_ALIGN_MASK) == 0);
+ DEBUGASSERT(STACK_IS_ALIGNED(stack));
/* Is there already a stack allocated? */
diff --git a/arch/ceva/src/common/ceva_usestack.c
b/arch/ceva/src/common/ceva_usestack.c
index e9b19a8bc20..a265765964f 100644
--- a/arch/ceva/src/common/ceva_usestack.c
+++ b/arch/ceva/src/common/ceva_usestack.c
@@ -85,7 +85,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t
stack_size)
/* Make certain that the user provided stack is properly aligned */
- DEBUGASSERT(((uintptr_t)stack & STACK_ALIGN_MASK) == 0);
+ DEBUGASSERT(STACK_IS_ALIGNED(stack));
/* Is there already a stack allocated? */
diff --git a/arch/hc/src/common/hc_usestack.c b/arch/hc/src/common/hc_usestack.c
index bccbdcc9428..c66b0687c13 100644
--- a/arch/hc/src/common/hc_usestack.c
+++ b/arch/hc/src/common/hc_usestack.c
@@ -89,7 +89,7 @@ int up_use_stack(FAR struct tcb_s *tcb, FAR void *stack,
size_t stack_size)
/* Make certain that the user provided stack is properly aligned */
- DEBUGASSERT(((uintptr_t)stack & STACK_ALIGN_MASK) == 0);
+ DEBUGASSERT(STACK_IS_ALIGNED(stack));
/* Is there already a stack allocated? */
diff --git a/arch/mips/src/common/mips_usestack.c
b/arch/mips/src/common/mips_usestack.c
index 57feab4c3a8..d4a11217342 100644
--- a/arch/mips/src/common/mips_usestack.c
+++ b/arch/mips/src/common/mips_usestack.c
@@ -89,7 +89,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t
stack_size)
/* Make certain that the user provided stack is properly aligned */
- DEBUGASSERT(((uintptr_t)stack & STACK_ALIGN_MASK) == 0);
+ DEBUGASSERT(STACK_IS_ALIGNED(stack));
/* Is there already a stack allocated? */
diff --git a/arch/misoc/src/lm32/lm32_usestack.c
b/arch/misoc/src/lm32/lm32_usestack.c
index 24768595538..72c0726b374 100644
--- a/arch/misoc/src/lm32/lm32_usestack.c
+++ b/arch/misoc/src/lm32/lm32_usestack.c
@@ -89,7 +89,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t
stack_size)
/* Make certain that the user provided stack is properly aligned */
- DEBUGASSERT(((uintptr_t)stack & STACK_ALIGN_MASK) == 0);
+ DEBUGASSERT(STACK_IS_ALIGNED(stack));
/* Is there already a stack allocated? */
diff --git a/arch/misoc/src/minerva/minerva_usestack.c
b/arch/misoc/src/minerva/minerva_usestack.c
index 5acd8082749..8dd5a26e607 100644
--- a/arch/misoc/src/minerva/minerva_usestack.c
+++ b/arch/misoc/src/minerva/minerva_usestack.c
@@ -89,7 +89,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t
stack_size)
/* Make certain that the user provided stack is properly aligned */
- DEBUGASSERT(((uintptr_t)stack & STACK_ALIGN_MASK) == 0);
+ DEBUGASSERT(STACK_IS_ALIGNED(stack));
/* Is there already a stack allocated? */
diff --git a/arch/or1k/src/common/or1k_usestack.c
b/arch/or1k/src/common/or1k_usestack.c
index 33268599814..744c9067ed5 100644
--- a/arch/or1k/src/common/or1k_usestack.c
+++ b/arch/or1k/src/common/or1k_usestack.c
@@ -89,7 +89,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t
stack_size)
/* Make certain that the user provided stack is properly aligned */
- DEBUGASSERT(((uintptr_t)stack & STACK_ALIGN_MASK) == 0);
+ DEBUGASSERT(STACK_IS_ALIGNED(stack));
/* Is there already a stack allocated? */
diff --git a/arch/renesas/src/common/renesas_usestack.c
b/arch/renesas/src/common/renesas_usestack.c
index 0565b616545..de3c49eb730 100644
--- a/arch/renesas/src/common/renesas_usestack.c
+++ b/arch/renesas/src/common/renesas_usestack.c
@@ -89,7 +89,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t
stack_size)
/* Make certain that the user provided stack is properly aligned */
- DEBUGASSERT(((uintptr_t)stack & STACK_ALIGN_MASK) == 0);
+ DEBUGASSERT(STACK_IS_ALIGNED(stack));
/* Is there already a stack allocated? */
diff --git a/arch/risc-v/src/common/riscv_usestack.c
b/arch/risc-v/src/common/riscv_usestack.c
index a2a925d0f77..95e2606175e 100644
--- a/arch/risc-v/src/common/riscv_usestack.c
+++ b/arch/risc-v/src/common/riscv_usestack.c
@@ -89,7 +89,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t
stack_size)
/* Make certain that the user provided stack is properly aligned */
- DEBUGASSERT(((uintptr_t)stack & STACK_ALIGN_MASK) == 0);
+ DEBUGASSERT(STACK_IS_ALIGNED(stack));
/* Is there already a stack allocated? */
diff --git a/arch/sim/src/sim/sim_usestack.c b/arch/sim/src/sim/sim_usestack.c
index 2dd72f5955c..39a6fd7dd35 100644
--- a/arch/sim/src/sim/sim_usestack.c
+++ b/arch/sim/src/sim/sim_usestack.c
@@ -88,7 +88,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t
stack_size)
/* Make certain that the user provided stack is properly aligned */
- DEBUGASSERT(((uintptr_t)stack & STACK_ALIGN_MASK) == 0);
+ DEBUGASSERT(STACK_IS_ALIGNED(stack));
/* Is there already a stack allocated? */
diff --git a/arch/sparc/src/common/sparc_internal.h
b/arch/sparc/src/common/sparc_internal.h
index 173a3862772..cb602219db1 100644
--- a/arch/sparc/src/common/sparc_internal.h
+++ b/arch/sparc/src/common/sparc_internal.h
@@ -82,7 +82,7 @@
# define CONFIG_ARCH_INTERRUPTSTACK 0
#endif
-#define INTSTACK_SIZE (CONFIG_ARCH_INTERRUPTSTACK & ~STACKFRAME_ALIGN_MASK)
+#define INTSTACK_SIZE STACKFRAME_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK)
/* This is the value used to mark the stack for subsequent stack monitoring
* logic.
diff --git a/arch/sparc/src/common/sparc_usestack.c
b/arch/sparc/src/common/sparc_usestack.c
index 7052b1b5a90..c74f142fb20 100644
--- a/arch/sparc/src/common/sparc_usestack.c
+++ b/arch/sparc/src/common/sparc_usestack.c
@@ -87,7 +87,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t
stack_size)
/* Make certain that the user provided stack is properly aligned */
- DEBUGASSERT(((uintptr_t)stack & STACK_ALIGN_MASK) == 0);
+ DEBUGASSERT(STACK_IS_ALIGNED(stack));
/* Is there already a stack allocated? */
diff --git a/arch/tricore/src/common/tricore_internal.h
b/arch/tricore/src/common/tricore_internal.h
index edbabc056eb..7296f109461 100644
--- a/arch/tricore/src/common/tricore_internal.h
+++ b/arch/tricore/src/common/tricore_internal.h
@@ -89,7 +89,7 @@
# define CONFIG_ARCH_INTERRUPTSTACK 0
#endif
-#define INTSTACK_SIZE (CONFIG_ARCH_INTERRUPTSTACK & ~STACKFRAME_ALIGN_MASK)
+#define INTSTACK_SIZE STACKFRAME_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK)
/* This is the value used to mark the stack for subsequent stack monitoring
* logic.
diff --git a/arch/tricore/src/common/tricore_usestack.c
b/arch/tricore/src/common/tricore_usestack.c
index a8f3706a552..1241fb5ff59 100644
--- a/arch/tricore/src/common/tricore_usestack.c
+++ b/arch/tricore/src/common/tricore_usestack.c
@@ -89,7 +89,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t
stack_size)
/* Make certain that the user provided stack is properly aligned */
- DEBUGASSERT(((uintptr_t)stack & STACK_ALIGN_MASK) == 0);
+ DEBUGASSERT(STACK_IS_ALIGNED(stack));
/* Is there already a stack allocated? */
diff --git a/arch/x86/src/i486/i486_usestack.c
b/arch/x86/src/i486/i486_usestack.c
index f3addd57fbe..5c06f472371 100644
--- a/arch/x86/src/i486/i486_usestack.c
+++ b/arch/x86/src/i486/i486_usestack.c
@@ -89,7 +89,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t
stack_size)
/* Make certain that the user provided stack is properly aligned */
- DEBUGASSERT(((uintptr_t)stack & STACK_ALIGN_MASK) == 0);
+ DEBUGASSERT(STACK_IS_ALIGNED(stack));
/* Is there already a stack allocated? */
diff --git a/arch/x86_64/src/intel64/intel64_usestack.c
b/arch/x86_64/src/intel64/intel64_usestack.c
index 81dc5752037..8fe5457826c 100644
--- a/arch/x86_64/src/intel64/intel64_usestack.c
+++ b/arch/x86_64/src/intel64/intel64_usestack.c
@@ -89,7 +89,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t
stack_size)
/* Make certain that the user provided stack is properly aligned */
- DEBUGASSERT(((uintptr_t)stack & STACK_ALIGN_MASK) == 0);
+ DEBUGASSERT(STACK_IS_ALIGNED(stack));
/* Is there already a stack allocated? */
diff --git a/arch/xtensa/src/common/xtensa_usestack.c
b/arch/xtensa/src/common/xtensa_usestack.c
index 0cdd762f71f..2e2e8786edf 100644
--- a/arch/xtensa/src/common/xtensa_usestack.c
+++ b/arch/xtensa/src/common/xtensa_usestack.c
@@ -89,7 +89,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t
stack_size)
/* Make certain that the user provided stack is properly aligned */
- DEBUGASSERT(((uintptr_t)stack & STACK_ALIGN_MASK) == 0);
+ DEBUGASSERT(STACK_IS_ALIGNED(stack));
/* Is there already a stack allocated? */
diff --git a/arch/z16/src/common/z16_usestack.c
b/arch/z16/src/common/z16_usestack.c
index 9027b4fbe8d..534c0839db7 100644
--- a/arch/z16/src/common/z16_usestack.c
+++ b/arch/z16/src/common/z16_usestack.c
@@ -89,7 +89,7 @@ int up_use_stack(FAR struct tcb_s *tcb, FAR void *stack,
size_t stack_size)
/* Make certain that the user provided stack is properly aligned */
- DEBUGASSERT(((uintptr_t)stack & STACK_ALIGN_MASK) == 0);
+ DEBUGASSERT(STACK_IS_ALIGNED(stack));
/* Is there already a stack allocated? */
diff --git a/arch/z80/src/common/z80_usestack.c
b/arch/z80/src/common/z80_usestack.c
index 2966d4b5ff1..11968fe37b2 100644
--- a/arch/z80/src/common/z80_usestack.c
+++ b/arch/z80/src/common/z80_usestack.c
@@ -89,7 +89,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t
stack_size)
/* Make certain that the user provided stack is properly aligned */
- DEBUGASSERT(((uintptr_t)stack & STACK_ALIGN_MASK) == 0);
+ DEBUGASSERT(STACK_IS_ALIGNED(stack));
/* Is there already a stack allocated? */