bpt/guile.git
12 years agoAdd Gnulib `largefile' module.
Ludovic Courtès [Tue, 22 Nov 2011 11:03:32 +0000 (12:03 +0100)]
Add Gnulib `largefile' module.

It will really be added next time we run "gnulib-tool --update".

12 years agoMerge remote-tracking branch 'origin/stable-2.0'
Andy Wingo [Fri, 11 Nov 2011 15:40:49 +0000 (16:40 +0100)]
Merge remote-tracking branch 'origin/stable-2.0'

12 years agoupdate letrec compilation test
Andy Wingo [Fri, 11 Nov 2011 15:39:28 +0000 (16:39 +0100)]
update letrec compilation test

* test-suite/tests/tree-il.test ("letrec"): Update to clear the
  temporary `let' bindings.

12 years agoMerge remote-tracking branch 'origin/stable-2.0'
Andy Wingo [Fri, 11 Nov 2011 15:27:30 +0000 (16:27 +0100)]
Merge remote-tracking branch 'origin/stable-2.0'

12 years agofix bit-set*! bug (!)
Andy Wingo [Thu, 10 Nov 2011 21:30:02 +0000 (22:30 +0100)]
fix bit-set*! bug (!)

* 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.

12 years agowhen leaving a non-tail let, allow bound vals to be collected
Andy Wingo [Wed, 9 Nov 2011 22:45:53 +0000 (23:45 +0100)]
when leaving a non-tail let, allow bound vals to be collected

* module/language/tree-il/compile-glil.scm (flatten-lambda-case): Clear
  lexical stack slots at the end of a non-tail let, letrec, or fix.
  Fixes http://debbugs.gnu.org/9900.

* test-suite/tests/gc.test ("gc"): Add test.

12 years agodisable port locking
Andy Wingo [Wed, 9 Nov 2011 22:02:02 +0000 (23:02 +0100)]
disable port locking

* 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.

12 years agoinline dynwind guards for normal control flow
Andy Wingo [Wed, 9 Nov 2011 18:36:10 +0000 (19:36 +0100)]
inline dynwind guards for normal control flow

* module/language/tree-il.scm (<tree-il>): Add `pre' and `post' fields
  to <dynwind>, so that we can inline the guard bodies in the normal
  control-flow case.  It also avoids duplicating code in compile-glil,
  which probably hides more bugs in 2.0.
  (parse-tree-il, unparse-tree-il, tree-il->scheme, tree-il-fold)
  (make-tree-il-folder, post-order!, pre-order!): Update.

* module/language/tree-il/analyze.scm (analyze-lexicals): Update.

* module/language/tree-il/compile-glil.scm (flatten-lambda-case): Update
  to use `pre' and `post' instead of compiling code twice.

* module/language/tree-il/debug.scm (verify-tree-il): Update.

* module/language/tree-il/peval.scm (peval): Update.  Instead of doing
  complicated things in <dynwind>, handle 'dynamic-wind primcalls.

* module/language/tree-il/primitives.scm (*primitive-expand-table*):
  Remove 'dynamic-wind mess.  Adapt '@dynamic-wind.

* test-suite/tests/tree-il.test ("partial evaluation"): Update tests.

12 years agoMerge remote-tracking branch 'origin/stable-2.0'
Andy Wingo [Wed, 9 Nov 2011 16:04:44 +0000 (17:04 +0100)]
Merge remote-tracking branch 'origin/stable-2.0'

Conflicts:
module/language/tree-il/peval.scm
module/language/tree-il/primitives.scm
test-suite/tests/tree-il.test

12 years agosimplify primitives.scm for dynwind
Andy Wingo [Wed, 9 Nov 2011 15:44:59 +0000 (16:44 +0100)]
simplify primitives.scm for dynwind

* module/language/tree-il/primitives.scm (*primitive-expand-table*):
  Remove a dynwind hack, as we have a good inliner now.

12 years agopeval: fix dynwind bug.
Andy Wingo [Wed, 9 Nov 2011 14:23:58 +0000 (15:23 +0100)]
peval: fix dynwind bug.

