You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/07/27 12:48:39 UTC

[incubator-nuttx] branch master updated (5dcc905f27 -> 9d4549d48b)

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


    from 5dcc905f27 rptun: change lock to recursive lock
     new 79597d0caf arch/up_stack_check: using running_task to get correct task context
     new 5c8fd46126 arch/stack: rename do_stack_check with arch prefix
     new 91d8ed319e arch/riscv: optimize stackdump
     new 0ca02a5564 arch/xtensa: optimize stackdump
     new 136b1d6d42 arch: using remain to ignore invalid stack content when sp is not within stack
     new 9d4549d48b arch: limit output maximum size stackdump when sp is not within stack

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 arch/Kconfig                               |   5 +
 arch/arm/src/common/arm_assert.c           |  18 +++-
 arch/arm/src/common/arm_checkstack.c       |  26 ++---
 arch/arm/src/common/arm_internal.h         |   1 +
 arch/arm64/src/common/arm64_checkstack.c   |  28 +++---
 arch/arm64/src/common/arm64_internal.h     |   1 +
 arch/avr/src/avr/up_checkstack.c           |  21 ++--
 arch/avr/src/common/up_internal.h          |   4 +
 arch/ceva/src/common/up_checkstack.c       |  24 +++--
 arch/ceva/src/common/up_internal.h         |   1 +
 arch/or1k/src/common/up_checkstack.c       |  25 +++--
 arch/or1k/src/common/up_internal.h         |   1 +
 arch/risc-v/src/common/riscv_assert.c      | 153 ++++++++++++-----------------
 arch/risc-v/src/common/riscv_checkstack.c  |  23 +++--
 arch/risc-v/src/common/riscv_internal.h    |   1 +
 arch/sim/src/sim/up_checkstack.c           |  23 +++--
 arch/sim/src/sim/up_internal.h             |   1 +
 arch/sparc/src/common/up_checkstack.c      |  22 ++---
 arch/sparc/src/common/up_internal.h        |   1 +
 arch/xtensa/src/common/xtensa.h            |   1 +
 arch/xtensa/src/common/xtensa_checkstack.c |  23 +++--
 arch/xtensa/src/common/xtensa_dumpstate.c  | 139 ++++++++++++--------------
 22 files changed, 258 insertions(+), 284 deletions(-)


[incubator-nuttx] 04/06: arch/xtensa: optimize stackdump

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 0ca02a5564b426a8d435265615dec8c726d1bcff
Author: Jiuzhu Dong <do...@xiaomi.com>
AuthorDate: Wed Jul 27 02:14:48 2022 +0000

    arch/xtensa: optimize stackdump
    
    Signed-off-by: Jiuzhu Dong <do...@xiaomi.com>
---
 arch/xtensa/src/common/xtensa_dumpstate.c | 125 +++++++++++-------------------
 1 file changed, 47 insertions(+), 78 deletions(-)

diff --git a/arch/xtensa/src/common/xtensa_dumpstate.c b/arch/xtensa/src/common/xtensa_dumpstate.c
index f99a745770..faeb0bcd8b 100644
--- a/arch/xtensa/src/common/xtensa_dumpstate.c
+++ b/arch/xtensa/src/common/xtensa_dumpstate.c
@@ -273,6 +273,39 @@ static inline void xtensa_registerdump(uintptr_t *regs)
 #endif
 }
 
+/****************************************************************************
+ * Name: xtensa_dump_stack
+ ****************************************************************************/
+
+static void xtensa_dump_stack(const char *tag, uint32_t sp,
+                              uint32_t base, uint32_t size, bool force)
+{
+  uint32_t top = base + size;
+
+  _alert("%s Stack:\n", tag);
+  _alert("sp:     %08" PRIx32 "\n", sp);
+  _alert("  base: %08" PRIx32 "\n", base);
+  _alert("  size: %08" PRIx32 "\n", size);
+#ifdef CONFIG_STACK_COLORATION
+  _alert("  used: %08" PRIx32 "\n", xtensa_stack_check((uintptr_t)base,
+                                                       size));
+#endif
+
+  if (sp >= base && sp < top)
+    {
+      xtensa_stackdump(sp, top);
+    }
+  else
+    {
+      _alert("ERROR: %s Stack pointer is not within the stack\n", tag);
+
+      if (force)
+        {
+          xtensa_stackdump(base, top);
+        }
+    }
+}
+
 /****************************************************************************
  * Name: xtensa_dumpstate
  ****************************************************************************/
