Newer
Older
/*
* Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
* Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
* Copyright (c) 1999-2001 by Hewlett-Packard Company. All rights reserved.
*
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
*
* Permission is hereby granted to use or copy this program
* for any purpose, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
/* Boehm, July 31, 1995 5:02 pm PDT */
#include <stdio.h>
#include <limits.h>
#define I_HIDE_POINTERS /* To make GC_call_with_alloc_lock visible */
#ifdef GC_SOLARIS_THREADS
#if defined(MSWIN32) || defined(MSWINCE)
# define WIN32_LEAN_AND_MEAN
# define NOSERVICE
#endif
# ifdef THREADS
# ifdef PCR
# include "il/PCR_IL.h"
PCR_Th_ML GC_allocate_ml;
# else
# ifdef SRC_M3
/* Critical section counter is defined in the M3 runtime */
/* That's all we use. */
# else
# ifdef GC_SOLARIS_THREADS
mutex_t GC_allocate_ml; /* Implicitly initialized. */
# else
# if defined(GC_WIN32_THREADS)
# if defined(GC_PTHREADS)
pthread_mutex_t GC_allocate_ml = PTHREAD_MUTEX_INITIALIZER;
# elif defined(GC_DLL)
__declspec(dllexport) CRITICAL_SECTION GC_allocate_ml;
# else
CRITICAL_SECTION GC_allocate_ml;
# endif
# if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS)
# if defined(USE_SPIN_LOCK)
pthread_t GC_lock_holder = NO_THREAD;
# else
pthread_mutex_t GC_allocate_ml = PTHREAD_MUTEX_INITIALIZER;
pthread_t GC_lock_holder = NO_THREAD;
/* Used only for assertions, and to prevent */
/* recursive reentry in the system call wrapper. */
# endif
# else
# endif
# endif
# endif
# endif
# endif
# endif
/* Dont unnecessarily call GC_register_main_static_data() in case */
/* dyn_load.c isn't linked in. */
#ifdef DYNAMIC_LOADING
# define GC_REGISTER_MAIN_STATIC_DATA() GC_register_main_static_data()
#else
# define GC_REGISTER_MAIN_STATIC_DATA() TRUE
#endif
GC_FAR struct _GC_arrays GC_arrays /* = { 0 } */;
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;
#ifdef IA64
ptr_t GC_register_stackbottom = 0;
#endif
#ifndef NO_DEBUGGING
GC_bool GC_dump_regularly = 0; /* Generate regular debugging dumps. */
#endif
#ifdef KEEP_BACK_PTRS
long GC_backtraces = 0; /* Number of random backtraces to */
/* generate for each GC. */
#endif
#ifdef FIND_LEAK
int GC_find_leak = 1;
#else
int GC_find_leak = 0;
#endif
#ifdef ALL_INTERIOR_POINTERS
int GC_all_interior_pointers = 1;
#else
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))
{
return(0);
}
GC_PTR (*GC_oom_fn) GC_PROTO((size_t bytes_requested)) = GC_default_oom_fn;
extern signed_word GC_mem_found;
void * GC_project2(arg1, arg2)
void *arg1;
void *arg2;
{
return arg2;
}
# ifdef MERGE_SIZES
/* Set things up so that GC_size_map[i] >= words(i), */
/* but not too much bigger */
/* and so that size_map contains relatively few distinct entries */
/* This is stolen from Russ Atkinson's Cedar quantization */
/* alogrithm (but we precompute it). */
void GC_init_size_map()
{
register unsigned i;
/* Map size 0 to something bigger. */
/* This avoids problems at lower levels. */
/* One word objects don't have to be 2 word aligned, */
/* unless we're using mark bytes. */
for (i = 0; i < sizeof(word); i++) {
GC_size_map[i] = MIN_WORDS;
# if MIN_WORDS > 1
GC_size_map[sizeof(word)] = MIN_WORDS;
# else
GC_size_map[sizeof(word)] = ROUNDED_UP_WORDS(sizeof(word));
# endif
}
for (i = 8*sizeof(word) + 1; i <= 16 * sizeof(word); i++) {
GC_size_map[i] = (ROUNDED_UP_WORDS(i) + 1) & (~1);
}
# ifdef GC_GCJ_SUPPORT
/* Make all sizes up to 32 words predictable, so that a */
/* compiler can statically perform the same computation, */
/* or at least a computation that results in similar size */
/* classes. */
for (i = 16*sizeof(word) + 1; i <= 32 * sizeof(word); i++) {
GC_size_map[i] = (ROUNDED_UP_WORDS(i) + 3) & (~3);
}
# endif
/* We leave the rest of the array to be filled in on demand. */
}
Loading
Loading full blame...