summaryrefslogtreecommitdiff
path: root/libguile/gc-malloc.c
AgeCommit message (Collapse)AuthorFilesLines
2014-02-27Rely on Gnulib for <unistd.h>.Mark H Weaver1-3/+2
* libguile/async.c: * libguile/backtrace.c: * libguile/error.c: * libguile/filesys.c: * libguile/fports.c: * libguile/gc-malloc.c: * libguile/gc.c: * libguile/gdbint.c: * libguile/init.c: * libguile/ioext.c: * libguile/load.c: * libguile/mallocs.c: * libguile/mkstemp.c: * libguile/ports.c: * libguile/posix.c: * libguile/r6rs-ports.c: * libguile/random.c: * libguile/rw.c: * libguile/scmsigs.c: * libguile/script.c: * libguile/simpos.c: * libguile/socket.c: * libguile/stime.c: * libguile/strports.c: * libguile/threads.c: Unconditionally include <unistd.h>.
2012-02-05Fix --enable-debug-mallocAndy Wingo1-37/+56
* libguile/gc-malloc.c (do_realloc, do_calloc, do_gc_malloc) (do_gc_malloc_atomic, do_gc_realloc, do_gc_free): Wrap the allocators in helper methods. The non-GC allocators call scm_gc_register_allocation, and the GC allocators ensure that gc_malloc returns a nonzero value. (scm_realloc, scm_calloc): Allow NULL return for malloc(0). It is permitted by POSIX. Don't wrap in a SCM_SYSCALL; the only possible errno is ENOMEM. (scm_gc_malloc_pointerless, scm_gc_malloc, scm_gc_calloc): (scm_gc_realloc, scm_gc_free, scm_gc_strndump): Use the wrappers. Don't call the debug-malloc registrations and deregistrations, as it is neither mandatory nor advised to call scm_gc_free. Fixes compilation with debug-malloc. (scm_must_free): Don't scm_malloc_unregister.
2011-12-22stdlib.h, not malloc.hAndy Wingo1-4/+1
* configure.ac: Remove check for malloc.h. * libguile/gc-malloc.c: * libguile/gc.c: * libguile/mallocs.c: * libguile/smob.c: Use stdlib instead of malloc.h.
2011-12-08fix compilation with gc 7.1Chris K. Jester-Young1-0/+4
* configure.ac: Add checks for GC_gcollect_and_unmap and GC_get_unmapped_bytes. * libguile/gc-malloc.c (scm_realloc): GC_gcollect() if we don't have GC_gcollect_and_unmap. * libguile/gc.c (GC_get_heap_usage_safe): Likewise, don't GC_get_unmapped_bytes if the function doesn't exist.
2011-12-02scm_gc_register_collectable_memory calls scm_gc_register_allocationAndy Wingo1-1/+2
* libguile/gc-malloc.c (scm_gc_register_collectable_memory): Call scm_gc_register_allocation.
2011-11-29attempt to handle steady-state mallocations betterAndy Wingo1-1/+3
* libguile/gc-malloc.c (scm_realloc): Call the new scm_gc_register_allocation() here. If we have to collect, do a GC_gcollect_and_unmap. * libguile/gc.c (scm_gc_register_allocation): Add a routine to track steady-state mallocation, and cause gc to run if there is a high mallocation rate. (adjust_gc_frequency): Reset the bytes-until-GC countdown timer.
2011-10-22Fix compilation with `--enable-debug-malloc'.Bake Timmons1-2/+3
* libguile/gc-malloc.c (scm_gc_register_collectable_memory): Add the missing second argument in the call to scm_malloc_register.
2010-12-04make-string et al nulls memory if not given an initializerAndy Wingo1-2/+4
* libguile/gc-malloc.c: Add a note that the gc-malloc does not clear the memory block, so users need to make sure it is initialized. * libguile/bitvectors.c (scm_c_make_bitvector): * libguile/bytevectors.c (scm_make_bytevector): * libguile/strings.c (scm_c_make_string): If no initializer is given, initialize the bytes to 0. Prevents information leakage if an app uses make-string et al without initializers. * libguile/foreign.c (make_cif): Initialize this too, to prevent leakage in the struct holes. Paranoia...
2010-03-29fix bug in scm_must_freeAndy Wingo1-11/+5
* libguile/gc-malloc.c: Update a comment. (scm_must_free): Must be able to free memory allocated with scm_must_malloc, and thus must be GC_FREE, not free.
2010-03-29remove out-of-date comment in scm_gc_mallocAndy Wingo1-12/+1
* libguile/gc-malloc.c (scm_gc_malloc): Remove out-of-date comment.
2009-11-17Fix stylistic issues revealed by "make syntax-check".Ludovic Courtès1-7/+2
* libguile/gc-malloc.c (scm_must_free): Remove unnecessary `if' before `free ()'. * libguile/stime.c (scm_localtime, scm_mktime): Likewise. * libguile/eval.i.c (ceval): Don't cast the result of alloca(3). * libguile/i18n.c (SCM_STRING_TO_U32_BUF): Likewise. * test-suite/standalone/test-unwind.c: Likewise. * libguile/strings.c (scm_i_deprecated_string_chars): Don't end error message in period.
2009-10-26Don't use memset(3) after `GC_MALLOC ()' calls.Ludovic Courtès1-4/+2
* libguile/gc-malloc.c (scm_gc_calloc): Don't use memset(3) as it's not needed. Reported by Andy Wingo.
2009-10-25Resolve warning in gcc-4.3 about transposed parameters passed to memsetJulian Graham1-1/+2
* libguile/gc-malloc.c (scm_gc_calloc): Add explicit check on size parameter Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2009-10-15Use pointer-less memory for `scm_gc_strdup ()'.Ludovic Courtès1-1/+1
* libguile/gc-malloc.c (scm_gc_strndup): Use `GC_MALLOC_ATOMIC ()' instead of `GC_MALLOC ()'.
2009-08-28Remove deprecated variables/macros from the GC headers.Ludovic Courtès1-21/+0
* libguile/deprecated.c (scm_mtrigger, scm_mallocated, scm_max_segment_size): New global variables, from gc.c. (scm_map_free_list, scm_gc_set_debug_check_freelist_x)[GUILE_DEBUG_FREELIST]: New stubs. * libguile/deprecated.h (scm_mallocated, scm_mtrigger, scm_max_segment_size): New declarations. (scm_map_free_list, scm_gc_set_debug_check_freelist_x)[GUILE_DEBUG_FREELIST]: New declarations. * libguile/gc-malloc.c (scm_i_minyield_malloc): Remove. (scm_gc_init_malloc): Remove references to `scm_i_minyield_malloc' and `scm_mtrigger'. * libguile/gc.c (scm_mtrigger, scm_mallocated): Remove. (scm_init_storage): Remove reference to `SCM_HEAP_SEG_SIZE'. * libguile/gc.h (scm_max_segment_size, SCM_SET_FREELIST_LOC, SCM_FREELIST_LOC, scm_i_master_freelist, scm_i_master_freelist2, scm_mallocated, scm_mtrigger): Remove. (scm_map_free_list, scm_gc_set_debug_check_freelist_x)[SCM_ENABLE_DEPRECATED && GUILE_DEBUG_FREELIST]: Remove. * libguile/private-gc.h (SCM_DEFAULT_INIT_HEAP_SIZE_1, SCM_DEFAULT_MIN_YIELD_1, SCM_DEFAULT_MIN_YIELD_2, DEFAULT_SWEEP_AMOUNT, SCM_DEFAULT_MAX_SEGMENT_SIZE, SCM_MIN_HEAP_SEG_SIZE, SCM_HEAP_SEG_SIZE, SCM_GC_CARD_BVEC_SIZE_IN_LONGS, SCM_GC_IN_CARD_HEADERP): Remove. (scm_getenv_int): Made internal. (scm_i_marking, scm_mark_all, scm_i_deprecated_memory_return, scm_i_find_heap_calls, scm_gc_init_malloc, scm_gc_init_freelist, scm_gc_init_segments, scm_gc_init_mark): Remove declarations. * libguile/gc-segment-table.c: Remove, finally.
2009-08-28Merge branch 'master' into boehm-demers-weiser-gcLudovic Courtès1-4/+6
Conflicts: libguile/Makefile.am libguile/bytevectors.c libguile/gc-card.c libguile/gc-mark.c libguile/programs.c libguile/srcprop.c libguile/srfi-14.c libguile/symbols.c libguile/threads.c libguile/unif.c libguile/vm.c
2009-08-25Merge wip-array refactor, up to cd43fdc5b7a7cAndy Wingo1-2/+2
Conflicts: NEWS libguile/print.c
2009-08-20Type-limits error in GC environment initializationMichael Gran1-2/+4
* libguile/gc-malloc.c (scm_gc_init_malloc): GUILE_INIT_MALLOC_LIMIT is cast to unsigned then tested as if it were still signed
2009-08-18Merge branch 'master' into boehm-demers-weiser-gcLudovic Courtès1-6/+7
Conflicts: lib/Makefile.am libguile/Makefile.am libguile/frames.c libguile/gc-card.c libguile/gc-freelist.c libguile/gc-mark.c libguile/gc-segment.c libguile/gc_os_dep.c libguile/load.c libguile/macros.c libguile/objcodes.c libguile/programs.c libguile/strings.c libguile/vm.c m4/gnulib-cache.m4 m4/gnulib-comp.m4 m4/inline.m4
2009-07-19rename unif.[ch] to arrays.[ch]Andy Wingo1-2/+2
* libguile/Makefile.am: * libguile/unif.c: * libguile/unif.h: * libguile/arrays.c: * libguile/arrays.h: Rename unif.[ch] to arrays.[ch]. * libguile.h: * libguile/array-handle.c: * libguile/array-map.c: * libguile/bitvectors.c: * libguile/bytevectors.c: * libguile/eq.c: * libguile/gc-card.c: * libguile/gc-malloc.c: * libguile/gc-mark.c: * libguile/gc.c: * libguile/init.c: * libguile/inline.h: * libguile/print.c: * libguile/random.c: * libguile/read.c: * libguile/socket.c: * libguile/sort.c: * libguile/srfi-4.c: * libguile/srfi-4.h: * libguile/strports.c: * libguile/vectors.c: * libguile/vectors.h: Update includers.
2009-06-17Change Guile license to LGPLv3+Neil Jerram1-6/+7
(Not quite finished, the following will be done tomorrow. module/srfi/*.scm module/rnrs/*.scm module/scripts/*.scm testsuite/*.scm guile-readline/* )
2008-09-13Merge branch 'master' into boehm-demers-weiser-gcLudovic Courtès1-1/+1
Conflicts: lib/Makefile.am libguile/gc-card.c libguile/gc-freelist.c libguile/gc-mark.c libguile/gc-segment.c libguile/gc.c libguile/gc.h libguile/gc_os_dep.c libguile/private-gc.h m4/.cvsignore m4/gnulib-cache.m4 m4/gnulib-comp.m4
2008-09-13Include <config.h> in all C files; use `#ifdef HAVE_CONFIG_H' rather than `#if'.Ludovic Courtès1-1/+1
2008-09-10Merge branch 'master' into boehm-demers-weiser-gcLudovic Courtès1-4/+4
Conflicts: libguile/Makefile.am libguile/coop-defs.h libguile/gc-card.c libguile/gc-freelist.c libguile/gc-malloc.c libguile/gc-mark.c libguile/gc-segment.c libguile/gc.c libguile/gc.h libguile/gc_os_dep.c libguile/hashtab.c libguile/hashtab.h libguile/inline.h libguile/private-gc.h libguile/struct.c libguile/struct.h libguile/threads.c libguile/threads.h libguile/vectors.h libguile/weaks.h test-suite/tests/gc.test
2008-09-10scm_gc_malloc: Handle zero-octet allocations.Ludovic Courtes1-1/+8
* libguile/gc-malloc.c (scm_gc_malloc): Pass a non-zero size to `GC_MALLOC ()' when SIZE is zero. git-archimport-id: lcourtes@laas.fr--2006-libre/guile-core--boehm-gc--0--patch-2
2008-09-05Added `scm_gc_malloc_pointerless ()', equivalent to `GC_MALLOC_ATOMIC ()'.Ludovic Courtes1-1/+10
* libguile/gc-malloc.c (scm_gc_register_collectable_memory): Tidied. (scm_gc_unregister_collectable_memory): Likewise. (scm_gc_malloc_pointerless): New. * libguile/gc.h (scm_gc_malloc_pointer_less): New declaration. * libguile/strings.c (make_stringbuf): Use it. git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-5
2008-09-05Merge from lcourtes@laas.fr--2005-mobileLudovic Courtes1-143/+10
Patches applied: * lcourtes@laas.fr--2005-mobile/guile-core--boehm-gc--1.9 (base, patch 1) - tag of lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--base-0 - Initial hack for Boehm's GC support: nothing works. git-archimport-id: lcourtes@laas.fr--2005-libre/guile-core--boehm-gc--1.9--patch-1
2008-08-21Style nitpicks: space before () in function call.Han-Wen Nienhuys1-5/+5
2008-08-16If realloc() fails in scm_realloc, then do a complete GC with completeHan-Wen Nienhuys1-13/+9
sweep directly.
2008-08-16Garbage collection cleanup.Han-Wen Nienhuys1-10/+14
* New file gc-segment-table.c: hold code for the segment table. * Remove data that might be out of date; remove scm_i_adjust_min_yield(). We don't store min_yields, since they are only accurate at one point in time (when the sweep finishes). We decide the min yield at that point from min_yield_fraction and freelist->collected / freelist->swept * Introduce scm_i_gc_heap_size_delta() replacing scm_i_gc_grow_heap_p(). * Remove foo_1 fields containing penultimate results. * After GC, count mark bit vector to discover number of live objects. This simplifies hairy updates. * Many formatting and layout cleanups. * Fix in scm_i_sweep_card(): return the length of free_list returned, rather than number of deleted objects. * For mtrigger GCs: do not also run a full sweep after the gc() call, as this is inconsistent with lazy sweeping. * Remove scm_i_make_initial_segment(). * Use calloc in scm_i_make_empty_heap_segment() to save on initialization code. * New function scm_i_sweep_for_freelist() which sweeps, with proper statistic variable updates. * New segments are conceptually blocks with 100% reclaimable cells. * Remove some useless constants/comments: SCM_HEAP_SIZE, SCM_INIT_HEAP_SIZE, SCM_EXPHEAP, SCM_HEAP_SEG_SIZE * Do not increment scm_cells_allocated() from the scm_[double]cell(). This would be a race condition. * Move some deprecation checks in separate functions to not distract from main code flow.
2008-02-15Release stuff: missing NEWS and 2007/2008 copyrights.Neil Jerram1-1/+1
2008-02-06(scm_gc_malloc): Return NULL if requested size is 0.Neil Jerram1-2/+3
(scm_gc_free): Don't call `free' if mem is NULL.
2006-04-17merge from 1.8 branchKevin Ryde1-1/+11
2006-02-14Ludovic's patch for scm_t_sweep_statistics.Han-Wen Nienhuys1-4/+6
2005-05-23The FSF has a new address.Marius Vollmer1-1/+1
2005-03-10* gc.h, gc.c (SCM_FREECELL_P): Removed for good.Marius Vollmer1-4/+9
(scm_block_gc, scm_gc_heap_lock): Removed. Removed all uses. (scm_gc_running_p): Now a macro that refers to the scm_i_thread field. (scm_i_sweep_mutex): Now a non-recursive mutex. GC can not happen recursively. (scm_igc, scm_i_gc): Renamed former to latter. Changed all uses. Do not lock scm_i_sweep_mutex, which is now non-recursive, or set scm_gc_running_p. Do not run the scm_after_gc_c_hook. (scm_gc): Lock scm_i_sweep_mutex, set scm_gc_running_p and run the scm_after_gc_c_hook here. (scm_gc_for_new_cell): Set scm_gc_running_p here and run the scm_after_gc_c_hook when a full GC has in fact been performed. (scm_i_expensive_validation_check): Call scm_gc, not scm_i_gc. * gc-segment.c (scm_i_get_new_heap_segment): Do not check scm_gc_heap_lock. * gc-malloc.c (scm_realloc, increase_mtrigger): Set scm_gc_running_p while the scm_i_sweep_mutex is locked.
2005-03-02See ChangeLog from 2005-03-02.Marius Vollmer1-12/+10
2005-01-24Reverted changed from 2005/01/24 19:14:54, which was a commit to theMarius Vollmer1-10/+12
wrong branch. Sorry.
2005-01-24Threading changes.Marius Vollmer1-12/+10
2004-08-19* gc.h, gc.c (scm_i_gc_admin_mutex): New, to protectMarius Vollmer1-5/+19
scm_gc_mallocated, for now. (scm_init_storage): Initialize it. * gc-malloc.c (descrease_mtrigger, increase_mtrigger): Use it. * gc-mark.c (scm_gc_mark_dependencies): Call scm_i_string_mark, scm_i_stringbuf_mark and scm_i_symbol_mark, as appropriate. * gc-card.c (scm_i_sweep_card): Call scm_i_string_free, scm_i_stringbuf_free and scm_i_symbol_free, as appropriate.
2004-02-16Add a copyright year.Kevin Ryde1-1/+1
2004-02-16(scm_done_malloc, scm_done_free): Allow negative sizes,Kevin Ryde1-3/+9
which were permitted in the past for these.
2003-07-09(scm_gc_realloc): Define "ptr" at start of function.Kevin Ryde1-1/+3
2003-07-06(decrease_mtrigger): new functionHan-Wen Nienhuys1-13/+35
(increase_mtrigger): new function, separate debug registering and mtrigger administration. (scm_gc_realloc): bugfix: do mtrigger administration before the actual realloc, for the realloc might invalidate a GC-d segment of memory. Thanks to Sam Hocevar for pointing this out. (scm_gc_realloc): use scm_malloc_reregister instead of unregistering and registering in sequence.
2003-05-14(scm_gc_register_collectable_memory): avoidHan-Wen Nienhuys1-2/+11
wrap-around for scm_mtrigger (scm_gc_register_collectable_memory): abort on overflowing scm_mallocated().
2003-04-05Changed license terms to the plain LGPL thru-out.Marius Vollmer1-35/+11
2003-03-25* gc-malloc.c: #include <config.h> if HAVE_CONFIG_H.Rob Browning1-0/+4
2002-12-21* gc.c, gc.h (scm_i_sweep_mutex): New mutex.Mikael Djurfeldt1-11/+15
* gc.c (scm_gc_for_newcell), gc-malloc.c (scm_realloc, scm_gc_register_collectable_memory): Substitute locking of scm_i_sweep_mutex for calls to scm_i_thread_put_to_sleep. (scm_igc): Lock sweep mutex here instead of in callers; Calls to scm_i_thread_put_to_sleep/scm_i_thread_wake_up used to demarkate the single-thread section (which now only contains the mark phase). (scm_gc): Don't lock sweeo mutex here since scm_igc locks it; Removed SCM_DEFER/ALLOW_INTS. Simply call scm_igc directly. * threads.c (gc_section_mutex): Removed.
2002-12-11* gc-malloc.c, gc.h, init.c: Reverted gc-malloc change ofMikael Djurfeldt1-16/+0
2002-12-10.
2002-12-10* gc-malloc.c, gc.h (scm_gc_malloc_prehistory): New function.Mikael Djurfeldt1-3/+7
* gc-malloc.c (malloc_mutex): New mutex. (scm_gc_malloc_prehistory): Initialize it. (scm_realloc): Serialize call to realloc (scm_calloc): Same for calloc. Thanks to Wolfgang Jaehrling! (Now we have to make sure all calls to malloc/realloc are made through scm_malloc.) * init.c (scm_init_guile_1): Call scm_gc_malloc_prehistory.