@@ -281,12 +314,6 @@ void xtensa_dumpstate(void)
 {
   struct tcb_s *rtcb = running_task();
   uint32_t sp = up_getsp();
-  uint32_t ustackbase;
-  uint32_t ustacksize;
-#if CONFIG_ARCH_INTERRUPTSTACK > 15
-  uint32_t istackbase;
-  uint32_t istacksize;
-#endif
 
 #ifdef CONFIG_SMP
   /* Show the CPU number */
@@ -316,88 +343,30 @@ void xtensa_dumpstate(void)
   sched_dumpstack(rtcb->pid);
 #endif
 
-  /* Get the limits on the user stack memory */
-
-  ustackbase = (uint32_t)rtcb->stack_base_ptr;
-  ustacksize = (uint32_t)rtcb->adj_stack_size;
-
-  /* Get the limits on the interrupt stack memory */
+  /* Dump the irq stack */
 
 #if CONFIG_ARCH_INTERRUPTSTACK > 15
-#ifdef CONFIG_SMP
-  istackbase = (uint32_t)xtensa_intstack_alloc();
-#else
-  istackbase = (uint32_t)&g_intstackalloc;
-#endif
-  istacksize = INTSTACK_SIZE;
-
-  /* Show interrupt stack info */
-
-  _alert("sp:     %08x\n", sp);
-  _alert("IRQ stack:\n");
-  _alert("  base: %08x\n", istackbase);
-  _alert("  size: %08x\n", istacksize);
-#ifdef CONFIG_STACK_COLORATION
-  _alert("  used: %08x\n", up_check_intstack());
-#endif
-
-  /* Does the current stack pointer lie within the interrupt
-   * stack?
-   */
-
-  if (sp >= istackbase && sp < istackbase + istacksize)
-    {
-      /* Yes.. dump the interrupt stack */
-
-      xtensa_stackdump(sp, istackbase + istacksize);
-    }
-  else if (CURRENT_REGS)
-    {
-      _alert("ERROR: Stack pointer is not within the interrupt stack\n");
-      xtensa_stackdump(istackbase, istackbase + istacksize);
-    }
-
-  /* Extract the user stack pointer if we are in an interrupt handler.
-   * If we are not in an interrupt handler.  Then sp is the user stack
-   * pointer (and the above range check should have failed).
-   */
+  xtensa_dump_stack("IRQ", sp,
+#  ifdef CONFIG_SMP
+                    (uint32_t)xtensa_intstack_alloc(),
+#  else
+                    (uint32_t)&g_intstackalloc,
+#  endif
+                    INTSTACK_SIZE,
+                    !!CURRENT_REGS);
 
   if (CURRENT_REGS)
     {
       sp = CURRENT_REGS[REG_A1];
-      _alert("sp:     %08x\n", sp);
     }
-
-  /* Show user stack info */
-
-  _alert("User stack:\n");
-  _alert("  base: %08x\n", ustackbase);
-  _alert("  size: %08x\n", ustacksize);
-#ifdef CONFIG_STACK_COLORATION
-  _alert("  used: %08x\n", up_check_tcbstack(rtcb));
-#endif
-#else
-  _alert("sp:         %08x\n", sp);
-  _alert("stack base: %08x\n", ustackbase);
-  _alert("stack size: %08x\n", ustacksize);
-#ifdef CONFIG_STACK_COLORATION
-  _alert("stack used: %08x\n", up_check_tcbstack(rtcb));
-#endif
 #endif
 
-  /* Dump the user stack if the stack pointer lies within the allocated user
-   * stack memory.
-   */
+  /* Dump the user stack */
 
-  if (sp >= ustackbase && sp < ustackbase + ustacksize)
-    {
-      xtensa_stackdump(sp, ustackbase + ustacksize);
-    }
-  else
-    {
-      _alert("ERROR: Stack pointer is not within allocated stack\n");
-      xtensa_stackdump(ustackbase, ustackbase + ustacksize);
-    }
+  xtensa_dump_stack("User", sp,
+                    (uint32_t)rtcb->stack_base_ptr,
+                    (uint32_t)rtcb->adj_stack_size,
+                    true);
 
   /* Dump the state of all tasks (if available) */
 


[incubator-nuttx] 06/06: arch: limit output maximum size stackdump when sp is not within stack

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 9d4549d48bfcfb17d635bad95a5808e47abb0e67
Author: Jiuzhu Dong <do...@xiaomi.com>
AuthorDate: Mon Jul 25 07:03:07 2022 +0000

    arch: limit output maximum size stackdump when sp is not within stack
    
    Signed-off-by: Jiuzhu Dong <do...@xiaomi.com>
---
 arch/Kconfig                              | 5 +++++
 arch/arm/src/common/arm_assert.c          | 7 +++++++
 arch/risc-v/src/common/riscv_assert.c     | 7 +++++++
 arch/xtensa/src/common/xtensa_dumpstate.c | 7 +++++++
 4 files changed, 26 insertions(+)

diff --git a/arch/Kconfig b/arch/Kconfig
index e4461c0323..52a3ccffff 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -837,6 +837,11 @@ config ARCH_STACKDUMP
 	---help---
 		Enable to do stack dumps after assertions
 
+config ARCH_STACKDUMP_MAX_LENGTH
+	int "The maximum length for dump stack on assertions"
+	depends on ARCH_STACKDUMP
+	default 0
+
 config DUMP_ON_EXIT
 	bool "Dump all tasks state on exit"
 	default n
diff --git a/arch/arm/src/common/arm_assert.c b/arch/arm/src/common/arm_assert.c
index 93bce4be33..6f5059fe1a 100644
--- a/arch/arm/src/common/arm_assert.c
+++ b/arch/arm/src/common/arm_assert.c
@@ -362,6 +362,13 @@ static void arm_dump_stack(const char *tag, uint32_t sp,
           size  -= remain;
 #endif
 
+#if CONFIG_ARCH_STACKDUMP_MAX_LENGTH > 0
+          if (size > CONFIG_ARCH_STACKDUMP_MAX_LENGTH)
+            {
+              size = CONFIG_ARCH_STACKDUMP_MAX_LENGTH;
+            }
+#endif
+
           arm_stackdump(base, base + size);
         }
     }
diff --git a/arch/risc-v/src/common/riscv_assert.c b/arch/risc-v/src/common/riscv_assert.c
index c04225447b..488bc88f33 100644
--- a/arch/risc-v/src/common/riscv_assert.c
+++ b/arch/risc-v/src/common/riscv_assert.c
@@ -339,6 +339,13 @@ static void riscv_dump_stack(const char *tag, uintptr_t sp,
           size  -= remain;
 #endif
 
+#if CONFIG_ARCH_STACKDUMP_MAX_LENGTH > 0
+          if (size > CONFIG_ARCH_STACKDUMP_MAX_LENGTH)
+            {
+              size = CONFIG_ARCH_STACKDUMP_MAX_LENGTH;
+            }
+#endif
+
           riscv_stackdump(base, base + size);
         }
     }
diff --git a/arch/xtensa/src/common/xtensa_dumpstate.c b/arch/xtensa/src/common/xtensa_dumpstate.c
index 140b5903e3..366f99a37d 100644
--- a/arch/xtensa/src/common/xtensa_dumpstate.c
+++ b/arch/xtensa/src/common/xtensa_dumpstate.c
@@ -308,6 +308,13 @@ static void xtensa_dump_stack(const char *tag, uint32_t sp,
           size = used;
 #endif
 
+#if CONFIG_ARCH_STACKDUMP_MAX_LENGTH > 0
+          if (size > CONFIG_ARCH_STACKDUMP_MAX_LENGTH)
+            {
+              size = CONFIG_ARCH_STACKDUMP_MAX_LENGTH;
+            }
+#endif
+
           xtensa_stackdump(base, base + size);
         }
     }


[incubator-nuttx] 05/06: arch: using remain to ignore invalid stack content when sp is not within stack

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 136b1d6d4286f2a6fc6c5a3060a1975c57855280
Author: Jiuzhu Dong <do...@xiaomi.com>
AuthorDate: Mon Jul 4 15:41:59 2022 +0800

    arch: using remain to ignore invalid stack content when sp is not within stack
    
    Signed-off-by: Jiuzhu Dong <do...@xiaomi.com>
---
 arch/arm/src/common/arm_assert.c          | 11 +++++++++--
 arch/risc-v/src/common/riscv_assert.c     | 10 +++++++++-
 arch/xtensa/src/common/xtensa_dumpstate.c | 13 ++++++++++---
 3 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/arch/arm/src/common/arm_assert.c b/arch/arm/src/common/arm_assert.c
index 7098c3eaf3..93bce4be33 100644
--- a/arch/arm/src/common/arm_assert.c
+++ b/arch/arm/src/common/arm_assert.c
@@ -352,10 +352,17 @@ static void arm_dump_stack(const char *tag, uint32_t sp,
   else
     {
       _alert("ERROR: %s Stack pointer is not within the stack\n", tag);
-
       if (force)
         {
-          arm_stackdump(base, top);
+#ifdef CONFIG_STACK_COLORATION
+          uint32_t remain;
+
+          remain = size - arm_stack_check((FAR void *)(uintptr_t)base, size);
+          base  += remain;
+          size  -= remain;
+#endif
+
+          arm_stackdump(base, base + size);
         }
     }
 }
diff --git a/arch/risc-v/src/common/riscv_assert.c b/arch/risc-v/src/common/riscv_assert.c
index 3d4d4c2d68..c04225447b 100644
--- a/arch/risc-v/src/common/riscv_assert.c
+++ b/arch/risc-v/src/common/riscv_assert.c
@@ -331,7 +331,15 @@ static void riscv_dump_stack(const char *tag, uintptr_t sp,
 
       if (force)
         {
-          riscv_stackdump(base, top);
+#ifdef CONFIG_STACK_COLORATION
+          uint32_t remain;
+
+          remain = size - riscv_stack_check((uintptr_t)base, size);
+          base  += remain;
+          size  -= remain;
+#endif
+
+          riscv_stackdump(base, base + size);
         }
     }
 }