* module/language/tree-il/peval.scm (peval): The <dynwind> compiler will
  copy the winder and unwinder values, so make sure that they are
  constant, and if not, create lexical bindings.  Fixes
  http://debbugs.gnu.org/9844.

* test-suite/tests/tree-il.test ("partial evaluation"): Add a couple
  <dynwind> tests.

12 years agofix <dynwind> serialization.
Andy Wingo [Wed, 9 Nov 2011 15:41:56 +0000 (16:41 +0100)]
fix <dynwind> serialization.

* module/language/tree-il.scm (unparse-tree-il): Fix <dynwind>
  serialization.

12 years agopeval: don't copy assigned lexical bindings
Andy Wingo [Wed, 9 Nov 2011 14:22:01 +0000 (15:22 +0100)]
peval: don't copy assigned lexical bindings

* module/language/tree-il/peval.scm (peval): Since constant-expression?
  is used to determine whether to copy values, return #f if any lexical
  is assigned.

12 years agolock ports in `write' and `display'
Andy Wingo [Tue, 8 Nov 2011 18:17:23 +0000 (19:17 +0100)]
lock ports in `write' and `display'

* libguile/print.c (scm_write, scm_display): Lock the port during
  `display' and `write' calls.  Fixes
  https://savannah.gnu.org/bugs/?33996.

12 years agoadd scm_dynwind_lock_port
Andy Wingo [Tue, 8 Nov 2011 18:16:33 +0000 (19:16 +0100)]
add scm_dynwind_lock_port

* libguile/ports.h:
* libguile/ports.c (scm_dynwind_lock_port): New function.

12 years agolocking for write, lfwrite
Andy Wingo [Mon, 7 Nov 2011 23:46:41 +0000 (00:46 +0100)]
locking for write, lfwrite

* libguile/ports.c (scm_c_write_unlocked, scm_c_write)
  (scm_lfwrite_unlocked, scm_lfwrite): Add locking and _unlocked
  variants.  Change uses to _unlocked.

12 years agolocking for putc, puts
Andy Wingo [Mon, 7 Nov 2011 23:36:48 +0000 (00:36 +0100)]
locking for putc, puts

* 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.

12 years agolocking on port buffering operations
Andy Wingo [Mon, 7 Nov 2011 23:29:46 +0000 (00:29 +0100)]
locking on port buffering operations

* 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.

12 years agolocking on unget_byte, ungetc, ungets
Andy Wingo [Mon, 7 Nov 2011 23:14:16 +0000 (00:14 +0100)]
locking on unget_byte, ungetc, ungets

* 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.

12 years agolocking on scm_c_read, scm_getc
Andy Wingo [Mon, 7 Nov 2011 22:53:06 +0000 (23:53 +0100)]
locking on scm_c_read, scm_getc

* 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.

12 years agothreadsafe get-byte-or-eof, peek-byte-or-eof
Andy Wingo [Mon, 7 Nov 2011 19:17:22 +0000 (20:17 +0100)]
threadsafe get-byte-or-eof, peek-byte-or-eof

* 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.

12 years agothreadsafe port revealed counts
Andy Wingo [Mon, 7 Nov 2011 19:00:39 +0000 (20:00 +0100)]
threadsafe port revealed counts

* 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.

12 years agoscm_c_lock_port takes a port
Andy Wingo [Mon, 7 Nov 2011 23:50:47 +0000 (00:50 +0100)]
scm_c_lock_port takes a port

* libguile/ports.h (scm_c_lock_port, scm_c_try_lock_port)
  (scm_c_unlock_port): Take a port instead of an entry.

12 years agoports implementation reordering
Andy Wingo [Mon, 7 Nov 2011 18:48:50 +0000 (19:48 +0100)]
ports implementation reordering

* 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.

12 years agothreadsafe access to scm_ptobs
Andy Wingo [Mon, 7 Nov 2011 17:58:01 +0000 (18:58 +0100)]
threadsafe access to scm_ptobs

* 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.

12 years agoreorder ports.h declarations
Andy Wingo [Mon, 7 Nov 2011 16:08:31 +0000 (17:08 +0100)]
reorder ports.h declarations

