diff --git a/NEWS b/NEWS index 80b06fd74..92dc19f3f 100644 --- a/NEWS +++ b/NEWS @@ -49,9 +49,9 @@ removed on those plaforms (basically only MinGW). ** Gnulib update. -Guile's copy of Gnulib was updated to XXX. The following modules were -imported from Gnulib: select, times, pipe-posix, fstat, getlogin, and -poll. +Guile's copy of Gnulib was updated to v0.0-7865-ga828bb2. The following +modules were imported from Gnulib: select, times, pipe-posix, fstat, +getlogin, and poll. ** New optimizations. @@ -93,6 +93,11 @@ more information. ** Update predefined character sets to Unicode 6.2. +** GMP 4.2 or later required + +Guile used to require GMP at least version 4.1 (released in May 2002), +and now requires at least version 4.2 (released in March 2006). + * Manual updates ** Better SXML documentation. diff --git a/README b/README index 31fdb80ca..480ef66c1 100644 --- a/README +++ b/README @@ -62,7 +62,7 @@ Required External Packages ================================================ Guile requires the following external packages: - - GNU MP, at least version 4.1 + - GNU MP, at least version 4.2 GNU MP is used for bignum arithmetic. It is available from http://gmplib.org/ . diff --git a/configure.ac b/configure.ac index 85e31704e..e25635b80 100644 --- a/configure.ac +++ b/configure.ac @@ -872,6 +872,14 @@ if test "x$HAVE_LIBGMP" != "xyes"; then AC_MSG_ERROR([GNU MP 4.1 or greater not found, see README]) fi +dnl `mpz_inits' and `mpz_clears' appeared in GMP 5.0.0. +save_CPPFLAGS="$CPPFLAGS" +if test "x$LIBGMP_PREFIX" != "x"; then + CPPFLAGS="-I$LIBGMP_PREFIX $CPPFLAGS" +fi +AC_CHECK_DECLS([mpz_inits], [], [], [[#include ]]) +CPPFLAGS="$save_CPPFLAGS" + dnl GNU libunistring is checked for by Gnulib's `libunistring' module. if test "x$LTLIBUNISTRING" = "x"; then AC_MSG_ERROR([GNU libunistring is required, please install it.]) diff --git a/doc/ref/api-evaluation.texi b/doc/ref/api-evaluation.texi index c4e77a9b4..7afbcfaef 100644 --- a/doc/ref/api-evaluation.texi +++ b/doc/ref/api-evaluation.texi @@ -22,6 +22,7 @@ loading, evaluating, and compiling Scheme code at run time. * Delayed Evaluation:: Postponing evaluation until it is needed. * Local Evaluation:: Evaluation in a local lexical environment. * Local Inclusion:: Compile-time inclusion of one file in another. +* REPL Servers:: Serving a REPL over a socket. @end menu @@ -1220,6 +1221,52 @@ the source files for a package (as you should!). It makes it possible to evaluate an installed file from source, instead of relying on the @code{.go} file being up to date. +@node REPL Servers +@subsection REPL Servers + +@cindex REPL server + +The procedures in this section are provided by +@lisp +(use-modules (system repl server)) +@end lisp + +When an application is written in Guile, it is often convenient to +allow the user to be able to interact with it by evaluating Scheme +expressions in a REPL. + +The procedures of this module allow you to spawn a @dfn{REPL server}, +which permits interaction over a local or TCP connection. Guile itself +uses them internally to implement the @option{--listen} switch, +@ref{Command-line Options}. + +@deffn {Scheme Procedure} make-tcp-server-socket [#:host=#f] @ + [#:addr] [#:port=37146] +Return a stream socket bound to a given address @var{addr} and port +number @var{port}. If the @var{host} is given, and @var{addr} is not, +then the @var{host} string is converted to an address. If neither is +given, we use the loopback address. +@end deffn + +@deffn {Scheme Procedure} make-unix-domain-server-socket [#:path="/tmp/guile-socket"] +Return a UNIX domain socket, bound to a given @var{path}. +@end deffn + +@deffn {Scheme Procedure} run-server [server-socket] +@deffnx {Scheme Procedure} spawn-server [server-socket] +Create and run a REPL, making it available over the given +@var{server-socket}. If @var{server-socket} is not provided, it +defaults to the socket created by calling @code{make-tcp-server-socket} +with no arguments. + +@code{run-server} runs the server in the current thread, whereas +@code{spawn-server} runs the server in a new thread. +@end deffn + +@deffn {Scheme Procedure} stop-server-and-clients! +Closes the connection on all running server sockets. +@end deffn + @c Local Variables: @c TeX-master: "guile.texi" @c End: diff --git a/doc/ref/srfi-modules.texi b/doc/ref/srfi-modules.texi index 8bf7c4126..365341dde 100644 --- a/doc/ref/srfi-modules.texi +++ b/doc/ref/srfi-modules.texi @@ -3844,7 +3844,7 @@ again. SRFI-41 can be made available with: SRFI-41 Streams are based on two mutually-recursive abstract data types: An object of the @code{stream} abstract data type is a promise that, -when forced, is either @code{stream-null} or is an object of type +when forced, is either @var{stream-null} or is an object of type @code{stream-pair}. An object of the @code{stream-pair} abstract data type contains a @code{stream-car} and a @code{stream-cdr}, which must be a @code{stream}. The essential feature of streams is the systematic @@ -3862,16 +3862,16 @@ stream, and is only forced on demand. @subsubsection SRFI-41 Stream Primitives This library provides eight operators: constructors for -@code{stream-null} and @code{stream-pair}s, type predicates for streams +@var{stream-null} and @code{stream-pair}s, type predicates for streams and the two kinds of streams, accessors for both fields of a @code{stream-pair}, and a lambda that creates procedures that return streams. -@deffn {Scheme Variable} stream-null +@defvr {Scheme Variable} stream-null A promise that, when forced, is a single object, distinguishable from -all other objects, that represents the null stream. @code{stream-null} +all other objects, that represents the null stream. @var{stream-null} is immutable and unique. -@end deffn +@end defvr @deffn {Scheme Syntax} stream-cons object-expr stream-expr Creates a newly-allocated stream containing a promise that, when forced, @@ -4003,7 +4003,7 @@ Returns a newly-allocated stream containing the elements from Returns a newly-allocated stream containing in its elements the characters on the port. If @var{port} is not given it defaults to the current input port. The returned stream has finite length and is -terminated by @code{stream-null}. +terminated by @var{stream-null}. It looks like one use of @code{port->stream} would be this: diff --git a/libguile/generalized-arrays.c b/libguile/generalized-arrays.c index 9382e817e..59925a09e 100644 --- a/libguile/generalized-arrays.c +++ b/libguile/generalized-arrays.c @@ -135,7 +135,7 @@ SCM_DEFINE (scm_array_length, "array-length", 1, 0, 0, (SCM array), "Return the length of an array: its first dimension.\n" "It is an error to ask for the length of an array of rank 0.") -#define FUNC_NAME s_scm_array_rank +#define FUNC_NAME s_scm_array_length { return scm_from_size_t (scm_c_array_length (array)); } diff --git a/libguile/numbers.c b/libguile/numbers.c index 29d266984..d941133df 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -1,4 +1,6 @@ -/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, + * 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, + * 2013 Free Software Foundation, Inc. * * Portions Copyright 1990, 1991, 1992, 1993 by AT&T Bell Laboratories * and Bellcore. See scm_divide. @@ -56,6 +58,8 @@ #include #endif +#include + #include "libguile/_scm.h" #include "libguile/feature.h" #include "libguile/ports.h" @@ -96,6 +100,31 @@ typedef scm_t_signed_bits scm_t_inum; #define DOUBLE_IS_POSITIVE_INFINITY(x) (isinf(x) && ((x) > 0)) #define DOUBLE_IS_NEGATIVE_INFINITY(x) (isinf(x) && ((x) < 0)) + +#if ! HAVE_DECL_MPZ_INITS + +/* GMP < 5.0.0 lacks `mpz_inits' and `mpz_clears'. Provide them. */ + +#define VARARG_MPZ_ITERATOR(func) \ + static void \ + func ## s (mpz_t x, ...) \ + { \ + va_list ap; \ + \ + va_start (ap, x); \ + while (x != NULL) \ + { \ + func (x); \ + x = va_arg (ap, mpz_ptr); \ + } \ + va_end (ap); \ + } + +VARARG_MPZ_ITERATOR (mpz_init) +VARARG_MPZ_ITERATOR (mpz_clear) + +#endif + /* diff --git a/test-suite/standalone/test-pthread-create-secondary.c b/test-suite/standalone/test-pthread-create-secondary.c index e145fa5bc..14ea240a4 100644 --- a/test-suite/standalone/test-pthread-create-secondary.c +++ b/test-suite/standalone/test-pthread-create-secondary.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 Free Software Foundation, Inc. +/* Copyright (C) 2011, 2013 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -30,15 +30,20 @@ #include -/* Up to GC 7.2alpha5, calling `GC_INIT' from a secondary thread would +/* Currently, calling `GC_INIT' from a secondary thread is only + supported on some systems, notably Linux-based systems (and not on + FreeBSD, for instance.) + + Up to GC 7.2alpha5, calling `GC_INIT' from a secondary thread would lead to a segfault. This was fixed in BDW-GC on 2011-04-16 by Ivan Maidanski. See for details. */ -#if (GC_VERSION_MAJOR > 7) \ - || ((GC_VERSION_MAJOR == 7) && (GC_VERSION_MINOR > 2)) \ - || ((GC_VERSION_MAJOR == 7) && (GC_VERSION_MINOR == 2) \ - && (GC_ALPHA_VERSION > 5)) +#if defined __linux__ \ + && (GC_VERSION_MAJOR > 7 \ + || (GC_VERSION_MAJOR == 7 && GC_VERSION_MINOR > 2) \ + || (GC_VERSION_MAJOR == 7 && GC_VERSION_MINOR == 2 \ + && GC_ALPHA_VERSION > 5)) static void * do_something (void *arg) @@ -73,7 +78,7 @@ main (int argc, char *argv[]) } -#else /* GC < 7.2 */ +#else /* Linux && GC < 7.2alpha5 */ int main (int argc, char *argv[]) diff --git a/test-suite/tests/ports.test b/test-suite/tests/ports.test index 372993032..886ab2418 100644 --- a/test-suite/tests/ports.test +++ b/test-suite/tests/ports.test @@ -2,7 +2,7 @@ ;;;; Jim Blandy --- May 1999 ;;;; ;;;; Copyright (C) 1999, 2001, 2004, 2006, 2007, 2009, 2010, -;;;; 2011, 2012 Free Software Foundation, Inc. +;;;; 2011, 2012, 2013 Free Software Foundation, Inc. ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public @@ -1162,33 +1162,35 @@ (with-test-prefix "%file-port-name-canonicalization" - (pass-if "absolute file name & empty %load-path entry" + (pass-if-equal "absolute file name & empty %load-path entry" "/dev/null" ;; In Guile 2.0.5 and earlier, this would return "dev/null" instead ;; of "/dev/null". See ;; ;; for a discussion. - (equal? "/dev/null" - (with-load-path (cons "" (delete "/" %load-path)) - (with-fluids ((%file-port-name-canonicalization 'relative)) - (port-filename (open-input-file "/dev/null")))))) + (with-load-path (cons "" (delete "/" %load-path)) + (with-fluids ((%file-port-name-canonicalization 'relative)) + (port-filename (open-input-file "/dev/null"))))) - (pass-if "relative canonicalization with /" - (equal? "dev/null" - (with-load-path (cons "/" %load-path) - (with-fluids ((%file-port-name-canonicalization 'relative)) - (port-filename (open-input-file "/dev/null")))))) + (pass-if-equal "relative canonicalization with /" "dev/null" + (with-load-path (cons "/" %load-path) + (with-fluids ((%file-port-name-canonicalization 'relative)) + (port-filename (open-input-file "/dev/null"))))) - (pass-if "relative canonicalization from ice-9" - (equal? "ice-9/q.scm" - (with-fluids ((%file-port-name-canonicalization 'relative)) - (port-filename - (open-input-file (%search-load-path "ice-9/q.scm")))))) + (pass-if-equal "relative canonicalization from ice-9" "ice-9/q.scm" + ;; If an entry in %LOAD-PATH is not canonical, then + ;; `scm_i_relativize_path' is unable to do its job. + (if (equal? (map canonicalize-path %load-path) %load-path) + (with-fluids ((%file-port-name-canonicalization 'relative)) + (port-filename + (open-input-file (%search-load-path "ice-9/q.scm")))) + (throw 'unresolved))) - (pass-if "absolute canonicalization from ice-9" - (equal? (string-append (assoc-ref %guile-build-info 'top_srcdir) - "/module/ice-9/q.scm") - (with-fluids ((%file-port-name-canonicalization 'absolute)) - (port-filename (open-input-file (%search-load-path "ice-9/q.scm"))))))) + (pass-if-equal "absolute canonicalization from ice-9" + (canonicalize-path + (string-append (assoc-ref %guile-build-info 'top_srcdir) + "/module/ice-9/q.scm")) + (with-fluids ((%file-port-name-canonicalization 'absolute)) + (port-filename (open-input-file (%search-load-path "ice-9/q.scm")))))) (delete-file (test-file))