+2010-03-19 Ivan Maidanski <ivmai@mail.ru> (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 <ivmai@mail.ru>
* os_dep.c (GC_get_main_stack_base): Use pthread_getattr_np() and
/* 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) && \
/* 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
}
# 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 */
/* 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")))
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 */
/* 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
/* 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];
# 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
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
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
(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)
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;
}
#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
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;
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 */
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
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;
n_root_sets--;
}
-#if !defined(MSWIN32) && !defined(MSWINCE)
+#if !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32)
STATIC void GC_rebuild_root_index(void)
{
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)
{
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)
}
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? */
}
return(FALSE);
}
-#endif /* MSWIN32 || MSWINCE */
+#endif /* MSWIN32 || MSWINCE || CYGWIN32 */
GC_INNER ptr_t GC_approx_sp(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
/* 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
# 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, */
}
return p;
}
-# endif
+# endif /* MSWIN32 */
# ifndef REDIRECT_MALLOC
/* We maintain a linked list of AllocationBase values that we know */
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;
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 =
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. */
return FALSE;
}
-# ifdef MSWIN32
+#ifdef MSWIN32
STATIC void GC_register_root_section(ptr_t static_root)
{
MEMORY_BASIC_INFORMATION buf;
}
if (base != limit) GC_add_roots_inner(base, limit, FALSE);
}
-#endif
+#endif /* MSWIN32 */
void GC_register_data_segments(void)
{
# 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
# 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 */
| 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. */
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
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 {
#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 */
}
*plast_stack_min = *lo;
}
-#endif /* !CYGWIN32 || DYNAMIC_LOADING */
+#endif /* DYNAMIC_LOADING || CYGWIN32 */
#ifdef PARALLEL_MARK