* libguile/ports.h: Reorder declarations.

12 years agoremove scm_markstream
Andy Wingo [Mon, 7 Nov 2011 15:25:37 +0000 (16:25 +0100)]
remove scm_markstream

* libguile/ports.h:
* libguile/ports.c (scm_markstream): Remove obsolete definition.  Moved
  around a couple of other declarations.

12 years agoports.h: remove unimplemented declarations
Andy Wingo [Mon, 7 Nov 2011 15:22:55 +0000 (16:22 +0100)]
ports.h: remove unimplemented declarations

* 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.

12 years agoinlined port functions to ports.h
Andy Wingo [Mon, 7 Nov 2011 15:14:15 +0000 (16:14 +0100)]
inlined port functions to ports.h

* 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.

12 years agoadd lock to scm_t_port
Andy Wingo [Mon, 7 Nov 2011 15:01:01 +0000 (16:01 +0100)]
add lock to scm_t_port

* 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.

12 years agoregenerate psyntax-pp
Andy Wingo [Mon, 7 Nov 2011 10:48:30 +0000 (11:48 +0100)]
regenerate psyntax-pp

* module/ice-9/psyntax-pp.scm: Regenerate.

12 years agoadd tests for hygienic name introduction
Andy Wingo [Mon, 7 Nov 2011 10:47:26 +0000 (11:47 +0100)]
add tests for hygienic name introduction

* test-suite/tests/syntax.test ("top-level define"): Add tests for
  hygienic introduction of names.

12 years agohygienically rename macro-introduced bindings, reproducibly
Andy Wingo [Fri, 4 Nov 2011 18:34:22 +0000 (19:34 +0100)]
hygienically rename macro-introduced bindings, reproducibly

* module/ice-9/psyntax.scm (chi-top-sequence): Detect bindings to
  identifiers introduced by macros.  In that case, in order to preserve
  hygiene, uniquify the variable's name, but in a way that is
  reproduceable (i.e., yields the same uniquified name after a
  recompile).

12 years agofix scope bug in <module> definition in boot-9
Andy Wingo [Mon, 7 Nov 2011 09:22:26 +0000 (10:22 +0100)]
fix scope bug in <module> definition in boot-9

* module/ice-9/boot-9.scm (define-record-type): Fix scope bug when
  generating identifiers.

12 years agoanother scoping test
Andy Wingo [Mon, 7 Nov 2011 10:44:54 +0000 (11:44 +0100)]
another scoping test

* test-suite/tests/syntax.test ("top-level define"): Add another test
  for scoping.

12 years agoresolve-identifier for toplevel definitions resolves by module
Andy Wingo [Mon, 7 Nov 2011 08:55:57 +0000 (09:55 +0100)]
resolve-identifier for toplevel definitions resolves by module

* module/ice-9/psyntax.scm (id-var-name): For mapping identifiers to
  toplevel definitions, also compare against the module.
  (resolve-identifier): Pass the module to id-var-name when looking up
  identifiers.
  (free-id=?): Adapt to id-var-name change.
  (chi-top-sequence): When adding a mapping from the given identifier
  to a toplevel definition, make the name be a pair.

12 years agoadd scoping test
Andy Wingo [Mon, 7 Nov 2011 10:41:00 +0000 (11:41 +0100)]
add scoping test

* test-suite/tests/syntax.test ("top-level define"): Add a test for
  module scoping of introduced identifiers.

12 years agodefined identifiers scoped in the current module
Andy Wingo [Fri, 4 Nov 2011 18:37:04 +0000 (19:37 +0100)]
defined identifiers scoped in the current module

* ice-9/psyntax.scm (chi-top-sequence): Wrap defined identifiers with
  the current module.  Fixes http://savannah.gnu.org/bugs/?31472.

12 years agosyntax parameters implemented properly
Andy Wingo [Sat, 5 Nov 2011 14:36:02 +0000 (15:36 +0100)]
syntax parameters implemented properly

