This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 1ccd940e44b253f2002954fde5e630d19f2301a6 Author: Marco Casaroli <[email protected]> AuthorDate: Tue Aug 11 20:54:43 2026 +0200 arch/xtensa: Use one name for the stack frame alignment. Two files each defined the same 16 byte constant, KSTACK_ALIGNMENT and SIGTRAMP_STACK_ALIGN. Use STACKFRAME_ALIGN, which arch/xtensa/include/irq.h already gives as 16, with the STACKFRAME_ALIGN_DOWN() of nuttx/irq.h. STACK_ALIGNMENT is not the name to use here. It is TLS_STACK_ALIGN when CONFIG_TLS_ALIGNED is set, which is the alignment of a thread stack and not of a frame. Assisted-by: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Marco Casaroli <[email protected]> --- arch/xtensa/src/common/xtensa_addrenv_kstack.c | 15 +++------------ arch/xtensa/src/common/xtensa_swint.c | 3 +-- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/arch/xtensa/src/common/xtensa_addrenv_kstack.c b/arch/xtensa/src/common/xtensa_addrenv_kstack.c index 57bb7495880..eb98d340039 100644 --- a/arch/xtensa/src/common/xtensa_addrenv_kstack.c +++ b/arch/xtensa/src/common/xtensa_addrenv_kstack.c @@ -38,15 +38,6 @@ #if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_ARCH_KERNEL_STACK) -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* The Xtensa windowed ABI requires 16-byte stack alignment */ - -#define KSTACK_ALIGNMENT 16 -#define KSTACK_ALIGN_DOWN(a) ((a) & ~(KSTACK_ALIGNMENT - 1)) - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -78,7 +69,7 @@ int up_addrenv_kstackalloc(struct tcb_s *tcb) { DEBUGASSERT(tcb && tcb->xcp.kstack == NULL); - tcb->xcp.kstack = kmm_memalign(KSTACK_ALIGNMENT, ARCH_KERNEL_STACKSIZE); + tcb->xcp.kstack = kmm_memalign(STACKFRAME_ALIGN, ARCH_KERNEL_STACKSIZE); if (tcb->xcp.kstack == NULL) { berr("ERROR: Failed to allocate the kernel stack\n"); @@ -89,8 +80,8 @@ int up_addrenv_kstackalloc(struct tcb_s *tcb) * far end of the allocation. */ - tcb->xcp.ktopstk = (uint32_t *) - KSTACK_ALIGN_DOWN((uintptr_t)tcb->xcp.kstack + ARCH_KERNEL_STACKSIZE); + tcb->xcp.ktopstk = (uint32_t *)STACKFRAME_ALIGN_DOWN( + (uintptr_t)tcb->xcp.kstack + ARCH_KERNEL_STACKSIZE); return OK; } diff --git a/arch/xtensa/src/common/xtensa_swint.c b/arch/xtensa/src/common/xtensa_swint.c index 97bbc81ba36..5552262aed5 100644 --- a/arch/xtensa/src/common/xtensa_swint.c +++ b/arch/xtensa/src/common/xtensa_swint.c @@ -49,7 +49,6 @@ * 16 bytes below one as the base save area of the frame that owns it. */ -# define SIGTRAMP_STACK_ALIGN 16 # define SIGTRAMP_SAVE_AREA 16 #endif @@ -377,7 +376,7 @@ int xtensa_swint(int irq, void *context, void *arg) */ usp = (usp - SIGTRAMP_SAVE_AREA - sizeof(siginfo_t)) & - ~(SIGTRAMP_STACK_ALIGN - 1); + ~(STACKFRAME_ALIGN - 1); memcpy((void *)usp, (void *)regs[REG_A4], sizeof(siginfo_t));
