WIN-31.1: boehm-gc don't do SEH in GCC
Adam Megacz
patches@lists.megacz.com
Sat Mar 9 00:07:00 GMT 2002
"Boehm, Hans" <hans_boehm@hp.com> writes:
> It looks to me like it's relatively easy to do that by suitably
> renaming the GC_win32s global (GC_no_win32_dlls?), initializing it
> to true in the gcc case, and dynamically setting it to true if we
> are really running on win32S (does it still exist?). But I haven't
> tried it. If that works, I'd favor such a patch. It seems like the
> most plausible short-term solution.
Sounds good to me. Tested crosscompiling linux-to-mingw. Ok to commit?
- a
2002-03-08 Adam Megacz <adam@xwt.org>
* dyn_load.c: Renamed GC_win32s to GC_no_win32_dlls.
* misc.c: Renamed GC_is_win32s() to GC_no_win32_dlls
* os_dep.c: Renamed GC_win32s to GC_no_win32_dlls and
statically initialized it to TRUE if compiling with GCC.
* win32_threads.c (thread_start): We no longer use SEH if
compiling with GCC.
* mark.c (GC_mark_some): We no longer use SEH if
compiling with GCC.
Index: dyn_load.c
===================================================================
RCS file: /cvs/gcc/gcc/boehm-gc/dyn_load.c,v
retrieving revision 1.15
diff -u -r1.15 dyn_load.c
--- dyn_load.c 2002/02/12 04:37:53 1.15
+++ dyn_load.c 2002/03/09 07:45:06
@@ -775,7 +775,7 @@
# endif
# ifndef MSWINCE
- extern GC_bool GC_win32s;
+ extern GC_bool GC_no_win32_dlls;
# endif
void GC_register_dynamic_libraries()
@@ -788,7 +788,7 @@
char * limit, * new_limit;
# ifdef MSWIN32
- if (GC_win32s) return;
+ if (GC_no_win32_dlls) return;
# endif
base = limit = p = GC_sysinfo.lpMinimumApplicationAddress;
# if defined(MSWINCE) && !defined(_WIN32_WCE_EMULATION)
Index: misc.c
===================================================================
RCS file: /cvs/gcc/gcc/boehm-gc/misc.c,v
retrieving revision 1.21
diff -u -r1.21 misc.c
--- misc.c 2002/02/12 04:37:53 1.21
+++ misc.c 2002/03/09 07:45:08
@@ -483,9 +483,9 @@
#endif
#ifdef MSWIN32
- extern GC_bool GC_is_win32s();
+extern GC_bool GC_no_win32_dlls;
#else
-# define GC_is_win32s() FALSE
+# define GC_no_win32_dlls FALSE
#endif
void GC_init_inner()
@@ -637,7 +637,7 @@
GC_pcr_install();
# endif
# if !defined(SMALL_CONFIG)
- if (!GC_is_win32s() && 0 != GETENV("GC_ENABLE_INCREMENTAL")) {
+ if (!GC_no_win32_dlls && 0 != GETENV("GC_ENABLE_INCREMENTAL")) {
GC_ASSERT(!GC_incremental);
GC_setpagesize();
# ifndef GC_SOLARIS_THREADS
@@ -681,7 +681,7 @@
LOCK();
if (GC_incremental) goto out;
GC_setpagesize();
- if (GC_is_win32s()) goto out;
+ if (GC_no_win32_dlls) goto out;
# ifndef GC_SOLARIS_THREADS
GC_dirty_init();
# endif
Index: os_dep.c
===================================================================
RCS file: /cvs/gcc/gcc/boehm-gc/os_dep.c,v
retrieving revision 1.21
diff -u -r1.21 os_dep.c
--- os_dep.c 2002/02/12 04:37:53 1.21
+++ os_dep.c 2002/03/09 07:45:15
@@ -928,19 +928,17 @@
/* all real work is done by GC_register_dynamic_libraries. Under */
/* win32s, we cannot find the data segments associated with dll's. */
/* We rgister the main data segment here. */
- GC_bool GC_win32s = FALSE; /* We're running under win32s. */
+# ifdef __GCC__
+ GC_bool GC_no_win32_dlls = TRUE; /* GCC can't do SEH, so we can't use VirtualQuery */
+# else
+ GC_bool GC_no_win32_dlls = FALSE;
+# endif
- GC_bool GC_is_win32s()
- {
- DWORD v = GetVersion();
-
- /* Check that this is not NT, and Windows major version <= 3 */
- return ((v & 0x80000000) && (v & 0xff) <= 3);
- }
-
void GC_init_win32()
{
- GC_win32s = GC_is_win32s();
+ /* if we're running under win32s, assume that no DLLs will be loaded */
+ DWORD v = GetVersion();
+ GC_no_win32_dlls |= ((v & 0x80000000) && (v & 0xff) <= 3);
}
/* Return the smallest address a such that VirtualQuery */
@@ -1008,7 +1006,7 @@
char * base;
char * limit, * new_limit;
- if (!GC_win32s) return;
+ if (!GC_no_win32_dlls) return;
p = base = limit = GC_least_described_address(static_root);
while (p < GC_sysinfo.lpMaximumApplicationAddress) {
result = VirtualQuery(p, &buf, sizeof(buf));
@@ -1307,7 +1305,7 @@
# ifdef USE_GLOBAL_ALLOC
# define GLOBAL_ALLOC_TEST 1
# else
-# define GLOBAL_ALLOC_TEST GC_win32s
+# define GLOBAL_ALLOC_TEST GC_no_win32_dlls
# endif
word GC_n_heap_bases = 0;
@@ -1338,7 +1336,7 @@
void GC_win32_free_heap ()
{
- if (GC_win32s) {
+ 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;
Index: win32_threads.c
===================================================================
RCS file: /cvs/gcc/gcc/boehm-gc/win32_threads.c,v
retrieving revision 1.9
diff -u -r1.9 win32_threads.c
--- win32_threads.c 2002/02/25 04:04:43 1.9
+++ win32_threads.c 2002/03/09 07:45:17
@@ -447,16 +447,22 @@
/* Clear the thread entry even if we exit with an exception. */
/* This is probably pointless, since an uncaught exception is */
/* supposed to result in the process being killed. */
+#ifndef __GNUC__
__try {
+#endif /* __GNUC__ */
ret = args.start (args.param);
+#ifndef __GNUC__
} __finally {
+#endif /* __GNUC__ */
LOCK();
args.entry->stack = 0;
args.entry->in_use = FALSE;
/* cast away volatile qualifier */
BZERO((void *) &args.entry->context, sizeof(CONTEXT));
UNLOCK();
+#ifndef __GNUC__
}
+#endif /* __GNUC__ */
return ret;
}
Index: mark.c
===================================================================
RCS file: /cvs/gcc/gcc/boehm-gc/mark.c,v
retrieving revision 1.12
diff -u -r1.12 mark.c
--- mark.c 2002/02/12 04:37:53 1.12
+++ mark.c 2002/03/09 07:45:21
@@ -264,7 +264,7 @@
GC_bool GC_mark_some(cold_gc_frame)
ptr_t cold_gc_frame;
{
-#ifdef MSWIN32
+#if defined(MSWIN32) && !defined(__GNUC__)
/* Windows 98 appears to asynchronously create and remove writable */
/* memory mappings, for reasons we haven't yet understood. Since */
/* we look for writable regions to determine the root set, we may */
@@ -274,7 +274,7 @@
/* Note that this code should never generate an incremental GC write */
/* fault. */
__try {
-#endif
+#endif /* defined(MSWIN32) && !defined(__GNUC__) */
switch(GC_mark_state) {
case MS_NONE:
return(FALSE);
@@ -395,7 +395,7 @@
ABORT("GC_mark_some: bad state");
return(FALSE);
}
-#ifdef MSWIN32
+#if defined(MSWIN32) && !defined(__GNUC__)
} __except (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ?
EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
# ifdef CONDPRINT
@@ -410,7 +410,7 @@
scan_ptr = 0;
return FALSE;
}
-#endif /* MSWIN32 */
+#endif /* defined(MSWIN32) && !defined(__GNUC__) */
}
More information about the Java-patches
mailing list