+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
{ 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;
}
void GC_init_dyld(void) {
static GC_bool initialized = FALSE;
- char *bind_fully_env = NULL;
if(initialized) return;
# 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");
}
/* 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;