bpt/guile.git
9 years agoFix typo in `transform-string' doc.
Dmitry Bogatov [Thu, 5 Jun 2014 00:49:28 +0000 (20:49 -0400)]
Fix typo in `transform-string' doc.

* doc/ref/texinfo.texi: Fix single typo.

Signed-off-by: Dmitry Bogatov <KAction@gnu.org>
9 years agoOptimize scm_ilength and 'length+'.
Mark H Weaver [Thu, 5 Jun 2014 00:42:21 +0000 (20:42 -0400)]
Optimize scm_ilength and 'length+'.

* libguile/list.c (scm_ilength): Test for SCM_NULL_OR_NIL_P only after
  testing scm_is_pair.  Conform to GNU coding standards.

* libguile/srfi-1.c (scm_srfi1_length_plus): Ditto.

9 years agotest-guild-compile: Increase sleep time before sending SIGINT.
Mark H Weaver [Thu, 5 Jun 2014 00:40:23 +0000 (20:40 -0400)]
test-guild-compile: Increase sleep time before sending SIGINT.

* test-suite/standalone/test-guild-compile: Increase sleep time
  before sending SIGINT, for slow machines.

9 years agoAvoid quadratic expansion time in 'and' and 'or' macros.
Mark H Weaver [Wed, 4 Jun 2014 23:30:16 +0000 (19:30 -0400)]
Avoid quadratic expansion time in 'and' and 'or' macros.

Fixes <http://bugs.gnu.org/17147>.
Reported by David Kastrup <dak@gnu.org>.

* module/ice-9/boot-9.scm (and, or): Use dotted tail instead of ellipsis
  in patterns.

9 years ago'guild compile' doesn't leave temporary files behind it.
Ludovic Courtès [Tue, 3 Jun 2014 12:58:55 +0000 (14:58 +0200)]
'guild compile' doesn't leave temporary files behind it.

* module/scripts/compile.scm (compile): Add 'sigaction' call.
* test-suite/standalone/test-guild-compile: New file.
* test-suite/standalone/Makefile.am (check_SCRIPTS, TESTS): Add it.

9 years agoSRFI-1 'length+' raises an error unless passed a proper or circular list.
Mark H Weaver [Fri, 18 Apr 2014 19:04:12 +0000 (15:04 -0400)]
SRFI-1 'length+' raises an error unless passed a proper or circular list.

Fixes <http://bugs.gnu.org/17296>.

* libguile/srfi-1.c (scm_srfi1_length_plus): Rewrite to raise an error
  unless passed a proper or circular list, based on code from
  'scm_ilength'.

* test-suite/tests/srfi-1.test (length+): Add tests.

9 years agoMark system async functions as SCM_API.
Mark H Weaver [Sun, 1 Jun 2014 23:08:25 +0000 (19:08 -0400)]
Mark system async functions as SCM_API.

Fixes <http://bugs.gnu.org/17661>.
Reported and fixed by Chris Vine <chris@cvine.freeserve.co.uk>.

* libguile/async.h (scm_c_call_with_blocked_asyncs)
  (scm_c_call_with_unblocked_asyncs, scm_dynwind_block_asyncs)
  (scm_dynwind_unblock_asyncs): Mark as SCM_API.

* THANKS: Add Chris Vine to fixes section.

9 years agoSlightly simplify 'scm_open_process'.
Ludovic Courtès [Wed, 28 May 2014 21:06:45 +0000 (23:06 +0200)]
Slightly simplify 'scm_open_process'.

* libguile/posix.c (scm_open_process): Call 'scm_fdes_to_port' with the
  '0' flag, and remove 'scm_setvbuf' calls.

9 years agordelim: Speed up 'read-string' (aka. 'get-string-all'.)
Ludovic Courtès [Wed, 28 May 2014 21:00:20 +0000 (23:00 +0200)]
rdelim: Speed up 'read-string' (aka. 'get-string-all'.)

This yields a 20% improvement on the "read-string" benchmark.

* module/ice-9/rdelim.scm (read-string): Rewrite as a 'case-lambda',
  with a tight loop around 'read-char', and without using
  'read-string!'.
