summaryrefslogtreecommitdiff
path: root/libguile
AgeCommit message (Collapse)AuthorFilesLines
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.
2011-11-08threadsafe port revealed countsAndy Wingo2-2/+31
* libguile/ports.h: * libguile/ports.c (scm_revealed_count, scm_set_port_revealed_x): Make threadsafe. (scm_adjust_port_revealed_x): New function, to adjust a port's revealed count in a threadsafe way.
2011-11-08scm_c_lock_port takes a portAndy Wingo1-9/+9
* libguile/ports.h (scm_c_lock_port, scm_c_try_lock_port) (scm_c_unlock_port): Take a port instead of an entry.
2011-11-07ports implementation reorderingAndy Wingo2-921/+953
* libguile/ports.h: Slight reorder. * libguile/ports.c: Reorder ports implementation to match the header file. This will make it easier to add locking and _unlocked variants.
2011-11-07threadsafe access to scm_ptobsAndy Wingo6-100/+140
* libguile/ports.h (SCM_PORT_DESCRIPTOR): New macro, to get at a port descriptor in the third word of a port instead of looking it up in a table. (scm_c_port_type_ref, scm_c_port_type_add_x): New API for working with numbered ptob descriptors. (SCM_PTOBNAME): Implement in terms of scm_c_port_type_ref. (scm_get_byte_or_eof, scm_peek_byte_or_eof): Use SCM_PORT_DESCRIPTOR. * libguile/ports.c (scm_c_num_port_types, scm_c_port_type_ref) (scm_c_port_type_add_x, scm_make_port_type): Protect scm_ptobs access with a mutex. Have it be an array of pointers instead of an array of structures. Adapt users to the new APIs. (scm_c_make_port_with_encoding): Allocate ports with three words. The third word is the ptob descriptor. * libguile/backtrace.c: * libguile/goops.c: * libguile/ioext.c: * libguile/print.c: Adapt to use scm_c_port_type_ref and SCM_PORT_DESCRIPTOR.
2011-11-07reorder ports.h declarationsAndy Wingo1-44/+74
* libguile/ports.h: Reorder declarations.
2011-11-07remove scm_markstreamAndy Wingo2-16/+3
* libguile/ports.h: * libguile/ports.c (scm_markstream): Remove obsolete definition. Moved around a couple of other declarations.
2011-11-07ports.h: remove unimplemented declarationsAndy Wingo1-9/+1
* libguile/ports.h (scm_grow_port_cbuf, scm_pt_size, scm_pt_member): Remove declarations of unimplemented functions. Move a couple of other definitions around.
2011-11-07inlined port functions to ports.hAndy Wingo2-107/+106
* libguile/inline.h: * libguile/ports.h (scm_get_byte_or_eof, scm_peek_byte_or_eof) (scm_putc, scm_puts): Move definitions here, from inline.h.
2011-11-07add lock to scm_t_portAndy Wingo3-0/+45
* libguile/ports.h (scm_c_lock_port, scm_c_try_lock_port) (scm_c_unlock_port): New inline functions. (scm_t_port): Add a lock field, if threads are enabled. This is a first step towards threadsafe ports. * libguile/ports.c (scm_c_make_port_with_encoding): Init the port's lock. * libguile/inline.c: Residualize the inline functions from ports.h.
2011-11-04more robust scm_exit_statusAndy Wingo1-2/+8
* libguile/throw.c (scm_exit_status): In one of my bogus patches, I managed to make #<unspecified> reach this function, causing a segfault on SCM_CAR. Refactor to be more robust.
2011-10-28add string-length, string-ref, vector-length instructionsAndy Wingo2-48/+95
* libguile/_scm.h (SCM_OBJCODE_MAJOR_VERSION): Bump the major version, indicating the first incompatibility between 2.0 and 2.2. * libguile/vm-i-scheme.c (string-length, string-ref, vector-length): New instructions. * module/language/tree-il/compile-glil.scm (*primcall-ops*): Add primcall ops for the new instructions.
2011-10-27fix hash of zero-length vectorsAndy Wingo1-2/+3
* libguile/hash.c (scm_raw_ihash): Fix for zero-length vectors.
2011-10-27Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo5-33/+115
Conflicts: GUILE-VERSION libguile/deprecated.c libguile/gc-malloc.c module/language/tree-il/peval.scm
2011-10-26update `hash'Andy Wingo1-100/+36
* libguile/hash.c (scm_raw_ihash): Rename from `hasher'. Remove the modulo argument; we expect the caller to deal with that. Use scm_i_hashq for immediates and non-immediate integers. Use scm_raw_ihashq on pointers too. Update the vector and pairs hashing code. There is still some work to do here. (scm_ihashv, scm_ihash): Adapt.
2011-10-26don't downcase characters before hashing themAndy Wingo1-7/+1
* libguile/hash.c (hasher, scm_ihashv): Don't downcase characters before hashing them. That is silly.
2011-10-26scm_hasher is staticAndy Wingo2-10/+8
* libguile/hash.c (hasher): Make static. * libguile/hash.h: Remove scm_hasher.
2011-10-26add thomas wang's integer hash function; use it for hashq, hashvAndy Wingo1-3/+30
* libguile/hash.c (scm_raw_ihashq): Add Thomas Wang's integer hash function, from http://www.cris.com/~Ttwang/tech/inthash.htm. (scm_ihashq, scm_ihashv): Use it here.
2011-10-26symbols.h reindentAndy Wingo1-1/+1
* libguile/symbols.h: Reindent.
2011-10-26use bob jenkins' hashword2 hash from lookup3.c for our string hashAndy Wingo1-62/+141
* libguile/hash.c (JENKINS_LOOKUP3_HASHWORD2, narrow_string_hash) (wide_string_hash, scm_string_hash, scm_i_string_hash) (scm_i_latin1_string_hash): Replace our lame string hash with Bob Jenkins' hash, treating each codepoint as a word, for the purposes of the algorithm. There are probably more optimal hashes for our use cases. (scm_i_locale_string_hash): Remove optimization, as it wasn't used. (scm_i_utf8_string_hash): Add a specialized implementation for utf8. It's tricky but mostly just cut-and-paste.
2011-10-25optimize scm_from_utf8_stringnAndy Wingo1-14/+93
* libguile/strings.c (decoding_error): Factor out of scm_from_stringn, properly handling errno. (scm_from_stringn): Adapt. (scm_from_utf8_stringn): Inline the conversion here, to avoid going through iconv.
2011-10-25most uses of scm_from_locale_symbol become scm_from_utf8_symbolAndy Wingo15-33/+33
* libguile/array-handle.c: * libguile/chars.c: * libguile/expand.c: * libguile/feature.c: * libguile/goops.c: * libguile/gsubr.c: * libguile/instructions.c: * libguile/load.c: * libguile/macros.c: * libguile/memoize.c: * libguile/modules.c: * libguile/options.c: * libguile/print.c: * libguile/smob.c: * libguile/snarf.h: Change most uses of scm_from_locale_symbol to scm_from_utf8_symbol, as the symbols really are not locale-dependent.
2011-10-25optimize utf8 symbol lookupAndy Wingo1-2/+84
* libguile/symbols.c (utf8_string_equals_wide_string) (utf8_lookup_predicate_fn, lookup_interned_utf8_symbol): Optimize utf8 symbol lookup.
2011-10-24slight scm_procedure_p, scm_i_procedure_arity refactorAndy Wingo2-27/+13
* libguile/procs.c (scm_procedure_p): * libguile/procprop.c (scm_i_procedure_arity): Refactor.
2011-10-24remove CELL_P macroAndy Wingo1-13/+1
* libguile/private-gc.h: Remove private CELL_P macro.
2011-10-24add SCM_HEAP_OBJECT_BASEAndy Wingo14-25/+41
* libguile/tags.h (SCM_HEAP_OBJECT_BASE): New macro. Given a SCM, returns a pointer to the start of its memory area on the heap. * libguile/bytevectors.c: * libguile/fluids.c: * libguile/foreign.c: * libguile/gc.h: * libguile/guardians.c: * libguile/numbers.h: * libguile/ports.c: * libguile/smob.c: * libguile/struct.c: * libguile/weak-set.c: * libguile/weak-table.c: * libguile/weak-vector.c: Use it.
2011-10-24add SCM_HEAP_OBJECT_PAndy Wingo14-32/+26
* libguile/tags.h (SCM_HEAP_OBJECT_P): New macro, an alias for SCM_NIMP. * libguile/arrays.c: * libguile/debug.c: * libguile/foreign.c: * libguile/gdbint.c: * libguile/guardians.c: * libguile/list.c: * libguile/modules.c: * libguile/options.c: * libguile/smob.c: * libguile/validate.h: * libguile/weak-set.c: * libguile/weak-table.c: * libguile/weak-vector.c: Use it instead of SCM_NIMP or !SCM_IMP.
2011-10-24boot_closure_print cleanupAndy Wingo1-1/+1
* libguile/eval.c (boot_closure_print): Get at the bits directly.
2011-10-24add SCM_{PACK,UNPACK}_POINTERAndy Wingo19-91/+83
* libguile/tags.h (SCM_UNPACK_POINTER, SCM_PACK_POINTER): New macros. The old SCM2PTR and PTR2SCM were defined in such a way that round-tripping through a pointer could lose precision, even in the case in which you weren't interested in actually dereferencing the pointer, it was simply that you needed to plumb a SCM through APIs that take pointers. These new macros are more like SCM_PACK and SCM_UNPACK, but for pointer types. The bit representation of the pointer should be the same as the scm_t_bits representation. * libguile/gc.h (PTR2SCM, SCM2PTR): Remove support for (old) UNICOS pointers. We are going to try tagging the SCM object itself in the future, and I don't think that keeping this support is worth its cost. It probably doesn't work anyway. * libguile/backtrace.c: * libguile/bytevectors.c: * libguile/continuations.c: * libguile/fluids.c: * libguile/foreign.c: * libguile/gc.h: * libguile/guardians.c: * libguile/hashtab.c: * libguile/load.c: * libguile/numbers.c: * libguile/ports.c: * libguile/smob.c: * libguile/strings.c: * libguile/symbols.c: * libguile/vm.c: * libguile/weak-set.c: * libguile/weak-table.c: * libguile/weak-vector.c: Update many sites to use the new macros.
2011-10-24refactor tc7 and tc16 checksAndy Wingo26-59/+56
* libguile/tags.h (SCM_HAS_TYP7, SCM_HAS_TYP7S, SCM_HAS_TYP16): New macros. * libguile/bytevectors.h (SCM_BYTEVECTOR_P): * libguile/control.h (SCM_PROMPT_P): * libguile/filesys.h (SCM_DIRP): * libguile/fluids.h (SCM_WITH_FLUIDS_P, SCM_FLUID_P) (SCM_I_DYNAMIC_STATE_P): * libguile/foreign.h (SCM_POINTER_P): * libguile/fports.h (SCM_FPORTP): * libguile/frames.h (SCM_VM_FRAME_P): * libguile/hashtab.h (SCM_HASHTABLE_P): * libguile/inline.h (scm_get_byte_or_eof): * libguile/numbers.h (SCM_REALP, SCM_BIGP, SCM_COMPLEXP, SCM_FRACTIONP): * libguile/objcodes.h (SCM_OBJCODE_P): * libguile/ports.h (SCM_OUTPUT_PORT_P): * libguile/programs.h (SCM_PROGRAM_P): * libguile/smob.h (SCM_SMOB_PREDICATE): * libguile/srfi-14.h (SCM_CHARSETP): * libguile/strings.c (IS_STRING): * libguile/strports.h (SCM_STRPORTP): * libguile/symbols.h (scm_is_symbol): * libguile/variable.h (SCM_VARIABLEP): * libguile/vectors.h (SCM_I_IS_VECTOR, SCM_I_IS_NONWEAK_VECTOR): * libguile/vm-i-system.c (call, tail-call, mv-call) * libguile/vm.h (SCM_VM_P, SCM_VM_CONT_P): * libguile/weak-set.c (SCM_WEAK_SET_P): * libguile/weak-table.c (SCM_WEAK_TABLE_P): * libguile/weak-vector.h (SCM_I_WVECTP): Use them.
2011-10-24check for pairs with scm_is_pair, not scm_nimpAndy Wingo5-13/+13
* libguile/array-map.c (scm_ra_matchp, scm_ramapc): * libguile/dynwind.c (scm_swap_bindings): * libguile/hooks.c (hook_print, scm_c_run_hook, scm_c_run_hookn): * libguile/objprop.c (scm_object_property, scm_set_object_property_x): Use !scm_is_pair as the termination condition, not scm_imp.
2011-10-24de-inline cons in scm_aconsAndy Wingo1-4/+2
* libguile/alist.c (scm_acons): Don't inline the conses.
2011-10-24remove weak pairs, rewrite weak vectorsAndy Wingo19-622/+349
* libguile/weak-vector.c: * libguile/weak-vector.h: Renamed from weaks.[ch]. Remove weak pairs. They were not safe to access with `car' and `cdr'. Remove weak alist vectors, as we have weak tables and sets. Reimplement weak vectors, moving the implementation here. * libguile/vectors.c: * libguile/vectors.h: Remove the extra header word. Use scm_c_weak_vector_ref / scm_c_weak_vector_set_x to access weak vectors. * libguile/snarf.h: Remove the extra header word in vectors. * libguile/threads.c (do_thread_exit, fat_mutex_lock, fat_mutex_unlock): Instead of weak pairs, store thread-owned mutexes in a list of one-element weak vectors. * libguile/guardians.c (finalize_guarded): Similarly, store object guardians in a list of one-element weak vectors. * libguile/modules.c (scm_module_reverse_lookup): We no longer need to handle the case of weak references. * libguile/print.c (iprin1): Use the standard vector accessor to print vectors. * libguile.h: * libguile/Makefile.am: * libguile/gc-malloc.c: * libguile/gc.c: * libguile/goops.c: * libguile/init.c: * libguile/objprop.c: * libguile/struct.c: Update includes. * module/ice-9/weak-vector.scm: Load weak vector definitions using an extension instead of %init-weaks-builtins. * test-suite/tests/weaks.test: Use the make-...-hash-table names instead of the old alist vector names.
2011-10-24convert internal weak hash table users to use the weak table apiAndy Wingo6-91/+51
The weak table API isn't public yet. It could be after some review. But we can go ahead and use it now internally. * libguile/foreign.c: * libguile/goops.c: * libguile/objprop.c: * libguile/procprop.c: * libguile/smob.c: * libguile/srcprop.c: Update weak table users to new API. No locking needed!
2011-10-24reimplement hashtab.c's weak hash tables in terms of weak-table.cAndy Wingo4-597/+235
* libguile/hashtab.c: * libguile/hashtab.h: Reimplement the weak hash table implementation in terms of weak tables. All is well except for the horrific hack for hashx tables. * libguile/weak-table.h: * libguile/weak-table.c (scm_make_weak_key_hash_table) (scm_make_weak_value_hash_table, scm_make_doubly_weak_hash_table) (scm_weak_key_hash_table_p, scm_weak_value_hash_table_p) (scm_doubly_weak_hash_table_p): Move these definitions here.
2011-10-24add weak table implementationAndy Wingo8-1/+1145
* libguile/weak-table.c: * libguile/weak-table.h: New files, implementing open-addressed weak hash tables, similar to the implementation of weak sets. This will let us remove weak pairs. * libguile.h: * libguile/Makefile.am: * libguile/evalext.c: * libguile/gc.c: * libguile/init.c: * libguile/print.c: * libguile/tags.h: Update all the pieces for the new files and tc7.
2011-10-23add scm_c_make_port; the port table is now a weak setAndy Wingo7-209/+141
* libguile/ports.c (scm_c_make_port_with_encoding, scm_c_make_port): New functions, to replace scm_new_port_table_entry. Use a weak set instead of a weak table. (scm_i_remove_port): (scm_c_port_for_each, scm_port_for_each): Adapt to use weak set. (scm_i_void_port): Use scm_c_make_port. (scm_init_ports): Make a weak set. * libguile/fports.c: * libguile/ioext.c: * libguile/r6rs-ports.c: * libguile/strports.c: * libguile/vports.c: Adapt to use the new scm_c_make_port API.
2011-10-23symbols.c uses weak setsAndy Wingo1-61/+30
* libguile/symbols.c (lookup_interned_symbol) (lookup_interned_latin1_symbol, intern_symbol): Adapt to use weak sets instead of weak-key hash tables.
2011-10-23add weak setsAndy Wingo8-1/+968
* libguile/weak-set.c: * libguile/weak-set.h: New files, implementing weak sets, for use in the symbol table and port set. Eventually we will be able to remove weak pairs. * libguile.h: * libguile/Makefile.am: Add new files. * libguile/evalext.c: * libguile/gc.c: * libguile/init.c: * libguile/print.c: * libguile/tags.h: Add support for the new types.
2011-10-22Fix compilation of `deprecated.c' with SCM_DEBUG_TYPING_STRICTNESS=2.Ludovic Courtès1-5/+5
* libguile/deprecated.c (init_module_stuff, scm_primitive_make_property): Use `scm_is_false' instead of direct comparison to SCM_BOOL_F'. (maybe_close_port, scm_close_all_ports_except): Use `SCM2PTR' and `PTR2SCM' instead of wild casts.