* module/ice-9/psyntax.scm (resolve-identifier): Take an additional
  argument, indicating whether syntax parameters should be resolved or
  not.  Just return three values: the binding type and value, and the
  module for resolving toplevels.
  (chi-install-global): Take an extra arg, the type.  If we are defining
  a syntax parameter, construct a pair for the binding.
  (chi-body): Syntax parameters now use a per-parameter unique value (a
  pair) as a key in the expansion-time environment `r'.
  (syntax-parameterize): Don't allow parameterization of
  non-parameters.  This is an incompatible change, but it is for the
  better; you don't want to allow users to parameterize `lambda', after
  all.

12 years agosyntax-parameterize, not fluid-let-syntax
Andy Wingo [Sat, 5 Nov 2011 12:53:33 +0000 (13:53 +0100)]
syntax-parameterize, not fluid-let-syntax

* module/ice-9/psyntax.scm (syntax-parameterize): Rename from
  fluid-let-syntax.

* module/ice-9/boot-9.scm (define-inlinable): Use syntax-parameterize
  (and define-syntax-parameter).

12 years agoadd define-syntax-parameter, same as define-syntax
Andy Wingo [Sat, 5 Nov 2011 11:40:58 +0000 (12:40 +0100)]
add define-syntax-parameter, same as define-syntax

* module/ice-9/psyntax.scm (define-syntax-parameter): New toplevel form.
  Will be used to implement syntax parameters, following Barzilay,
  Culpepper, and Flatt's 2011 SFP workshop paper, "Keeping it Clean with
  syntax-parameterize".  Adds a new binding type and definition form.

12 years agopsyntax: resolve-identifier refactor
Andy Wingo [Fri, 4 Nov 2011 17:50:38 +0000 (18:50 +0100)]
psyntax: resolve-identifier refactor

* module/ice-9/psyntax.scm (id-var-name): Add a nice long comment.
  (lookup): Remove, as it is no longer used.
  (resolve-identifier): New helper, replaces most uses of id-var-name
  then `lookup'.
  (syntax-type, syntax, set!, fluid-let-syntax): Adapt to use
  resolve-identifier.
  (free-id=?): Adapt to id-var-name returning syntax objects.

12 years agochi-top-sequence refactor
Andy Wingo [Fri, 4 Nov 2011 12:47:24 +0000 (13:47 +0100)]
chi-top-sequence refactor

* module/ice-9/psyntax.scm (chi-top-sequence): Reimplement, more like
  chi-body.  Instead of adding empty definitions to the toplevel, add
  toplevel definitions to the wrap shared by all forms in the sequence.

12 years agominor psyntax refactors
Andy Wingo [Fri, 4 Nov 2011 12:44:41 +0000 (13:44 +0100)]
minor psyntax refactors

* module/ice-9/psyntax.scm (syntax-type): Remove redundant lexical
  case.
  (syntax-rules, define-syntax-rule): Use `_' instead of `dummy' for the
  keyword.

* module/ice-9/boot-9.scm (define-syntax-rule): Remove redundant
  definition.

12 years agopeval doesn't resolve primitives
Andy Wingo [Fri, 4 Nov 2011 12:38:28 +0000 (13:38 +0100)]
peval doesn't resolve primitives

* module/language/tree-il/peval.scm (peval): Don't resolve primitives,
  as resolve-primitives! handles that already.

* test-suite/tests/tree-il.test (pass-if-peval): Always resolve and
  expand primitives.
  ("partial evaluation"): Update tests to assume expanded primitives.

12 years agoresolve-primitives! does not primitivize local definitions
Andy Wingo [Fri, 4 Nov 2011 12:37:58 +0000 (13:37 +0100)]
resolve-primitives! does not primitivize local definitions

* module/language/tree-il/primitives.scm (resolve-primitives!): Don't
  resolve toplevels defined in the same compilation unit to primitives,
  as it could be that the module doesn't have those bindings yet.

12 years agomore robust scm_exit_status
Andy Wingo [Fri, 4 Nov 2011 12:35:19 +0000 (13:35 +0100)]
more robust scm_exit_status

* 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.

12 years agoFix R6RS `fold-left' so the accumulator is the first argument.
Ian Price [Wed, 26 Oct 2011 19:24:05 +0000 (20:24 +0100)]
Fix R6RS `fold-left' so the accumulator is the first argument.

