]> gcc.gnu.org Git - gcc.git/blobdiff - boehm-gc/solaris_threads.c
Merged GC 5.0alpha4 with local changes, plus:
[gcc.git] / boehm-gc / solaris_threads.c
index 1f5ebcdc39017ac8fda419480fbe7647e66cdc03..65b2c6517b179da2d918d4de888317f2a0c8d6d9 100644 (file)
@@ -616,6 +616,25 @@ GC_thread GC_lookup_thread(thread_t id)
     return(p);
 }
 
+# define MAX_ORIG_STACK_SIZE (8 * 1024 * 1024)
+
+word GC_get_orig_stack_size() {
+    struct rlimit rl;
+    static int warned = 0;
+    int result;
+
+    if (getrlimit(RLIMIT_STACK, &rl) != 0) ABORT("getrlimit failed");
+    result = (word)rl.rlim_cur & ~(HBLKSIZE-1);
+    if (result > MAX_ORIG_STACK_SIZE) {
+       if (!warned) {
+           WARN("Large stack limit(%ld): only scanning 8 MB", result);
+           warned = 1;
+       }
+       result = MAX_ORIG_STACK_SIZE;
+    }
+    return result;
+}
+
 /* Notify dirty bit implementation of unused parts of my stack. */
 /* Caller holds allocation lock.                               */
 void GC_my_stack_limits()
@@ -628,12 +647,9 @@ void GC_my_stack_limits()
     
     if (stack_size == 0) {
       /* original thread */
-        struct rlimit rl;
-         
-        if (getrlimit(RLIMIT_STACK, &rl) != 0) ABORT("getrlimit failed");
         /* Empirically, what should be the stack page with lowest      */
         /* address is actually inaccessible.                           */
-        stack_size = ((word)rl.rlim_cur & ~(HBLKSIZE-1)) - GC_page_sz;
+        stack_size = GC_get_orig_stack_size() - GC_page_sz;
         stack = GC_stackbottom - stack_size + GC_page_sz;
     } else {
         stack = me -> stack;
@@ -671,8 +687,7 @@ void GC_push_all_stacks()
             top = p -> stack + p -> stack_size;
         } else {
             /* The original stack. */
-            if (getrlimit(RLIMIT_STACK, &rl) != 0) ABORT("getrlimit failed");
-            bottom = GC_stackbottom - rl.rlim_cur + GC_page_sz;
+            bottom = GC_stackbottom - GC_get_orig_stack_size() + GC_page_sz;
             top = GC_stackbottom;
         }
         if ((word)sp > (word)bottom && (word)sp < (word)top) bottom = sp;
This page took 0.030185 seconds and 5 git commands to generate.