]> granicus.if.org Git - gc/commitdiff
2009-10-16 Ivan Maidanski <ivmai@mail.ru>
authorivmai <ivmai>
Fri, 16 Oct 2009 06:41:03 +0000 (06:41 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:06:50 +0000 (21:06 +0400)
* alloc.c (GC_finish_collection): Replace getenv() with GETENV().
* dyn_load.c (GC_init_dyld): Ditto.
* os_dep.c (GC_print_callers): Ditto.
* dyn_load.c (GC_dyld_name_for_hdr): Cast _dyld_get_image_name()
result (since it's always of "struct mach_header" type).
* dyn_load.c (GC_init_dyld): Cast GC_dyld_image_add and
GC_dyld_image_remove (to always have the first argument of
"struct mach_header" pointer type).

ChangeLog
alloc.c
dyn_load.c
os_dep.c

index bd63c4a9a3e55b757136b325b5af04cea30dce66..60cd9776e25b3c9084f7f9ecb9ed71b65fff9c47 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2009-10-16  Ivan Maidanski <ivmai@mail.ru>
+
+       * alloc.c (GC_finish_collection): Replace getenv() with GETENV().
+       * dyn_load.c (GC_init_dyld): Ditto.
+       * os_dep.c (GC_print_callers): Ditto.
+       * dyn_load.c (GC_dyld_name_for_hdr): Cast _dyld_get_image_name()
+       result (since it's always of "struct mach_header" type).
+       * dyn_load.c (GC_init_dyld): Cast GC_dyld_image_add and
+       GC_dyld_image_remove (to always have the first argument of
+       "struct mach_header" pointer type).
+
 2009-10-16  Ivan Maidanski <ivmai@mail.ru> (really Petter Urkedal)
 
        * configure.ac: Add threads support for OpenBSD case (threads may
diff --git a/alloc.c b/alloc.c
index d5309ce79fe1b39a6f71c4bbf29bb70dcc1baea6..8d4dbe033a9b441ad65fb49949bfc049b82c16ee 100644 (file)
--- a/alloc.c
+++ b/alloc.c
@@ -782,7 +782,7 @@ STATIC void GC_finish_collection(void)
 
     GC_bytes_found = 0;
 #   if defined(LINUX) && defined(__ELF__) && !defined(SMALL_CONFIG)
-        if (getenv("GC_PRINT_ADDRESS_MAP") != 0) {
+        if (GETENV("GC_PRINT_ADDRESS_MAP") != 0) {
           GC_print_address_map();
         }
 #   endif
index b4f733e23d1e0fe8a73dec7603a29e93201837f8..498879af7ce9d907b23130e714c1075829e663c8 100644 (file)
@@ -1155,10 +1155,12 @@ const static struct {
         { SEG_DATA, SECT_COMMON }
 };
 
-static const char *GC_dyld_name_for_hdr(const struct GC_MACH_HEADER *hdr) {
-    unsigned long i,c;
+static const char *GC_dyld_name_for_hdr(const struct GC_MACH_HEADER *hdr)
+{
+    unsigned long i, c;
     c = _dyld_image_count();
-    for(i=0;i<c;i++) if(_dyld_get_image_header(i) == hdr)
+    for (i = 0; i < c; i++)
+      if ((const struct GC_MACH_HEADER *)_dyld_get_image_header(i) == hdr)
         return _dyld_get_image_name(i);
     return NULL;
 }
@@ -1235,7 +1237,6 @@ void GC_register_dynamic_libraries(void) {
 
 void GC_init_dyld(void) {
   static GC_bool initialized = FALSE;
-  char *bind_fully_env = NULL;
 
   if(initialized) return;
 
@@ -1244,29 +1245,28 @@ void GC_init_dyld(void) {
 #   endif
 
   /* Apple's Documentation:
-     When you call _dyld_register_func_for_add_image, the dynamic linker runtime
-     calls the specified callback (func) once for each of the images that is
-     currently loaded into the program. When a new image is added to the program,
-     your callback is called again with the mach_header for the new image, and the
-     virtual memory slide amount of the new image.
+     When you call _dyld_register_func_for_add_image, the dynamic linker
+     runtime calls the specified callback (func) once for each of the images
+     that is currently loaded into the program. When a new image is added to
+     the program, your callback is called again with the mach_header for the
+     new image, and the virtual memory slide amount of the new image.
 
      This WILL properly register already linked libraries and libraries
-     linked in the future
+     linked in the future.
   */
 
-    _dyld_register_func_for_add_image(GC_dyld_image_add);
-    _dyld_register_func_for_remove_image(GC_dyld_image_remove);
+    _dyld_register_func_for_add_image(
+              (void (*)(struct mach_header *, intptr_t))GC_dyld_image_add);
+    _dyld_register_func_for_remove_image(
+              (void (*)(struct mach_header *, intptr_t))GC_dyld_image_remove);
 
     /* Set this early to avoid reentrancy issues. */
     initialized = TRUE;
 
-    bind_fully_env = getenv("DYLD_BIND_AT_LAUNCH");
-
-    if (bind_fully_env == NULL) {
-#   ifdef DARWIN_DEBUG
-      GC_printf("Forcing full bind of GC code...\n");
-#   endif
-
+    if (GETENV("DYLD_BIND_AT_LAUNCH") == 0) {
+#     ifdef DARWIN_DEBUG
+        GC_printf("Forcing full bind of GC code...\n");
+#     endif
       if(!_dyld_bind_fully_image_containing_address((unsigned long*)GC_malloc))
         ABORT("_dyld_bind_fully_image_containing_address failed");
     }
index db049ed6ec4adedcac0c5c278bdf16cdb22438a2..7e27dff643fb73425ade22a52eb725f82705234d 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -4273,7 +4273,7 @@ void GC_print_callers (struct callinfo info[NFRAMES])
                 /* isn't time critical.                                 */
                 sprintf(cmd_buf, "/usr/bin/addr2line -f -e %s 0x%lx", exe_name,
                                  (unsigned long)info[i].ci_pc);
-                old_preload = getenv ("LD_PRELOAD");
+                old_preload = GETENV("LD_PRELOAD");
                 if (0 != old_preload) {
                   if (strlen (old_preload) >= PRELOAD_SZ) {
                     will_fail = TRUE;