You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/08/23 14:24:06 UTC

[incubator-nuttx] 02/03: arm_xxxxstack.c: small style fixes, changed calculation of stack start for checkstack.

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

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

commit 01715e4566a90413c91382bcfeb93e63f5d80344
Author: Johannes Schock <jo...@nivus.com>
AuthorDate: Thu Aug 13 18:04:48 2020 +0200

    arm_xxxxstack.c: small style fixes, changed calculation of stack start for checkstack.
---
 arch/arm/src/common/arm_checkstack.c  | 29 +++++++----------------------
 arch/arm/src/common/arm_createstack.c |  1 -
 arch/arm/src/common/arm_usestack.c    |  5 ++---
 3 files changed, 9 insertions(+), 26 deletions(-)

diff --git a/arch/arm/src/common/arm_checkstack.c b/arch/arm/src/common/arm_checkstack.c
index 61faad4..8f624a6 100644
--- a/arch/arm/src/common/arm_checkstack.c
+++ b/arch/arm/src/common/arm_checkstack.c
@@ -59,7 +59,7 @@
  * Private Function Prototypes
  ****************************************************************************/
 
-static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack);
+static size_t do_stackcheck(uintptr_t alloc, size_t size);
 
 /****************************************************************************
  * Name: do_stackcheck
@@ -78,7 +78,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack);
  *
  ****************************************************************************/
 
-static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack)
+static size_t do_stackcheck(uintptr_t alloc, size_t size)
 {
   FAR uintptr_t start;
   FAR uintptr_t end;
@@ -92,20 +92,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack)
 
   /* Get aligned addresses of the top and bottom of the stack */
 
-  if (!int_stack)
-    {
-      /* Skip over the TLS data structure at the bottom of the stack */
-
-#ifdef CONFIG_TLS_ALIGNED
-      DEBUGASSERT((alloc & TLS_STACK_MASK) == 0);
-#endif
-      start = alloc + sizeof(struct tls_info_s);
-    }
-  else
-    {
-      start = alloc & ~3;
-    }
-
+  start = alloc & ~3;
   end   = (alloc + size + 3) & ~3;
 
   /* Get the adjusted size based on the top and bottom of the stack */
@@ -188,8 +175,8 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack)
 
 size_t up_check_tcbstack(FAR struct tcb_s *tcb)
 {
-  return do_stackcheck((uintptr_t)tcb->stack_alloc_ptr, tcb->adj_stack_size,
-                       false);
+  return do_stackcheck((uintptr_t)tcb->adj_stack_ptr - tcb->adj_stack_size,
+      tcb->adj_stack_size);
 }
 
 ssize_t up_check_tcbstack_remain(FAR struct tcb_s *tcb)
@@ -212,12 +199,10 @@ size_t up_check_intstack(void)
 {
 #ifdef CONFIG_SMP
   return do_stackcheck(arm_intstack_base(),
-                       (CONFIG_ARCH_INTERRUPTSTACK & ~3),
-                       true);
+                       (CONFIG_ARCH_INTERRUPTSTACK & ~3));
 #else
   return do_stackcheck((uintptr_t)&g_intstackalloc,
-                       (CONFIG_ARCH_INTERRUPTSTACK & ~3),
-                       true);
+                       (CONFIG_ARCH_INTERRUPTSTACK & ~3));
 #endif
 }
 
diff --git a/arch/arm/src/common/arm_createstack.c b/arch/arm/src/common/arm_createstack.c
index 51cc7bd..d4b699b 100644
--- a/arch/arm/src/common/arm_createstack.c
+++ b/arch/arm/src/common/arm_createstack.c
@@ -218,7 +218,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
 
       arm_stack_color((FAR void *)((uintptr_t)tcb->adj_stack_ptr -
           tcb->adj_stack_size), tcb->adj_stack_size);
-
 #endif /* CONFIG_STACK_COLORATION */
 
       board_autoled_on(LED_STACKCREATED);
diff --git a/arch/arm/src/common/arm_usestack.c b/arch/arm/src/common/arm_usestack.c
index 9975578..3197eb8 100644
--- a/arch/arm/src/common/arm_usestack.c
+++ b/arch/arm/src/common/arm_usestack.c
@@ -137,7 +137,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
 
       memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s));
 
-    #ifdef CONFIG_STACK_COLORATION
+#ifdef CONFIG_STACK_COLORATION
       /* If stack debug is enabled, then fill the stack with a
        * recognizable value that we can use later to test for high
        * water marks.
@@ -145,8 +145,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
 
       arm_stack_color((FAR void *)((uintptr_t)tcb->adj_stack_ptr -
           tcb->adj_stack_size), tcb->adj_stack_size);
-
-    #endif /* CONFIG_STACK_COLORATION */
+#endif /* CONFIG_STACK_COLORATION */
 
       return OK;
     }