* module/rnrs/lists.scm (fold-left): New procedure.

* module/rnrs/records/syntactic.scm (define-record-type): Fix to use
  corrected `fold-left'.

* test-suite/tests/r6rs-lists.test: Add tests.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
12 years agorefactor chi-top-sequence
Andy Wingo [Fri, 28 Oct 2011 10:14:00 +0000 (12:14 +0200)]
refactor chi-top-sequence

* module/ice-9/psyntax.scm (chi-top-sequence): Refactor slightly.
* module/ice-9/psyntax-pp.scm: Regenerate.

12 years agoregenerate psyntax-pp
Andy Wingo [Fri, 28 Oct 2011 09:41:08 +0000 (11:41 +0200)]
regenerate psyntax-pp

* module/ice-9/psyntax-pp.scm: Regenerate.

12 years agoadd string-length, string-ref, vector-length instructions
Andy Wingo [Fri, 28 Oct 2011 09:38:56 +0000 (11:38 +0200)]
add string-length, string-ref, vector-length instructions

* 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.

12 years agoadd vector-length primitive
Andy Wingo [Fri, 28 Oct 2011 09:19:01 +0000 (11:19 +0200)]
add vector-length primitive

* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*, *effect-free-primitives*): Recognize
  vector-length as an effect-free primitive.

12 years agosimplify primitives.scm
Andy Wingo [Fri, 28 Oct 2011 08:29:46 +0000 (10:29 +0200)]
simplify primitives.scm

* module/language/tree-il/primitives.scm (*primitive-expand-table*):
  Remove a hack to compensate for the lack of a good inliner, now that
  we do have a good inliner.

12 years agofix the peval merge and a test
Andy Wingo [Thu, 27 Oct 2011 12:09:47 +0000 (14:09 +0200)]
fix the peval merge and a test

* module/language/tree-il/peval.scm (peval): Accessor primitives applied
  to constants are pure if the call type-checks.  Also, fold constants
  in accessor primcalls.

* test-suite/tests/tree-il.test ("partial evaluation"): Fix the "yo"
  test.

12 years agofix hash of zero-length vectors
Andy Wingo [Thu, 27 Oct 2011 12:00:38 +0000 (14:00 +0200)]
fix hash of zero-length vectors

* libguile/hash.c (scm_raw_ihash): Fix for zero-length vectors.

12 years agoMerge remote-tracking branch 'origin/stable-2.0'
Andy Wingo [Thu, 27 Oct 2011 11:45:04 +0000 (13:45 +0200)]
Merge remote-tracking branch 'origin/stable-2.0'

Conflicts:
GUILE-VERSION
libguile/deprecated.c
libguile/gc-malloc.c
module/language/tree-il/peval.scm

12 years agoupdate `hash'
Andy Wingo [Tue, 25 Oct 2011 23:44:48 +0000 (01:44 +0200)]
update `hash'

* 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.

12 years agodon't downcase characters before hashing them
Andy Wingo [Tue, 25 Oct 2011 22:42:17 +0000 (00:42 +0200)]
don't downcase characters before hashing them

* libguile/hash.c (hasher, scm_ihashv): Don't downcase characters before
  hashing them.  That is silly.

12 years agoscm_hasher is static
Andy Wingo [Tue, 25 Oct 2011 22:38:47 +0000 (00:38 +0200)]
scm_hasher is static

* libguile/hash.c (hasher): Make static.
* libguile/hash.h: Remove scm_hasher.

12 years agoadd thomas wang's integer hash function; use it for hashq, hashv
Andy Wingo [Tue, 25 Oct 2011 22:37:24 +0000 (00:37 +0200)]
add thomas wang's integer hash function; use it for hashq, hashv

* 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.

12 years agosymbols.h reindent
Andy Wingo [Tue, 25 Oct 2011 22:06:53 +0000 (00:06 +0200)]
symbols.h reindent

* libguile/symbols.h: Reindent.

12 years agouse bob jenkins' hashword2 hash from lookup3.c for our string hash
Andy Wingo [Tue, 25 Oct 2011 21:46:17 +0000 (23:46 +0200)]
use bob jenkins' hashword2 hash from lookup3.c for our string hash

* 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.

12 years agofix a vhash test
Andy Wingo [Tue, 25 Oct 2011 22:06:33 +0000 (00:06 +0200)]
fix a vhash test

* test-suite/tests/vlist.test ("vhash"): As far as I can tell this test
  was not testing the right thing.

12 years agooptimize scm_from_utf8_stringn
Andy Wingo [Tue, 25 Oct 2011 16:18:39 +0000 (18:18 +0200)]
optimize scm_from_utf8_stringn

* 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.

12 years agomost uses of scm_from_locale_symbol become scm_from_utf8_symbol
Andy Wingo [Tue, 25 Oct 2011 15:45:29 +0000 (17:45 +0200)]
most uses of scm_from_locale_symbol become scm_from_utf8_symbol

* 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.

12 years agooptimize utf8 symbol lookup
Andy Wingo [Tue, 25 Oct 2011 15:32:50 +0000 (17:32 +0200)]
optimize utf8 symbol lookup

* libguile/symbols.c (utf8_string_equals_wide_string)
  (utf8_lookup_predicate_fn, lookup_interned_utf8_symbol): Optimize
  utf8 symbol lookup.

12 years agoslight scm_procedure_p, scm_i_procedure_arity refactor
Andy Wingo [Mon, 24 Oct 2011 16:29:45 +0000 (18:29 +0200)]
slight scm_procedure_p, scm_i_procedure_arity refactor

* libguile/procs.c (scm_procedure_p):
* libguile/procprop.c (scm_i_procedure_arity): Refactor.

12 years agoremove CELL_P macro
Andy Wingo [Mon, 24 Oct 2011 16:28:24 +0000 (18:28 +0200)]
remove CELL_P macro

* libguile/private-gc.h: Remove private CELL_P macro.

12 years agoadd SCM_HEAP_OBJECT_BASE
Andy Wingo [Mon, 24 Oct 2011 16:22:35 +0000 (18:22 +0200)]
add SCM_HEAP_OBJECT_BASE

* 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.

12 years agoadd SCM_HEAP_OBJECT_P
Andy Wingo [Mon, 24 Oct 2011 16:13:51 +0000 (18:13 +0200)]
add SCM_HEAP_OBJECT_P

* 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.

12 years agoboot_closure_print cleanup
Andy Wingo [Mon, 24 Oct 2011 15:59:23 +0000 (17:59 +0200)]
boot_closure_print cleanup

* libguile/eval.c (boot_closure_print): Get at the bits directly.

12 years agoadd SCM_{PACK,UNPACK}_POINTER
Andy Wingo [Mon, 24 Oct 2011 15:58:22 +0000 (17:58 +0200)]
add SCM_{PACK,UNPACK}_POINTER

* 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.

12 years agorefactor tc7 and tc16 checks
Andy Wingo [Mon, 24 Oct 2011 15:34:47 +0000 (17:34 +0200)]
refactor tc7 and tc16 checks

* 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.

12 years agocheck for pairs with scm_is_pair, not scm_nimp
Andy Wingo [Mon, 24 Oct 2011 15:22:47 +0000 (17:22 +0200)]
check for pairs with scm_is_pair, not scm_nimp

* 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.

12 years agode-inline cons in scm_acons
Andy Wingo [Mon, 24 Oct 2011 15:14:27 +0000 (17:14 +0200)]
de-inline cons in scm_acons

* libguile/alist.c (scm_acons): Don't inline the conses.

12 years agoremove mutex in make-object-property
Andy Wingo [Mon, 24 Oct 2011 08:55:46 +0000 (10:55 +0200)]
remove mutex in make-object-property

* module/ice-9/boot-9.scm (make-object-property): Remove the mutex; weak
  tables are now threadsafe.

12 years agoremove weak pairs, rewrite weak vectors
Andy Wingo [Mon, 24 Oct 2011 08:52:55 +0000 (10:52 +0200)]
remove weak pairs, rewrite weak vectors

* 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.

12 years agoremove a stale comment
Andy Wingo [Mon, 24 Oct 2011 06:28:06 +0000 (08:28 +0200)]
remove a stale comment

* module/system/foreign.scm (define-wrapped-pointer-type): Remove stale
  comment.

12 years agoconvert internal weak hash table users to use the weak table api
Andy Wingo [Sun, 23 Oct 2011 21:38:51 +0000 (23:38 +0200)]
convert internal weak hash table users to use the weak table api

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!

12 years agoreimplement hashtab.c's weak hash tables in terms of weak-table.c
Andy Wingo [Mon, 24 Oct 2011 05:57:17 +0000 (07:57 +0200)]
reimplement hashtab.c's weak hash tables in terms of weak-table.c

* 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.

12 years agoadd weak table implementation
Andy Wingo [Sun, 23 Oct 2011 21:23:47 +0000 (23:23 +0200)]
add weak table implementation

* 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.

12 years agoadd scm_c_make_port; the port table is now a weak set
Andy Wingo [Sun, 23 Oct 2011 18:51:52 +0000 (20:51 +0200)]
add scm_c_make_port; the port table is now a weak set

* 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.

12 years agosymbols.c uses weak sets
Andy Wingo [Sun, 23 Oct 2011 18:46:48 +0000 (20:46 +0200)]
symbols.c uses weak sets

* libguile/symbols.c (lookup_interned_symbol)
  (lookup_interned_latin1_symbol, intern_symbol): Adapt to use weak sets
  instead of weak-key hash tables.

12 years agoadd weak sets
Andy Wingo [Sun, 23 Oct 2011 18:45:01 +0000 (20:45 +0200)]
add weak sets

* 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.

12 years agoUpdate `NEWS'.
Ludovic Courtès [Sat, 22 Oct 2011 14:53:43 +0000 (16:53 +0200)]
Update `NEWS'.

12 years agoFix compilation of `deprecated.c' with SCM_DEBUG_TYPING_STRICTNESS=2.
Ludovic Courtès [Sat, 22 Oct 2011 14:48:46 +0000 (16:48 +0200)]
Fix compilation of `deprecated.c' with SCM_DEBUG_TYPING_STRICTNESS=2.

* 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.

12 years agoBump version number for 2.0.3.
Ludovic Courtès [Sat, 22 Oct 2011 14:29:20 +0000 (16:29 +0200)]
Bump version number for 2.0.3.

* GUILE-VERSION (GUILE_MICRO_VERSION): Increment.
  (LIBGUILE_INTERFACE_CURRENT): Increment to account for new C functions
  `scm_is_exact' etc.
  (LIBGUILE_INTERFACE_AGE): Increment.

