Module: xenomai-3
Branch: master
Commit: c212cc2f4cea63c8aaa8118a4dfb8681c11037a2
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c212cc2f4cea63c8aaa8118a4dfb8681c11037a2

Author: Philippe Gerum <r...@xenomai.org>
Date:   Mon Aug 24 12:04:31 2015 +0200

boilerplate: define a reasonable default stack size

PTHREAD_STACK_MIN can be quite large (128k) on several architectures,
and small on others (16k). Instead of using a multiple of such value
which tends to be overkill in the former case, define
PTHREAD_STACK_DEFAULT = max(64k, PTHREAD_STACK_MIN) as the reasonable
default size.

NOTE: this is only a default value, applications needing a larger
stack size should override it into the thread attribute descriptor by
a call to pthread_attr_setstacksize().

---

 include/boilerplate/libc.h  |   12 ++++++++++++
 lib/boilerplate/Makefile.am |    2 +-
 lib/boilerplate/setup.c     |    2 ++
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/include/boilerplate/libc.h b/include/boilerplate/libc.h
index 7dd305f..d65ce3f 100644
--- a/include/boilerplate/libc.h
+++ b/include/boilerplate/libc.h
@@ -18,6 +18,8 @@
 #ifndef _BOILERPLATE_LIBC_H
 #define _BOILERPLATE_LIBC_H
 
+#include <limits.h>
+
 #ifdef __IN_XENO__
 /*
  * Quirks for dealing with outdated libc* issues.  This header will be
@@ -205,4 +207,14 @@ int pthread_setname_np(pthread_t thread, const char *name);
 #endif /* !HAVE_PTHREAD_SETNAME_NP */
 #endif /* __COBALT_WRAP__ || __IN_XENO__ */
 
+#ifndef PTHREAD_STACK_DEFAULT
+#define PTHREAD_STACK_DEFAULT                  \
+       ({                                      \
+               int __ret = PTHREAD_STACK_MIN;  \
+               if (__ret < 65536)              \
+                       __ret = 65536;          \
+               __ret;                          \
+       })
+#endif /* !PTHREAD_STACK_DEFAULT */
+
 #endif /* _BOILERPLATE_LIBC_H */
diff --git a/lib/boilerplate/Makefile.am b/lib/boilerplate/Makefile.am
index 27b5dcb..4176c6d 100644
--- a/lib/boilerplate/Makefile.am
+++ b/lib/boilerplate/Makefile.am
@@ -48,7 +48,7 @@ config-dump.h: Makefile $(CONFIG_HEADER)
        -e 's/^.*$$/\"&\",/' $(CONFIG_HEADER); echo '"---",'; \
        sed -e '/#undef CONFIG_/!d' \
        -e 's/.*\(CONFIG_[^ ]*\).*/\1/' \
-       -e 's/^.*$$/\"& is OFF\",/' $(CONFIG_HEADER) ) > $@
+       -e 's/^.*$$/\"& is OFF\",/' $(CONFIG_HEADER); echo '"---",' ) > $@
 
 libboilerplate_la_CPPFLAGS =                           \
        @XENO_USER_CFLAGS@                              \
diff --git a/lib/boilerplate/setup.c b/lib/boilerplate/setup.c
index 2ccb4f4..5273a5e 100644
--- a/lib/boilerplate/setup.c
+++ b/lib/boilerplate/setup.c
@@ -129,6 +129,8 @@ static inline void dump_configuration(void)
 
        for (n = 0; config_strings[n]; n++)
                puts(config_strings[n]);
+
+       printf("PTHREAD_STACK_DEFAULT=%d\n", PTHREAD_STACK_DEFAULT);
 }
 
 static int collect_cpu_affinity(const char *cpu_list)


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

Reply via email to