aboutsummaryrefslogtreecommitdiffstats
path: root/gc/misc.c
diff options
context:
space:
mode:
authorFumitoshi UKAI <ukai@debian.or.jp>2002-07-10 14:21:11 +0000
committerFumitoshi UKAI <ukai@debian.or.jp>2002-07-10 14:21:11 +0000
commitbb118b7356439a930be13962ced5f36aab9f74bf (patch)
tree5a9fad8dd6dc7f236bfc8e6b22c04cad0b837928 /gc/misc.c
parentdelete old ftp site (diff)
downloadw3m-bb118b7356439a930be13962ced5f36aab9f74bf.tar.gz
w3m-bb118b7356439a930be13962ced5f36aab9f74bf.zip
import gc6.1alpha5
Diffstat (limited to '')
-rw-r--r--gc/misc.c130
1 files changed, 80 insertions, 50 deletions
diff --git a/gc/misc.c b/gc/misc.c
index 2d516a7..d62c98c 100644
--- a/gc/misc.c
+++ b/gc/misc.c
@@ -16,6 +16,7 @@
#include <stdio.h>
+#include <limits.h>
#ifndef _WIN32_WCE
#include <signal.h>
#endif
@@ -45,8 +46,10 @@
# ifdef GC_SOLARIS_THREADS
mutex_t GC_allocate_ml; /* Implicitly initialized. */
# else
-# ifdef GC_WIN32_THREADS
-# if !defined(GC_NOT_DLL) && (defined(_DLL) || defined(GC_DLL))
+# if defined(GC_WIN32_THREADS)
+# if defined(GC_PTHREADS)
+ pthread_mutex_t GC_allocate_ml = PTHREAD_MUTEX_INITIALIZER;
+# elif !defined(GC_NOT_DLL) && (defined(_DLL) || defined(GC_DLL))
__declspec(dllexport) CRITICAL_SECTION GC_allocate_ml;
# else
CRITICAL_SECTION GC_allocate_ml;
@@ -70,7 +73,7 @@
# endif
# endif
-#ifdef ECOS
+#if defined(NOSYS) || defined(ECOS)
#undef STACKBASE
#endif
@@ -81,6 +84,7 @@ GC_bool GC_debugging_started = FALSE;
/* defined here so we don't have to load debug_malloc.o */
void (*GC_check_heap) GC_PROTO((void)) = (void (*) GC_PROTO((void)))0;
+void (*GC_print_all_smashed) GC_PROTO((void)) = (void (*) GC_PROTO((void)))0;
void (*GC_start_call_back) GC_PROTO((void)) = (void (*) GC_PROTO((void)))0;
@@ -112,6 +116,12 @@ GC_bool GC_print_back_height = 0;
int GC_all_interior_pointers = 0;
#endif
+long GC_large_alloc_warn_interval = 5;
+ /* Interval between unsuppressed warnings. */
+
+long GC_large_alloc_warn_suppressed = 0;
+ /* Number of warnings suppressed so far. */
+
/*ARGSUSED*/
GC_PTR GC_default_oom_fn GC_PROTO((size_t bytes_requested))
{
@@ -439,6 +449,11 @@ void GC_init()
DCL_LOCK_STATE;
DISABLE_SIGNALS();
+
+#if defined(GC_WIN32_THREADS) && !defined(GC_PTHREADS)
+ if (!GC_is_initialized) InitializeCriticalSection(&GC_allocate_ml);
+#endif /* MSWIN32 */
+
LOCK();
GC_init_inner();
UNLOCK();
@@ -477,6 +492,12 @@ int sig;
}
#endif
+#ifdef MSWIN32
+extern GC_bool GC_no_win32_dlls;
+#else
+# define GC_no_win32_dlls FALSE
+#endif
+
void GC_init_inner()
{
# if !defined(THREADS) && defined(GC_ASSERTIONS)
@@ -488,6 +509,9 @@ void GC_init_inner()
# ifdef PRINTSTATS
GC_print_stats = 1;
# endif
+# if defined(MSWIN32) || defined(MSWINCE)
+ InitializeCriticalSection(&GC_write_cs);
+# endif
if (0 != GETENV("GC_PRINT_STATS")) {
GC_print_stats = 1;
}
@@ -503,6 +527,33 @@ void GC_init_inner()
if (0 != GETENV("GC_PRINT_BACK_HEIGHT")) {
GC_print_back_height = 1;
}
+ if (0 != GETENV("GC_NO_BLACKLIST_WARNING")) {
+ GC_large_alloc_warn_interval = LONG_MAX;
+ }
+ {
+ char * time_limit_string = GETENV("GC_PAUSE_TIME_TARGET");
+ if (0 != time_limit_string) {
+ long time_limit = atol(time_limit_string);
+ if (time_limit < 5) {
+ WARN("GC_PAUSE_TIME_TARGET environment variable value too small "
+ "or bad syntax: Ignoring\n", 0);
+ } else {
+ GC_time_limit = time_limit;
+ }
+ }
+ }
+ {
+ char * interval_string = GETENV("GC_LARGE_ALLOC_WARN_INTERVAL");
+ if (0 != interval_string) {
+ long interval = atol(interval_string);
+ if (interval <= 0) {
+ WARN("GC_LARGE_ALLOC_WARN_INTERVAL environment variable has "
+ "bad value: Ignoring\n", 0);
+ } else {
+ GC_large_alloc_warn_interval = interval;
+ }
+ }
+ }
# ifdef UNIX_LIKE
if (0 != GETENV("GC_LOOP_ON_ABORT")) {
GC_set_and_save_fault_handler(looping_handler);
@@ -512,9 +563,6 @@ void GC_init_inner()
if (ALIGNMENT > GC_DS_TAGS && EXTRA_BYTES != 0) {
GC_obj_kinds[NORMAL].ok_descriptor = ((word)(-ALIGNMENT) | GC_DS_LENGTH);
}
-# if defined(MSWIN32) || defined(MSWINCE)
- InitializeCriticalSection(&GC_write_cs);
-# endif
GC_setpagesize();
GC_exclude_static_roots(beginGC_arrays, endGC_arrays);
GC_exclude_static_roots(beginGC_obj_kinds, endGC_obj_kinds);
@@ -612,8 +660,19 @@ void GC_init_inner()
PCR_IL_Unlock();
GC_pcr_install();
# endif
- /* Get black list set up */
- if (!GC_dont_precollect) GC_gcollect_inner();
+# if !defined(SMALL_CONFIG)
+ if (!GC_no_win32_dlls && 0 != GETENV("GC_ENABLE_INCREMENTAL")) {
+ GC_ASSERT(!GC_incremental);
+ GC_setpagesize();
+# ifndef GC_SOLARIS_THREADS
+ GC_dirty_init();
+# endif
+ GC_ASSERT(GC_words_allocd == 0)
+ GC_incremental = TRUE;
+ }
+# endif /* !SMALL_CONFIG */
+ /* Get black list set up and/or incrmental GC started */
+ if (!GC_dont_precollect || GC_incremental) GC_gcollect_inner();
GC_is_initialized = TRUE;
# ifdef STUBBORN_ALLOC
GC_stubborn_init();
@@ -646,20 +705,14 @@ void GC_enable_incremental GC_PROTO(())
LOCK();
if (GC_incremental) goto out;
GC_setpagesize();
-# ifdef MSWIN32
- {
- extern GC_bool GC_is_win32s();
-
- /* VirtualProtect is not functional under win32s. */
- if (GC_is_win32s()) goto out;
- }
-# endif /* MSWIN32 */
+ if (GC_no_win32_dlls) goto out;
# ifndef GC_SOLARIS_THREADS
GC_dirty_init();
# endif
if (!GC_is_initialized) {
GC_init_inner();
}
+ if (GC_incremental) goto out;
if (GC_dont_gc) {
/* Can't easily do it. */
UNLOCK();
@@ -745,7 +798,8 @@ int GC_tmp; /* Should really be local ... */
# endif
#endif
-#if !defined(MSWIN32) && !defined(MSWINCE) && !defined(OS2) && !defined(MACOS)
+#if !defined(MSWIN32) && !defined(MSWINCE) && !defined(OS2) \
+ && !defined(MACOS) && !defined(ECOS) && !defined(NOSYS)
int GC_write(fd, buf, len)
int fd;
GC_CONST char *buf;
@@ -768,7 +822,7 @@ size_t len;
}
#endif /* UN*X */
-#if defined(ECOS)
+#ifdef ECOS
int GC_write(fd, buf, len)
{
_Jv_diag_write (buf, len);
@@ -776,6 +830,14 @@ int GC_write(fd, buf, len)
}
#endif
+#ifdef NOSYS
+int GC_write(fd, buf, len)
+{
+ /* No writing. */
+ return len;
+}
+#endif
+
#if defined(MSWIN32) || defined(MSWINCE)
# define WRITE(f, buf, len) GC_write(buf, len)
@@ -890,38 +952,6 @@ GC_CONST char * msg;
}
#endif
-#ifdef NEED_CALLINFO
-
-void GC_print_callers (info)
-struct callinfo info[NFRAMES];
-{
- register int i;
-
-# if NFRAMES == 1
- GC_err_printf0("\tCaller at allocation:\n");
-# else
- GC_err_printf0("\tCall chain at allocation:\n");
-# endif
- for (i = 0; i < NFRAMES; i++) {
- if (info[i].ci_pc == 0) break;
-# if NARGS > 0
- {
- int j;
-
- GC_err_printf0("\t\targs: ");
- for (j = 0; j < NARGS; j++) {
- if (j != 0) GC_err_printf0(", ");
- GC_err_printf2("%d (0x%X)", ~(info[i].ci_arg[j]),
- ~(info[i].ci_arg[j]));
- }
- GC_err_printf0("\n");
- }
-# endif
- GC_err_printf1("\t\t##PC##= 0x%X\n", info[i].ci_pc);
- }
-}
-
-#endif /* SAVE_CALL_CHAIN */
/* Needed by SRC_M3, gcj, and should perhaps be the official interface */
/* to GC_dont_gc. */