summaryrefslogtreecommitdiff
path: root/libguile
AgeCommit message (Collapse)AuthorFilesLines
2011-12-06port locking refactorAndy Wingo3-73/+121
* libguile/ports.h (struct scm_t_port): Make the lock into a pointer field instead of an inline field. It should be possible to make unlocked ports by having a NULL lock field. (scm_c_lock_port, scm_c_try_lock_port): Return the mutex if the port was actually locked. (scm_c_unlock_port): Remove. * libguile/ports.c (scm_c_make_port_with_encoding): For now, leave `lock' set to 0. Change scm_c_lock_port callers to pay attention to the new API. * libguile/print.c (scm_write, scm_display): Fix call to dynwind-lock-port for ports-with-print-states.
2011-12-05warnings written to warning portAndy Wingo2-12/+12
* libguile/deprecation.c (scm_c_issue_deprecation_warning): * libguile/load.c (auto_compile_catch_handler): (scm_sys_warn_auto_compilation_enabled, scm_primitive_load_path): * module/ice-9/boot-9.scm (warn, %load-announce, duplicate-handlers) (load-in-vicinity): * module/system/base/message.scm (warning): Write to the warning port. (*current-warning-port*): Alias the warning port.
2011-12-05add current-warning-portAndy Wingo2-0/+26
* libguile/ports.h: * libguile/ports.c (scm_current_warning_port) (scm_set_current_warning_port): New functions, wrapping the Scheme parameter. * module/ice-9/boot-9.scm (current-warning-port): New parameter, defining a port for warnings.
2011-12-04ice-9/poll: verify sizeof(struct pollfd)Andy Wingo1-0/+1
* libguile/poll.c (scm_init_poll): Define %sizeof-struct-pollfd. * module/ice-9/poll.scm: Check %sizeof-struct-pollfd.
2011-12-04new print option escape-newlines, defaults to #tAndy Wingo2-10/+18
* libguile/private-options.h (SCM_PRINT_ESCAPE_NEWLINES_P): * libguile/print.c: Add new escape-newlines print option, defaulting to on. (write_character): For newlines, if SCM_PRINT_ESCAPE_NEWLINES_P, then print them as \n. (scm_init_print): Refactor print options initialization.
2011-12-02fix `free' of mpz_to_strAndy Wingo1-1/+7
* libguile/numbers.c (scm_number_to_string): Don't `free' the result of mpz_get_str; use the mp free function.
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-12-02Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo3-2/+44
Conflicts: libguile/guile.c libguile/numbers.c
2011-12-02install gmp memory functions that let libgc know about allocationsAndy Wingo3-3/+45
* libguile/numbers.c (custom_gmp_malloc, custom_gmp_realloc, custom_gmp_free): New static functions used by GMP for allocation. These are just wrappers for scm_malloc, scm_realloc, and free. (scm_init_numbers): If scm_install_gmp_memory_functions is nonzero, use mp_set_memory_functions to configure GMP to use custom_gmp_{malloc,realloc,free} for memory allocation. (scm_bigprint): Ask gmp for the function used to deallocate the string returned by mpz_get_str. * libguile/numbers.h: Declare scm_install_gmp_memory_functions. * libguile/guile.c: When running the Guile binary, install the gmp_memory_functions. Based on a patch by Mark H Weaver <mhw@netris.org>.
2011-12-01Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo19-76/+415
Conflicts: configure.ac libguile/fluids.c libguile/gc.c libguile/gc.h libguile/objcodes.c libguile/procprop.c libguile/vm.c module/ice-9/psyntax-pp.scm module/ice-9/psyntax.scm
2011-12-01fix deadlock in before-gc-hook on certain 7.2alpha gc versionsAndy Wingo1-1/+10
* libguile/gc.c (scm_init_gc): Only adjust gc frequency in the gc start hook if we know that it won't take a lock.
2011-11-29attempt to handle steady-state mallocations betterAndy Wingo3-1/+40
* 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-11-29collect a little in call-with-new-threadAndy Wingo1-0/+1
* libguile/threads.c (scm_call_with_new_thread): Collect a little before making a new thread. Our adjust_gc_frequency hack doesn't work well if the main allocation load is thread creation, as in https://savannah.gnu.org/bugs/?34140. This does not appreciably affect the speed of the test in that bug, but does effectively limit the image size.
2011-11-29adjust_gc_frequency before gc, for more precisionAndy Wingo1-1/+1
* libguile/gc.c (scm_init_gc): Run the adjust_gc_frequency from the before-gc-hook, not the after-gc-hook. More precise, this way.
2011-11-29fix uninitialized variable in gc.cAndy Wingo1-1/+1
* libguile/gc.c (get_image_size): Fix use of uninitialized variable.
2011-11-29switch off debugging flag that was mistakenly left onAndy Wingo1-1/+1
* libguile/gc.c (HEURISTICS_DEBUG): Whoops, switch this off.
2011-11-29increase garbage collection rate if the process is growingAndy Wingo1-2/+148
* configure.ac: Check for GC_get_free_space_divisor. * libguile/gc.c (GC_get_free_space_divisor): Define an implementation, if needed. (accumulate_gc_timer): Fix indentation. (get_image_size): New terrible hack. Needs implementations on other platforms. (adjust_gc_frequency): Attempt to adjust the GC frequency based on process image growth. Needs more comments. (scm_init_gc): Add the adjust_gc_frequency to the after_gc_c_hook.
2011-11-28get heap stats with GC_get_heap_usage_safe, if available.Andy Wingo1-6/+20
* configure.ac: Check for GC_get_heap_usage_safe. * libguile/gc.c (SCM_DEFINE): Use GC_get_heap_usage_safe.
2011-11-26FFI: Hold a weak reference to the procedure passed to `procedure->pointer'.Ludovic Courtès1-2/+4
* libguile/foreign.c (scm_procedure_to_pointer): Keep a weak reference to PROC. * test-suite/tests/foreign.test ("procedure->pointer")["procedure is retained"]: New test.
2011-11-24support for new GC_move_disappearing_linkAndy Wingo2-4/+34
* configure.ac: Check for GC_move_disappearing_link. * libguile/weak-set.c (move_weak_entry): * libguile/weak-table.c (move_disappearing_links): (move_weak_entry): Use GC_move_disappearing_link if available.
2011-11-24remove scm_si_name_accessAndy Wingo1-2/+1
* libguile/goops.h (scm_si_name_access): Remove alias for scm_si_getters_n_setters.
2011-11-24remove unused <class> slot: keyword-accessAndy Wingo2-6/+2
* libguile/goops.h (SCM_CLASS_CLASS_LAYOUT, scm_si_keyword_access): * libguile/goops.c (build_class_class_slots): Remove unused keyword-access slot from classes.
2011-11-24deprecate make-vtable-vtableAndy Wingo3-4/+40
* libguile/struct.h: * libguile/struct.c (scm_make_vtable_vtable): Deprecate, as you can handle most of the use cases with make-vtable, and we don't want to promote the creation of new roots to the type hierarchy. (scm_i_make_vtable_vtable): The internal replacement.
2011-11-24Scheme standard-vtable-fields bindingAndy Wingo1-0/+1
* libguile/struct.c (scm_init_struct): Export standard-vtable-fields to Scheme.
2011-11-24add Scheme binding for scm_standard_vtable_vtableAndy Wingo1-0/+1
* libguile/struct.c (scm_init_struct): Export <standard-vtable> to Scheme.
2011-11-24remove public scm_protects exportAndy Wingo2-4/+2
* libguile/gc.h: * libguile/gc.c: Remove scm_protects from the API. It is deprecated on stable-2.0.
2011-11-24no gc_register_root in scm_init_printAndy Wingo1-2/+0
* libguile/print.c (scm_init_print): No need to gc_register_root here.
2011-11-24remove object protection from options.cAndy Wingo1-26/+10
* libguile/options.c (change_option_setting, scm_init_options): Rely on the options being allocated in GC-able memory, as in static memory. Therefore there is no need for the gc-protect dance.
2011-11-24simplify scm_init_printAndy Wingo1-5/+3
* libguile/print.c (scm_init_print): Simplify creation of print-state vtable.
2011-11-23use new scm_make_fluid_with_defaultAndy Wingo3-9/+7
* libguile/load.c (scm_init_load): * libguile/ports.c (scm_init_ports): * libguile/read.c (scm_init_read): Use scm_make_fluid_with_default.
2011-11-23optional default-value arg to make-fluidAndy Wingo5-20/+36
* libguile/fluids.c (grow_dynamic_state, new_fluid): Arrange for the default value in the dynamic-state vector to be SCM_UNDEFINED instead of SCM_BOOL_F. If the value in the dynamic-state is #f, default to a value attached to the fluid instead. This allows useful default values. (scm_make_fluid_with_default): New function, allows the user to specify a default value for the fluid. Defaults to #f. Bound to `make-fluid' on the Scheme side. (scm_make_unbound_fluid): Use SCM_UNDEFINED as the default in all threads. (scm_fluid_unset_x): Also unset the default value. Not sure if this is the right thing. (fluid_ref): Update to the new default-value strategy. * libguile/threads.c (scm_i_reset_fluid): Reset to SCM_UNDEFINED. * libguile/threads.h: Remove extra arg to scm_i_reset_fluid. * libguile/vm-i-system.c (fluid-ref): Update to new default-value strategy. * module/ice-9/vlist.scm (block-growth-factor): Default to 2 in all threads. Fixes http://debbugs.gnu.org/10093.
2011-11-22Install the current locale when Guile is invoked directly.Ludovic Courtès1-2/+12
* libguile/guile.c (main): Add `setlocale' call.
2011-11-22Add missing implicit `SCM_API' for `scm_c_make_objcode_slice'.Ludovic Courtès1-1/+1
* libguile/objcodes.h (scm_c_make_objcode_slice): Add implicit `SCM_API'.
2011-11-22Complete cross-compilation support.Ludovic Courtès3-31/+102
* module/system/base/target.scm (%target-endianness, %target-word-size): New fluids. (%native-word-size): New variable. (with-target): Set these fluids. (cpu-endianness, cpu-word-size, triplet-cpu, triplet-vendor, triplet-os): New procedures. (target-cpu, target-vendor, target-os): Use them. (target-endianness, target-word-size): Refer to the corresponding fluid. * libguile/objcodes.c (target_endianness_var, target_word_size_var): New global variables. (NATIVE_ENDIANNESS): New macro. (target_endianness, target_word_size, to_native_order): New functions. (make_objcode_from_file): Use `scm_bytecode_to_native_objcode' instead of `scm_bytecode_to_objcode'. (bytecode_to_objcode): New function, based on `scm_bytecode_to_objcode', with the addition of an `endianness' and `word_size' parameters. (scm_bytecode_to_objcode): Use it. (scm_bytecode_to_native_objcode): New function. (scm_write_objcode): Use `target_word_size' and `target_endianness'. Convert OBJCODE's len and meta-len to native byte order. (scm_init_objcodes): Initialize `target_endianness_var' and `target_word_size_var'. * libguile/objcodes.h (scm_bytecode_to_native_objcode): New declaration. * libguile/vm.c (really_make_boot_program): Use `scm_bytecode_to_native_objcode' instead of `scm_bytecode_to_objcode'. * test-suite/tests/asm-to-bytecode.test (%objcode-cookie-size): New variable. (test-target): New procedure. ("cross-compilation"): Add `test-target' calls and the "unknown target" test.
2011-11-21deprecate direct scm_protects accessAndy Wingo2-3/+8
* libguile/gc.h: * libguile/gc.c: Deprecate direct access to scm_protects.
2011-11-20Allow overlapping regions to be passed to `bytevector-copy!'.Ludovic Courtès1-3/+3
Reported by Dmitry Chestnykh <dmitry@codingrobots.com>. Fixes <http://debbugs.gnu.org/10070>. * libguile/bytevectors.c (scm_bytevector_copy_x): Use `memmove', not `memcpy'. * test-suite/tests/bytevectors.test ("2.2 General Operations")["bytevector-copy! overlapping"]: New test. * doc/ref/api-data.texi (Bytevector Manipulation): Mention possible overlapping.
2011-11-16FFI: Hold a weak reference to the CIF made by `procedure->pointer'.Ludovic Courtès1-3/+11
* libguile/foreign.c (scm_procedure_to_pointer): Keep a weak reference to CIF so that it is not reclaimed before POINTER. Before that it could be reclaimed and typically reused to store the CIF of another procedure with the same arity, leading to obscure wrong-type-arg errors.
2011-11-16memoize: booleanify the rest argAndy Wingo1-1/+1
* libguile/memoize.c (memoize): Turn the rest arg into a boolean. Fixes an error when rest gets passed to set-procedure-minimum-arity!.
2011-11-15better debuggability for interpreted proceduresAndy Wingo2-0/+39
* libguile/procprop.c (scm_set_procedure_minimum_arity_x): New function, allows a user to override a function's arity. (scm_i_procedure_arity): Look up in the overrides table first. * libguile/procprop.h: Add scm_set_procedure_minimum_arity_x. * module/ice-9/eval.scm (primitive-eval): Override arity of "general closures". * test-suite/tests/procprop.test ("procedure-arity"): Add tests. Based on a patch from Stefan Israelsson Tampe. Test based on work by Patrick Bernaud.
2011-11-11Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-3/+3
2011-11-10fix bit-set*! bug (!)Andy Wingo1-4/+4
* libguile/bitvectors.c (scm_bit_set_star_x): Fix a long-standing (since 2005) bug in which instead of using the kv bitvector, we actually use the `v' bitvector. Also, change to allow `kv' being shorter than `v'. * test-suite/tests/bitvectors.test ("bit-set*!"): Add tests.
2011-11-09disable port lockingAndy Wingo1-3/+3
* libguile/ports.h (scm_c_lock_port, scm_c_try_lock_port) (scm_c_unlock_port): Disable port locking until I have time to sort out the bugs that are coming up.
2011-11-08lock ports in `write' and `display'Andy Wingo1-0/+8
* libguile/print.c (scm_write, scm_display): Lock the port during `display' and `write' calls. Fixes https://savannah.gnu.org/bugs/?33996.
2011-11-08add scm_dynwind_lock_portAndy Wingo2-0/+27
* libguile/ports.h: * libguile/ports.c (scm_dynwind_lock_port): New function.
2011-11-08locking for write, lfwriteAndy Wingo6-27/+46
* libguile/ports.c (scm_c_write_unlocked, scm_c_write) (scm_lfwrite_unlocked, scm_lfwrite): Add locking and _unlocked variants. Change uses to _unlocked.
2011-11-08locking for putc, putsAndy Wingo44-215/+233
* libguile/ports.c (scm_putc, scm_puts): * libguile/ports.h (scm_putc_unlocked, scm_puts_unlocked): Separate into _unlocked and locked variants. Change all callers to use the _unlocked versions.
2011-11-08locking on port buffering operationsAndy Wingo10-24/+57
* libguile/ports.c (scm_fill_input_unlocked, scm_fill_input) (scm_end_input, scm_end_input_unlocked, scm_flush) (scm_flush_unlocked): Add locking and _unlocked variants. * libguile/filesys.c: * libguile/fports.c: * libguile/gdbint.c: * libguile/r6rs-ports.c: * libguile/read.c: * libguile/rw.c: Adapt callers to use _unlocked variants.
2011-11-08locking on unget_byte, ungetc, ungetsAndy Wingo6-38/+63
* libguile/ports.h: * libguile/ports.c (scm_unget_byte_unlocked, scm_unget_byte) (scm_ungetc_unlocked, scm_ungetc, scm_ungets_unlocked, scm_ungets): Add locking and _unlocked variants. * libguile/arrays.c: * libguile/rdelim.c: * libguile/read.c: * libguile/vports.c: Adapt callers to use the _unlocked variants.
2011-11-08locking on scm_c_read, scm_getcAndy Wingo6-39/+65
* libguile/ports.c (scm_c_read_unlocked, scm_c_read, scm_getc_unlocked) (scm_getc): Split getc and read operations into locked and unlocked variants. Change most uses to use the _unlocked version.
2011-11-08threadsafe get-byte-or-eof, peek-byte-or-eofAndy Wingo3-19/+45
* libguile/ports.h (scm_get_byte_or_eof_unlocked): (scm_peek_byte_or_eof_unlocked): Rename, adding _unlocked. * libguile/ports.c (scm_get_byte_or_eof, scm_peek_byte_or_eof): Add locking implementations. Adapt callers to use _unlocked variants; they will do locking. * libguile/read.c (read_token, scm_read_semicolon_comment) (scm_read_shebang): Use unlocked variants. We will add locking later.