* test-suite/tests/rdelim.test ("read-string")["longer than 100 chars,
  with limit"]: New test.
* benchmark-suite/benchmarks/ports.bm ("rdelim")["read-string"]: New
  benchmark.

9 years agotests: Add test for <http://bugs.gnu.org/17466>.
Ludovic Courtès [Wed, 28 May 2014 20:19:16 +0000 (22:19 +0200)]
tests: Add test for <http://bugs.gnu.org/17466>.

* test-suite/tests/r6rs-ports.test ("7.2.8 Binary
  Input")("http://bugs.gnu.org/17466"): New test.

9 years agoFix shrinking of contiguous bytevectors, as from 'get-bytevector-n'.
Ludovic Courtès [Wed, 28 May 2014 17:26:45 +0000 (19:26 +0200)]
Fix shrinking of contiguous bytevectors, as from 'get-bytevector-n'.

Fixes <http://bugs.gnu.org/17466>.
Reported by J Kalbhenn <jkal@posteo.eu>.

* libguile/bytevectors.c (scm_c_shrink_bytevector): When BV is
  contiguous, add use of 'SCM_BYTEVECTOR_SET_CONTENTS'.

10 years agoweb: Keep the default size for the client's in-kernel receive buffer.
Ludovic Courtès [Fri, 23 May 2014 20:00:21 +0000 (22:00 +0200)]
web: Keep the default size for the client's in-kernel receive buffer.

Fixes <http://bugs.gnu.org/15368>.

* module/web/client.scm (open-socket-for-uri): Remove call to
  'setsockopt'.  Contrary to what the comment said, its effect was to
  shrink the receive buffer from 124 KiB (the default size, per
  /proc/sys/net/core/rmem_default on Linux-based systems) to 12 KiB.

10 years agotests: Add test for _IOLBF.
Ludovic Courtès [Wed, 21 May 2014 13:34:22 +0000 (15:34 +0200)]
tests: Add test for _IOLBF.

* test-suite/tests/ports.test ("pipe, fdopen, and _IOLBF"): New test.

10 years agoSilence GCC warning.
Ludovic Courtès [Fri, 16 May 2014 09:32:43 +0000 (11:32 +0200)]
Silence GCC warning.

* libguile/fports.c (scm_setvbuf): Initialize 'drained'.  GCC 4.9 raises
  a "may be used uninitialized warning" for 'drained', because it can't
  tell that 'drained' is initialized anytime NDRAINED > 0.

10 years agoPrefer foreign objects over smobs in manual
Andy Wingo [Mon, 28 Apr 2014 16:00:05 +0000 (18:00 +0200)]
Prefer foreign objects over smobs in manual

* doc/ref/api-memory.texi (Memory Blocks): Recommend against
  scm_gc_free.  Refer to foreign objects instead of smobs.  Remove
  discussion of scm_must_malloc et al.

* doc/ref/guile.texi (API Reference): Rename SMOB menu item.

* doc/ref/libguile-snarf.texi (Function Snarfing): Update example to not
  refer to smobs.
* doc/ref/tools.texi (How guile-snarf works): Likewise.

10 years agoAdd new standalone tests to gitignore
Andy Wingo [Mon, 28 Apr 2014 15:47:54 +0000 (17:47 +0200)]
Add new standalone tests to gitignore

* .gitignore: Add entries.

10 years agoRemove doc/example-smob/
Andy Wingo [Mon, 28 Apr 2014 15:46:59 +0000 (17:46 +0200)]
Remove doc/example-smob/

* doc/example-smob/: Remove example.  It's smaller than it used to be in
  Guile 1.8, and with foreign objects there's practically nothing
  interesting to test.

* doc/oldfmt.c: Remove this hoary thing.

* doc/README:
* doc/Makefile.am: Update.

10 years agoRemove SMOB tutorial; update manual.
Andy Wingo [Mon, 28 Apr 2014 15:45:07 +0000 (17:45 +0200)]
Remove SMOB tutorial; update manual.

* doc/ref/libguile-smobs.texi: Remove; this tutorial is superseded by
  libguile-foreign-objects.

* doc/ref/libguile-foreign-objects.texi: Proofreading.

* doc/ref/libguile-program.texi: Update Dia examples to refer to foreign
  objects.

* doc/ref/libguile-concepts.texi (Garbage Collection): Update to
  accurately describe the BDW-GC, and to avoid reference to mark
  functions.

* doc/ref/guile.texi: Remove libguile-smobs, and reword API menu.

* doc/ref/api-utility.texi (Equality): Mention GOOPS instead of SMOBs.

* doc/ref/api-smobs.texi (Smobs): Describe as a legacy interface.
  Exhort readers against the writing of mark functions.

* doc/ref/api-foreign-objects.texi (Foreign Objects): Proofreading.

* doc/ref/api-control.texi (Catch): Fix ref to point to foreign
  objects.

* doc/ref/Makefile.am: Remove libguile-smobs.texi.

10 years agoAdd foreign object documentation
Andy Wingo [Mon, 28 Apr 2014 14:27:09 +0000 (16:27 +0200)]
Add foreign object documentation

* doc/ref/api-foreign-objects.texi:
* doc/ref/libguile-foreign-objects.texi: New files.

* doc/ref/guile.texi:
* doc/ref/Makefile.am: Link new files into docs.

10 years agoAdd more foreign object interfaces
Andy Wingo [Mon, 28 Apr 2014 09:27:31 +0000 (11:27 +0200)]
Add more foreign object interfaces

* libguile/foreign-object.c:
* libguile/foreign-object.h (scm_make_foreign_object_1)
  (scm_make_foreign_object_2, scm_make_foreign_object_3)
  (scm_make_foreign_object_n): Change to take void * arguments, and to
  add a comment to the header indicating that these are convenience
  constructors.

* libguile/foreign-object.c:
* libguile/foreign-object.h (scm_foreign_object_unsigned_ref)
  (scm_foreign_object_unsigned_set_x): New functions, equivalent to the
  old scm_foreign_object_ref and scm_foreign_object_set_x.

* libguile/foreign-object.c:
* libguile/foreign-object.h (scm_foreign_object_signed_ref)
  (scm_foreign_object_signed_set_x): New functions taking
  scm_t_signed_bits.

* libguile/foreign-object.c:
* libguile/foreign-object.h (scm_foreign_object_ref)
  (scm_foreign_object_set_x): New functions that take void*.

10 years agoAvoid non-constant struct initializers
Andy Wingo [Mon, 28 Apr 2014 09:01:44 +0000 (11:01 +0200)]
Avoid non-constant struct initializers

* libguile/foreign-object.c (scm_make_foreign_object_2):
  (scm_make_foreign_object_3): Avoid non-constant struct initializers.

10 years agoAdd scm_make_foreign_object_0; optimize scm_make_foreign_object_n.
Andy Wingo [Mon, 28 Apr 2014 08:55:26 +0000 (10:55 +0200)]
Add scm_make_foreign_object_0; optimize scm_make_foreign_object_n.

* libguile/foreign-object.c (scm_make_foreign_object_0): New function.
  (scm_make_foreign_object_n): Pre-fetch layout_chars.

* libguile/foreign-object.h: Add scm_make_foreign_object_0.

10 years agoNew foreign object facility, to replace SMOBs
Andy Wingo [Sun, 27 Apr 2014 12:47:40 +0000 (14:47 +0200)]
New foreign object facility, to replace SMOBs

* libguile/foreign-object.c:
* libguile/foreign-object.h:
* module/system/foreign-object.scm:
* test-suite/standalone/test-foreign-object-c.c:
* test-suite/standalone/test-foreign-object-scm: New files.

* test-suite/standalone/Makefile.am:
* module/Makefile.am:
* libguile/Makefile.am: Add new files.

* libguile.h: Add foreign-object.h.
* libguile/init.c (scm_i_init_guile): Call scm_register_foreign_object.

10 years agoFix foreign slot initialization and access
Andy Wingo [Sun, 27 Apr 2014 09:02:35 +0000 (11:02 +0200)]
Fix foreign slot initialization and access

* libguile/goops.c (scm_sys_initialize_object): Refactor initialization
  so that we don't ref uninitialized slots before initializing them.
  This allows foreign slots, whose initial value is 0, to be initialized
  via #:init-form.

* module/oop/goops.scm (@slot-ref, @slot-set!): Remove definitions.
  Change callers to use struct-ref and struct-set!.  slot-ref and
  slot-set! were only marginally more efficient and were much more
  dangerous.  This change allows the standard accessors to work on
  foreign slots; that was not the case before, as the 'u' fields of the
  struct were read as if they were 'p' slots.
* module/language/tree-il/compile-glil.scm (lambda): Remove support for
  compiling @slot-ref/@slot-set!.  These were private to GOOPS.

* test-suite/tests/goops.test ("active-slot"): Update to not expect a
  ref before initialization.
  ("foreign slots"): Add tests.

10 years agoAdd interface to disable automatic finalization
Andy Wingo [Thu, 17 Apr 2014 13:29:13 +0000 (15:29 +0200)]
Add interface to disable automatic finalization

* libguile/finalizers.h:
* libguile/finalizers.c (run_finalizers_async_thunk): Call the new
  scm_run_finalizers helper.
  (scm_set_automatic_finalization_enabled, scm_run_finalizers): New
  functions.
  (scm_init_finalizers): Only set a finalizer notifier if automatic
  finalization is enabled.

* doc/ref/libguile-smobs.texi (Garbage Collecting Smobs): Add discussion
  of concurrency.

* doc/ref/api-smobs.texi (Smobs): Document new functions.

10 years agoSupport weak vectors, arrays, and bitvectors in (system base types).
Mark H Weaver [Thu, 24 Apr 2014 21:57:19 +0000 (17:57 -0400)]
Support weak vectors, arrays, and bitvectors in (system base types).

* module/system/base/types.scm (%tc7-wvect, %tc7-array, %tc7-bitvector):
  New variables.
  (cell->object): Add cases for weak vectors, arrays, and bitvectors.

10 years agoprint: avoid triggering deprecation warnings when printing weak vectors.
Mark H Weaver [Thu, 24 Apr 2014 21:55:47 +0000 (17:55 -0400)]
print: avoid triggering deprecation warnings when printing weak vectors.

* libguile/print.c (iprin1): Use 'scm_c_weak_vector_ref' to access
  elements of weak vectors.

10 years agobuild: Clean up rules for meta/{guild,guile-config}.
Ludovic Courtès [Thu, 24 Apr 2014 21:46:20 +0000 (23:46 +0200)]
build: Clean up rules for meta/{guild,guile-config}.

* meta/Makefile.am (guile-config, guild): Avoid useless 'cat'
  invocation'.  Quote all occurrences of '@'.
  Suggested by Eric Blake <eblake@redhat.com>.

10 years agobuild: Honor program name transformation in 'guild'.
Ludovic Courtès [Thu, 24 Apr 2014 09:16:21 +0000 (11:16 +0200)]
build: Honor program name transformation in 'guild'.

* configure.ac: Remove erroneous 'guile_program_name' substitute; see
  <https://lists.gnu.org/archive/html/autoconf/2014-04/msg00010.html>
  for details.  Remove 'meta/guild' config file.
* meta/Makefile.am (guild): New target.
  (CLEANFILES): Add 'guild'.
* meta/guild.in: Remove 'prefix' and 'exec_prefix' definitions; use
  @installed_guile@.

10 years agoFix memory leak on `realloc' failure
Dmitry Bogatov [Thu, 10 Apr 2014 05:23:28 +0000 (09:23 +0400)]
Fix memory leak on `realloc' failure

* libguile/script.c (realloc0): New helper.
  (script_read_arg, scm_get_meta_args): Use realloc0, not realloc.

Signed-off-by: Dmitry Bogatov <KAction@gnu.org>
10 years agoUpdate libgc URL in README.
Mark H Weaver [Wed, 16 Apr 2014 04:49:40 +0000 (00:49 -0400)]
Update libgc URL in README.

* README: Update libgc URL.  Suggested by Ian Grant
  <ian.a.n.grant@googlemail.com>.

10 years agoReadline history preserves newlines
Andy Wingo [Mon, 14 Apr 2014 14:12:14 +0000 (16:12 +0200)]
Readline history preserves newlines

* guile-readline/ice-9/readline.scm (make-readline-port): Preserve
  newlines.  This preserves the semantics of history entries that
  contain until-end-of-line comments using `;'.

10 years agoMake reverse! forego the cost of SCM_VALIDATE_LIST
David Kastrup [Tue, 1 Apr 2014 14:24:29 +0000 (16:24 +0200)]
Make reverse! forego the cost of SCM_VALIDATE_LIST

* libguile/list.c (scm_reverse_x): Do not validate first argument to
  reverse! in advance.  Instead undo reversal in error case.

Signed-off-by: David Kastrup <dak@gnu.org>
Signed-off-by: Mark H Weaver <mhw@netris.org>
10 years agoCalculate usecs correctly in thread-sleep!
Nathaniel Alderson [Thu, 19 Sep 2013 21:02:26 +0000 (14:02 -0700)]
Calculate usecs correctly in thread-sleep!

* module/srfi/srfi-18.scm (thread-sleep!): Correctly compute
  microseconds.

* test-suite/tests/srfi-18.test: Add test.

10 years agoBump version number for 2.0.11.
Ludovic Courtès [Thu, 20 Mar 2014 20:21:21 +0000 (21:21 +0100)]
Bump version number for 2.0.11.

* GUILE-VERSION (GUILE_MICRO_VERSION): Increment.
  (LIBGUILE_INTERFACE_REVISION): Increment.

10 years agoUpdate NEWS.
Ludovic Courtès [Thu, 20 Mar 2014 20:20:59 +0000 (21:20 +0100)]
Update NEWS.

10 years agotests: Add #undef NDEBUG when using <assert.h>.
Ludovic Courtès [Thu, 20 Mar 2014 08:43:01 +0000 (09:43 +0100)]
tests: Add #undef NDEBUG when using <assert.h>.

* test-suite/standalone/test-loose-ends.c,
  test-suite/standalone/test-num2integral.c,
  test-suite/standalone/test-round.c,
  test-suite/standalone/test-scm-c-bind-keyword-arguments.c,
  test-suite/standalone/test-scm-c-read.c,
  test-suite/standalone/test-scm-values.c,
  test-suite/standalone/test-smob-mark.c,
  test-suite/standalone/test-srfi-4.c: Add #undef NDEBUG.

10 years agotests: Check 'simple-format' with closed current-output-port.
Ludovic Courtès [Thu, 20 Mar 2014 08:40:42 +0000 (09:40 +0100)]
tests: Check 'simple-format' with closed current-output-port.

This is a follow-up to e26ab06.

* libguile/print.c (scm_simple_format): Pass 1 to
  SCM_VALIDATE_OPORT_VALUE, for 'destination'.
* test-suite/tests/format.test ("simple-format"): Add test.

10 years agoFix (rnrs io simple) to open file ports in textual mode.
Mark H Weaver [Thu, 20 Mar 2014 03:36:46 +0000 (23:36 -0400)]
Fix (rnrs io simple) to open file ports in textual mode.

Fixes <http://bugs.gnu.org/17044>.
Reported and diagnosed by Xin Wang <dram.wang@gmail.com>.

* module/rnrs/io/simple.scm (open-input-file, open-output-file): Pass
  missing buffer-mode argument to open-file-{input,output}-port.
  Previously, (native-transcoder) was incorrectly passed as the
  buffer-mode argument, so no transcoder was provided, thus creating a
  binary port.

10 years agosimple-format: Don't assume the current output port is valid.
Mark H Weaver [Wed, 19 Mar 2014 21:55:20 +0000 (17:55 -0400)]
simple-format: Don't assume the current output port is valid.

* libguile/print.c (scm_simple_format): Validate the current output
  port.

10 years agoFix breakage of SRFI-4 C accessors
Andy Wingo [Wed, 19 Mar 2014 21:41:19 +0000 (22:41 +0100)]
Fix breakage of SRFI-4 C accessors

* libguile/srfi-4.c (DEFINE_SRFI_4_C_FUNCS): Fix bad assumption that
  width was a byte width.  Thanks very much to Barry Fishman for the
  report, and to Daniel Llorens for tracking it down.

* test-suite/standalone/Makefile.am (test_srfi_4_CFLAGS):
* test-suite/standalone/test-srfi-4.c: Add test.

10 years agoBump version number for 2.0.10.
Ludovic Courtès [Mon, 17 Mar 2014 22:18:38 +0000 (23:18 +0100)]
Bump version number for 2.0.10.

* GUILE-VERSION (GUILE_MICRO_VERSION): Increment.
  (LIBGUILE_INTERFACE_REVISION): Increment.

10 years agoFix typo in NEWS.
Ludovic Courtès [Mon, 17 Mar 2014 22:06:21 +0000 (23:06 +0100)]
Fix typo in NEWS.

10 years agoUpdate NEWS.
Ludovic Courtès [Mon, 17 Mar 2014 21:13:09 +0000 (22:13 +0100)]
Update NEWS.

* NEWS: Remove last 'XXX'.

10 years agoUpdate NEWS
Andy Wingo [Mon, 17 Mar 2014 21:05:39 +0000 (22:05 +0100)]
Update NEWS

* NEWS: Update.

10 years agoUpdate NEWS.
Ludovic Courtès [Mon, 17 Mar 2014 20:55:26 +0000 (21:55 +0100)]
Update NEWS.

* NEWS: Move "New interfaces" higher.  Complement.

10 years agoFix newline preservation in @example with lines beginning with @
Andy Wingo [Thu, 27 Feb 2014 16:16:29 +0000 (17:16 +0100)]
Fix newline preservation in @example with lines beginning with @

* module/texinfo.scm (read-char-data): Preserve newlines in @example and
  similar environments in the case when the next line starts with an @.

* test-suite/tests/texinfo.test ("test-texinfo->stexinfo"): Add a test.

10 years agoMinor NEWS tweaks.
Mark H Weaver [Mon, 17 Mar 2014 06:54:47 +0000 (02:54 -0400)]
Minor NEWS tweaks.

* NEWS: Fix typo and improve wording in custom ellipsis entry.

10 years agoAdd first draft of NEWS for 2.0.10.
Mark H Weaver [Mon, 17 Mar 2014 06:42:38 +0000 (02:42 -0400)]
Add first draft of NEWS for 2.0.10.

* NEWS: Add first draft of changes in 2.0.10.

10 years agoDocumentation tweaks for the 'r7rs-symbols' read/print options.
Mark H Weaver [Mon, 17 Mar 2014 06:40:23 +0000 (02:40 -0400)]
Documentation tweaks for the 'r7rs-symbols' read/print options.

* doc/ref/api-data.texi (Symbol Read Syntax): Mention the 'r7rs-symbols'
  print option, and provide example code to enable both the read and
  print options.  Add 'r7rs-symbols' to the concept index.

10 years agobuild: Link 'test-unwind.c' against libgnu.la.
Ludovic Courtès [Sun, 16 Mar 2014 22:24:34 +0000 (23:24 +0100)]
build: Link 'test-unwind.c' against libgnu.la.

* test-suite/standalone/Makefile.am (test_unwind_LDADD): Add libgnu.la,
  which provides 'rpl_mkstemp' on systems missing 'mkstemp'.

10 years agoFix (system base types) on big-endian systems.
Mark H Weaver [Sat, 15 Mar 2014 17:23:21 +0000 (13:23 -0400)]
Fix (system base types) on big-endian systems.

* module/system/base/types.scm (cell->object): When reading stringbufs,
  use UTF-32BE on big-endian systems.

10 years agoSRFI-43 documentation tweaks
Mark H Weaver [Fri, 14 Mar 2014 19:07:10 +0000 (15:07 -0400)]
SRFI-43 documentation tweaks

* doc/ref/api-compound.texi (Vectors): Add cross-reference to SRFI-43.
* doc/ref/srfi-modules.texi (SRFI-43 Selectors): Simplify description of
  'vector-ref'.

10 years agoCheck SCM_USE_PTHREAD_THREADS using #if not #ifdef.
Mark H Weaver [Fri, 14 Mar 2014 03:21:48 +0000 (23:21 -0400)]
Check SCM_USE_PTHREAD_THREADS using #if not #ifdef.

* libguile/bdw-gc.h: Check SCM_USE_PTHREAD_THREADS using #if not #ifdef.

10 years agoInclude <config.h> in gen-scmconfig even when cross-compiling.
Mark H Weaver [Thu, 13 Mar 2014 20:47:11 +0000 (16:47 -0400)]
Include <config.h> in gen-scmconfig even when cross-compiling.

Partially reverts 8cb0d6d7fa9aaac316c29a64c541336b51b6f93d.

* libguile/Makefile.am (gen-scmconfig.$(OBJEXT)): Remove
  -DCROSS_COMPILING=1 from cross-compiling case.
* libguile/gen-scmconfig.c: Include <config.h> regardless of
  whether CROSS_COMPILING is defined.

10 years agobuild: Remove libguile-2.0-gdb.scm and $infodir/dir upon uninstall.
Ludovic Courtès [Wed, 12 Mar 2014 14:56:11 +0000 (15:56 +0100)]
build: Remove libguile-2.0-gdb.scm and $infodir/dir upon uninstall.

* libguile/Makefile.am (uninstall-data-hook): New target.

10 years agobuild: Install libguile-2.0-gdb.scm after libguile-2.0.so.
Ludovic Courtès [Wed, 12 Mar 2014 14:18:27 +0000 (15:18 +0100)]
build: Install libguile-2.0-gdb.scm after libguile-2.0.so.

* libguile/Makefile.am (install-data-local): Rename to...
  (install-data-hook): ... this.  This guarantees that the rule runs
  after libguile-2.0.so has been installed.

10 years agobuild: Don't include <config.h> in native programs when cross-compiling.
Ludovic Courtès [Wed, 12 Mar 2014 13:35:07 +0000 (14:35 +0100)]
build: Don't include <config.h> in native programs when cross-compiling.

* libguile/Makefile.am (gen-scmconfig.$(OBJEXT)): When cross-compiling,
  pass -DCROSS_COMPILING=1.
  (c-tokenize.$(OBJEXT)): Likewise.
* libguile/c-tokenize.lex (%top): Include <config.h> only when
  CROSS_COMPILING is undefined.
* libguile/gen-scmconfig.c: Likewise.

10 years agobuild: Fix Gnulib compilation when $builddir != $srcdir.
Ludovic Courtès [Wed, 12 Mar 2014 13:24:11 +0000 (14:24 +0100)]
build: Fix Gnulib compilation when $builddir != $srcdir.

* configure.ac: Add -I$top_srcdir_absolute to 'CPPFLAGS'.  Fixes
  out-of-source-tree compilation of lib/regex.c.  Reported at
  <https://lists.gnu.org/archive/html/guile-devel/2014-03/msg00022.html>.

10 years agoTest for deleted weak pairs in hash-for-each.
David Thompson [Sat, 8 Mar 2014 22:15:52 +0000 (17:15 -0500)]
Test for deleted weak pairs in hash-for-each.

* libguile/hashtab.c (scm_internal_hash_for_each_handle): Test for
  deleted weak pairs.
* test-suite/tests/hash.test: Add test case.

10 years agoSCM_I_INUM: Rewrite to avoid unspecified behavior when not using GNU C.
Mark H Weaver [Wed, 12 Mar 2014 01:33:48 +0000 (21:33 -0400)]
SCM_I_INUM: Rewrite to avoid unspecified behavior when not using GNU C.

* libguile/numbers.h (SCM_I_INUM): Unless using GNU C, use a portable
  implementation that avoids unspecified behavior.

10 years agoSCM_SRS: Improve fallback implemention to avoid unspecified behavior.
Mark H Weaver [Wed, 12 Mar 2014 01:27:21 +0000 (21:27 -0400)]
SCM_SRS: Improve fallback implemention to avoid unspecified behavior.

* libguile/numbers.h (SCM_SRS): Rewrite preprocessor test to avoid
  left-shifting negative integers, and to test more comprehensively for
  the behavior we need.  Rewrite fallback implementation to avoid
  unspecified behavior.

10 years agoSRFI-60: Reimplement 'rotate-bit-field' on inums to be more portable.
Mark H Weaver [Wed, 12 Mar 2014 00:34:28 +0000 (20:34 -0400)]
SRFI-60: Reimplement 'rotate-bit-field' on inums to be more portable.

* libguile/srfi-60.c (scm_srfi60_rotate_bit_field): Avoid division by
  zero in the (start == end) case.  Rewrite inum case to work with
  unsigned integers in two's complement format.

* test-suite/tests/srfi-60.test ("rotate-bit-field"): Add more tests.

10 years agoUse 'offsetof' to avoid undefined behavior.
Mark H Weaver [Wed, 12 Mar 2014 00:31:38 +0000 (20:31 -0400)]
Use 'offsetof' to avoid undefined behavior.

* libguile/socket.c (SUN_LEN): Use 'offsetof'.

10 years agoAvoid undefined behavior regarding signed integers and left shifts.
Mark H Weaver [Wed, 12 Mar 2014 00:19:17 +0000 (20:19 -0400)]
Avoid undefined behavior regarding signed integers and left shifts.

* libguile/numbers.c (scm_logbit_p): If the requested bit is the sign
  bit (or above), check the sign portably.  Otherwise, ensure that we're
  testing the bit in a two's complement representation.
  (left_shift_exact_integer): Avoid left-shifting negative integers.

* libguile/vm-i-scheme.c (ash): Avoid left-shifting negative integers.

10 years agoAvoid signed overflow in random.c.
Mark H Weaver [Wed, 12 Mar 2014 00:15:27 +0000 (20:15 -0400)]
Avoid signed overflow in random.c.

* libguile/random.c (scm_i_mask32): Avoid signed overflow from shifting
  an unsigned char (promoted to signed int) 24 bits to the left.

10 years agoAvoid side effects in argument to SCM_I_INUM.
Mark H Weaver [Wed, 12 Mar 2014 00:12:32 +0000 (20:12 -0400)]
Avoid side effects in argument to SCM_I_INUM.

* libguile/vm-i-system.c (halt): Avoid side effects in argument to
  SCM_I_INUM.

10 years agoThank Paul.
Ludovic Courtès [Tue, 11 Mar 2014 23:03:03 +0000 (00:03 +0100)]
Thank Paul.

10 years agoProvide glthread/lock.h implementation in terms of Guile threads.
Ludovic Courtès [Tue, 11 Mar 2014 23:02:01 +0000 (00:02 +0100)]
Provide glthread/lock.h implementation in terms of Guile threads.

Fixes <http://bugs.gnu.org/14404>.
Thanks to Paul Eggert <eggert@cs.ucla.edu> for the suggestion.

* m4/gnulib-cache.m4: Avoid 'lock' module.
* m4/lock.m4, m4/threadlib.m4, lib/glthread/threadlib.c,
  lib/glthread/lock.c: Remove.
* lib/glthread/lock.h: Rewrite in terms of libguile/threads.h.
* m4/gnulib-common.m4, m4/gnulib-comp.m4, lib/Makefile.am,
  lib/unistd.in.h, maint.mk : Update, from Gnulib v0.1-92-g546ff82.

* configure.ac (GNULIB_LOCK): Define 'GNULIB_LOCK'.  Define
  'USE_POSIX_THREADS' when building with pthread support.
* Makefile.am (noinst_HEADERS): New variable.
  (BUILT_SOURCES): Add libguile/scmconfig.h.
  (libguile/scmconfig.h): New target.

10 years agoImprove compliance with C standards regarding signed integer shifts.
Mark H Weaver [Fri, 7 Mar 2014 09:21:46 +0000 (04:21 -0500)]
Improve compliance with C standards regarding signed integer shifts.

* configure.ac: Add -fwrapv when using GCC (or compatible), if
  supported.

* libguile/numbers.h (SCM_I_MAKINUM): Cast to scm_t_bits (unsigned)
  before shifting, to avoid undefined behavior.

10 years agochars.c: Remove duplicate 'const' specifiers.
Mark H Weaver [Fri, 7 Mar 2014 04:59:56 +0000 (23:59 -0500)]
chars.c: Remove duplicate 'const' specifiers.

* libguile/chars.c (scm_r5rs_charnums, scm_r6rs_charnums)
  (scm_r7rs_charnums, scm_C0_control_charnums, scm_alt_charnums):
  Remove duplicate 'const' specifiers.

10 years agosnarf.h: Declare static const function name vars as SCM_UNUSED.
Mark H Weaver [Fri, 7 Mar 2014 04:56:48 +0000 (23:56 -0500)]
snarf.h: Declare static const function name vars as SCM_UNUSED.

* libguile/snarf.h (SCM_DEFINE_GSUBR, SCM_DEFINE, SCM_PRIMITIVE_GENERIC,
  SCM_DEFINE_PUBLIC, SCM_PROC, SCM_REGISTER_PROC, SCM_GPROC): Declare
  static const function name variables as SCM_UNUSED to avoid spurious
  warnings.

10 years agoMake snarfing tools more robust to varied C preprocessor behavior.
Mark H Weaver [Thu, 6 Mar 2014 22:17:11 +0000 (17:17 -0500)]
Make snarfing tools more robust to varied C preprocessor behavior.

* libguile/guile-snarf.in (modern_snarf): Rewrite sed script to cope
  with newlines in the snarfed code segments, or multiple code segments
  on the same line.

* module/scripts/snarf-check-and-output-texi.scm (process-stream):
  Strip all 'hash' tokens from the stream.
  (do-command): Remove special cases that handled 'hash' tokens
  in a few places.

10 years agoSRFI-19: Update the table of leap seconds.
Mark H Weaver [Mon, 3 Mar 2014 22:20:03 +0000 (17:20 -0500)]
SRFI-19: Update the table of leap seconds.

* module/srfi/srfi-19.scm (leap-second-table): Update to include the two
  most recent leap seconds.

10 years agoAdd missing files to the test-suite Makefile.
Mark H Weaver [Sun, 2 Mar 2014 00:03:35 +0000 (19:03 -0500)]
Add missing files to the test-suite Makefile.

* test-suite/Makefile.am (SCM_TESTS): Add "tests/compiler.test",
  "tests/encoding-escapes.test", "tests/encoding-iso88591.test",
  "tests/encoding-iso88597.test", "tests/encoding-utf8.test",
  "tests/pairs.test", "tests/records.test", "tests/sort.test",
  "tests/srfi-17.test", "tests/srfi-18.test", "tests/srfi-98.test",
  "tests/streams.test", "tests/vectors.test", and "tests/web-client.test".

10 years agobuild: Make c-tokenize.c build on non-GNU systems.
Ludovic Courtès [Fri, 28 Feb 2014 20:00:11 +0000 (21:00 +0100)]
build: Make c-tokenize.c build on non-GNU systems.

* libguile/c-tokenize.lex: Add %top directive to include <config.h>
  first.  This fixes builds on systems that use Gnulib's <stdio.h> and
  similar replacements.  See <http://hydra.nixos.org/build/9259627> for
  an example.

10 years agoSRFI-18: Export 'current-thread'.
Mark H Weaver [Fri, 28 Feb 2014 02:31:57 +0000 (21:31 -0500)]
SRFI-18: Export 'current-thread'.

Fixes <http://debbugs.gnu.org/16890>.
Reported by Xin Wang <dram.wang@gmail.com>.

* module/srfi/srfi-18.scm: Reexport 'current-thread'.
* THANKS: Add "Xin Wang" to fixes section.

10 years agoRely on Gnulib for <unistd.h>.
Mark H Weaver [Fri, 28 Feb 2014 03:04:39 +0000 (22:04 -0500)]
Rely on Gnulib for <unistd.h>.

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

10 years agoRely on Gnulib for fsync, link, readlink, mkdir, rmdir, and rename.
Mark H Weaver [Fri, 28 Feb 2014 02:24:40 +0000 (21:24 -0500)]
Rely on Gnulib for fsync, link, readlink, mkdir, rmdir, and rename.

* libguile/filesys.c: Remove 'fsync' wrapper for MinGW.
  (scm_link, scm_readlink, scm_mkdir, scm_rmdir): Define these
  unconditionally.
  (my_rename): Remove.
  (scm_rename): Use 'rename' instead of 'my_rename'.

10 years agoImport Gnulib modules: link, fsync, readlink, rename, mkdir, rmdir, unistd.
Mark H Weaver [Thu, 27 Feb 2014 03:15:13 +0000 (22:15 -0500)]
Import Gnulib modules: link, fsync, readlink, rename, mkdir, rmdir, unistd.

* lib/fsync.c:
* lib/link.c:
* lib/mkdir.c:
* lib/strdup.c:
* m4/fsync.m4:
* m4/link.m4:
* m4/mkdir.m4:
* m4/strdup.m4: New files.

* lib/Makefile.am
* m4/gnulib-cache.m4
* m4/gnulib-comp.m4: Add modules.

10 years agoFix typo in manual.
Mark H Weaver [Tue, 25 Feb 2014 22:38:34 +0000 (17:38 -0500)]
Fix typo in manual.

* doc/ref/api-foreign.texi (Void Pointers and Byte Access):
  (rnrs bytevector) --> (rnrs bytevectors).

10 years agobuild: Fix out-of-source-tree installation of libguile-2.0-gdb.scm.
Ludovic Courtès [Thu, 27 Feb 2014 13:14:21 +0000 (14:14 +0100)]
build: Fix out-of-source-tree installation of libguile-2.0-gdb.scm.

* libguile/Makefile.am (install-data-local): Use $< instead of just
  libguile-2.0-gdb.scm.  Quote file names in $(INSTALL_DATA) invocation.

10 years agoMake sure 'ftw' allows directory traversal when running as root.
Ludovic Courtès [Thu, 20 Feb 2014 21:57:26 +0000 (22:57 +0100)]
Make sure 'ftw' allows directory traversal when running as root.

* module/ice-9/ftw.scm (stat-dir-readable?-proc): Return #t when UID is
  zero.  Reported Frank Terbeck <ft@bewatermyfriend.org>.

10 years agobuild: Bail out when 'PKG_CHECK_MODULES' is missing.
Ludovic Courtès [Thu, 20 Feb 2014 21:56:17 +0000 (22:56 +0100)]
build: Bail out when 'PKG_CHECK_MODULES' is missing.

* configure.ac: Add 'm4_pattern_forbid' invocation.

10 years agoAdd GDB extension to support Guile.
Ludovic Courtès [Mon, 17 Feb 2014 14:40:34 +0000 (15:40 +0100)]
Add GDB extension to support Guile.

* libguile/libguile-2.0-gdb.scm: New file.
* libguile/Makefile.am (install-data-local): New target.  Based on code
  from GNU libstdc++.
  (EXTRA_DIST): Add 'libguile-2.0-gdb.scm'.
* doc/ref/api-debug.texi (GDB Support): New section.

10 years agoAdd (system base types).
Ludovic Courtès [Tue, 18 Feb 2014 22:04:01 +0000 (23:04 +0100)]
Add (system base types).

* module/system/base/types.scm, test-suite/tests/types.test: New files.
* module/Makefile.am (SYSTEM_BASE_SOURCES): Add system/base/types.scm.
* test-suite/Makefile.am (SCM_TESTS): Add tests/types.test.

10 years agoFix inline asm of VM numerical operations for x32.
Mark H Weaver [Wed, 12 Feb 2014 19:28:03 +0000 (14:28 -0500)]
Fix inline asm of VM numerical operations for x32.

* libguile/vm-i-scheme.c (_CX): Choose register size based on
  'SIZEOF_VOID_P' instead of '__x86_64__'.

10 years agoRely on Gnulib for 'select', 'lstat', and 'mkstemp'.
Mark H Weaver [Wed, 12 Feb 2014 22:47:13 +0000 (17:47 -0500)]
Rely on Gnulib for 'select', 'lstat', and 'mkstemp'.

* libguile/iselect.h:
* libguile/threads.c:
* libguile/deprecated.h: Rely on Gnulib for sys/select.h.

* libguile/filesys.c: Rely on Gnulib for 'lstat' and 'mkstemp'.

10 years agoImport 'lstat' and 'mkstemp' modules from Gnulib.
Mark H Weaver [Wed, 12 Feb 2014 22:43:35 +0000 (17:43 -0500)]
Import 'lstat' and 'mkstemp' modules from Gnulib.

* lib/mkstemp.c:
* lib/secure_getenv.c:
* lib/tempname.c:
* lib/tempname.h:
* m4/mkstemp.m4:
* m4/secure_getenv.m4:
* m4/tempname.m4: New files.

* lib/Makefile.am:
* m4/gnulib-cache.m4:
* m4/gnulib-comp.m4: Add modules.

10 years agoAdd cooperative REPL server module.
David Thompson [Sun, 19 Jan 2014 18:16:02 +0000 (13:16 -0500)]
Add cooperative REPL server module.

Modified-by: Mark H Weaver <mhw@netris.org>
* module/system/repl/coop-server.scm: New module.

* module/system/repl/repl.scm (start-repl): Extract body to start-repl*.
  (start-repl*): New procedure.
  (run-repl): Extract body to run-repl*.
  (run-repl*): New procedure.

* module/system/repl/server.scm (run-server): Extract body to
  run-server*.
  (run-server*): New procedure.

* doc/ref/api-evaluation.texi (Cooperative REPL Servers): New node.

* module/Makefile.am (SYSTEM_SOURCES): Add system/repl/coop-server.scm.

10 years agoREPL Server: Fix 'stop-server-and-clients!'.
Mark H Weaver [Tue, 4 Feb 2014 17:18:22 +0000 (12:18 -0500)]
REPL Server: Fix 'stop-server-and-clients!'.

* module/system/repl/server.scm: Import (ice-9 match) and (srfi srfi-1).
  (*open-sockets*): Add comment.  This is now a list of pairs with a
  'force-close' procedure in the cdr.
  (close-socket!): Add comment noting that it is unsafe to call this
  from another thread.
  (add-open-socket!): Add 'force-close' argument, and put it in the cdr
  of the '*open-sockets*' entry.
  (stop-server-and-clients!): Use 'match'.  Remove the first element
  from *open-sockets* immediately.  Call the 'force-close' procedure
  instead of 'close-socket!'.
  (errs-to-retry): New variable.
  (run-server): Add a pipe, used in the 'force-close' procedure to
  cleanly shut down the server.  Put the server socket into non-blocking
  mode.  Use 'select' to monitor both the server socket and the pipe.
  Don't call 'add-open-socket!' on the client-socket.  Close the pipe
  and the server socket cleanly when we're asked to shut down.
  (serve-client): Call 'add-open-socket!' with a 'force-close' procedure
  that cancels the thread.  Set the thread cleanup handler to call
  'close-socket!', instead of calling it in the main body.

* doc/ref/api-evaluation.texi (REPL Servers): Add a caveat to the manual
  entry for 'stop-servers-and-clients!'.

10 years agoguile.m4 tweaks
Andy Wingo [Tue, 11 Feb 2014 19:59:38 +0000 (20:59 +0100)]
guile.m4 tweaks

* meta/guile.m4 (GUILE_PKG): Don't print "checking for guile 2.0" if
  we've already found 2.2.  Print the correct effective version at the
  end.
  (GUILE_PROGS): Allow prereleases, whose micro version does not yet
  match the effective version.  Default to the already-chosen effective
  version.

10 years agoFix improper use of 'with-locale'.
Mark H Weaver [Sat, 8 Feb 2014 17:35:35 +0000 (12:35 -0500)]
Fix improper use of 'with-locale'.

* test-suite/guile-test (run-tests): Use 'setlocale' with check
  instead of 'with-locale'.

10 years agoDeprecate the use of the vector interface on arrays
Andy Wingo [Sat, 8 Feb 2014 15:13:54 +0000 (16:13 +0100)]
Deprecate the use of the vector interface on arrays

* libguile/vectors.c (scm_is_vector): Deprecate use on weak vectors and
  arrays.
  (scm_is_simple_vector): Deprecate use on weak vectors.
  (scm_vector_length, scm_c_vector_ref, scm_c_vector_set_x): Deprecate
  use on arrays.

* libguile/sort.c: Adapt to check explicitly for arrays.

10 years agoDeprecate use of vector-length, vector-ref, vector-set! as primitive-generics
Andy Wingo [Sat, 8 Feb 2014 15:02:59 +0000 (16:02 +0100)]
Deprecate use of vector-length, vector-ref, vector-set! as primitive-generics

* libguile/vectors.c (scm_vector_length, scm_c_vector_ref):
  (scm_c_vector_set_x): Deprecate the use of vector-length, vector-ref,
  and vector-set! as primitive generics.

10 years agoDeprecate general "uniform-vector" interface
Andy Wingo [Sat, 8 Feb 2014 13:18:40 +0000 (14:18 +0100)]
Deprecate general "uniform-vector" interface

* libguile/uniform.h:
* libguile/uniform.c (scm_is_uniform_vector, scm_uniform_vector_p)
  (scm_c_uniform_vector_length, scm_uniform_vector_length)
  (scm_uniform_vector_element_type, scm_uniform_vector_element_size)
  (scm_c_uniform_vector_ref, scm_uniform_vector_ref):
  (scm_c_uniform_vector_set_x, scm_uniform_vector_set_x):
  (scm_uniform_vector_to_list)
  (scm_uniform_vector_elements, scm_uniform_vector_writable_elements):
  Deprecate.  This interface lacked both generality and specificity.
  The general replacement is array-length, array-ref, and friends on the
  scheme side, or the array handle interface on the C side.  On the
  specific side of things, there are the specific bytevector, srfi-4,
  and bitvector interfaces.

* test-suite/tests/arrays.test:
* test-suite/tests/bitvectors.test:
* test-suite/tests/ports.test:
* test-suite/tests/srfi-4.test: Update to use array interfaces.

* doc/ref/api-foreign.texi (Void Pointers and Byte Access):
* doc/ref/srfi-modules.texi (SRFI-4): Update.

10 years agoSimplify srfi-4 C implementation
Andy Wingo [Sat, 8 Feb 2014 12:52:21 +0000 (13:52 +0100)]
Simplify srfi-4 C implementation

* libguile/srfi-4.c (DEFINE_SRFI_4_C_FUNCS): In the raw element
  accessors (e.g scm_u32vector_writable_elements), only permit
  bytevectors, as the constructors will only make bytevectors.  This
  harmonizes with the Scheme interfaces as well, which expect packed
  bytevectors.
  (scm_make_srfi_4_vector): Knowing that the new value is a bytevector
  with base 0 and inc 1, simplify initialization.

10 years agoDeprecate htons, htonl, ntohs, ntohl
Andy Wingo [Sat, 8 Feb 2014 13:27:49 +0000 (14:27 +0100)]
Deprecate htons, htonl, ntohs, ntohl

* libguile/sockets.h:
* libguile/sockets.c:
* libguile/deprecated.h:
* libguile/deprecated.c (scm_htons, scm_htonl, scm_ntohs, scm_ntohl):
  Deprecate.  Bytevectors adequately subsume their functionality.

* doc/ref/posix.texi:
* test-suite/tests/00-socket.test: Update.

10 years agoImprove handling of locales in the test suite.
Mark H Weaver [Sat, 8 Feb 2014 02:42:28 +0000 (21:42 -0500)]
Improve handling of locales in the test suite.

* test-suite/guile-test (run-tests): Load each test file within
  (with-locale "C" ...).

* test-suite/tests/encoding-iso88591.test:
* test-suite/tests/encoding-iso88597.test:
* test-suite/tests/encoding-utf8.test:
* test-suite/tests/srfi-14.test: Remove broken code to save and restore
  the previous locale.

* test-suite/tests/bytevectors.test:
* test-suite/tests/format.test:
* test-suite/tests/regexp.test:
* test-suite/tests/srfi-19.test:
* test-suite/tests/tree-il.test: Make sure 'setlocale' is defined before
  calling it.

10 years agoBetter error reporting in 'weak-vector-ref' and 'weak-vector-set!'.
Mark H Weaver [Fri, 7 Feb 2014 21:53:48 +0000 (16:53 -0500)]
Better error reporting in 'weak-vector-ref' and 'weak-vector-set!'.

* libguile/weaks.c (scm_c_weak_vector_ref, scm_c_weak_vector_set_x):
  Pass procedure name to 'scm_out_of_range'.