* allchblk.c (DEBUG): Remove macro (since unused).
* allchblk.c: Include private/gc_priv.h before other includes and
definitions.
* alloc.c: Ditto.
* gc_dlopen.c: Ditto.
* headers.c: Ditto.
* mallocx.c: Ditto.
* mark_rts.c: Ditto.
* new_hblk.c: Ditto.
* reclaim.c: Ditto.
* mark.c: Include private/gc_pmark.h before other includes.
* misc.c: Ditto.
* dyn_load.c (_GNU_SOURCE): Move the definition to gc_priv.h.
* pthread_support.c (_USING_POSIX4A_DRAFT10): Ditto.
* pthread_support.c (_POSIX4A_DRAFT10_SOURCE): Remove (since
already defined in gc_config_macros.h).
* dyn_load.c (GC_init_dyld): Remove parameter cast for
_dyld_register_func_for_add_image() and
_dyld_register_func_for_remove_image(); add the comment about
possible warnings; add FIXME for the deprecated
_dyld_bind_fully_image_containing_address().
* include/private/gc_priv.h: Include gc.h before the standard
headers inclusion.
* tests/test.c: Ditto.
* include/private/gcconfig.h (DebugBreak): Update the comment.
* typd_mlc.c (ED_INITIAL_SIZE): Remove ';'.
* alloc.c: Reformat the code (partly adjust indentation).
* backgraph.c: Ditto.
* blacklst.c: Ditto.
* checksums.c: Ditto.
* finalize.c: Ditto.
* gcj_mlc.c: Ditto.
* mach_dep.c: Ditto.
* mark_rts.c: Ditto.
* obj_map.c: Ditto.
* os_dep.c: Ditto.
* ptr_chck.c: Ditto.
* stubborn.c: Ditto.
* thread_local_alloc.c: Ditto.
* typd_mlc.c: Ditto.
+2009-10-21 Ivan Maidanski <ivmai@mail.ru>
+
+ * allchblk.c (DEBUG): Remove macro (since unused).
+ * allchblk.c: Include private/gc_priv.h before other includes and
+ definitions.
+ * alloc.c: Ditto.
+ * gc_dlopen.c: Ditto.
+ * headers.c: Ditto.
+ * mallocx.c: Ditto.
+ * mark_rts.c: Ditto.
+ * new_hblk.c: Ditto.
+ * reclaim.c: Ditto.
+ * mark.c: Include private/gc_pmark.h before other includes.
+ * misc.c: Ditto.
+ * dyn_load.c (_GNU_SOURCE): Move the definition to gc_priv.h.
+ * pthread_support.c (_USING_POSIX4A_DRAFT10): Ditto.
+ * pthread_support.c (_POSIX4A_DRAFT10_SOURCE): Remove (since
+ already defined in gc_config_macros.h).
+ * dyn_load.c (GC_init_dyld): Remove parameter cast for
+ _dyld_register_func_for_add_image() and
+ _dyld_register_func_for_remove_image(); add the comment about
+ possible warnings; add FIXME for the deprecated
+ _dyld_bind_fully_image_containing_address().
+ * include/private/gc_priv.h: Include gc.h before the standard
+ headers inclusion.
+ * tests/test.c: Ditto.
+ * include/private/gcconfig.h (DebugBreak): Update the comment.
+ * typd_mlc.c (ED_INITIAL_SIZE): Remove ';'.
+ * alloc.c: Reformat the code (partly adjust indentation).
+ * backgraph.c: Ditto.
+ * blacklst.c: Ditto.
+ * checksums.c: Ditto.
+ * finalize.c: Ditto.
+ * gcj_mlc.c: Ditto.
+ * mach_dep.c: Ditto.
+ * mark_rts.c: Ditto.
+ * obj_map.c: Ditto.
+ * os_dep.c: Ditto.
+ * ptr_chck.c: Ditto.
+ * stubborn.c: Ditto.
+ * thread_local_alloc.c: Ditto.
+ * typd_mlc.c: Ditto.
+
2009-10-20 Ivan Maidanski <ivmai@mail.ru> (really mostly OpenBSD contributors)
* configure.ac (openbsd): Define GC_OPENBSD_THREADS.
* modified is included with the above copyright notice.
*/
-/* #define DEBUG */
-#include <stdio.h>
#include "private/gc_priv.h"
+#include <stdio.h>
+
GC_bool GC_use_entire_heap = 0;
/*
*
*/
-# include "private/gc_priv.h"
+#include "private/gc_priv.h"
-# include <stdio.h>
-# if !defined(MACOS) && !defined(MSWINCE)
-# include <signal.h>
-# include <sys/types.h>
-# endif
+#include <stdio.h>
+#if !defined(MACOS) && !defined(MSWINCE)
+# include <signal.h>
+# include <sys/types.h>
+#endif
/*
* Separate free lists are maintained for different sized objects
unsigned long GC_time_limit = GC_TIME_LIMIT;
#ifndef NO_CLOCK
-STATIC CLOCK_TYPE GC_start_time = 0;
+ STATIC CLOCK_TYPE GC_start_time = 0;
/* Time at which we stopped world. */
/* used only in GC_timeout_stop_func. */
#endif
}
#if defined(SMALL_CONFIG) || defined(NO_CLOCK)
-# define GC_timeout_stop_func GC_default_stop_func
+# define GC_timeout_stop_func GC_default_stop_func
#else
STATIC int GC_CALLBACK GC_timeout_stop_func (void)
{
return(result);
}
-# if !defined(REDIRECT_MALLOC) && (defined(MSWIN32) || defined(MSWINCE))
+#if !defined(REDIRECT_MALLOC) && (defined(MSWIN32) || defined(MSWINCE))
void GC_add_current_malloc_heap(void);
-# endif
+#endif
+
#ifdef MAKE_BACK_GRAPH
void GC_build_back_graph(void);
#endif
}
#ifdef GC_ASSERTIONS
-/* Check that all mark bits for the free list whose first entry is q */
-/* are set. */
-void GC_check_fl_marks(ptr_t q)
-{
+ /* Check that all mark bits for the free list whose first entry is q */
+ /* are set. */
+ void GC_check_fl_marks(ptr_t q)
+ {
ptr_t p;
for (p = q; p != 0; p = obj_link(p)) {
if (!GC_is_marked(p)) {
ABORT("Unmarked local free list entry.");
}
}
-}
+ }
#endif
/* Clear all mark bits for the free list whose first entry is q */
}
#if defined(GC_ASSERTIONS) && defined(THREADS) && defined(THREAD_LOCAL_ALLOC)
-void GC_check_tls(void);
+ void GC_check_tls(void);
#endif
#ifdef MAKE_BACK_GRAPH
-void GC_traverse_back_graph(void);
+ void GC_traverse_back_graph(void);
#endif
/* Finish up a collection. Assumes mark bits are consistent, lock is */
GC_n_memory++;
}
#endif
+
/*
* Use the chunk of memory starting at p of size bytes as part of the heap.
* Assumes p is HBLKSIZE aligned, and bytes is a multiple of HBLKSIZE.
}
}
-# if !defined(NO_DEBUGGING)
-void GC_print_heap_sects(void)
-{
+#if !defined(NO_DEBUGGING)
+ void GC_print_heap_sects(void)
+ {
unsigned i;
GC_printf("Total heap size: %lu\n", (unsigned long) GC_heapsize);
i, start, start + len,
(unsigned long)nbl, (unsigned long)(len/HBLKSIZE));
}
-}
-# endif
+ }
+#endif
void * GC_least_plausible_heap_addr = (void *)ONES;
void * GC_greatest_plausible_heap_addr = 0;
*
*/
+#include "private/dbg_mlc.h"
+
/*
* This implements a full, though not well-tuned, representation of the
* backwards points-to graph. This is used to test for non-GC-robust
* a growing space leak.
*/
-#include "private/dbg_mlc.h"
-
#ifdef MAKE_BACK_GRAPH
#define MAX_IN 10 /* Maximum in-degree we handle directly */
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
-/* Boehm, August 9, 1995 6:09 pm PDT */
-# include "private/gc_priv.h"
+
+#include "private/gc_priv.h"
/*
* We maintain several hash tables of hblks that have had false hits.
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
-/* Boehm, March 29, 1995 12:51 pm PST */
#include "private/gc_priv.h"
/* We assume that stubborn objects are changed only when they are */
/* enabled for writing. (Certain kinds of writing are actually */
/* safe under other conditions.) */
-# define NSUMS 10000
+#define NSUMS 10000
-# define OFFSET 0x10000
+#define OFFSET 0x10000
typedef struct {
GC_bool new_valid;
return(result | 0x80000000 /* doesn't look like pointer */);
}
-# ifdef STUBBORN_ALLOC
-/* Check whether a stubborn object from the given block appears on */
-/* the appropriate free list. */
-STATIC GC_bool GC_on_free_list(struct hblk *h)
-{
+#ifdef STUBBORN_ALLOC
+ /* Check whether a stubborn object from the given block appears on */
+ /* the appropriate free list. */
+ STATIC GC_bool GC_on_free_list(struct hblk *h)
+ {
hdr * hhdr = HDR(h);
size_t sz = BYTES_TO_WORDS(hhdr -> hb_sz);
ptr_t p;
if (HBLKPTR(p) == h) return(TRUE);
}
return(FALSE);
-}
-# endif
+ }
+#endif
int GC_n_dirty_errors = 0;
int GC_n_faulted_dirty_errors = 0;
(unsigned long)GC_n_changed_errors);
GC_printf("These may be benign (provoked by nonpointer changes)\n");
# ifdef THREADS
- GC_printf(
+ GC_printf(
"Also expect 1 per thread currently allocating a stubborn obj.\n");
# endif
}
* Heavily modified by Hans Boehm and others
*/
+#include "private/gc_priv.h"
+
/*
* This is incredibly OS specific code for tracking down data sections in
* dynamic libraries. There appears to be no way of doing this quickly
* But then not much of anything is safe in the presence of dlclose.
*/
-#if (defined(__linux__) || defined(__GLIBC__) || defined(__GNU__)) \
- && !defined(_GNU_SOURCE)
- /* Can't test LINUX, since this must be defined before other includes */
-# define _GNU_SOURCE
-#endif
-
-#include "private/gc_priv.h"
-
#if !defined(MACOS) && !defined(_WIN32_WCE)
# include <sys/types.h>
#endif
linked in the future.
*/
- _dyld_register_func_for_add_image(
- (void (*)(struct mach_header *, intptr_t))GC_dyld_image_add);
- _dyld_register_func_for_remove_image(
- (void (*)(struct mach_header *, intptr_t))GC_dyld_image_remove);
+ _dyld_register_func_for_add_image(GC_dyld_image_add);
+ _dyld_register_func_for_remove_image(GC_dyld_image_remove);
+ /* Ignore 2 compiler warnings here: passing argument 1 of */
+ /* '_dyld_register_func_for_add/remove_image' from incompatible */
+ /* pointer type. */
+
/* Set this early to avoid reentrancy issues. */
initialized = TRUE;
# ifdef DARWIN_DEBUG
GC_printf("Forcing full bind of GC code...\n");
# endif
+ /* FIXME: '_dyld_bind_fully_image_containing_address' is deprecated. */
if(!_dyld_bind_fully_image_containing_address((unsigned long*)GC_malloc))
ABORT("_dyld_bind_fully_image_containing_address failed");
}
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
-/* Boehm, February 1, 1996 1:19 pm PST */
#include "private/gc_pmark.h"
-# ifdef FINALIZE_ON_DEMAND
- int GC_finalize_on_demand = 1;
-# else
- int GC_finalize_on_demand = 0;
-# endif
+#ifdef FINALIZE_ON_DEMAND
+ int GC_finalize_on_demand = 1;
+#else
+ int GC_finalize_on_demand = 0;
+#endif
-# ifdef JAVA_FINALIZATION
- int GC_java_finalization = 1;
-# else
- int GC_java_finalization = 0;
-# endif
+#ifdef JAVA_FINALIZATION
+ int GC_java_finalization = 1;
+#else
+ int GC_java_finalization = 0;
+#endif
/* Type of mark procedure used for marking from finalizable object. */
/* This procedure normally does not mark the object, only its */
/* descendents. */
typedef void (* finalization_mark_proc)(ptr_t /* finalizable_obj_ptr */);
-# define HASH3(addr,size,log_size) \
- ((((word)(addr) >> 3) ^ ((word)(addr) >> (3+(log_size)))) \
- & ((size) - 1))
+#define HASH3(addr,size,log_size) \
+ ((((word)(addr) >> 3) ^ ((word)(addr) >> (3 + (log_size)))) \
+ & ((size) - 1))
#define HASH2(addr,log_size) HASH3(addr, 1 << log_size, log_size)
struct hash_chain_entry {
# define dl_hidden_link prolog.hidden_key
/* Field to be cleared. */
# define dl_next(x) (struct disappearing_link *)((x) -> prolog.next)
-# define dl_set_next(x,y) (x) -> prolog.next = (struct hash_chain_entry *)(y)
+# define dl_set_next(x,y) (x)->prolog.next = (struct hash_chain_entry *)(y)
word dl_hidden_obj; /* Pointer to object base */
} **dl_head = 0;
/* No longer hidden once object */
/* is on finalize_now queue. */
# define fo_next(x) (struct finalizable_object *)((x) -> prolog.next)
-# define fo_set_next(x,y) (x) -> prolog.next = (struct hash_chain_entry *)(y)
+# define fo_set_next(x,y) (x)->prolog.next = (struct hash_chain_entry *)(y)
GC_finalization_proc fo_fn; /* Finalizer. */
ptr_t fo_client_data;
word fo_object_size; /* In bytes. */
}
#ifndef NO_DEBUGGING
-void GC_dump_finalization(void)
-{
+ void GC_dump_finalization(void)
+ {
struct disappearing_link * curr_dl;
struct finalizable_object * curr_fo;
ptr_t real_ptr, real_link;
GC_printf("Finalizable object: %p\n", real_ptr);
}
}
-}
+ }
#endif
#ifndef SMALL_CONFIG
#ifndef JAVA_FINALIZATION_NOT_NEEDED
-/* Enqueue all remaining finalizers to be run - Assumes lock is held. */
-STATIC void GC_enqueue_all_finalizers(void)
-{
+ /* Enqueue all remaining finalizers to be run - Assumes lock is held. */
+ STATIC void GC_enqueue_all_finalizers(void)
+ {
struct finalizable_object * curr_fo, * prev_fo, * next_fo;
ptr_t real_ptr;
register int i;
}
return;
-}
+ }
-/* Invoke all remaining finalizers that haven't yet been run.
- * This is needed for strict compliance with the Java standard,
- * which can make the runtime guarantee that all finalizers are run.
- * Unfortunately, the Java standard implies we have to keep running
- * finalizers until there are no more left, a potential infinite loop.
- * YUCK.
- * Note that this is even more dangerous than the usual Java
- * finalizers, in that objects reachable from static variables
- * may have been finalized when these finalizers are run.
- * Finalizers run at this point must be prepared to deal with a
- * mostly broken world.
- * This routine is externally callable, so is called without
- * the allocation lock.
- */
-GC_API void GC_CALL GC_finalize_all(void)
-{
+ /* Invoke all remaining finalizers that haven't yet been run.
+ * This is needed for strict compliance with the Java standard,
+ * which can make the runtime guarantee that all finalizers are run.
+ * Unfortunately, the Java standard implies we have to keep running
+ * finalizers until there are no more left, a potential infinite loop.
+ * YUCK.
+ * Note that this is even more dangerous than the usual Java
+ * finalizers, in that objects reachable from static variables
+ * may have been finalized when these finalizers are run.
+ * Finalizers run at this point must be prepared to deal with a
+ * mostly broken world.
+ * This routine is externally callable, so is called without
+ * the allocation lock.
+ */
+ GC_API void GC_CALL GC_finalize_all(void)
+ {
DCL_LOCK_STATE;
LOCK();
LOCK();
}
UNLOCK();
-}
-#endif
+ }
+
+#endif /* !JAVA_FINALIZATION_NOT_NEEDED */
/* Returns true if it is worth calling GC_invoke_finalizers. (Useful if */
/* finalizers can only be called from some kind of `safe state' and */
}
#ifndef SMALL_CONFIG
-
-void GC_print_finalization_stats(void)
-{
+ void GC_print_finalization_stats(void)
+ {
struct finalizable_object *fo = GC_finalize_now;
unsigned long ready = 0;
GC_log_printf("%lu objects are eligible for immediate finalization; "
"%ld links cleared\n",
ready, (long)GC_old_dl_entries - (long)GC_dl_entries);
-}
-
+ }
#endif /* SMALL_CONFIG */
* Heavily modified by Hans Boehm and others
*/
+#include "private/gc_priv.h"
+
/*
* This used to be in dyn_load.c. It was extracted into a separate file
* to avoid having to link against libdl.{a,so} if the client doesn't call
* library. -HB
*/
-#include "private/gc_priv.h"
-
# if (defined(GC_PTHREADS) && !defined(GC_DARWIN_THREADS)) && !defined(GC_WIN32_PTHREADS)\
|| defined(GC_SOLARIS_THREADS)
* modified is included with the above copyright notice.
*
*/
-/* Boehm, July 31, 1995 5:02 pm PDT */
#include "private/gc_pmark.h" /* includes gc_priv.h */
* modified is included with the above copyright notice.
*/
+#include "private/gc_priv.h"
+
/*
* This implements:
* 1. allocation of heap block headers
* level tree.
*/
-# include "private/gc_priv.h"
-
STATIC bottom_index * GC_all_bottom_indices = 0;
/* Pointer to first (lowest addr) */
/* bottom_index. */
# define GC_BUILD
#endif
+#if (defined(__linux__) || defined(__GLIBC__) || defined(__GNU__)) \
+ && !defined(_GNU_SOURCE)
+ /* Can't test LINUX, since this must be defined before other includes. */
+# define _GNU_SOURCE
+#endif
+
+#if (defined(DGUX) && defined(GC_THREADS) || defined(DGUX386_THREADS) \
+ || defined(GC_DGUX386_THREADS)) && !defined(_USING_POSIX4A_DRAFT10)
+# define _USING_POSIX4A_DRAFT10 1
+#endif
+
+#ifndef GC_H
+# define GC_I_HIDE_POINTERS /* to get GC_HIDE_POINTER() and friends */
+# include "../gc.h"
+#endif
+
#include <stdlib.h>
#if !defined(sony_news)
# include <stddef.h>
# endif
#endif
-#ifndef GC_H
-# define GC_I_HIDE_POINTERS /* to get GC_HIDE_POINTER() and friends */
-# include "../gc.h"
-#endif
-
#ifndef GC_TINY_FL_H
# include "../gc_tiny_fl.h"
#endif
# if defined(x86) || defined(__i386__)
# define I386
# if defined(__MINGW32CE__) && !defined(DebugBreak)
- /* x86mingw32ce toolchain doesn't have proper DebugBreak() now. */
+ /* A workaround for x86mingw32ce toolchain (if it is still */
+ /* declaring DebugBreak() instead of defining it as a macro). */
# define DebugBreak() _exit(-1)
# endif
# endif
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
-/* Boehm, November 17, 1995 12:13 pm PST */
-# include "private/gc_priv.h"
-# include <stdio.h>
-# include <setjmp.h>
-# if defined(OS2) || defined(CX_UX)
-# define _setjmp(b) setjmp(b)
-# define _longjmp(b,v) longjmp(b,v)
-# endif
-# ifdef AMIGA
-# ifndef __GNUC__
-# include <dos.h>
-# else
-# include <machine/reg.h>
-# endif
+
+#include "private/gc_priv.h"
+
+#include <stdio.h>
+#include <setjmp.h>
+
+#if defined(OS2) || defined(CX_UX)
+# define _setjmp(b) setjmp(b)
+# define _longjmp(b,v) longjmp(b,v)
+#endif
+
+#ifdef AMIGA
+# ifndef __GNUC__
+# include <dos.h>
+# else
+# include <machine/reg.h>
# endif
+#endif
#if defined(__MWERKS__) && !defined(POWERPC)
* modified is included with the above copyright notice.
*/
+#include "private/gc_priv.h"
+
/*
* These are extra allocation routines which are likely to be less
* frequently used than those in malloc.c. They are separate in the
*/
#include <stdio.h>
-#include "private/gc_priv.h"
/* Some externally visible but unadvertised variables to allow access to */
/* free lists from inlined allocators without including gc_priv.h */
*
*/
-# include <stdio.h>
-# include "private/gc_pmark.h"
+#include "private/gc_pmark.h"
+
+#include <stdio.h>
#if defined(MSWIN32) && defined(__GNUC__)
# include <excpt.h>
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
-# include <stdio.h>
-# include "private/gc_priv.h"
+
+#include "private/gc_priv.h"
+
+#include <stdio.h>
/* Data structure for list of root sets. */
/* We keep a hash table, so that we can filter out duplicate additions. */
int GC_no_dls = 0; /* Register dynamic library data segments. */
static int n_root_sets = 0;
-
/* GC_static_roots[0..n_root_sets) contains the valid root sets. */
-# if !defined(NO_DEBUGGING)
-/* For debugging: */
-void GC_print_static_roots(void)
-{
+#if !defined(NO_DEBUGGING)
+ /* For debugging: */
+ void GC_print_static_roots(void)
+ {
int i;
size_t total = 0;
GC_err_printf("GC_root_size incorrect: %ld!!\n",
(long) GC_root_size);
}
-}
-# endif /* NO_DEBUGGING */
+ }
+#endif /* !NO_DEBUGGING */
/* Primarily for debugging support: */
-/* Is the address p in one of the registered static */
-/* root sections? */
+/* Is the address p in one of the registered static root sections? */
GC_bool GC_is_static_root(ptr_t p)
{
static int last_root_set = MAX_ROOT_SETS;
/* "activation frame" in backing store. */
if (GC_activation_frame != NULL && cold_gc_bs_pointer <
GC_activation_frame->backing_store_end)
- cold_gc_bs_pointer = GC_activation_frame->backing_store_end;
+ cold_gc_bs_pointer =
+ GC_activation_frame->backing_store_end;
GC_push_all_register_frames(BACKING_STORE_BASE,
cold_gc_bs_pointer, FALSE, GC_activation_frame);
GC_push_all_eager(cold_gc_bs_pointer, bsp);
* 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 "private/gc_pmark.h"
#include <stdio.h>
#include <limits.h>
#include <stdarg.h>
-#include "private/gc_pmark.h"
-
#ifndef MSWINCE
# include <signal.h>
#endif
* 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.
- *
+ */
+
+#include "private/gc_priv.h"
+
+/*
* This file contains the functions:
* ptr_t GC_build_flXXX(h, old_fl)
* void GC_new_hblk(size)
*/
-/* Boehm, May 19, 1994 2:09 pm PDT */
-
-# include <stdio.h>
-# include "private/gc_priv.h"
+#include <stdio.h>
#ifndef SMALL_CONFIG
/*
* modified is included with the above copyright notice.
*/
+#include "private/gc_priv.h"
+
/* Routines for maintaining maps describing heap block
* layouts for various object sizes. Allows fast pointer validity checks
* and fast location of object start locations on machines (such as SPARC)
* with slow division.
*/
-# include "private/gc_priv.h"
-
/* Consider pointers that are offset bytes displaced from the beginning */
/* of an object to be valid. */
}
#ifdef MARK_BIT_PER_GRANULE
-/* Add a heap block map for objects of size granules to obj_map. */
-/* Return FALSE on failure. */
-/* A size of 0 granules is used for large objects. */
-GC_bool GC_add_map_entry(size_t granules)
-{
+ /* Add a heap block map for objects of size granules to obj_map. */
+ /* Return FALSE on failure. */
+ /* A size of 0 granules is used for large objects. */
+ GC_bool GC_add_map_entry(size_t granules)
+ {
unsigned displ;
short * new_map;
}
GC_obj_map[granules] = new_map;
return(TRUE);
-}
+ }
#endif
-static GC_bool offsets_initialized = FALSE;
-
void GC_initialize_offsets(void)
{
+ static GC_bool offsets_initialized = FALSE;
+
if (!offsets_initialized) {
int i;
if (GC_all_interior_pointers) {
- for (i = 0; i < VALID_OFFSET_SZ; ++i) GC_valid_offsets[i] = TRUE;
+ for (i = 0; i < VALID_OFFSET_SZ; ++i)
+ GC_valid_offsets[i] = TRUE;
}
offsets_initialized = TRUE;
}
* modified is included with the above copyright notice.
*/
-# include "private/gc_priv.h"
+#include "private/gc_priv.h"
-# if defined(THREADS) && defined(MPROTECT_VDB)
-# include "atomic_ops.h"
-# endif
+#if defined(THREADS) && defined(MPROTECT_VDB)
+# include "atomic_ops.h"
+#endif
-# if defined(LINUX) && !defined(POWERPC)
-# include <linux/version.h>
-# if (LINUX_VERSION_CODE <= 0x10400)
- /* Ugly hack to get struct sigcontext_struct definition. Required */
- /* for some early 1.3.X releases. Will hopefully go away soon. */
- /* in some later Linux releases, asm/sigcontext.h may have to */
- /* be included instead. */
-# define __KERNEL__
-# include <asm/signal.h>
-# undef __KERNEL__
-# else
- /* Kernels prior to 2.1.1 defined struct sigcontext_struct instead of */
- /* struct sigcontext. libc6 (glibc2) uses "struct sigcontext" in */
- /* prototypes, so we have to include the top-level sigcontext.h to */
- /* make sure the former gets defined to be the latter if appropriate. */
-# include <features.h>
-# if 2 <= __GLIBC__
-# if 2 == __GLIBC__ && 0 == __GLIBC_MINOR__
- /* glibc 2.1 no longer has sigcontext.h. But signal.h */
- /* has the right declaration for glibc 2.1. */
-# include <sigcontext.h>
-# endif /* 0 == __GLIBC_MINOR__ */
-# else /* not 2 <= __GLIBC__ */
- /* libc5 doesn't have <sigcontext.h>: go directly with the kernel */
- /* one. Check LINUX_VERSION_CODE to see which we should reference. */
-# include <asm/sigcontext.h>
-# endif /* 2 <= __GLIBC__ */
-# endif
+#if defined(LINUX) && !defined(POWERPC)
+# include <linux/version.h>
+# if (LINUX_VERSION_CODE <= 0x10400)
+ /* Ugly hack to get struct sigcontext_struct definition. Required */
+ /* for some early 1.3.X releases. Will hopefully go away soon. */
+ /* in some later Linux releases, asm/sigcontext.h may have to */
+ /* be included instead. */
+# define __KERNEL__
+# include <asm/signal.h>
+# undef __KERNEL__
+# else
+ /* Kernels prior to 2.1.1 defined struct sigcontext_struct instead of */
+ /* struct sigcontext. libc6 (glibc2) uses "struct sigcontext" in */
+ /* prototypes, so we have to include the top-level sigcontext.h to */
+ /* make sure the former gets defined to be the latter if appropriate. */
+# include <features.h>
+# if 2 <= __GLIBC__
+# if 2 == __GLIBC__ && 0 == __GLIBC_MINOR__
+ /* glibc 2.1 no longer has sigcontext.h. But signal.h */
+ /* has the right declaration for glibc 2.1. */
+# include <sigcontext.h>
+# endif /* 0 == __GLIBC_MINOR__ */
+# else /* not 2 <= __GLIBC__ */
+ /* libc5 doesn't have <sigcontext.h>: go directly with the kernel */
+ /* one. Check LINUX_VERSION_CODE to see which we should reference. */
+# include <asm/sigcontext.h>
+# endif /* 2 <= __GLIBC__ */
# endif
-# if !defined(OS2) && !defined(PCR) && !defined(AMIGA) && !defined(MACOS) \
+#endif
+
+#if !defined(OS2) && !defined(PCR) && !defined(AMIGA) && !defined(MACOS) \
&& !defined(MSWINCE)
-# include <sys/types.h>
-# if !defined(MSWIN32)
-# include <unistd.h>
-# endif
+# include <sys/types.h>
+# if !defined(MSWIN32)
+# include <unistd.h>
# endif
+#endif
-# include <stdio.h>
-# if defined(MSWINCE)
-# define SIGSEGV 0 /* value is irrelevant */
-# else
-# include <signal.h>
-# endif
+#include <stdio.h>
+#if defined(MSWINCE)
+# define SIGSEGV 0 /* value is irrelevant */
+#else
+# include <signal.h>
+#endif
#if defined(UNIX_LIKE) || defined(CYGWIN32)
# include <fcntl.h>
#endif
#ifdef DARWIN
-/* for get_etext and friends */
-#include <mach-o/getsect.h>
+ /* for get_etext and friends */
+# include <mach-o/getsect.h>
#endif
#ifdef DJGPP
# define OPT_PROT_EXEC 0
#endif
-#if defined(LINUX) && \
- (defined(USE_PROC_FOR_LIBRARIES) || defined(IA64) || !defined(SMALL_CONFIG))
+#if defined(LINUX) && (defined(USE_PROC_FOR_LIBRARIES) || defined(IA64) \
+ || !defined(SMALL_CONFIG))
# define NEED_PROC_MAPS
#endif
#ifdef NEED_PROC_MAPS
-/* We need to parse /proc/self/maps, either to find dynamic libraries, */
-/* and/or to find the register backing store base (IA64). Do it once */
-/* here. */
+/* We need to parse /proc/self/maps, either to find dynamic libraries, */
+/* and/or to find the register backing store base (IA64). Do it once */
+/* here. */
#define READ read
}
#ifdef THREADS
-/* Determine the length of a file by incrementally reading it into a */
-/* This would be silly to use on a file supporting lseek, but Linux */
-/* /proc files usually do not. */
-STATIC size_t GC_get_file_len(int f)
-{
+ /* Determine the length of a file by incrementally reading it into a */
+ /* This would be silly to use on a file supporting lseek, but Linux */
+ /* /proc files usually do not. */
+ STATIC size_t GC_get_file_len(int f)
+ {
size_t total = 0;
ssize_t result;
# define GET_FILE_LEN_BUF_SZ 500
total += result;
} while (result > 0);
return total;
-}
+ }
-STATIC size_t GC_get_maps_len(void)
-{
+ STATIC size_t GC_get_maps_len(void)
+ {
int f = open("/proc/self/maps", O_RDONLY);
size_t result = GC_get_file_len(f);
close(f);
return result;
-}
-#endif
+ }
+#endif /* THREADS */
/*
* Copy the contents of /proc/self/maps to a buffer in our address space.
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
+
+#include "private/pthread_support.h"
+
/*
* Support code originally for LinuxThreads, the clone()-based kernel
* thread package for Linux which is included in libc6.
* + # define GC_LOCK_TAKEN GC_allocate_lock
*/
-/*#define DEBUG_THREADS 1*/
-
-#include "private/pthread_support.h"
+#if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS)
-# if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS)
-
-# if defined(GC_DGUX386_THREADS) && !defined(_POSIX4A_DRAFT10_SOURCE)
-# define _POSIX4A_DRAFT10_SOURCE 1
-# endif
-
-# if defined(GC_DGUX386_THREADS) && !defined(_USING_POSIX4A_DRAFT10)
-# define _USING_POSIX4A_DRAFT10 1
-# endif
+/*#define DEBUG_THREADS 1*/
# include <stdlib.h>
# include <pthread.h>
#endif /* PARALLEL_MARK */
-# endif /* GC_LINUX_THREADS and friends */
+#endif /* GC_LINUX_THREADS and friends */
* modified is included with the above copyright notice.
*/
+#include "private/gc_pmark.h"
+
/*
* These are checking routines calls to which could be inserted by a
* preprocessor to validate C pointer arithmetic.
*/
-#include "private/gc_pmark.h"
-
STATIC void GC_CALLBACK GC_default_same_obj_print_proc(void * p, void * q)
{
GC_err_printf("%p and %p are not in the same object\n", p, q);
return(p);
}
-
GC_API void * GC_CALL GC_pre_incr (void **p, ptrdiff_t how_much)
{
void * initial = *p;
* modified is included with the above copyright notice.
*/
-#include <stdio.h>
#include "private/gc_priv.h"
+#include <stdio.h>
+
GC_INNER signed_word GC_bytes_found = 0;
/* Number of bytes of memory reclaimed */
/* minus the number of bytes originally */
* 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 "private/gc_priv.h"
#if defined(MANUAL_VDB)
-/* Stubborn object (hard to change, nearly immutable) allocation. */
-/* This interface is deprecated. We mostly emulate it using */
-/* MANUAL_VDB. But that imposes the additional constraint that */
-/* written, but not yet GC_dirty()ed objects must be referenced */
-/* by a stack. */
-GC_API void * GC_CALL GC_malloc_stubborn(size_t lb)
-{
+
+ /* Stubborn object (hard to change, nearly immutable) allocation. */
+ /* This interface is deprecated. We mostly emulate it using */
+ /* MANUAL_VDB. But that imposes the additional constraint that */
+ /* written, but not yet GC_dirty()ed objects must be referenced */
+ /* by a stack. */
+
+ GC_API void * GC_CALL GC_malloc_stubborn(size_t lb)
+ {
return(GC_malloc(lb));
-}
+ }
-GC_API void GC_CALL GC_end_stubborn_change(void *p)
-{
+ GC_API void GC_CALL GC_end_stubborn_change(void *p)
+ {
GC_dirty(p);
-}
+ }
-/*ARGSUSED*/
-GC_API void GC_CALL GC_change_stubborn(void *p)
-{
-}
+ /*ARGSUSED*/
+ GC_API void GC_CALL GC_change_stubborn(void *p)
+ {
+ }
#else /* !MANUAL_VDB */
-GC_API void * GC_CALL GC_malloc_stubborn(size_t lb)
-{
+ GC_API void * GC_CALL GC_malloc_stubborn(size_t lb)
+ {
return(GC_malloc(lb));
-}
+ }
-/*ARGSUSED*/
-GC_API void GC_CALL GC_end_stubborn_change(void *p)
-{
-}
+ /*ARGSUSED*/
+ GC_API void GC_CALL GC_end_stubborn_change(void *p)
+ {
+ }
-/*ARGSUSED*/
-GC_API void GC_CALL GC_change_stubborn(void *p)
-{
-}
+ /*ARGSUSED*/
+ GC_API void GC_CALL GC_change_stubborn(void *p)
+ {
+ }
#endif /* !MANUAL_VDB */
# undef GC_BUILD
+#if (defined(DBG_HDRS_ALL) || defined(MAKE_BACK_GRAPH)) && !defined(GC_DEBUG)
+# define GC_DEBUG
+#endif
+
+#include "gc.h"
+
#ifndef NTHREADS /* Number of additional threads to fork. */
# define NTHREADS 5 /* excludes main thread, which also runs a test. */
/* Not respected by PCR test. */
#endif
-#if (defined(DBG_HDRS_ALL) || defined(MAKE_BACK_GRAPH)) && !defined(GC_DEBUG)
-# define GC_DEBUG
-#endif
-
# if defined(mips) && defined(SYSTYPE_BSD43)
/* MIPS RISCOS 4 */
# else
# else
# include <assert.h> /* Not normally used, but handy for debugging. */
# endif
-# include "gc.h"
+
# include "gc_typed.h"
# include "private/gc_priv.h" /* For output, locking, MIN_WORDS, */
/* and some statistics, and gcconfig.h. */
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
+
#include "private/gc_priv.h"
-# if defined(THREAD_LOCAL_ALLOC)
+#if defined(THREAD_LOCAL_ALLOC)
#ifndef THREADS
# error "invalid config - THREAD_LOCAL_ALLOC requires GC_THREADS"
#include "private/thread_local_alloc.h"
#include "gc_inline.h"
-# include <stdlib.h>
+#include <stdlib.h>
#if defined(USE_COMPILER_TLS)
__thread
#ifdef GC_GCJ_SUPPORT
-#include "atomic_ops.h" /* for AO_compiler_barrier() */
+# include "atomic_ops.h" /* for AO_compiler_barrier() */
-#include "include/gc_gcj.h"
+# include "include/gc_gcj.h"
/* Gcj-style allocation without locks is extremely tricky. The */
/* fundamental issue is that we may end up marking a free list, which */
}
#endif /* GC_ASSERTIONS */
-# endif /* THREAD_LOCAL_ALLOC */
+#endif /* THREAD_LOCAL_ALLOC */
*
*/
+#include "private/gc_pmark.h"
/*
* Some simple primitives for allocation with explicit type information.
* since they are not accessible through the current interface.
*/
-#include "private/gc_pmark.h"
#include "gc_typed.h"
-# define TYPD_EXTRA_BYTES (sizeof(word) - EXTRA_BYTES)
+#define TYPD_EXTRA_BYTES (sizeof(word) - EXTRA_BYTES)
STATIC GC_bool GC_explicit_typing_initialized = FALSE;
/* descriptors. */
STATIC size_t GC_ed_size = 0; /* Current size of above arrays. */
-# define ED_INITIAL_SIZE 100;
+#define ED_INITIAL_SIZE 100
STATIC size_t GC_avail_descr = 0; /* Next available slot. */
/* The implementation knows that GC_DS_LENGTH is 0. */
/* *leaf, *complex_d, and *simple_d may be used as temporaries */
/* during the construction. */
-# define COMPLEX 2
-# define LEAF 1
-# define SIMPLE 0
-# define NO_MEM (-1)
+#define COMPLEX 2
+#define LEAF 1
+#define SIMPLE 0
+#define NO_MEM (-1)
STATIC int GC_make_array_descriptor(size_t nelements, size_t size,
GC_descr descriptor, GC_descr *simple_d,
complex_descriptor **complex_d,
}
#ifdef UNDEFINED
-complex_descriptor * GC_make_complex_array_descriptor(word nelements,
+ complex_descriptor * GC_make_complex_array_descriptor(word nelements,
complex_descriptor *descr)
-{
+ {
struct ComplexArrayDescriptor * result =
(struct ComplexArrayDescriptor *)
GC_malloc(sizeof(struct ComplexArrayDescriptor));
result -> ad_element_descr = descr;
}
return((complex_descriptor *)result);
-}
+ }
#endif
STATIC ptr_t * GC_eobjfreelist = NULL;