OSDN Git Service

* config/alpha/alpha.md (unop): Add 0 offset for some gas versions.
[pf3gnuchains/gcc-fork.git] / boehm-gc / solaris_threads.c
index 1f5ebcd..11b0e03 100644 (file)
  */
 /* Boehm, September 14, 1994 4:44 pm PDT */
 
-# if defined(SOLARIS_THREADS)
+# if defined(GC_SOLARIS_THREADS)
 
-# include "gc_priv.h"
-# include "solaris_threads.h"
+# include "private/gc_priv.h"
+# include "private/solaris_threads.h"
 # include <thread.h>
 # include <synch.h>
 # include <signal.h>
@@ -558,6 +558,11 @@ void GC_old_stacks_are_fresh()
 # define THREAD_TABLE_SZ 128   /* Must be power of 2   */
 volatile GC_thread GC_threads[THREAD_TABLE_SZ];
 
+void GC_push_thread_structures GC_PROTO((void))
+{
+    GC_push_all((ptr_t)(GC_threads), (ptr_t)(GC_threads)+sizeof(GC_threads));
+}
+
 /* Add a thread to GC_threads.  We assume it wasn't already there.     */
 /* Caller holds allocation lock.                                       */
 GC_thread GC_new_thread(thread_t id)
@@ -573,7 +578,7 @@ GC_thread GC_new_thread(thread_t id)
        /* Dont acquire allocation lock, since we may already hold it. */
     } else {
         result = (struct GC_Thread_Rep *)
-                GC_generic_malloc_inner(sizeof(struct GC_Thread_Rep), NORMAL);
+                GC_INTERNAL_MALLOC(sizeof(struct GC_Thread_Rep), NORMAL);
     }
     if (result == 0) return(0);
     result -> id = id;
@@ -616,6 +621,36 @@ GC_thread GC_lookup_thread(thread_t id)
     return(p);
 }
 
+/* Solaris 2/Intel uses an initial stack size limit slightly bigger than the
+   SPARC default of 8 MB.  Account for this to warn only if the user has
+   raised the limit beyond the default.
+
+   This is identical to DFLSSIZ defined in <sys/vm_machparam.h>.  This file
+   is installed in /usr/platform/`uname -m`/include, which is not in the
+   default include directory list, so copy the definition here.  */
+#ifdef I386
+# define MAX_ORIG_STACK_SIZE (8 * 1024 * 1024 + ((USRSTACK) & 0x3FFFFF))
+#else
+# define MAX_ORIG_STACK_SIZE (8 * 1024 * 1024)
+#endif
+
+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\n", 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 +663,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;
@@ -645,7 +677,8 @@ void GC_my_stack_limits()
 }
 
 
-/* We hold allocation lock.  We assume the world is stopped.   */
+/* We hold allocation lock.  Should do exactly the right thing if the  */
+/* world is stopped.  Should not fail if it isn't.                     */
 void GC_push_all_stacks()
 {
     register int i;
@@ -656,7 +689,7 @@ void GC_push_all_stacks()
     
 #   define PUSH(bottom,top) \
       if (GC_dirty_maintained) { \
-       GC_push_dirty((bottom), (top), GC_page_was_ever_dirty, \
+       GC_push_selected((bottom), (top), GC_page_was_ever_dirty, \
                      GC_push_all_stack); \
       } else { \
         GC_push_all_stack((bottom), (top)); \
@@ -671,8 +704,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;
@@ -687,7 +719,6 @@ int GC_is_thread_stack(ptr_t addr)
     register int i;
     register GC_thread p;
     register ptr_t bottom, top;
-    struct rlimit rl;
     
     for (i = 0; i < THREAD_TABLE_SZ; i++) {
       for (p = GC_threads[i]; p != 0; p = p -> next) {
@@ -698,6 +729,7 @@ int GC_is_thread_stack(ptr_t addr)
        }
       }
     }
+    return 0;
 }
 
 /* The only thread that ever really performs a thr_join.       */
@@ -885,7 +917,7 @@ GC_thr_create(void *stack_base, size_t stack_size,
     }
     GC_multithreaded++;
     if (stack == 0) {
-       if (stack_size == 0) stack_size = GC_min_stack_sz;
+       if (stack_size == 0) stack_size = 1024*1024;
        stack = (void *)GC_stack_alloc(&stack_size);
        if (stack == 0) {
            GC_multithreaded--;
@@ -917,7 +949,7 @@ GC_thr_create(void *stack_base, size_t stack_size,
     return(result);
 }
 
-# else /* SOLARIS_THREADS */
+# else /* !GC_SOLARIS_THREADS */
 
 #ifndef LINT
   int GC_no_sunOS_threads;