set stack size to 8 MB explicitly, should fix light compile crash on OS X

git-svn-id: svn://svn.icculus.org/netradiant/trunk@362 61c419a2-8eb2-4b30-bcec-8cead039b335
This commit is contained in:
divverent 2009-05-06 08:04:10 +00:00
parent 4218236572
commit e51048cf0e
2 changed files with 12 additions and 8 deletions

View File

@ -423,7 +423,7 @@ void RunThreadsOn (int workcnt, qboolean showpacifier, void(*func)(int))
======================================================================= =======================================================================
*/ */
#if defined(__linux__) || defined(__APPLE__) #if defined(__linux__) || (defined(__APPLE__) && !MAC_STATIC_HACK)
#define USED #define USED
int numthreads = 4; int numthreads = 4;
@ -525,7 +525,9 @@ RunThreadsOn
void RunThreadsOn (int workcnt, qboolean showpacifier, void(*func)(int)) void RunThreadsOn (int workcnt, qboolean showpacifier, void(*func)(int))
{ {
pthread_mutexattr_t mattrib; pthread_mutexattr_t mattrib;
pthread_attr_t attr;
pthread_t work_threads[MAX_THREADS]; pthread_t work_threads[MAX_THREADS];
size_t stacksize;
int start, end; int start, end;
int i=0, status=0; int i=0, status=0;
@ -536,6 +538,14 @@ void RunThreadsOn (int workcnt, qboolean showpacifier, void(*func)(int))
dispatch = 0; dispatch = 0;
oldf = -1; oldf = -1;
workcount = workcnt; workcount = workcnt;
pthread_attr_init(&attr);
if(pthread_attr_setstacksize(&attr, 8388608) != 0)
{
stacksize = 0;
pthread_attr_getstacksize(&attr, &stacksize);
Sys_Printf("Could not set a per-thread stack size of 8 MB, using only %.2f MB\n", stacksize / 1048576.0);
}
if(numthreads == 1) if(numthreads == 1)
func(0); func(0);
@ -555,7 +565,7 @@ void RunThreadsOn (int workcnt, qboolean showpacifier, void(*func)(int))
for (i=0 ; i<numthreads ; i++) for (i=0 ; i<numthreads ; i++)
{ {
/* Default pthread attributes: joinable & non-realtime scheduling */ /* Default pthread attributes: joinable & non-realtime scheduling */
if(pthread_create(&work_threads[i], NULL, (void*)func, (void*)i) != 0) if(pthread_create(&work_threads[i], &attr, (void*)func, (void*)i) != 0)
Error("pthread_create failed"); Error("pthread_create failed");
} }
for (i=0 ; i<numthreads ; i++) for (i=0 ; i<numthreads ; i++)

View File

@ -1580,12 +1580,6 @@ int main( int argc, char **argv )
} }
} }
#if MAC_STATIC_HACK
if(numthreads > 1)
Sys_Printf("MAC_STATIC_HACK does not allow using threads\n");
numthreads = 1;
#endif
/* init model library */ /* init model library */
PicoInit(); PicoInit();
PicoSetMallocFunc( safe_malloc ); PicoSetMallocFunc( safe_malloc );