diff --git a/arch/xtensa/src/common/xtensa_dumpstate.c b/arch/xtensa/src/common/xtensa_dumpstate.c
index faeb0bcd8b..140b5903e3 100644
--- a/arch/xtensa/src/common/xtensa_dumpstate.c
+++ b/arch/xtensa/src/common/xtensa_dumpstate.c
@@ -281,14 +281,16 @@ static void xtensa_dump_stack(const char *tag, uint32_t sp,
                               uint32_t base, uint32_t size, bool force)
 {
   uint32_t top = base + size;
+#ifdef CONFIG_STACK_COLORATION
+  uint32_t used = xtensa_stack_check((uintptr_t)base, size);
+#endif
 
   _alert("%s Stack:\n", tag);
   _alert("sp:     %08" PRIx32 "\n", sp);
   _alert("  base: %08" PRIx32 "\n", base);
   _alert("  size: %08" PRIx32 "\n", size);
 #ifdef CONFIG_STACK_COLORATION
-  _alert("  used: %08" PRIx32 "\n", xtensa_stack_check((uintptr_t)base,
-                                                       size));
+  _alert("  used: %08" PRIx32 "\n", used);
 #endif
 
   if (sp >= base && sp < top)
@@ -301,7 +303,12 @@ static void xtensa_dump_stack(const char *tag, uint32_t sp,
 
       if (force)
         {
-          xtensa_stackdump(base, top);
+#ifdef CONFIG_STACK_COLORATION
+          base += size - used;
+          size = used;
+#endif
+
+          xtensa_stackdump(base, base + size);
         }
     }
 }


[incubator-nuttx] 03/06: arch/riscv: optimize stackdump

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 91d8ed319e75fbbf5379be68a1b1093203c90bd6
Author: Jiuzhu Dong <do...@xiaomi.com>
AuthorDate: Tue Jul 26 04:20:54 2022 +0000

    arch/riscv: optimize stackdump
    
    Signed-off-by: Jiuzhu Dong <do...@xiaomi.com>
---
 arch/risc-v/src/common/riscv_assert.c | 138 ++++++++++++----------------------
 1 file changed, 46 insertions(+), 92 deletions(-)

diff --git a/arch/risc-v/src/common/riscv_assert.c b/arch/risc-v/src/common/riscv_assert.c
index 1cd757cd59..3d4d4c2d68 100644
--- a/arch/risc-v/src/common/riscv_assert.c
+++ b/arch/risc-v/src/common/riscv_assert.c
@@ -307,6 +307,35 @@ static inline void riscv_showtasks(void)
 #endif
 }
 
+/****************************************************************************
+ * Name: riscv_dump_stack
+ ****************************************************************************/
+
+static void riscv_dump_stack(const char *tag, uintptr_t sp,
+                             uintptr_t base, uint32_t size, bool force)
+{
+  uintptr_t top = base + size;
+
+  _alert("%s Stack:\n", tag);
+  _alert("sp:     %08" PRIxPTR "\n", sp);
+  _alert("  base: %08" PRIxPTR "\n", base);
+  _alert("  size: %08" PRIx32 "\n", size);
+
+  if (sp >= base && sp < top)
+    {
+      riscv_stackdump(sp, top);
+    }
+  else
+    {
+      _alert("ERROR: %s Stack pointer is not within the stack\n", tag);
+
+      if (force)
+        {
+          riscv_stackdump(base, top);
+        }
+    }
+}
+
 /****************************************************************************
  * Name: riscv_dumpstate
  ****************************************************************************/
@@ -315,15 +344,6 @@ static void riscv_dumpstate(void)
 {
   struct tcb_s *rtcb = running_task();
   uintptr_t sp = up_getsp();
-  uintptr_t ustackbase;
-  uintptr_t ustacksize;
-#if CONFIG_ARCH_INTERRUPTSTACK > 15
-  uintptr_t istackbase;
-  uintptr_t istacksize;
-#endif
-#ifdef CONFIG_ARCH_KERNEL_STACK
-  uintptr_t kstackbase = 0;
-#endif
 
   /* Show back trace */
 
@@ -346,101 +366,35 @@ static void riscv_dumpstate(void)
 
   riscv_registerdump(rtcb->xcp.regs);
 
-  /* Get the limits on the user stack memory */
-
-  ustackbase = (uintptr_t)rtcb->stack_base_ptr;
-  ustacksize = (uintptr_t)rtcb->adj_stack_size;
-
   /* Get the limits on the interrupt stack memory */
 
 #if CONFIG_ARCH_INTERRUPTSTACK > 15
-  istackbase = (uintptr_t)&g_intstackalloc;
-  istacksize = (CONFIG_ARCH_INTERRUPTSTACK & ~15);
-
-  /* Show interrupt stack info */
-
-  _alert("sp:     %" PRIxREG "\n", sp);
-  _alert("IRQ stack:\n");
-  _alert("  base: %" PRIxREG "\n", istackbase);
-  _alert("  size: %" PRIxREG "\n", istacksize);
-
-  /* Does the current stack pointer lie within the interrupt
-   * stack?
-   */
-
-  if (sp >= istackbase && sp < istackbase + istacksize)
-    {
-      /* Yes.. dump the interrupt stack */
-
-      riscv_stackdump(sp, istackbase + istacksize);
-
-      /* Extract the user stack pointer */
-
-      if (CURRENT_REGS)
-        {
-          sp = CURRENT_REGS[REG_SP];
-        }
-
-      _alert("sp:     %" PRIxREG "\n", sp);
-    }
-  else if (CURRENT_REGS)
+  riscv_dump_stack("IRQ", sp,
+                   (uintptr_t)&g_intstackalloc,
+                   (CONFIG_ARCH_INTERRUPTSTACK & ~15),
+                   !!CURRENT_REGS);
+  if (CURRENT_REGS)
     {
-      _alert("ERROR: Stack pointer is not within the interrupt stack\n");
-      riscv_stackdump(istackbase, istackbase + istacksize);
+      sp = CURRENT_REGS[REG_SP];
     }
-
-  /* Show user stack info */
-
-  _alert("User stack:\n");
-  _alert("  base: %" PRIxREG "\n", ustackbase);
-  _alert("  size: %" PRIxREG "\n", ustacksize);
-#else
-  _alert("sp:         %" PRIxREG "\n", sp);
-  _alert("stack base: %" PRIxREG "\n", ustackbase);
-  _alert("stack size: %" PRIxREG "\n", ustacksize);
 #endif
 
+  riscv_dump_stack("User", sp,
+                   (uintptr_t)rtcb->stack_base_ptr,
+                   (uint32_t)rtcb->adj_stack_size,
 #ifdef CONFIG_ARCH_KERNEL_STACK
-  /* Does this thread have a kernel stack allocated? */
-
-  if (rtcb->xcp.kstack)
-    {
-      kstackbase = (uintptr_t)rtcb->xcp.kstack;
-
-      _alert("Kernel stack:\n");
-      _alert("  base: %" PRIxREG "\n", kstackbase);
-      _alert("  size: %" PRIxREG "\n", CONFIG_ARCH_KERNEL_STACKSIZE);
-    }
+                 false
+#else
+                 true
 #endif
-
-  /* Dump the user stack if the stack pointer lies within the allocated user
-   * stack memory.
-   */
-
-  if (sp >= ustackbase && sp < ustackbase + ustacksize)
-    {
-      _alert("User Stack\n");
-      riscv_stackdump(sp, ustackbase + ustacksize);
-    }
+                );
 
 #ifdef CONFIG_ARCH_KERNEL_STACK
-  /* Dump the kernel stack if the stack pointer lies within the allocated
-   * kernel stack memory.
-   */
-
-  else if (kstackbase != 0 &&
-           sp >= kstackbase &&
-           sp < kstackbase + CONFIG_ARCH_KERNEL_STACKSIZE)
-    {
-      _alert("Kernel Stack\n");
-      riscv_stackdump(sp, kstackbase + CONFIG_ARCH_KERNEL_STACKSIZE);
-    }
+  riscv_dump_stack("Kernel", sp,
+                   (uintptr_t)rtcb->xcp.kstack,
+                   CONFIG_ARCH_KERNEL_STACKSIZE,
+                   false);
 #endif
-  else
-    {
-      _alert("ERROR: Stack pointer is not within allocated stack\n");
-      riscv_stackdump(ustackbase, ustackbase + ustacksize);
-    }
 }
 #else
 #  define riscv_dumpstate()


