Module: xenomai-jki
Branch: for-forge
Commit: be7b21e91daf0efb9fc056b86ee32f729aa10791
URL:    
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=be7b21e91daf0efb9fc056b86ee32f729aa10791

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Tue Apr 21 16:07:01 2015 +0200

lib/cobalt: Introduce and use COBALT_STACKSIZE_DEFAULT/MIN

We can simplify and consolidate, now that COBALT_STACKSIZE_MIN no longer
depends on getpagesize().

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>

---

 lib/cobalt/internal.c |    9 +++------
 lib/cobalt/internal.h |    4 ++++
 lib/cobalt/printf.c   |    2 +-
 lib/cobalt/thread.c   |    2 +-
 4 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/lib/cobalt/internal.c b/lib/cobalt/internal.c
index 83dd219..a75cb3c 100644
--- a/lib/cobalt/internal.c
+++ b/lib/cobalt/internal.c
@@ -145,14 +145,11 @@ int cobalt_serial_debug(const char *fmt, ...)
 
 size_t cobalt_get_stacksize(size_t size)
 {
-       static const size_t default_size = PTHREAD_STACK_MIN * 4;
-       static const size_t min_size = PTHREAD_STACK_MIN * 2;
-
        if (size == 0)
-               size = default_size;
+               size = COBALT_STACKSIZE_DEFAULT;
 
-       if (size < min_size)
-               size = min_size;
+       if (size < COBALT_STACKSIZE_MIN)
+               size = COBALT_STACKSIZE_MIN;
 
        return size;
 }
diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h
index e126480..f2f2ee1 100644
--- a/lib/cobalt/internal.h
+++ b/lib/cobalt/internal.h
@@ -18,9 +18,13 @@
 #ifndef _LIB_COBALT_INTERNAL_H
 #define _LIB_COBALT_INTERNAL_H
 
+#include <limits.h>
 #include <cobalt/sys/cobalt.h>
 #include "current.h"
 
+#define COBALT_STACKSIZE_MIN           (PTHREAD_STACK_MIN * 2)
+#define COBALT_STACKSIZE_DEFAULT       (PTHREAD_STACK_MIN * 4)
+
 extern void *cobalt_umm_private;
 
 extern void *cobalt_umm_shared;
diff --git a/lib/cobalt/printf.c b/lib/cobalt/printf.c
index f19f4ea..4e1dff3 100644
--- a/lib/cobalt/printf.c
+++ b/lib/cobalt/printf.c
@@ -666,7 +666,7 @@ static void spawn_printer_thread(void)
        pthread_attr_t thattr;
 
        pthread_attr_init(&thattr);
-       pthread_attr_setstacksize(&thattr, cobalt_get_stacksize(0));
+       pthread_attr_setstacksize(&thattr, COBALT_STACKSIZE_DEFAULT);
        pthread_create(&printer_thread, &thattr, printer_loop, NULL);
 }
 
diff --git a/lib/cobalt/thread.c b/lib/cobalt/thread.c
index 8d16ceb..8675dea 100644
--- a/lib/cobalt/thread.c
+++ b/lib/cobalt/thread.c
@@ -52,7 +52,7 @@ static int std_maxpri;
 static void commit_stack_memory(void)
 {
        if (pthread_self() == __cobalt_main_ptid) {
-               char stk[cobalt_get_stacksize(1)];
+               char stk[COBALT_STACKSIZE_MIN];
                cobalt_commit_memory(stk);
        }
 }


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to