12 years agoUpdate Gnulib to v0.0-6523-gb3609c1.
Ludovic Courtès [Sat, 22 Oct 2011 14:24:32 +0000 (16:24 +0200)]
Update Gnulib to v0.0-6523-gb3609c1.

12 years agodoc: Document the `sitedir' and `extensiondir' pkg-config variables.
Ludovic Courtès [Sat, 22 Oct 2011 14:11:01 +0000 (16:11 +0200)]
doc: Document the `sitedir' and `extensiondir' pkg-config variables.

* doc/ref/libguile-parallel.texi (Parallel Installations): Document the
  `sitedir' and `extensiondir' pkg-config variables.  This fixes
  <https://savannah.gnu.org/bugs/index.php?32515>, reported by
  Dale. P. Smith.

12 years agoFix compilation with `--enable-debug-malloc'.
Bake Timmons [Sat, 22 Oct 2011 11:28:53 +0000 (13:28 +0200)]
Fix compilation with `--enable-debug-malloc'.

* libguile/gc-malloc.c (scm_gc_register_collectable_memory): Add the
  missing second argument in the call to scm_malloc_register.

12 years agoInitialize `get_internal_run_time' before it is used.
Ludovic Courtès [Sat, 22 Oct 2011 11:25:11 +0000 (13:25 +0200)]
Initialize `get_internal_run_time' before it is used.

