revised_pthread_stacksize_diff.txt .. contains only the changes for setting thread stacksize on non-linux platforms. All other issues have been separated out so that we can address them individually in subsequent posts. Tested on RH 9, FreeBSD 5.2.1 and OpenBSD 3.5. Index: utils.c =================================================================== RCS file: /usr/cvsroot/asterisk/utils.c,v retrieving revision 1.15 diff -u -r1.15 utils.c --- utils.c 29 Jun 2004 17:54:25 -0000 1.15 +++ utils.c 8 Aug 2004 06:11:00 -0000 @@ -12,12 +12,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include static char base64[64]; static char b2a[256]; @@ -344,3 +346,19 @@ base64_init(); return 0; } + + +#ifndef LINUX +int ast_pthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *data) +{ + pthread_attr_t lattr; + if (!attr) { + pthread_attr_init(&lattr); + attr = &lattr; + } + errno = pthread_attr_setstacksize(attr, PTHREAD_ATTR_STACKSIZE); + if (errno) + ast_log(LOG_WARNING, "pthread_attr_setstacksize returned non-zero: %s\n", strerror(errno)); + return pthread_create(thread, attr, start_routine, data); +} +#endif /* ! LINUX */ Index: include/asterisk/utils.h =================================================================== RCS file: /usr/cvsroot/asterisk/include/asterisk/utils.h,v retrieving revision 1.6 diff -u -r1.6 utils.h --- include/asterisk/utils.h 29 Jun 2004 17:54:25 -0000 1.6 +++ include/asterisk/utils.h 8 Aug 2004 06:11:34 -0000 @@ -12,7 +12,9 @@ #ifndef _ASTERISK_UTIL_H #define _ASTERISK_UTIL_H +#include #include +#include static inline int ast_strlen_zero(const char *s) { @@ -36,5 +38,13 @@ #undef inet_ntoa #endif #define inet_ntoa __dont__use__inet_ntoa__use__ast_inet_ntoa__instead__ + +#ifdef LINUX +#define ast_pthread_create pthread_create +#else +/* Linux threads have a default 2Mb stack size. */ +#define PTHREAD_ATTR_STACKSIZE 2097152 +extern int ast_pthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *data); +#endif /* LINUX */ #endif