From: ivmai Date: Fri, 19 Mar 2010 19:21:02 +0000 (+0000) Subject: 2010-03-19 Ivan Maidanski (really Dave Korn) X-Git-Tag: gc7_2alpha5-20110107~59 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=40d3de7f9affcc48104b505b4903f164f6b672ff;p=gc 2010-03-19 Ivan Maidanski (really Dave Korn) * dyn_load.c (GC_get_next_stack, GC_cond_add_roots): Define for Cygwin as well as other win32 targets. * dyn_load.c (GC_wnt): Define to constant true. * dyn_load.c (GC_register_dynamic_libraries): Define for Cygwin as well as other win32 targets. * mark_rts.c (rt_hash, GC_roots_present, add_roots_to_index): Don't define for Cygwin, as on other win32. * mark_rts.c (GC_add_roots_inner, GC_clear_roots): Handle on Cygwin as for other win32 targets. * mark_rts.c (GC_rebuild_root_index): Don't declare on Cygwin, as other win32. * mark_rts.c (GC_remove_tmp_roots): Do declare on Cygwin as on other win32. * mark_rts.c (GC_remove_roots, GC_remove_roots_inner): Don't declare on Cygwin as on other win32. * mark_rts.c (GC_is_tmp_root): Do declare on Cygwin when !NO_DEBUGGING, as on other win32 targets. * mark_rts.c (GC_cond_register_dynamic_libraries): Handle on Cygwin as for other win32 targets. * os_dep.c (GC_setpagesize): Handle on Cygwin as on other win32. * os_dep.c (GC_get_main_stack_base): Don't declare on Cygwin, as other win32. * os_dep.c (GC_sysinfo): Declare on Cygwin, as other win32. * os_dep.c (GC_win32_get_mem): Declare on Cygwin, as on other Win32, but call GC_unix_get_mem instead of GlobalAlloc. * os_dep.c (GC_win32_free_heap): Declare on Cygwin (as empty). * ptr_chck.c (GC_is_visible): Register dynamic libraries on Cygwin as on other win32 platforms. * win32_threads.c (GC_get_next_stack): Define on Cygwin as well as for dynamic loading targets. * include/private/gc_priv.h (GC_INNER): Don't try to use visibility on Cygwin which does not support it. * include/private/gc_priv.h (struct roots): Don't declare r_next member on Cygwin as on other windows hosts. * include/private/gc_priv.h (LOG_RT_SIZE, RT_SIZE): Don't define likewise. * include/private/gc_priv.h (struct _GC_arrays): Do declare _heap_bases[] member and don't declare _root_index likewise. * include/private/gc_priv.h (GC_heap_bases): Do define likewise. * include/private/gc_priv.h (_SYSTEM_INFO): Do forward-declare likewise. * include/private/gc_priv.h (GC_sysinfo): Do declare extern likewise. * include/private/gcconfig.h (GC_win32_get_mem, GET_MEM): Do prototype on Cygwin as other win32 platforms. --- diff --git a/ChangeLog b/ChangeLog index 092c572c..9cf21518 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,51 @@ +2010-03-19 Ivan Maidanski (really Dave Korn) + + * dyn_load.c (GC_get_next_stack, GC_cond_add_roots): Define for + Cygwin as well as other win32 targets. + * dyn_load.c (GC_wnt): Define to constant true. + * dyn_load.c (GC_register_dynamic_libraries): Define for Cygwin as + well as other win32 targets. + * mark_rts.c (rt_hash, GC_roots_present, add_roots_to_index): + Don't define for Cygwin, as on other win32. + * mark_rts.c (GC_add_roots_inner, GC_clear_roots): Handle on + Cygwin as for other win32 targets. + * mark_rts.c (GC_rebuild_root_index): Don't declare on Cygwin, as + other win32. + * mark_rts.c (GC_remove_tmp_roots): Do declare on Cygwin as on + other win32. + * mark_rts.c (GC_remove_roots, GC_remove_roots_inner): Don't + declare on Cygwin as on other win32. + * mark_rts.c (GC_is_tmp_root): Do declare on Cygwin when + !NO_DEBUGGING, as on other win32 targets. + * mark_rts.c (GC_cond_register_dynamic_libraries): Handle on + Cygwin as for other win32 targets. + * os_dep.c (GC_setpagesize): Handle on Cygwin as on other win32. + * os_dep.c (GC_get_main_stack_base): Don't declare on Cygwin, as + other win32. + * os_dep.c (GC_sysinfo): Declare on Cygwin, as other win32. + * os_dep.c (GC_win32_get_mem): Declare on Cygwin, as on other + Win32, but call GC_unix_get_mem instead of GlobalAlloc. + * os_dep.c (GC_win32_free_heap): Declare on Cygwin (as empty). + * ptr_chck.c (GC_is_visible): Register dynamic libraries on Cygwin + as on other win32 platforms. + * win32_threads.c (GC_get_next_stack): Define on Cygwin as well as + for dynamic loading targets. + * include/private/gc_priv.h (GC_INNER): Don't try to use + visibility on Cygwin which does not support it. + * include/private/gc_priv.h (struct roots): Don't declare r_next + member on Cygwin as on other windows hosts. + * include/private/gc_priv.h (LOG_RT_SIZE, RT_SIZE): Don't define + likewise. + * include/private/gc_priv.h (struct _GC_arrays): Do declare + _heap_bases[] member and don't declare _root_index likewise. + * include/private/gc_priv.h (GC_heap_bases): Do define likewise. + * include/private/gc_priv.h (_SYSTEM_INFO): Do forward-declare + likewise. + * include/private/gc_priv.h (GC_sysinfo): Do declare extern + likewise. + * include/private/gcconfig.h (GC_win32_get_mem, GET_MEM): Do + prototype on Cygwin as other win32 platforms. + 2010-03-13 Ivan Maidanski * os_dep.c (GC_get_main_stack_base): Use pthread_getattr_np() and diff --git a/dyn_load.c b/dyn_load.c index d9799db1..8b5eb9d6 100644 --- a/dyn_load.c +++ b/dyn_load.c @@ -52,11 +52,11 @@ /* FIXME: Add filter support for more platforms. */ STATIC GC_has_static_roots_func GC_has_static_roots = 0; -#if (defined(DYNAMIC_LOADING) || defined(MSWIN32) || defined(MSWINCE)) \ - && !defined(PCR) +#if (defined(DYNAMIC_LOADING) || defined(MSWIN32) || defined(MSWINCE) \ + || defined(CYGWIN32)) && !defined(PCR) #if !defined(SOLARISDL) && !defined(IRIX5) && \ - !defined(MSWIN32) && !defined(MSWINCE) && \ + !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) && \ !(defined(ALPHA) && defined(OSF1)) && \ !defined(HPUX) && !(defined(LINUX) && defined(__ELF__)) && \ !defined(AIX) && !defined(SCO_ELF) && !defined(DGUX) && \ @@ -842,7 +842,7 @@ GC_INNER void GC_register_dynamic_libraries(void) /* GC_register_main_static_data is not needed unless DYNAMIC_LOADING. */ GC_INNER GC_bool GC_register_main_static_data(void) { -# ifdef MSWINCE +# if defined(MSWINCE) || defined(CYGWIN32) /* Do we need to separately register the main static data segment? */ return FALSE; # else @@ -864,7 +864,7 @@ GC_INNER void GC_register_dynamic_libraries(void) } # endif /* DEBUG_VIRTUALQUERY */ -# ifdef MSWINCE +# if defined(MSWINCE) || defined(CYGWIN32) /* FIXME: Should we really need to scan MEM_PRIVATE sections? */ /* For now, we don't add MEM_PRIVATE sections to the data roots for */ /* WinCE because otherwise SEGV fault sometimes happens to occur in */ diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index cf28d159..c93aac96 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -104,7 +104,7 @@ typedef char * ptr_t; /* A generic pointer to which we can add */ /* called from the "dated" source files (pcr_interface.c, specific.c */ /* and in the "extra" folder). */ # if defined(GC_DLL) && defined(__GNUC__) && !defined(MSWIN32) \ - && !defined(MSWINCE) + && !defined(MSWINCE) && !defined(CYGWIN32) # if __GNUC__ >= 4 /* See the corresponding GC_API definition. */ # define GC_INNER __attribute__((__visibility__("hidden"))) @@ -920,14 +920,14 @@ struct exclusion { struct roots { ptr_t r_start;/* multiple of word size */ ptr_t r_end; /* multiple of word size and greater than r_start */ -# if !defined(MSWIN32) && !defined(MSWINCE) +# if !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) struct roots * r_next; # endif GC_bool r_tmp; /* Delete before registering new dynamic libraries */ }; -#if !defined(MSWIN32) && !defined(MSWINCE) +#if !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) /* Size of hash table index to roots. */ # define LOG_RT_SIZE 6 # define RT_SIZE (1 << LOG_RT_SIZE) /* Power of 2, may be != MAX_ROOT_SETS */ @@ -1112,7 +1112,7 @@ struct _GC_arrays { /* memory. Includes block */ /* headers and the like. */ # endif -# if defined(MSWIN32) || defined(MSWINCE) +# if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32) ptr_t _heap_bases[MAX_HEAP_SECTS]; /* Start address of memory regions obtained from kernel. */ # endif @@ -1121,7 +1121,7 @@ struct _GC_arrays { /* Committed lengths of memory regions obtained from kernel. */ # endif struct roots _static_roots[MAX_ROOT_SETS]; -# if !defined(MSWIN32) && !defined(MSWINCE) +# if !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) struct roots * _root_index[RT_SIZE]; # endif struct exclusion _excl_table[MAX_EXCLUSIONS]; @@ -1192,7 +1192,7 @@ GC_API_PRIV GC_FAR struct _GC_arrays GC_arrays; # else # define GC_unmapped_bytes 0 # endif -# if defined(MSWIN32) || defined(MSWINCE) +# if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32) # define GC_heap_bases GC_arrays._heap_bases # endif # ifdef MSWINCE @@ -1289,7 +1289,7 @@ GC_EXTERN word GC_n_heap_sects; /* Number of separately added heap */ GC_EXTERN word GC_page_size; -#if defined(MSWIN32) || defined(MSWINCE) +#if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32) struct _SYSTEM_INFO; GC_EXTERN struct _SYSTEM_INFO GC_sysinfo; #endif @@ -1537,7 +1537,7 @@ GC_INNER void GC_set_fl_marks(ptr_t p); void GC_add_roots_inner(ptr_t b, ptr_t e, GC_bool tmp); GC_INNER void GC_exclude_static_roots_inner(void *start, void *finish); #if defined(DYNAMIC_LOADING) || defined(MSWIN32) || defined(MSWINCE) \ - || defined(PCR) + || defined(CYGWIN32) || defined(PCR) GC_INNER void GC_register_dynamic_libraries(void); /* Add dynamic library data sections to the root set. */ #endif diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index 4bacda7b..f82a1ca1 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -2567,7 +2567,7 @@ (defined(SOLARIS) && !defined(USE_MMAP)) # define GET_MEM(bytes) HBLKPTR((size_t) calloc(1, (size_t)bytes + GC_page_size) \ + GC_page_size-1) -# elif defined(MSWIN32) +# elif defined(MSWIN32) || defined(CYGWIN32) ptr_t GC_win32_get_mem(GC_word bytes); # define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes) # elif defined(MACOS) diff --git a/mark_rts.c b/mark_rts.c index 377be443..c47e17a5 100644 --- a/mark_rts.c +++ b/mark_rts.c @@ -24,7 +24,7 @@ struct roots { ptr_t r_start; ptr_t r_end; -# if !defined(MSWIN32) && !defined(MSWINCE) +# if !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) struct roots * r_next; # endif GC_bool r_tmp; @@ -83,7 +83,7 @@ static int n_root_sets = 0; } #endif /* !THREADS */ -#if !defined(MSWIN32) && !defined(MSWINCE) +#if !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) /* # define LOG_RT_SIZE 6 # define RT_SIZE (1 << LOG_RT_SIZE) -- Power of 2, may be != MAX_ROOT_SETS @@ -131,7 +131,7 @@ static int n_root_sets = 0; p -> r_next = GC_root_index[h]; GC_root_index[h] = p; } -#endif /* !MSWIN32 */ +#endif /* !MSWIN32 && !MSWINCE && !CYGWIN32 */ GC_INNER word GC_root_size = 0; @@ -162,7 +162,7 @@ void GC_add_roots_inner(ptr_t b, ptr_t e, GC_bool tmp) GC_ASSERT(b <= e); if (b == e) return; /* nothing to do? */ -# if defined(MSWIN32) || defined(MSWINCE) +# if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32) /* Spend the time to ensure that there are no overlapping */ /* or adjacent intervals. */ /* This could be done faster with e.g. a */ @@ -231,7 +231,7 @@ void GC_add_roots_inner(ptr_t b, ptr_t e, GC_bool tmp) GC_static_roots[n_root_sets].r_start = (ptr_t)b; GC_static_roots[n_root_sets].r_end = (ptr_t)e; GC_static_roots[n_root_sets].r_tmp = tmp; -# if !defined(MSWIN32) && !defined(MSWINCE) +# if !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) GC_static_roots[n_root_sets].r_next = 0; add_roots_to_index(GC_static_roots + n_root_sets); # endif @@ -250,7 +250,7 @@ GC_API void GC_CALL GC_clear_roots(void) roots_were_cleared = TRUE; n_root_sets = 0; GC_root_size = 0; -# if !defined(MSWIN32) && !defined(MSWINCE) +# if !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) { int i; for (i = 0; i < RT_SIZE; i++) GC_root_index[i] = 0; @@ -269,7 +269,7 @@ STATIC void GC_remove_root_at_pos(int i) n_root_sets--; } -#if !defined(MSWIN32) && !defined(MSWINCE) +#if !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) STATIC void GC_rebuild_root_index(void) { int i; @@ -281,7 +281,7 @@ STATIC void GC_remove_root_at_pos(int i) #endif #if defined(DYNAMIC_LOADING) || defined(MSWIN32) || defined(MSWINCE) \ - || defined(PCR) + || defined(PCR) || defined(CYGWIN32) /* Internal use only; lock held. */ STATIC void GC_remove_tmp_roots(void) { @@ -294,13 +294,13 @@ STATIC void GC_remove_tmp_roots(void) i++; } } -# if !defined(MSWIN32) && !defined(MSWINCE) +# if !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) GC_rebuild_root_index(); # endif } #endif -#if !defined(MSWIN32) && !defined(MSWINCE) +#if !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) STATIC void GC_remove_roots_inner(ptr_t b, ptr_t e); GC_API void GC_CALL GC_remove_roots(void *b, void *e) @@ -331,9 +331,10 @@ STATIC void GC_remove_tmp_roots(void) } GC_rebuild_root_index(); } -#endif /* !defined(MSWIN32) && !defined(MSWINCE) */ +#endif /* !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) */ -#if (defined(MSWIN32) || defined(MSWINCE)) && !defined(NO_DEBUGGING) +#if (defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32)) \ + && !defined(NO_DEBUGGING) /* Not used at present (except for, may be, debugging purpose). */ /* Workaround for the OS mapping and unmapping behind our back: */ /* Is the address p in one of the temporary static root sections? */ @@ -355,7 +356,7 @@ STATIC void GC_remove_tmp_roots(void) } return(FALSE); } -#endif /* MSWIN32 || MSWINCE */ +#endif /* MSWIN32 || MSWINCE || CYGWIN32 */ GC_INNER ptr_t GC_approx_sp(void) { @@ -700,7 +701,7 @@ STATIC void GC_push_gc_structures(void) GC_INNER void GC_cond_register_dynamic_libraries(void) { # if defined(DYNAMIC_LOADING) || defined(MSWIN32) || defined(MSWINCE) \ - || defined(PCR) + || defined(CYGWIN32) || defined(PCR) GC_remove_tmp_roots(); if (!GC_no_dls) GC_register_dynamic_libraries(); # else diff --git a/os_dep.c b/os_dep.c index e8d50547..5b2e8139 100644 --- a/os_dep.c +++ b/os_dep.c @@ -690,7 +690,7 @@ struct o32_obj { /* Find the page size */ GC_INNER word GC_page_size = 0; -# if defined(MSWIN32) || defined(MSWINCE) +# if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32) # ifndef VER_PLATFORM_WIN32_CE # define VER_PLATFORM_WIN32_CE 3 @@ -1537,7 +1537,7 @@ void GC_register_data_segments(void) # define GetWriteWatch_alloc_flag 0 # endif /* GWW_VDB */ -# if defined(MSWIN32) || defined(MSWINCE) +# if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32) # ifdef MSWIN32 /* Unfortunately, we have to handle win32s very differently from NT, */ @@ -1593,7 +1593,7 @@ void GC_register_data_segments(void) } return p; } -# endif +# endif /* MSWIN32 */ # ifndef REDIRECT_MALLOC /* We maintain a linked list of AllocationBase values that we know */ @@ -1624,6 +1624,9 @@ void GC_register_data_segments(void) return FALSE; } + STATIC size_t GC_max_root_size = 100000; /* Appr. largest root size. */ + +# ifndef CYGWIN32 STATIC void *GC_get_allocation_base(void *p) { MEMORY_BASIC_INFORMATION buf; @@ -1634,8 +1637,6 @@ void GC_register_data_segments(void) return buf.AllocationBase; } - STATIC size_t GC_max_root_size = 100000; /* Appr. largest root size. */ - GC_INNER void GC_add_current_malloc_heap(void) { struct GC_malloc_heap_list *new_l = @@ -1665,7 +1666,9 @@ void GC_register_data_segments(void) new_l -> next = GC_malloc_heap_l; GC_malloc_heap_l = new_l; } -# endif /* REDIRECT_MALLOC */ +# endif /* !CYGWIN32 */ + +# endif /* !REDIRECT_MALLOC */ STATIC word GC_n_heap_bases = 0; /* See GC_heap_bases. */ @@ -1684,7 +1687,7 @@ void GC_register_data_segments(void) return FALSE; } -# ifdef MSWIN32 +#ifdef MSWIN32 STATIC void GC_register_root_section(ptr_t static_root) { MEMORY_BASIC_INFORMATION buf; @@ -1717,7 +1720,7 @@ void GC_register_data_segments(void) } if (base != limit) GC_add_roots_inner(base, limit, FALSE); } -#endif +#endif /* MSWIN32 */ void GC_register_data_segments(void) { @@ -2053,12 +2056,11 @@ void * os2_alloc(size_t bytes) # endif /* OS2 */ - -# if defined(MSWIN32) || defined(MSWINCE) +# if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32) GC_INNER SYSTEM_INFO GC_sysinfo; # endif -# ifdef MSWIN32 +#ifdef MSWIN32 # ifdef USE_GLOBAL_ALLOC # define GLOBAL_ALLOC_TEST 1 @@ -2066,19 +2068,26 @@ void * os2_alloc(size_t bytes) # define GLOBAL_ALLOC_TEST GC_no_win32_dlls # endif -#ifdef GC_USE_MEM_TOP_DOWN - STATIC DWORD GC_mem_top_down = MEM_TOP_DOWN; +# ifdef GC_USE_MEM_TOP_DOWN + STATIC DWORD GC_mem_top_down = MEM_TOP_DOWN; /* Use GC_USE_MEM_TOP_DOWN for better 64-bit */ /* testing. Otherwise all addresses tend to */ /* end up in first 4GB, hiding bugs. */ -#else - STATIC DWORD GC_mem_top_down = 0; -#endif +# else + STATIC DWORD GC_mem_top_down = 0; +# endif + +#endif /* MSWIN32 */ + +#if defined(MSWIN32) || defined(CYGWIN32) ptr_t GC_win32_get_mem(word bytes) { ptr_t result; +# ifdef CYGWIN32 + result = GC_unix_get_mem (bytes); +# else if (GLOBAL_ALLOC_TEST) { /* VirtualAlloc doesn't like PAGE_EXECUTE_READWRITE. */ /* There are also unconfirmed rumors of other */ @@ -2117,6 +2126,7 @@ ptr_t GC_win32_get_mem(word bytes) | GC_mem_top_down, PAGE_EXECUTE_READWRITE); } +# endif /* !CYGWIN32 */ if (HBLKDISPL(result) != 0) ABORT("Bad VirtualAlloc result"); /* If I read the documentation correctly, this can */ /* only happen if HBLKSIZE > 64k or not a power of 2. */ @@ -2127,14 +2137,17 @@ ptr_t GC_win32_get_mem(word bytes) GC_API void GC_CALL GC_win32_free_heap(void) { +# ifndef CYGWIN32 if (GC_no_win32_dlls) { while (GC_n_heap_bases > 0) { GlobalFree (GC_heap_bases[--GC_n_heap_bases]); GC_heap_bases[GC_n_heap_bases] = 0; } } -} # endif +} + +#endif /* MSWIN32 || CYGWIN32 */ #ifdef AMIGA # define GC_AMIGA_AM diff --git a/ptr_chck.c b/ptr_chck.c index 6195ac86..9b0da0c1 100644 --- a/ptr_chck.c +++ b/ptr_chck.c @@ -205,11 +205,11 @@ GC_API void * GC_CALL GC_is_visible(void *p) if (hhdr == 0) { if (GC_is_static_root(p)) return(p); /* Else do it again correctly: */ -# if (defined(DYNAMIC_LOADING) || defined(MSWIN32) || \ - defined(MSWINCE) || defined(PCR)) - GC_register_dynamic_libraries(); - if (GC_is_static_root(p)) - return(p); +# if defined(DYNAMIC_LOADING) || defined(MSWIN32) \ + || defined(MSWINCE) || defined(CYGWIN32) || defined(PCR) + GC_register_dynamic_libraries(); + if (GC_is_static_root(p)) + return(p); # endif goto fail; } else { diff --git a/win32_threads.c b/win32_threads.c index 9e852fad..b70b5ec3 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -1360,7 +1360,7 @@ GC_INNER void GC_push_all_stacks(void) #endif -#if !defined(CYGWIN32) || defined(DYNAMIC_LOADING) +#if defined(DYNAMIC_LOADING) || defined(CYGWIN32) /* Find stack with the lowest address which overlaps the */ /* interval [start, limit). */ /* Return stack bounds in *lo and *hi. If no such stack */ @@ -1463,7 +1463,7 @@ GC_INNER void GC_get_next_stack(char *start, char *limit, } *plast_stack_min = *lo; } -#endif /* !CYGWIN32 || DYNAMIC_LOADING */ +#endif /* DYNAMIC_LOADING || CYGWIN32 */ #ifdef PARALLEL_MARK