* libguile/init.c (scm_i_init_guile): Call `scm_init_stime' before
  `scm_init_gc'.  Fixes <https://savannah.gnu.org/bugs/?34616> reported
  by Bake Timmons.

12 years agoset width for `,trace' command
BT Templeton [Fri, 22 Jul 2011 15:35:30 +0000 (11:35 -0400)]
set width for `,trace' command

* module/system/repl/command.scm (trace): Set trace width to terminal
  width by default.

12 years agofix segfault in goops if class fields are redefined
Andy Wingo [Thu, 20 Oct 2011 22:22:44 +0000 (00:22 +0200)]
fix segfault in goops if class fields are redefined

* libguile/goops.c (map, filter_cpl, remove_duplicate_slots): Use
  scm_is_pair instead of !scm_is_null, given that we use accessor
  macros.
  (check_cpl, build_slots_list): Check that descendents of <class> can't
  redefine slots of <class>.

* test-suite/tests/goops.test ("defining classes"): Add a test.

Patch originally by Stefan Israelsson Tampe.

12 years agofix misallocation of some <fix> procedures
Andy Wingo [Thu, 20 Oct 2011 21:50:05 +0000 (23:50 +0200)]
fix misallocation of some <fix> procedures

* module/language/tree-il/analyze.scm (analyze-lexicals): When stepping
  into a non-tail form, we know that labels allocation will be invalid,
  so use an empty labels set.  Fixes http://debbugs.gnu.org/9769.