[incubator-nuttx] 01/06: arch/up_stack_check: using running_task to get correct task context

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 79597d0cafcd6de841af826efa1832b754f81068
Author: Jiuzhu Dong <do...@xiaomi.com>
AuthorDate: Thu Jul 14 07:07:20 2022 +0000

    arch/up_stack_check: using running_task to get correct task context
    
    Signed-off-by: Jiuzhu Dong <do...@xiaomi.com>
---
 arch/arm/src/common/arm_checkstack.c       | 4 ++--
 arch/arm64/src/common/arm64_checkstack.c   | 4 ++--
 arch/avr/src/avr/up_checkstack.c           | 4 ++--
 arch/ceva/src/common/up_checkstack.c       | 4 ++--
 arch/or1k/src/common/up_checkstack.c       | 4 ++--
 arch/risc-v/src/common/riscv_checkstack.c  | 4 ++--
 arch/sim/src/sim/up_checkstack.c           | 4 ++--
 arch/sparc/src/common/up_checkstack.c      | 4 ++--
 arch/xtensa/src/common/xtensa_checkstack.c | 4 ++--
 9 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/arch/arm/src/common/arm_checkstack.c b/arch/arm/src/common/arm_checkstack.c
index a762ec6f79..5f69d62e91 100644
--- a/arch/arm/src/common/arm_checkstack.c
+++ b/arch/arm/src/common/arm_checkstack.c
@@ -209,12 +209,12 @@ ssize_t up_check_tcbstack_remain(struct tcb_s *tcb)
 
 size_t up_check_stack(void)
 {
-  return up_check_tcbstack(this_task());
+  return up_check_tcbstack(running_task());
 }
 
 ssize_t up_check_stack_remain(void)
 {
-  return up_check_tcbstack_remain(this_task());
+  return up_check_tcbstack_remain(running_task());
 }
 
 #if CONFIG_ARCH_INTERRUPTSTACK > 3
diff --git a/arch/arm64/src/common/arm64_checkstack.c b/arch/arm64/src/common/arm64_checkstack.c
index a319c5dafe..006568702a 100644
--- a/arch/arm64/src/common/arm64_checkstack.c
+++ b/arch/arm64/src/common/arm64_checkstack.c
@@ -210,12 +210,12 @@ ssize_t up_check_tcbstack_remain(struct tcb_s *tcb)
 
 size_t up_check_stack(void)
 {
-  return up_check_tcbstack(this_task());
+  return up_check_tcbstack(running_task());
 }
 
 ssize_t up_check_stack_remain(void)
 {
-  return up_check_tcbstack_remain(this_task());
+  return up_check_tcbstack_remain(running_task());
 }
 
 #if CONFIG_ARCH_INTERRUPTSTACK > 7
diff --git a/arch/avr/src/avr/up_checkstack.c b/arch/avr/src/avr/up_checkstack.c
index 5003c8a4d5..256b153e72 100644
--- a/arch/avr/src/avr/up_checkstack.c
+++ b/arch/avr/src/avr/up_checkstack.c
@@ -156,12 +156,12 @@ ssize_t up_check_tcbstack_remain(FAR struct tcb_s *tcb)
 
 size_t up_check_stack(void)
 {
-  return up_check_tcbstack(this_task());
+  return up_check_tcbstack(running_task());
 }
 
 ssize_t up_check_stack_remain(void)
 {
-  return up_check_tcbstack_remain(this_task());
+  return up_check_tcbstack_remain(running_task());
 }
 
 #if CONFIG_ARCH_INTERRUPTSTACK > 3
diff --git a/arch/ceva/src/common/up_checkstack.c b/arch/ceva/src/common/up_checkstack.c
index e58c20c917..8b70574ca6 100644
--- a/arch/ceva/src/common/up_checkstack.c
+++ b/arch/ceva/src/common/up_checkstack.c
@@ -152,12 +152,12 @@ ssize_t up_check_tcbstack_remain(struct tcb_s *tcb)
 
 size_t up_check_stack(void)
 {
-  return up_check_tcbstack(this_task());
+  return up_check_tcbstack(running_task());
 }
 
 ssize_t up_check_stack_remain(void)
 {
-  return up_check_tcbstack_remain(this_task());
+  return up_check_tcbstack_remain(running_task());
 }
 
 size_t up_check_intstack(void)
diff --git a/arch/or1k/src/common/up_checkstack.c b/arch/or1k/src/common/up_checkstack.c
index 7bd4ba14ee..8b06ee38a9 100644
--- a/arch/or1k/src/common/up_checkstack.c
+++ b/arch/or1k/src/common/up_checkstack.c
@@ -127,12 +127,12 @@ ssize_t up_check_tcbstack_remain(struct tcb_s *tcb)
 
 size_t up_check_stack(void)
 {
-  return up_check_tcbstack(this_task());
+  return up_check_tcbstack(running_task());
 }
 
 ssize_t up_check_stack_remain(void)
 {
-  return up_check_tcbstack_remain(this_task());
+  return up_check_tcbstack_remain(running_task());
 }
 
 #if CONFIG_ARCH_INTERRUPTSTACK > 3
diff --git a/arch/risc-v/src/common/riscv_checkstack.c b/arch/risc-v/src/common/riscv_checkstack.c
index 2f8e0a0580..b5d34440cd 100644
--- a/arch/risc-v/src/common/riscv_checkstack.c
+++ b/arch/risc-v/src/common/riscv_checkstack.c
@@ -167,12 +167,12 @@ ssize_t up_check_tcbstack_remain(struct tcb_s *tcb)
 
 size_t up_check_stack(void)
 {
-  return up_check_tcbstack(this_task());
+  return up_check_tcbstack(running_task());
 }
 
 ssize_t up_check_stack_remain(void)
 {
-  return up_check_tcbstack_remain(this_task());
+  return up_check_tcbstack_remain(running_task());
 }
 
 #if CONFIG_ARCH_INTERRUPTSTACK > 15
