diff options
author | Richard Braun <rbraun@sceen.net> | 2012-09-03 20:29:10 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2012-11-25 00:29:48 +0100 |
commit | 536420a581f9f822cdef0fc460b5176a840f49e5 (patch) | |
tree | 0d993fec12628cc86a1efa7c1be0fb834a5a68e9 | |
parent | 2531b513b4c3338a69230f273a57f6a7f927b3c8 (diff) |
Allow applications to set the default stack size
This change is a temporary hack intended for the Hurd servers. Once Hurd
threadvars are replaced with TLS, this commit should be reverted.
* pthread/pt-internal.h (__pthread_default_attr): Remove const qualifier.
* sysdeps/generic/pt-attr.c (__pthread_default_attr): Likewise.
* sysdeps/mach/hurd/pt-sysdep.c (__pthread_stack_default_size): New variable.
(init_routine): Set __pthread_default_attr.stacksize if
__pthread_stack_default_size exists.
-rw-r--r-- | pthread/pt-internal.h | 5 | ||||
-rw-r--r-- | sysdeps/generic/pt-attr.c | 3 | ||||
-rw-r--r-- | sysdeps/mach/hurd/pt-sysdep.c | 14 |
3 files changed, 19 insertions, 3 deletions
diff --git a/pthread/pt-internal.h b/pthread/pt-internal.h index 067fb73..291baf5 100644 --- a/pthread/pt-internal.h +++ b/pthread/pt-internal.h @@ -292,8 +292,9 @@ extern error_t __pthread_sigstate (struct __pthread *__restrict thread, int how, int clear_pending); -/* Default thread attributes. */ -extern const struct __pthread_attr __pthread_default_attr; +/* Default thread attributes. + FIXME Normally const, see sysdeps/mach/hurd/pt-sysdep.c. */ +extern struct __pthread_attr __pthread_default_attr; /* Default barrier attributes. */ extern const struct __pthread_barrierattr __pthread_default_barrierattr; diff --git a/sysdeps/generic/pt-attr.c b/sysdeps/generic/pt-attr.c index e501dc7..4f95918 100644 --- a/sysdeps/generic/pt-attr.c +++ b/sysdeps/generic/pt-attr.c @@ -24,7 +24,8 @@ #include <pt-internal.h> -const struct __pthread_attr __pthread_default_attr = +/* FIXME Normally const, see sysdeps/mach/hurd/pt-sysdep.c. */ +struct __pthread_attr __pthread_default_attr = { schedparam: { sched_priority: 0 }, stacksize: PTHREAD_STACK_DEFAULT, diff --git a/sysdeps/mach/hurd/pt-sysdep.c b/sysdeps/mach/hurd/pt-sysdep.c index f40fee5..882af69 100644 --- a/sysdeps/mach/hurd/pt-sysdep.c +++ b/sysdeps/mach/hurd/pt-sysdep.c @@ -30,6 +30,16 @@ __thread struct __pthread *___pthread_self; +/* Allow programs that know about this library to override the default stack + size. + + FIXME Stack sizes should normally be set at thread creation time using the + standard interface, but Hurd threadvars have special alignment constraints. + Until they are completely replaced with correct TLS, make this hack + available. */ +extern size_t __pthread_stack_default_size; +weak_extern(__pthread_stack_default_size); + /* Forward. */ static void *init_routine (void); @@ -46,6 +56,10 @@ init_routine (void) struct __pthread *thread; int err; + /* FIXME */ + if (&__pthread_stack_default_size != NULL) + __pthread_default_attr.stacksize = __pthread_stack_default_size; + /* Initialize the library. */ __pthread_init (); |