+2009-10-17 Ivan Maidanski <ivmai@mail.ru>
+
+ * alloc.c (GC_never_stop_func, GC_check_fl_marks,
+ GC_finish_collection): Reformat the code (make opening bracket
+ style uniform across the file).
+ * allchblk.c (GC_allochblk): Ditto.
+ * backgraph.c (add_edge): Ditto.
+ * dbg_mlc.c (GC_marked_for_finalization): Ditto.
+ * dyn_load.c (GC_register_dynamic_libraries, GC_init_dyld): Ditto.
+ * finalize.c (GC_null_finalize_mark_proc): Ditto.
+ * gc_dlopen.c (GC_dlopen): Ditto.
+ * mark.c (GC_push_marked1, GC_push_marked2, GC_push_marked4):
+ Ditto.
+ * misc.c (looping_handler, GC_call_with_gc_active,
+ GC_do_blocking_inner, GC_do_blocking): Ditto.
+ * os_dep.c (GC_get_main_stack_base, GC_read_dirty): Ditto.
+ * pthread_support.c (GC_pthread_create, GC_pthread_sigmask,
+ GC_pthread_join, GC_pthread_detach, GC_check_tls,
+ GC_do_blocking_inner, GC_call_with_gc_active): Ditto.
+ * reclaim.c (GC_reclaim_clear, GC_reclaim_block,
+ GC_print_free_list): Ditto.
+ * os_dep.c (GC_page_was_dirty, GC_page_was_ever_dirty,
+ GC_remove_protection): Reformat the code (wrap long lines).
+
2009-10-16 Ivan Maidanski <ivmai@mail.ru>
* alloc.c (GC_finish_collection): Replace getenv() with GETENV().
/* avoid splitting, since that might require remapping */
split_limit = 0;
# else
- if (GC_finalizer_bytes_freed > (GC_heapsize >> 4)) {
+ if (GC_finalizer_bytes_freed > (GC_heapsize >> 4)) {
/* If we are deallocating lots of memory from */
/* finalizers, fail and collect sooner rather */
/* than later. */
GC_bool GC_collection_in_progress(void);
/* Collection is in progress, or was abandoned. */
-int GC_CALLBACK GC_never_stop_func (void) { return(0); }
+int GC_CALLBACK GC_never_stop_func(void)
+{
+ return(0);
+}
#ifndef GC_TIME_LIMIT
# define GC_TIME_LIMIT 50 /* We try to keep pause times from exceeding */
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)) {
- GC_err_printf("Unmarked object %p on list %p\n", p, q);
- ABORT("Unmarked local free list entry.");
- }
+ for (p = q; p != 0; p = obj_link(p)) {
+ if (!GC_is_marked(p)) {
+ GC_err_printf("Unmarked object %p on list %p\n", p, q);
+ ABORT("Unmarked local free list entry.");
+ }
}
}
#endif
(unsigned long)GC_composite_in_use,
(unsigned long)GC_atomic_in_use);
}
- if (GC_is_full_gc) {
+ if (GC_is_full_gc) {
GC_used_heap_size_after_full = USED_HEAP_SIZE;
GC_need_full_gc = FALSE;
} else {
ensure_struct(q);
old_back_ptr = GET_OH_BG_PTR(q);
be = (back_edges *)((word)old_back_ptr & ~FLAG_MANY);
- for (i = be -> n_edges, be_cont = be; i > MAX_IN;
- be_cont = be_cont -> cont, i -= MAX_IN) {}
+ for (i = be -> n_edges, be_cont = be; i > MAX_IN; i -= MAX_IN)
+ be_cont = be_cont -> cont;
if (i == MAX_IN) {
be_cont -> cont = new_back_edges();
be_cont = be_cont -> cont;
}
}
- void GC_marked_for_finalization(ptr_t dest) {
+ void GC_marked_for_finalization(ptr_t dest)
+ {
GC_store_back_pointer(MARKED_FOR_FINALIZATION, dest);
}
static GC_describe_type_fn GC_describe_type_fns[MAXOBJKINDS] = {0};
GC_API void GC_CALL GC_register_describe_type_fn(int kind,
- GC_describe_type_fn fn)
+ GC_describe_type_fn fn)
{
GC_describe_type_fns[kind] = fn;
}
}
GC_API void * GC_CALL GC_debug_malloc_ignore_off_page(size_t lb,
- GC_EXTRA_PARAMS)
+ GC_EXTRA_PARAMS)
{
void * result = GC_malloc_ignore_off_page(lb + DEBUG_BYTES);
}
GC_API void * GC_CALL GC_debug_malloc_atomic_ignore_off_page(size_t lb,
- GC_EXTRA_PARAMS)
+ GC_EXTRA_PARAMS)
{
void * result = GC_malloc_atomic_ignore_off_page(lb + DEBUG_BYTES);
#define OFN_UNSET (GC_finalization_proc)(signed_word)-1
/* Set ofn and ocd to reflect the values we got back. */
-static void store_old (void *obj, GC_finalization_proc my_old_fn,
- struct closure *my_old_cd, GC_finalization_proc *ofn,
- void **ocd)
+static void store_old(void *obj, GC_finalization_proc my_old_fn,
+ struct closure *my_old_cd, GC_finalization_proc *ofn,
+ void **ocd)
{
if (0 != my_old_fn) {
if (my_old_fn == OFN_UNSET) {
{
struct link_map *lm;
-
# ifdef HAVE_DL_ITERATE_PHDR
if (GC_register_dynamic_libraries_dl_iterate_phdr()) {
return;
# endif
}
-void GC_register_dynamic_libraries(void) {
+void GC_register_dynamic_libraries(void)
+{
/* Currently does nothing. The callbacks are setup by GC_init_dyld()
The dyld library takes it from there. */
}
This should be called BEFORE any thread in created and WITHOUT the
allocation lock held. */
-void GC_init_dyld(void) {
+void GC_init_dyld(void)
+{
static GC_bool initialized = FALSE;
if(initialized) return;
}
}
-
#else /* !PCR */
void GC_register_dynamic_libraries(void) {}
}
/*ARGSUSED*/
-STATIC void GC_null_finalize_mark_proc(ptr_t p)
-{
-}
+STATIC void GC_null_finalize_mark_proc(ptr_t p) {}
/* Possible finalization_marker procedures. Note that mark stack */
/* overflow is handled by the caller, and is not a disaster. */
}
GC_API void * GC_CALL GC_call_with_alloc_lock(GC_fn_type fn,
- void * client_data)
+ void * client_data)
{
void * result;
DCL_LOCK_STATE;
/* Define GC_ function as an alias for the plain one, which will be */
/* intercepted. This allows files which include gc.h, and hence */
/* generate references to the GC_ symbol, to see the right symbol. */
- GC_API int GC_dlopen(const char *path, int mode) {
+ GC_API int GC_dlopen(const char *path, int mode)
+ {
return dlopen(path, mode);
}
#endif /* Linker-based interception. */
plim = (word *)(((word)h) + HBLKSIZE);
/* go through all words in block */
- while( p < plim ) {
+ while (p < plim) {
mark_word = *mark_word_addr++;
q = p;
while(mark_word != 0) {
plim = (word *)(((word)h) + HBLKSIZE);
/* go through all words in block */
- while( p < plim ) {
+ while (p < plim) {
mark_word = *mark_word_addr++;
q = p;
while(mark_word != 0) {
plim = (word *)(((word)h) + HBLKSIZE);
/* go through all words in block */
- while( p < plim ) {
+ while (p < plim) {
mark_word = *mark_word_addr++;
q = p;
while(mark_word != 0) {
static void looping_handler(int sig)
{
GC_err_printf("Caught signal %d: looping in handler\n", sig);
- for(;;);
+ for (;;) {}
}
static GC_bool installed_looping_handler = FALSE;
/* This is nearly the same as in win32_threads.c */
GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn,
- void * client_data) {
+ void * client_data)
+{
struct GC_activation_frame_s frame;
GC_ASSERT(GC_is_initialized);
/* This is nearly the same as in win32_threads.c */
/*ARGSUSED*/
-STATIC void GC_do_blocking_inner(ptr_t data, void * context) {
+STATIC void GC_do_blocking_inner(ptr_t data, void * context)
+{
struct blocking_data * d = (struct blocking_data *) data;
GC_ASSERT(GC_is_initialized);
GC_ASSERT(GC_blocked_sp == NULL);
/* more precise (i.e. scan only stack frames of functions that allocate */
/* garbage collected memory and/or manipulate pointers to the garbage */
/* collected heap). */
-GC_API void * GC_CALL GC_do_blocking(GC_fn_type fn, void * client_data) {
+GC_API void * GC_CALL GC_do_blocking(GC_fn_type fn, void * client_data)
+{
struct blocking_data my_data;
my_data.fn = fn;
# endif /* MS Windows */
# ifdef BEOS
-# include <kernel/OS.h>
-ptr_t GC_get_main_stack_base(void){
- thread_info th;
- get_thread_info(find_thread(NULL),&th);
- return th.stack_end;
-}
+# include <kernel/OS.h>
+ ptr_t GC_get_main_stack_base(void)
+ {
+ thread_info th;
+ get_thread_info(find_thread(NULL),&th);
+ return th.stack_end;
+ }
# endif /* BEOS */
GC_bool GC_page_was_dirty(struct hblk * h)
# endif
{
- return HDR(h) == 0 || get_pht_entry_from_index(GC_grungy_pages, PHT_HASH(h));
+ return HDR(h) == 0 ||
+ get_pht_entry_from_index(GC_grungy_pages, PHT_HASH(h));
}
# ifdef MPROTECT_VDB
GC_bool GC_page_was_ever_dirty(struct hblk * h)
# endif
{
- return HDR(h) == 0 || get_pht_entry_from_index(GC_written_pages, PHT_HASH(h));
+ return HDR(h) == 0 ||
+ get_pht_entry_from_index(GC_written_pages, PHT_HASH(h));
}
# ifndef MPROTECT_VDB
/*ARGSUSED*/
- void GC_remove_protection(struct hblk *h, word nblocks, GC_bool is_ptrfree)
- {}
+ void GC_remove_protection(struct hblk *h, word nblocks,
+ GC_bool is_ptrfree) {}
# endif
# endif /* GWW_VDB */
/* Retrieve system dirty bits for heap to a local buffer. */
/* Restore the systems notion of which pages are dirty. */
-void GC_read_dirty(void)
-{}
+void GC_read_dirty(void) {}
/* Is the HBLKSIZE sized page at h marked dirty in the local buffer? */
/* If the actual page size is different, this returns TRUE if any */
#endif /* !AO_HAVE_test_and_set_acquire */
#else /* !THREADS */
# define async_set_pht_entry_from_index(db, index) \
- set_pht_entry_from_index(db, index)
+ set_pht_entry_from_index(db, index)
#endif /* !THREADS */
#ifdef CHECKSUMS
limit = vaddr + ps * np;
bufp += sizeof (struct prasmap);
for (current_addr = vaddr;
- current_addr < limit; current_addr += ps){
+ current_addr < limit; current_addr += ps) {
if ((*bufp++) & PG_MODIFIED) {
register struct hblk * h = (struct hblk *) current_addr;
#define FWD() GC_forward_exception(thread, task, exception, code, code_count)
/* This violates the namespace rules but there isn't anything that can be done
- about it. The exception handling stuff is hard coded to call this */
+ about it. The exception handling stuff is hard coded to call this. */
kern_return_t
catch_exception_raise(mach_port_t exception_port, mach_port_t thread,
mach_port_t task, exception_type_t exception,
/* be intercepted. This allows files which include gc.h, and hence */
/* generate references to the GC_ symbols, to see the right symbols. */
GC_API int GC_pthread_create(pthread_t * t, const pthread_attr_t * a,
- void * (* fn)(void *), void * arg) {
+ void * (* fn)(void *), void * arg)
+ {
return pthread_create(t, a, fn, arg);
}
+
GC_API int GC_pthread_sigmask(int how, const sigset_t *mask,
- sigset_t *old) {
+ sigset_t *old)
+ {
return pthread_sigmask(how, mask, old);
}
- GC_API int GC_pthread_join(pthread_t t, void **res) {
+
+ GC_API int GC_pthread_join(pthread_t t, void **res)
+ {
return pthread_join(t, res);
}
- GC_API int GC_pthread_detach(pthread_t t) {
+
+ GC_API int GC_pthread_detach(pthread_t t)
+ {
return pthread_detach(t);
}
#endif /* Linker-based interception. */
# endif
/* Check that all thread-local free-lists are completely marked. */
/* also check that thread-specific-data structures are marked. */
- void GC_check_tls(void) {
+ void GC_check_tls(void)
+ {
int i;
GC_thread p;
#if !defined(GC_DARWIN_THREADS)
GC_API int WRAP_FUNC(pthread_sigmask)(int how, const sigset_t *set,
- sigset_t *oset)
+ sigset_t *oset)
{
sigset_t fudged_set;
/* length of time. */
/*ARGSUSED*/
-void GC_do_blocking_inner(ptr_t data, void * context) {
+void GC_do_blocking_inner(ptr_t data, void * context)
+{
struct blocking_data * d = (struct blocking_data *) data;
GC_thread me;
LOCK();
/* GC_do_blocking() to temporarily back allow calling any GC function */
/* and/or manipulating pointers to the garbage collected heap. */
GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn,
- void * client_data) {
+ void * client_data)
+{
struct GC_activation_frame_s frame;
GC_thread me;
LOCK(); /* This will block if the world is stopped. */
plim = (word *)(hbp->hb_body + HBLKSIZE - sz);
/* go through all words in block */
- while( p <= plim ) {
+ while (p <= plim) {
if( mark_bit_from_hdr(hhdr, bit_no) ) {
p = (word *)((ptr_t)p + sz);
} else {
plim = (word *)((ptr_t)hbp + HBLKSIZE - sz);
/* go through all words in block */
- while( p <= plim ) {
+ while (p <= plim) {
if( !mark_bit_from_hdr(hhdr, bit_no) ) {
n_bytes_found += sz;
/* object is available - put on list */
plim = p + HBLKSIZE - sz;
/* go through all words in block */
- while( p <= plim ) {
+ while (p <= plim) {
if( !mark_bit_from_hdr(hhdr, bit_no) ) {
GC_add_leaked(p);
}
} else if (empty) {
GC_bytes_found += HBLKSIZE;
GC_freehblk(hbp);
- } else if (GC_find_leak || !GC_block_nearly_full(hhdr)){
+ } else if (GC_find_leak || !GC_block_nearly_full(hhdr)) {
/* group of smaller objects, enqueue the real work */
rlh = &(ok -> ok_reclaim_list[BYTES_TO_GRANULES(sz)]);
hhdr -> hb_next = *rlh;
struct hblk *lastBlock = 0;
int n = 0;
- while (flh){
+ while (flh) {
struct hblk *block = HBLKPTR(flh);
- if (block != lastBlock){
+ if (block != lastBlock) {
GC_printf("\nIn heap block at %p:\n\t", block);
lastBlock = block;
}