diff options
author | Andrew MacIntyre <andymac@bullseye.apana.org.au> | 2006-06-04 12:31:09 (GMT) |
---|---|---|
committer | Andrew MacIntyre <andymac@bullseye.apana.org.au> | 2006-06-04 12:31:09 (GMT) |
commit | 6539d2d3c758b507f10779e218d52d6c9f355025 (patch) | |
tree | d3677cd901f44e2341a50be45d8a3d2f6d1f4da6 /Python/thread.c | |
parent | 7a071939d96702e13c377a5e7f87df7bf20391e5 (diff) | |
download | cpython-6539d2d3c758b507f10779e218d52d6c9f355025.zip cpython-6539d2d3c758b507f10779e218d52d6c9f355025.tar.gz cpython-6539d2d3c758b507f10779e218d52d6c9f355025.tar.bz2 |
Patch #1454481: Make thread stack size runtime tunable.
Diffstat (limited to 'Python/thread.c')
-rw-r--r-- | Python/thread.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Python/thread.c b/Python/thread.c index 5e7fc6c..dd9c3ad 100644 --- a/Python/thread.c +++ b/Python/thread.c @@ -94,6 +94,31 @@ void PyThread_init_thread(void) PyThread__init_thread(); } +/* Support for runtime thread stack size tuning. + A value of 0 means using the platform's default stack size + or the size specified by the THREAD_STACK_SIZE macro. */ +static size_t _pythread_stacksize = 0; + +size_t +PyThread_get_stacksize(void) +{ + return _pythread_stacksize; +} + +static int +_pythread_unsupported_set_stacksize(size_t size) +{ + return PyErr_Warn(PyExc_RuntimeWarning, + "setting thread stack size not supported on " + "this platform"); +} + +/* Only platforms with THREAD_SET_STACKSIZE() defined in + pthread_<platform>.h, overriding this default definition, + will support changing the stack size. + Return 1 if an exception is pending, 0 otherwise. */ +#define THREAD_SET_STACKSIZE(x) _pythread_unsupported_set_stacksize(x) + #ifdef SGI_THREADS #include "thread_sgi.h" #endif @@ -149,6 +174,14 @@ void PyThread_init_thread(void) #endif */ +/* use appropriate thread stack size setting routine. + Return 1 if an exception is pending, 0 otherwise. */ +int +PyThread_set_stacksize(size_t size) +{ + return THREAD_SET_STACKSIZE(size); +} + #ifndef Py_HAVE_NATIVE_TLS /* If the platform has not supplied a platform specific TLS implementation, provide our own. |