This is an automated email from the ASF dual-hosted git repository.
casaroli 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 1aae3a56a3b irq: shrink IRQ mapping table element types to save memory
1aae3a56a3b is described below
commit 1aae3a56a3bf8b155b4b4f2f38853dc9701aef7c
Author: zhangyuan29 <[email protected]>
AuthorDate: Wed Aug 12 23:15:56 2026 +0800
irq: shrink IRQ mapping table element types to save memory
g_irqrevmap stores IRQ numbers but was declared as int[], wasting memory
since the table is replicated per-CPU under BMP. Change its element type
to irq_t, sized to hold the largest IRQ number, shrinking each entry with
no truncation risk.
Signed-off-by: zhangyuan29 <[email protected]>
---
include/nuttx/irq.h | 2 +-
sched/irq/irq_attach.c | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/nuttx/irq.h b/include/nuttx/irq.h
index 582aca629ec..566d7d2b6b2 100644
--- a/include/nuttx/irq.h
+++ b/include/nuttx/irq.h
@@ -226,7 +226,7 @@ extern "C"
# if !defined(CONFIG_ARCH_IRQ_TO_NDX)
extern irq_mapped_t g_irqmap[];
# endif
-extern int g_irqrevmap[];
+extern irq_t g_irqrevmap[];
int irq_to_ndx(int irq);
#elif defined(CONFIG_ARCH_MINIMAL_VECTORTABLE)
extern const irq_mapped_t g_irqmap[];
diff --git a/sched/irq/irq_attach.c b/sched/irq/irq_attach.c
index 5dcebc62dcf..06f2ff37668 100644
--- a/sched/irq/irq_attach.c
+++ b/sched/irq/irq_attach.c
@@ -60,7 +60,7 @@ static int g_irqmap_count = 1;
# if !defined(CONFIG_ARCH_IRQ_TO_NDX)
irq_mapped_t g_irqmap[NR_IRQS];
# endif
-int g_irqrevmap[CONFIG_ARCH_NUSER_INTERRUPTS];
+irq_t g_irqrevmap[CONFIG_ARCH_NUSER_INTERRUPTS];
#endif
/****************************************************************************
@@ -74,9 +74,11 @@ int irq_to_ndx(int irq)
DEBUGASSERT(g_irqmap_count < CONFIG_ARCH_NUSER_INTERRUPTS);
irqstate_t flags = spin_lock_irqsave(&g_irqlock);
+
if (g_irqmap[irq] == 0)
{
int ndx = g_irqmap_count++;
+
g_irqmap[irq] = ndx;
g_irqrevmap[ndx] = irq;
}
@@ -116,6 +118,7 @@ int irq_attach(int irq, xcpt_t isr, FAR void *arg)
int ret = OK;
#if NR_IRQS > 0
int ndx = IRQ_TO_NDX(irq);
+
if (ndx < 0)
{
ret = ndx;
@@ -128,6 +131,7 @@ int irq_attach(int irq, xcpt_t isr, FAR void *arg)
*/
irqstate_t flags = spin_lock_irqsave(&g_irqlock);
+
if (isr == NULL)
{
/* Disable the interrupt if we can before detaching it. We might