]> git.xonotic.org Git - xonotic/netradiant.git/commitdiff
set stack size to 8 MB explicitly, should fix light compile crash on OS X
authordivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Wed, 6 May 2009 08:04:10 +0000 (08:04 +0000)
committerdivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Wed, 6 May 2009 08:04:10 +0000 (08:04 +0000)
git-svn-id: svn://svn.icculus.org/netradiant/trunk@362 61c419a2-8eb2-4b30-bcec-8cead039b335

tools/quake3/common/threads.c
tools/quake3/q3map2/main.c

index ae398324fbabde18e364ea072ca231073616c702..a486abafaea5006e169ece64f156579523260734 100644 (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
 
 int numthreads = 4;
@@ -525,7 +525,9 @@ RunThreadsOn
 void RunThreadsOn (int workcnt, qboolean showpacifier, void(*func)(int))
 {
   pthread_mutexattr_t         mattrib;
+  pthread_attr_t              attr;
   pthread_t work_threads[MAX_THREADS];
+  size_t stacksize;
   
   int    start, end;
   int   i=0, status=0;
@@ -536,6 +538,14 @@ void RunThreadsOn (int workcnt, qboolean showpacifier, void(*func)(int))
   dispatch  = 0;
   oldf      = -1;
   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)
     func(0);
@@ -555,7 +565,7 @@ void RunThreadsOn (int workcnt, qboolean showpacifier, void(*func)(int))
     for (i=0 ; i<numthreads ; i++)
     {
       /* 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");
     }
     for (i=0 ; i<numthreads ; i++)
index d0a916efa85f954ecef0af8c34ea9d4c805bd2ed..213a975bfde537da6eb0deaf287c526bba3d2e09 100644 (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 */
        PicoInit();
        PicoSetMallocFunc( safe_malloc );