diff --git a/arch/sim/src/sim/up_checkstack.c b/arch/sim/src/sim/up_checkstack.c
index 407717f8fe..0e26086e0a 100644
--- a/arch/sim/src/sim/up_checkstack.c
+++ b/arch/sim/src/sim/up_checkstack.c
@@ -166,10 +166,10 @@ ssize_t up_check_tcbstack_remain(struct tcb_s *tcb)
 
 size_t up_check_stack(void)
 {
-  return up_check_tcbstack(this_task());
+  return up_check_tcbstack(running_task());
 }
 
 ssize_t up_check_stack_remain(void)
 {
-  return up_check_tcbstack_remain(this_task());
+  return up_check_tcbstack_remain(running_task());
 }
diff --git a/arch/sparc/src/common/up_checkstack.c b/arch/sparc/src/common/up_checkstack.c
index 03ba25d743..ee56466510 100644
--- a/arch/sparc/src/common/up_checkstack.c
+++ b/arch/sparc/src/common/up_checkstack.c
@@ -210,12 +210,12 @@ ssize_t up_check_tcbstack_remain(struct tcb_s *tcb)
 
 size_t up_check_stack(void)
 {
-  return up_check_tcbstack(this_task());
+  return up_check_tcbstack(running_task());
 }
 
 ssize_t up_check_stack_remain(void)
 {
-  return up_check_tcbstack_remain(this_task());
+  return up_check_tcbstack_remain(running_task());
 }
 
 #if CONFIG_ARCH_INTERRUPTSTACK > 3
diff --git a/arch/xtensa/src/common/xtensa_checkstack.c b/arch/xtensa/src/common/xtensa_checkstack.c
index 6fea6bc2e2..3a7e1881db 100644
--- a/arch/xtensa/src/common/xtensa_checkstack.c
+++ b/arch/xtensa/src/common/xtensa_checkstack.c
@@ -170,12 +170,12 @@ ssize_t up_check_tcbstack_remain(struct tcb_s *tcb)
 
 size_t up_check_stack(void)
 {
-  return up_check_tcbstack(this_task());
+  return up_check_tcbstack(running_task());
 }
 
 ssize_t up_check_stack_remain(void)
 {
-  return up_check_tcbstack_remain(this_task());
+  return up_check_tcbstack_remain(running_task());
 }
 
 #if CONFIG_ARCH_INTERRUPTSTACK > 15


[incubator-nuttx] 02/06: arch/stack: rename do_stack_check with arch prefix

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 5c8fd461261f6e4a792fff9320ea199bc262564e
Author: Jiuzhu Dong <do...@xiaomi.com>
AuthorDate: Mon Jul 25 08:32:38 2022 +0000

    arch/stack: rename do_stack_check with arch prefix
    
    Signed-off-by: Jiuzhu Dong <do...@xiaomi.com>
---
 arch/arm/src/common/arm_checkstack.c       | 22 +++++++++++-----------
 arch/arm/src/common/arm_internal.h         |  1 +
 arch/arm64/src/common/arm64_checkstack.c   | 24 +++++++++++-------------
 arch/arm64/src/common/arm64_internal.h     |  1 +
 arch/avr/src/avr/up_checkstack.c           | 17 ++++++++---------
 arch/avr/src/common/up_internal.h          |  4 ++++
 arch/ceva/src/common/up_checkstack.c       | 20 +++++++++-----------
 arch/ceva/src/common/up_internal.h         |  1 +
 arch/or1k/src/common/up_checkstack.c       | 21 ++++++++++-----------
 arch/or1k/src/common/up_internal.h         |  1 +
 arch/risc-v/src/common/riscv_checkstack.c  | 19 +++++++++----------
 arch/risc-v/src/common/riscv_internal.h    |  1 +
 arch/sim/src/sim/up_checkstack.c           | 19 +++++++++----------
 arch/sim/src/sim/up_internal.h             |  1 +
 arch/sparc/src/common/up_checkstack.c      | 18 +++++++++---------
 arch/sparc/src/common/up_internal.h        |  1 +
 arch/xtensa/src/common/xtensa.h            |  1 +
 arch/xtensa/src/common/xtensa_checkstack.c | 19 +++++++++----------
 18 files changed, 97 insertions(+), 94 deletions(-)

diff --git a/arch/arm/src/common/arm_checkstack.c b/arch/arm/src/common/arm_checkstack.c
index 5f69d62e91..1a54ae8853 100644
--- a/arch/arm/src/common/arm_checkstack.c
+++ b/arch/arm/src/common/arm_checkstack.c
@@ -43,7 +43,11 @@
  ****************************************************************************/
 
 /****************************************************************************
- * Name: do_stackcheck
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: arm_stack_check
  *
  * Description:
  *   Determine (approximately) how much stack has been used by searching the
@@ -59,7 +63,7 @@
  *
  ****************************************************************************/
 
-static size_t do_stackcheck(void *stackbase, size_t nbytes)
+size_t arm_stack_check(void *stackbase, size_t nbytes)
 {
   uintptr_t start;
   uintptr_t end;
@@ -134,10 +138,6 @@ static size_t do_stackcheck(void *stackbase, size_t nbytes)
   return mark << 2;
 }
 
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
 /****************************************************************************
  * Name: arm_stack_color
  *
@@ -199,7 +199,7 @@ void arm_stack_color(void *stackbase, size_t nbytes)
 
 size_t up_check_tcbstack(struct tcb_s *tcb)
 {
-  return do_stackcheck(tcb->stack_base_ptr, tcb->adj_stack_size);
+  return arm_stack_check(tcb->stack_base_ptr, tcb->adj_stack_size);
 }
 
 ssize_t up_check_tcbstack_remain(struct tcb_s *tcb)
@@ -221,11 +221,11 @@ ssize_t up_check_stack_remain(void)
 size_t up_check_intstack(void)
 {
 #ifdef CONFIG_SMP
-  return do_stackcheck((void *)arm_intstack_alloc(),
-                        STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK));
+  return arm_stack_check((void *)arm_intstack_alloc(),
+                         STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK));
 #else
-  return do_stackcheck((void *)&g_intstackalloc,
-                        STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK));
+  return arm_stack_check((void *)&g_intstackalloc,
+                         STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK));
 #endif
 }
 
diff --git a/arch/arm/src/common/arm_internal.h b/arch/arm/src/common/arm_internal.h
index fca29ff51a..02c0b53852 100644
--- a/arch/arm/src/common/arm_internal.h
+++ b/arch/arm/src/common/arm_internal.h
@@ -440,6 +440,7 @@ void arm_usbuninitialize(void);
 
 /* Debug ********************************************************************/
 #ifdef CONFIG_STACK_COLORATION
+size_t arm_stack_check(void *stackbase, size_t nbytes);
 void arm_stack_color(void *stackbase, size_t nbytes);
 #endif
 