* test-suite/tests/tree-il.test ("labels allocation"): Add a test.

12 years agoslight frames.h refactor
Andy Wingo [Wed, 19 Oct 2011 09:55:27 +0000 (11:55 +0200)]
slight frames.h refactor

* libguile/frames.h: Instead of doing a lot of nasty pointer match and
  casts here, simply define a struct that aliases the contents of a
  stack frame.  There are some naming issues here, that the SCM_FRAME
  macros access the scm_vm_frame structure, but SCM_VM_FRAME macros
  access scm_frame; oh well.

12 years agodoc: Add `libguile-parallel.texi' to the distribution.
Ludovic Courtès [Tue, 18 Oct 2011 16:47:09 +0000 (18:47 +0200)]
doc: Add `libguile-parallel.texi' to the distribution.

This is a followup to d32df1325dfe5f550cf1262dc7e90ba86b526a7c ("manual:
reorganize autoconf, pkg-config info").

* doc/ref/Makefile.am (guile_TEXINFOS): Add `libguile-parallel.texi'.

12 years agofix (web http) write-date for mondays
Andy Wingo [Mon, 17 Oct 2011 07:48:19 +0000 (09:48 +0200)]
fix (web http) write-date for mondays

* module/web/http.scm (write-date): Fix bug on Mondays.  Jeez!

12 years agodoc: Complete renaming of `autoconf.texi'.
Ludovic Courtès [Sun, 16 Oct 2011 19:55:29 +0000 (21:55 +0200)]
doc: Complete renaming of `autoconf.texi'.

This is a followup to d32df1325dfe5f550cf1262dc7e90ba86b526a7c ("manual:
reorganize autoconf, pkg-config info").

* doc/ref/Makefile.am: Replace references to `autoconf.texi' by
  `libguile-autoconf.texi'.

12 years agoUpdate (ice-9 match) from Chibi-Scheme.
Ludovic Courtès [Sun, 16 Oct 2011 16:36:20 +0000 (18:36 +0200)]
Update (ice-9 match) from Chibi-Scheme.

* module/ice-9/match.scm (match): Remove macro.

* module/ice-9/match.upstream.scm: Update from Chibi-Scheme, which fixes
  <http://debbugs.gnu.org/9567>.

* test-suite/tests/match.test.upstream: Likewise.

12 years agocoverage: Add tests for `case-lambda'.
Ludovic Courtès [Sat, 15 Oct 2011 15:05:23 +0000 (17:05 +0200)]
coverage: Add tests for `case-lambda'.

* test-suite/tests/coverage.test
  ("line-execution-counts")["case-lambda"]: New test.
  ("procedure-execution-count")["case-lambda"]: New test.