]> granicus.if.org Git - gc/commitdiff
2011-07-05 Ivan Maidanski <ivmai@mail.ru>
authorivmai <ivmai>
Tue, 5 Jul 2011 17:53:24 +0000 (17:53 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:07:00 +0000 (21:07 +0400)
* misc.c (GC_init): Use HOTTER_THAN (instead of STACK_GROWS_DOWN)
for GC_stackbottom assertion.
* os_dep.c (GC_enclosing_mapping): Define only if IA64 or
INCLUDE_LINUX_THREAD_DESCR; make GC_INNER.
* pthread_support.c (GC_enclosing_mapping): Declare (only if
INCLUDE_LINUX_THREAD_DESCR).
* os_dep.c (GC_get_main_stack_base): Don't call pthread_getattr_np
if REDIRECT_MALLOC as the former is observed to call redirected
malloc (while GC is not initialized yet) on some Linux platforms.
* include/private/gc_priv.h (MAX_HEAP_SECTS): Don't use a smaller
value for SMALL_CONFIG if USE_PROC_FOR_LIBRARIES defined.

ChangeLog
include/private/gc_priv.h
misc.c
os_dep.c
pthread_support.c

index 5370f51860d2da75a353d018e8939e78ff0c9f8b..5776b929163610c9325d2adfd61493c696b26314 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2011-07-05  Ivan Maidanski <ivmai@mail.ru>
+
+       * misc.c (GC_init): Use HOTTER_THAN (instead of STACK_GROWS_DOWN)
+       for GC_stackbottom assertion.
+       * os_dep.c (GC_enclosing_mapping): Define only if IA64 or
+       INCLUDE_LINUX_THREAD_DESCR; make GC_INNER.
+       * pthread_support.c (GC_enclosing_mapping): Declare (only if
+       INCLUDE_LINUX_THREAD_DESCR).
+       * os_dep.c (GC_get_main_stack_base): Don't call pthread_getattr_np
+       if REDIRECT_MALLOC as the former is observed to call redirected
+       malloc (while GC is not initialized yet) on some Linux platforms.
+       * include/private/gc_priv.h (MAX_HEAP_SECTS): Don't use a smaller
+       value for SMALL_CONFIG if USE_PROC_FOR_LIBRARIES defined.
+
 2011-07-05  Ivan Maidanski <ivmai@mail.ru>
 
        * malloc.c (GC_init_lib_bounds): Call GC_init (to ensure GC is
index daf2069c43aef00c4304bd8f1ae5b73b812db457..d3d14ca355b37b25c78cf8e20e3d0a712dd84087 100644 (file)
@@ -952,7 +952,7 @@ struct roots {
 #   else
 #     define MAX_HEAP_SECTS 768         /* Separately added heap sections. */
 #   endif
-# elif defined(SMALL_CONFIG)
+# elif defined(SMALL_CONFIG) && !defined(USE_PROC_FOR_LIBRARIES)
 #   define MAX_HEAP_SECTS 128           /* Roughly 256MB (128*2048*1K)  */
 # elif CPP_WORDSZ > 32
 #   define MAX_HEAP_SECTS 1024          /* Roughly 8GB                  */
diff --git a/misc.c b/misc.c
index c2d5cab3eb5f0df58a3a25b0ce31b6d50184e7a3..ab3fef9975ddae7ab4b0f6650fd96f594230f812 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -914,8 +914,8 @@ GC_API void GC_CALL GC_init(void)
 #   if defined(NETBSD) && defined(__ELF__)
         GC_init_netbsd_elf();
 #   endif
-#   if !defined(THREADS) || defined(GC_PTHREADS) || defined(GC_WIN32_THREADS) \
-        || defined(GC_SOLARIS_THREADS)
+#   if !defined(THREADS) || defined(GC_PTHREADS) \
+        || defined(GC_WIN32_THREADS) || defined(GC_SOLARIS_THREADS)
       if (GC_stackbottom == 0) {
         GC_stackbottom = GC_get_main_stack_base();
 #       if (defined(LINUX) || defined(HPUX)) && defined(IA64)
@@ -937,11 +937,7 @@ GC_API void GC_CALL GC_init(void)
     GC_STATIC_ASSERT(sizeof (signed_word) == sizeof(word));
     GC_STATIC_ASSERT(sizeof (struct hblk) == HBLKSIZE);
 #   ifndef THREADS
-#     ifdef STACK_GROWS_DOWN
-        GC_ASSERT((word)(&dummy) <= (word)GC_stackbottom);
-#     else
-        GC_ASSERT((word)(&dummy) >= (word)GC_stackbottom);
-#     endif
+      GC_ASSERT(!((word)GC_stackbottom HOTTER_THAN (word)(&dummy)));
 #   endif
 #   if !defined(_AUX_SOURCE) || defined(__GNUC__)
       GC_STATIC_ASSERT((word)(-1) > (word)0);
index 73b493969fdf46fd480bfdf5e8577f8e199ff5a0..2d73340ad0f0fd4c86cbea3ce89b1665752fa46e 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -349,34 +349,37 @@ GC_INNER char *GC_parse_map_entry(char *buf_ptr, ptr_t *start, ptr_t *end,
     return p;
 }
 
-/* Try to read the backing store base from /proc/self/maps.             */
-/* Return the bounds of the writable mapping with a 0 major device,     */
-/* which includes the address passed as data.                           */
-/* Return FALSE if there is no such mapping.                            */
-GC_bool GC_enclosing_mapping(ptr_t addr, ptr_t *startp, ptr_t *endp)
-{
-  char *prot;
-  ptr_t my_start, my_end;
-  unsigned int maj_dev;
-  char *maps = GC_get_maps();
-  char *buf_ptr = maps;
+#if defined(IA64) || defined(INCLUDE_LINUX_THREAD_DESCR)
+  /* Try to read the backing store base from /proc/self/maps.           */
+  /* Return the bounds of the writable mapping with a 0 major device,   */
+  /* which includes the address passed as data.                         */
+  /* Return FALSE if there is no such mapping.                          */
+  GC_INNER GC_bool GC_enclosing_mapping(ptr_t addr, ptr_t *startp,
+                                        ptr_t *endp)
+  {
+    char *prot;
+    ptr_t my_start, my_end;
+    unsigned int maj_dev;
+    char *maps = GC_get_maps();
+    char *buf_ptr = maps;
 
-  if (0 == maps) return(FALSE);
-  for (;;) {
-    buf_ptr = GC_parse_map_entry(buf_ptr, &my_start, &my_end,
-                                 &prot, &maj_dev, 0);
-
-    if (buf_ptr == NULL) return FALSE;
-    if (prot[1] == 'w' && maj_dev == 0) {
-        if (my_end > addr && my_start <= addr) {
-          *startp = my_start;
-          *endp = my_end;
-          return TRUE;
-        }
+    if (0 == maps) return(FALSE);
+    for (;;) {
+      buf_ptr = GC_parse_map_entry(buf_ptr, &my_start, &my_end,
+                                   &prot, &maj_dev, 0);
+
+      if (buf_ptr == NULL) return FALSE;
+      if (prot[1] == 'w' && maj_dev == 0) {
+          if (my_end > addr && my_start <= addr) {
+            *startp = my_start;
+            *endp = my_end;
+            return TRUE;
+          }
+      }
     }
+    return FALSE;
   }
-  return FALSE;
-}
+#endif /* IA64 || INCLUDE_LINUX_THREAD_DESCR */
 
 #if defined(REDIRECT_MALLOC)
   /* Find the text(code) mapping for the library whose name, after      */
@@ -1144,7 +1147,8 @@ GC_INNER word GC_page_size = 0;
   {
     ptr_t result; /* also used as "dummy" to get the approx. sp value */
 #   if defined(LINUX) && !defined(NACL) \
-       && (defined(USE_GET_STACKBASE_FOR_MAIN) || defined(THREADS))
+       && (defined(USE_GET_STACKBASE_FOR_MAIN) \
+           || (defined(THREADS) && !defined(REDIRECT_MALLOC)))
       pthread_attr_t attr;
       void *stackaddr;
       size_t size;
index 7e7e29144ad95c3a2006557548bfd0143c9a2bb8..bcdfebd1437f978d6deef27a55b83a0b6462a7e3 100644 (file)
@@ -879,6 +879,8 @@ STATIC void GC_fork_child_proc(void)
 
 #ifdef INCLUDE_LINUX_THREAD_DESCR
   __thread int GC_dummy_thread_local;
+  GC_INNER GC_bool GC_enclosing_mapping(ptr_t addr,
+                                        ptr_t *startp, ptr_t *endp);
 #endif
 
 /* We hold the allocation lock. */