diff --git a/arch/arm64/src/common/arm64_checkstack.c b/arch/arm64/src/common/arm64_checkstack.c
index 006568702a..6940b5644d 100644
--- a/arch/arm64/src/common/arm64_checkstack.c
+++ b/arch/arm64/src/common/arm64_checkstack.c
@@ -46,14 +46,16 @@
  * Private Function Prototypes
  ****************************************************************************/
 
-static size_t do_stackcheck(void *stackbase, size_t nbytes);
-
 /****************************************************************************
  * Private Functions
  ****************************************************************************/
 
 /****************************************************************************
- * Name: do_stackcheck
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: arm64_stack_check
  *
  * Description:
  *   Determine (approximately) how much stack has been used by searching the
@@ -69,7 +71,7 @@ static size_t do_stackcheck(void *stackbase, size_t nbytes);
  *
  ****************************************************************************/
 
-static size_t do_stackcheck(void *stackbase, size_t nbytes)
+size_t arm64_stack_check(void *stackbase, size_t nbytes)
 {
   uintptr_t start;
   uintptr_t end;
@@ -144,10 +146,6 @@ static size_t do_stackcheck(void *stackbase, size_t nbytes)
   return mark << 2;
 }
 
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
 /****************************************************************************
  * Name: arm64_stack_color
  *
@@ -200,7 +198,7 @@ void arm64_stack_color(void *stackbase, size_t nbytes)
 
 size_t up_check_tcbstack(struct tcb_s *tcb)
 {
-  return do_stackcheck(tcb->stack_base_ptr, tcb->adj_stack_size);
+  return arm64_stack_check(tcb->stack_base_ptr, tcb->adj_stack_size);
 }
 
 ssize_t up_check_tcbstack_remain(struct tcb_s *tcb)
@@ -222,11 +220,11 @@ ssize_t up_check_stack_remain(void)
 size_t up_check_intstack(void)
 {
 #ifdef CONFIG_SMP
-  return do_stackcheck((void *)arm64_intstack_alloc(),
-                        STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK));
+  return arm64_stack_check((void *)arm64_intstack_alloc(),
+                           STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK));
 #else
-  return do_stackcheck((void *)&g_interrupt_stack,
-                        STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK));
+  return arm64_stack_check((void *)&g_interrupt_stack,
+                           STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK));
 #endif
 }
 
diff --git a/arch/arm64/src/common/arm64_internal.h b/arch/arm64/src/common/arm64_internal.h
index d92523b821..ca8f6c653e 100644
--- a/arch/arm64/src/common/arm64_internal.h
+++ b/arch/arm64/src/common/arm64_internal.h
@@ -352,6 +352,7 @@ void arm64_usbuninitialize(void);
 /* Debug */
 
 #ifdef CONFIG_STACK_COLORATION
+size_t arm64_stack_check(void *stackbase, size_t nbytes);
 void arm64_stack_color(void *stackbase, size_t nbytes);
 #endif
 
diff --git a/arch/avr/src/avr/up_checkstack.c b/arch/avr/src/avr/up_checkstack.c
index 256b153e72..b54421773b 100644
--- a/arch/avr/src/avr/up_checkstack.c
+++ b/arch/avr/src/avr/up_checkstack.c
@@ -45,10 +45,12 @@
  * Private Functions
  ****************************************************************************/
 
-static size_t do_stackcheck(uintptr_t alloc, size_t size);
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
 
 /****************************************************************************
- * Name: do_stackcheck
+ * Name: avr_stack_check
  *
  * Description:
  *   Determine (approximately) how much stack has been used be searching the
@@ -64,7 +66,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size);
  *
  ****************************************************************************/
 
-static size_t do_stackcheck(uintptr_t alloc, size_t size)
+size_t avr_stack_check(uintptr_t alloc, size_t size)
 {
   FAR uint8_t *ptr;
   size_t mark;
@@ -124,10 +126,6 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size)
   return mark;
 }
 
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
 /****************************************************************************
  * Name: up_check_stack and friends
  *
@@ -146,7 +144,8 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size)
 
 size_t up_check_tcbstack(FAR struct tcb_s *tcb)
 {
-  return do_stackcheck((uintptr_t)tcb->stack_base_ptr, tcb->adj_stack_size);
+  return avr_stack_check((uintptr_t)tcb->stack_base_ptr,
+                         tcb->adj_stack_size);
 }
 
 ssize_t up_check_tcbstack_remain(FAR struct tcb_s *tcb)
@@ -168,7 +167,7 @@ ssize_t up_check_stack_remain(void)
 size_t up_check_intstack(void)
 {
   uintptr_t start = (uintptr_t)g_intstackalloc;
-  return do_stackcheck(start, CONFIG_ARCH_INTERRUPTSTACK & ~3);
+  return avr_stack_check(start, CONFIG_ARCH_INTERRUPTSTACK & ~3);
 }
 
 size_t up_check_intstack_remain(void)
diff --git a/arch/avr/src/common/up_internal.h b/arch/avr/src/common/up_internal.h
index 14dc78ec33..2d9e4cdc19 100644
--- a/arch/avr/src/common/up_internal.h
+++ b/arch/avr/src/common/up_internal.h
@@ -172,5 +172,9 @@ void up_usbuninitialize(void);
 # define up_usbuninitialize()
 #endif
 
+#ifdef CONFIG_STACK_COLORATION
+size_t avr_stack_check(uintptr_t alloc, size_t size);
+#endif
+
 #endif /* __ASSEMBLY__ */
 #endif /* __ARCH_AVR_SRC_COMMON_UP_INTERNAL_H */
diff --git a/arch/ceva/src/common/up_checkstack.c b/arch/ceva/src/common/up_checkstack.c
index 8b70574ca6..f7195913de 100644
--- a/arch/ceva/src/common/up_checkstack.c
+++ b/arch/ceva/src/common/up_checkstack.c
@@ -38,10 +38,12 @@
  * Private Function Prototypes
  ****************************************************************************/
 
-static size_t do_stackcheck(uintptr_t alloc, size_t size);
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
 
 /****************************************************************************
- * Name: do_stackcheck
+ * Name: ceva_stack_check
  *
  * Description:
  *   Determine (approximately) how much stack has been used be searching the
@@ -57,7 +59,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size);
  *
  ****************************************************************************/
 
-static size_t do_stackcheck(uintptr_t alloc, size_t size)
+size_t ceva_stack_check(uintptr_t alloc, size_t size)
 {
   uint32_t *ptr;
   size_t nwords;
@@ -119,10 +121,6 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size)
   return mark * sizeof(uint32_t);
 }
 
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
 /****************************************************************************
  * Name: up_check_stack and friends
  *
@@ -141,8 +139,8 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size)
 
 size_t up_check_tcbstack(struct tcb_s *tcb)
 {
-  return do_stackcheck((uintptr_t)tcb->stack_alloc_ptr,
-                       tcb->adj_stack_size);
+  return ceva_stack_check((uintptr_t)tcb->stack_alloc_ptr,
+                          tcb->adj_stack_size);
 }
 
 ssize_t up_check_tcbstack_remain(struct tcb_s *tcb)
@@ -162,8 +160,8 @@ ssize_t up_check_stack_remain(void)
 
 size_t up_check_intstack(void)
 {
-  return do_stackcheck((uintptr_t)&g_intstackalloc,
-                       &g_intstackbase - &g_intstackalloc);
+  return ceva_stack_check((uintptr_t)&g_intstackalloc,
+                          &g_intstackbase - &g_intstackalloc);
 }
 
 size_t up_check_intstack_remain(void)
diff --git a/arch/ceva/src/common/up_internal.h b/arch/ceva/src/common/up_internal.h
index 695f3b4a59..c8be910d69 100644
--- a/arch/ceva/src/common/up_internal.h
+++ b/arch/ceva/src/common/up_internal.h
@@ -311,6 +311,7 @@ void up_usbuninitialize(void);
 #endif
 
 #ifdef CONFIG_STACK_COLORATION
+size_t ceva_stack_check(uintptr_t alloc, size_t size);
 void up_stack_color(void *stackbase, size_t nbytes);
 #endif
 
diff --git a/arch/or1k/src/common/up_checkstack.c b/arch/or1k/src/common/up_checkstack.c
index 8b06ee38a9..c564709b2d 100644
--- a/arch/or1k/src/common/up_checkstack.c
+++ b/arch/or1k/src/common/up_checkstack.c
@@ -42,14 +42,16 @@
  * Private Function Prototypes
  ****************************************************************************/
 
-static size_t do_stackcheck(uintptr_t alloc, size_t size);
-
 /****************************************************************************
  * Private Function
  ****************************************************************************/
 
 /****************************************************************************
- * Name: do_stackcheck
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: or1k_stack_check
  *
  * Description:
  *   Determine (approximately) how much stack has been used be searching the
@@ -65,7 +67,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size);
  *
  ****************************************************************************/
 
-static size_t do_stackcheck(uintptr_t alloc, size_t size)
+size_t or1k_stack_check(uintptr_t alloc, size_t size)
 {
   uintptr_t start;
   uintptr_t end;
@@ -95,10 +97,6 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size)
   return mark << 2;
 }
 
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
 /****************************************************************************
  * Name: up_check_stack and friends
  *
@@ -117,7 +115,8 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size)
 
 size_t up_check_tcbstack(struct tcb_s *tcb)
 {
-  return do_stackcheck((uintptr_t)tcb->stack_base_ptr, tcb->adj_stack_size);
+  return or1k_stack_check((uintptr_t)tcb->stack_base_ptr,
+                          tcb->adj_stack_size);
 }
 
 ssize_t up_check_tcbstack_remain(struct tcb_s *tcb)
@@ -138,8 +137,8 @@ ssize_t up_check_stack_remain(void)
 #if CONFIG_ARCH_INTERRUPTSTACK > 3
 size_t up_check_intstack(void)
 {
-  return do_stackcheck((uintptr_t)&g_intstackalloc,
-                       (CONFIG_ARCH_INTERRUPTSTACK & ~3));
+  return or1k_stack_check((uintptr_t)&g_intstackalloc,
+                          (CONFIG_ARCH_INTERRUPTSTACK & ~3));
 }
 
 size_t up_check_intstack_remain(void)
diff --git a/arch/or1k/src/common/up_internal.h b/arch/or1k/src/common/up_internal.h
index f7e7600219..1ad2b140ca 100644
--- a/arch/or1k/src/common/up_internal.h
+++ b/arch/or1k/src/common/up_internal.h
@@ -329,6 +329,7 @@ void up_usbuninitialize(void);
 
 /* Debug ********************************************************************/
 #ifdef CONFIG_STACK_COLORATION
+size_t or1k_stack_check(uintptr_t alloc, size_t size);
 void up_stack_color(void *stackbase, size_t nbytes);
 #endif
 
diff --git a/arch/risc-v/src/common/riscv_checkstack.c b/arch/risc-v/src/common/riscv_checkstack.c
index b5d34440cd..c3160c9a9a 100644
--- a/arch/risc-v/src/common/riscv_checkstack.c
+++ b/arch/risc-v/src/common/riscv_checkstack.c
@@ -41,10 +41,12 @@
  * Private Function Prototypes
  ****************************************************************************/
 
-static size_t do_stackcheck(uintptr_t alloc, size_t size);
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
 
 /****************************************************************************
- * Name: do_stackcheck
+ * Name: riscv_stack_check
  *
  * Description:
  *   Determine (approximately) how much stack has been used be searching the
@@ -60,7 +62,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size);
  *
  ****************************************************************************/
 
-static size_t do_stackcheck(uintptr_t alloc, size_t size)
+size_t riscv_stack_check(uintptr_t alloc, size_t size)
 {
   uintptr_t start;
   uintptr_t end;
@@ -135,10 +137,6 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size)
   return mark << 2;
 }
 
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
 /****************************************************************************
  * Name: up_check_stack and friends
  *
@@ -157,7 +155,8 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size)
 
 size_t up_check_tcbstack(struct tcb_s *tcb)
 {
-  return do_stackcheck((uintptr_t)tcb->stack_base_ptr, tcb->adj_stack_size);
+  return riscv_stack_check((uintptr_t)tcb->stack_base_ptr,
+                           tcb->adj_stack_size);
 }
 
 ssize_t up_check_tcbstack_remain(struct tcb_s *tcb)
@@ -178,8 +177,8 @@ ssize_t up_check_stack_remain(void)
 #if CONFIG_ARCH_INTERRUPTSTACK > 15
 size_t up_check_intstack(void)
 {
-  return do_stackcheck((uintptr_t)&g_intstackalloc,
-                       (CONFIG_ARCH_INTERRUPTSTACK & ~15));
+  return riscv_stack_check((uintptr_t)&g_intstackalloc,
+                           (CONFIG_ARCH_INTERRUPTSTACK & ~15));
 }
 
 size_t up_check_intstack_remain(void)
diff --git a/arch/risc-v/src/common/riscv_internal.h b/arch/risc-v/src/common/riscv_internal.h
index 472967db10..861c412cd2 100644
--- a/arch/risc-v/src/common/riscv_internal.h
+++ b/arch/risc-v/src/common/riscv_internal.h
@@ -267,6 +267,7 @@ int riscv_misaligned(int irq, void *context, void *arg);
 /* Debug ********************************************************************/
 
 #ifdef CONFIG_STACK_COLORATION
+size_t riscv_stack_check(uintptr_t alloc, size_t size);
 void riscv_stack_color(void *stackbase, size_t nbytes);
 #endif
 
diff --git a/arch/sim/src/sim/up_checkstack.c b/arch/sim/src/sim/up_checkstack.c
index 0e26086e0a..a933a5e81f 100644
--- a/arch/sim/src/sim/up_checkstack.c
+++ b/arch/sim/src/sim/up_checkstack.c
@@ -40,10 +40,12 @@
  * Private Function Prototypes
  ****************************************************************************/
 
-static size_t do_stackcheck(uintptr_t alloc, size_t size);
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
 
 /****************************************************************************
- * Name: do_stackcheck
+ * Name: sim_stack_check
  *
  * Description:
  *   Determine (approximately) how much stack has been used be searching the
@@ -59,7 +61,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size);
  *
  ****************************************************************************/
 
-static size_t do_stackcheck(uintptr_t alloc, size_t size)
+size_t sim_stack_check(void *alloc, size_t size)
 {
   uintptr_t start;
   uintptr_t end;
@@ -73,8 +75,8 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size)
 
   /* Get aligned addresses of the top and bottom of the stack */
 
-  start = (alloc + 3) & ~3;
-  end   = (alloc + size) & ~3;
+  start = ((uintptr_t)alloc + 3) & ~3;
+  end   = ((uintptr_t)alloc + size) & ~3;
 
   /* Get the adjusted size based on the top and bottom of the stack */
 
@@ -134,10 +136,6 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size)
   return mark << 2;
 }
 
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
 /****************************************************************************
  * Name: up_check_stack and friends
  *
@@ -156,7 +154,8 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size)
 
 size_t up_check_tcbstack(struct tcb_s *tcb)
 {
-  return do_stackcheck((uintptr_t)tcb->stack_base_ptr, tcb->adj_stack_size);
+  return sim_stack_check((void *)(uintptr_t)tcb->stack_base_ptr,
+                         tcb->adj_stack_size);
 }
 
 ssize_t up_check_tcbstack_remain(struct tcb_s *tcb)
diff --git a/arch/sim/src/sim/up_internal.h b/arch/sim/src/sim/up_internal.h
index 1c1d21af17..86acc24e39 100644
--- a/arch/sim/src/sim/up_internal.h
+++ b/arch/sim/src/sim/up_internal.h
@@ -361,6 +361,7 @@ int sim_spi_uninitialize(struct spi_dev_s *dev);
 /* Debug ********************************************************************/
 
 #ifdef CONFIG_STACK_COLORATION
+size_t sim_stack_check(void *alloc, size_t size);
 void up_stack_color(void *stackbase, size_t nbytes);
 #endif
 
diff --git a/arch/sparc/src/common/up_checkstack.c b/arch/sparc/src/common/up_checkstack.c
index ee56466510..27d495979c 100644
--- a/arch/sparc/src/common/up_checkstack.c
+++ b/arch/sparc/src/common/up_checkstack.c
@@ -44,7 +44,11 @@
  ****************************************************************************/
 
 /****************************************************************************
- * Name: do_stackcheck
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sparc_stack_check
  *
  * Description:
  *   Determine (approximately) how much stack has been used by searching the
@@ -60,7 +64,7 @@
  *
  ****************************************************************************/
 
-static size_t do_stackcheck(void *stackbase, size_t nbytes)
+size_t sparc_stack_check(void *stackbase, size_t nbytes)
 {
   uintptr_t start;
   uintptr_t end;
@@ -135,10 +139,6 @@ static size_t do_stackcheck(void *stackbase, size_t nbytes)
   return mark << 2;
 }
 
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
 /****************************************************************************
  * Name: up_stack_color
  *
@@ -200,7 +200,7 @@ void up_stack_color(void *stackbase, size_t nbytes)
 
 size_t up_check_tcbstack(struct tcb_s *tcb)
 {
-  return do_stackcheck(tcb->stack_base_ptr, tcb->adj_stack_size);
+  return sparc_stack_check(tcb->stack_base_ptr, tcb->adj_stack_size);
 }
 
 ssize_t up_check_tcbstack_remain(struct tcb_s *tcb)
@@ -221,8 +221,8 @@ ssize_t up_check_stack_remain(void)
 #if CONFIG_ARCH_INTERRUPTSTACK > 3
 size_t up_check_intstack(void)
 {
-  return do_stackcheck((uintptr_t)&g_intstackalloc,
-                       STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK));
+  return sparc_stack_check((uintptr_t)&g_intstackalloc,
+                           STACK_ALIGN_DOWN(CONFIG_ARCH_INTERRUPTSTACK));
 }
 
 size_t up_check_intstack_remain(void)
diff --git a/arch/sparc/src/common/up_internal.h b/arch/sparc/src/common/up_internal.h
index 00f88847da..e88a9a64ff 100644
--- a/arch/sparc/src/common/up_internal.h
+++ b/arch/sparc/src/common/up_internal.h
@@ -259,6 +259,7 @@ void up_usbuninitialize(void);
 
 /* Debug ********************************************************************/
 #ifdef CONFIG_STACK_COLORATION
+size_t sparc_stack_check(void *stackbase, size_t nbytes);
 void up_stack_color(void *stackbase, size_t nbytes);
 #endif
 
diff --git a/arch/xtensa/src/common/xtensa.h b/arch/xtensa/src/common/xtensa.h
index 4b7a02d4a0..528fe81d4f 100644
--- a/arch/xtensa/src/common/xtensa.h
+++ b/arch/xtensa/src/common/xtensa.h
@@ -346,6 +346,7 @@ int xtensa_swint(int irq, void *context, void *arg);
 /* Debug ********************************************************************/
 
 #ifdef CONFIG_STACK_COLORATION
+size_t xtensa_stack_check(uintptr_t alloc, size_t size);
 void xtensa_stack_color(void *stackbase, size_t nbytes);
 #endif
 
diff --git a/arch/xtensa/src/common/xtensa_checkstack.c b/arch/xtensa/src/common/xtensa_checkstack.c
index 3a7e1881db..5e543e8553 100644
--- a/arch/xtensa/src/common/xtensa_checkstack.c
+++ b/arch/xtensa/src/common/xtensa_checkstack.c
@@ -42,10 +42,12 @@
  * Private Function Prototypes
  ****************************************************************************/
 
-static size_t do_stackcheck(uintptr_t alloc, size_t size);
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
 
 /****************************************************************************
- * Name: do_stackcheck
+ * Name: xtensa_stack_check
  *
  * Description:
  *   Determine (approximately) how much stack has been used be searching the
@@ -61,7 +63,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size);
  *
  ****************************************************************************/
 
-static size_t do_stackcheck(uintptr_t alloc, size_t size)
+size_t xtensa_stack_check(uintptr_t alloc, size_t size)
 {
   uintptr_t start;
   uintptr_t end;
@@ -138,10 +140,6 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size)
   return mark << 2;
 }
 
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
 /****************************************************************************
  * Name: up_check_stack and friends
  *
@@ -160,7 +158,8 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size)
 
 size_t up_check_tcbstack(struct tcb_s *tcb)
 {
-  return do_stackcheck((uintptr_t)tcb->stack_base_ptr, tcb->adj_stack_size);
+  return xtensa_stack_check((uintptr_t)tcb->stack_base_ptr,
+                            tcb->adj_stack_size);
 }
 
 ssize_t up_check_tcbstack_remain(struct tcb_s *tcb)
@@ -182,9 +181,9 @@ ssize_t up_check_stack_remain(void)
 size_t up_check_intstack(void)
 {
 #ifdef CONFIG_SMP
-  return do_stackcheck(xtensa_intstack_alloc(), INTSTACK_SIZE);
+  return xtensa_stack_check(xtensa_intstack_alloc(), INTSTACK_SIZE);
 #else
-  return do_stackcheck((uintptr_t)&g_intstackalloc, INTSTACK_SIZE);
+  return xtensa_stack_check((uintptr_t)&g_intstackalloc, INTSTACK_SIZE);
 #endif
 }