1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00
Commit graph

21194 commits

Author SHA1 Message Date
Daniel Llorens
ed5e37caa0 Provide a hook for the exception printer 2024-12-02 13:23:26 +01:00
Natanael Copa
bb7154fb80
Fix build failure with GCC 14 and musl on 32-bit systems.
Fixes <https://bugs.gnu.org/73835>.

This fixes this error when compiling with GCC 14 and musl libc on 32-bit
Alpine Linux:

  filesys.c: In function 'scm_sendfile':
  filesys.c:1405:16: error: assignment to 'off_t *' {aka 'long long int *'} from incompatible pointer type 'scm_t_off *' {aka 'long int *'} [-Wincompatible-pointer-types]
   1405 |     offset_ptr = SCM_UNBNDP (offset) ? NULL : &c_offset;
	|                ^

* libguile/filesys.c (scm_sendfile): Change type of ‘c_offset’.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-26 19:45:12 +02:00
Tomas Volf
1c093d8bc4
doc: Recommend alist-copy instead of list-copy.
The current recommendation of `list-copy' is not right and does not lead
to preserving the original list:

    scheme@(guile-user)> (define x (list (cons 'a 1) (cons 'b 2)))
    scheme@(guile-user)> (define y (list-copy x))
    scheme@(guile-user)> (assq-set! y 'b 3)
    $1 = ((a . 1) (b . 3))
    scheme@(guile-user)> x
    $2 = ((a . 1) (b . 3))

Correct approach seems to be use `alist-copy' from SRFI-1 leading to the
expected behavior of:

    scheme@(guile-user)> ,use (srfi srfi-1)
    scheme@(guile-user)> (define x (list (cons 'a 1) (cons 'b 2)))
    scheme@(guile-user)> (define y (alist-copy x))
    scheme@(guile-user)> (assq-set! y 'b 3)
    $1 = ((a . 1) (b . 3))
    scheme@(guile-user)> x
    $2 = ((a . 1) (b . 2))

* doc/ref/api-data.texi (Adding or Setting Alist Entries): Recommend
`alist-copy'.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-26 19:45:11 +02:00
Nikolaos Chatzikonstantinou
a0368a6120
doc: Fix typo in FFI documentation.
The incorrect procedure is mentioned; see the example that immediately
follows.

* doc/ref/api-foreign.texi (Foreign Functions): fix typo to
pointer->procedure.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-26 19:45:03 +02:00
Juliana Sims
8d45f63c85
doc: Document the peek and pk procedures.
* doc/ref/api-debug.texi: Document the peek and pk procedures.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-26 19:44:41 +02:00
Tomas Volf
bfff7e1d6d
doc: Fix implication of omitting optional arguments.
According to the previous wording, omitting all optional arguments led
to empty interface.  That however was not the case and was only a
documentation bug (as confirmed by wingo on IRC).  So let us fix that.

* doc/ref/api-modules.texi (Using Guile Modules): Fix implication of
omitting optional arguments.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-26 19:44:40 +02:00
Tomas Volf
130fdb0c8d
doc: Document #:hide.
* doc/ref/api-modules.texi (Using Guile Modules): Document #:hide.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-26 19:44:40 +02:00
Tomas Volf
1a5e35f0eb
srfi-64: Accept symbols as test group names.
The specification mandates a string, but with rationale suggesting symbols
would be a more natural fit.

> In some ways using symbols would be preferable. However, we want
> human-readable names, and standard Scheme does not provide a way to include
> spaces or mixed-case text in literal symbols.

Add support for symbols as an implementation extension and for backwards
compatibility with the reference implementation.

* module/srfi/srfi-64.scm (%cmp-group-name): New procedure.
(test-end): Use it.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Reported-by: Daniel Llorens <lloda@sarc.name>
2024-10-26 19:44:40 +02:00
Taylan Kammer
242e8698c2 Better REPL behavior on syntax errors in meta commands.
Fixes <https://bugs.gnu.org/30600>.

* module/system/repl/command.scm (define-meta-command): Flush all
remaining input after handling a read error.
* module/system/repl/common.scm (flush-all-input): New public procedure.
* module/system/repl/repl.scm: Remove local flush-all-input definition.
2024-10-25 13:35:31 +02:00
Daniel Llorens
818b879b2e doc: Fix use of literals in alist example
Fixes https://bugs.gnu.org/32841.

* doc/ref/srfi-modules.texi (alist-copy): Add anchor.
* doc/ref/api-data.texi (Alist Example): Fix use of literals.
2024-10-22 11:42:20 +02:00
Ludovic Courtès
faa8ab8a88
Update NEWS. 2024-10-20 21:22:55 +02:00
Tomas Volf
0175343deb
posix.c: Set errno when pipe2 is not available and flags provided.
If pipe2 is not available (e.g. on MacOS) and flags are set,
SCM_SYSERROR was correctly signaled, however errno was not set, so it
reported as:

    Undefined error: 0

That sucks both in tests (the test is not skipped) and in actual
usage (user has no idea what went wrong).

So set errno to ENOSYS as well.

* libguile/posix.c (scm_pipe2) [!HAVE_PIPE2] <c_flags>: Set errno to
ENOSYS.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-20 21:22:23 +02:00
Tomas Volf
ff256c356b
Do not depend on tmpnam in posix.test.
`tmpnam' is a deprecated procedure that can be excluded during a
configure (`--disable-tmpnam').  There currently was a single test
relying on it, and therefore failing is such configuration.  This commit
switches to mkstemp instead.

* test-suite/tests/posix.test ("system*"): Use mkstemp instead of
tmpnam.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-20 21:22:23 +02:00
Tomas Volf
58a722d883
tests: Fix spawn if file not found with Gnulib.
On Darwin posix_spawnp is not considered secured and therefore we
fallback to Gnulib's version.  That one however does not return ENOENT
when the file does not exist, but PID of the child process.  This seems
to be allowed by the standard.

* test-suite/tests/posix.test (skip-on-darwin): New procedure.
("spawn")["file not file"]: Skip on Darwin.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-20 21:22:23 +02:00
Tomas Volf
1746dbbe4d
tests: Fix spawn with #:environment on MacOS.
MacOS adds __CF_USER_TEXT_ENCODING to every program, in similar way GNU
Hurd prepends LD_ORIGIN_PATH (based on the comment).  So extend the
logic to do similar stripping on MacOS.

* test-suite/tests/posix.test ("spawn")
["env with #:environment and #:output"]: Strip trailing
__CF_USER_TEXT_ENCODING environment variable when on Darwin.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-20 21:22:23 +02:00
Tomas Volf
8579b73aba
tests: Skip mkdtemp test for invalid template on Darwin.
Darwin accepts any template, as demonstrated here:

    #include <stdio.h>
    #include <unistd.h>

    int
    main(void)
    {
    	char template[] = {'T', '-', 'A', 'A', 'A', 'A', 'A', 'A', '\0'};
    	char *res = mkdtemp(template);
    	puts(res ? res : "(null)");
    	perror("mkdtemp");
    }

Outputs:

    T-AAAAAA
    mkdtemp: Undefined error: 0

This does not match prescribed POSIX behavior, but it is what it is.

* test-suite/tests/filesys.test (skip-on-darwin): New procedure.
("mkdtemp")["invalid template"]: Skip on Darwin.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-20 21:22:23 +02:00
Tomas Volf
0ceb0036c3
filesys.c: Fix readlink for ports on Darwin.
When passed a port, `readlink' relies on the Linux specific behavior of
empty c_path meaning "the fd itself".  That does not work on Darwin.
Since there is no branch that would yield both fd and c_path, fallback
to freadlink when __APPLE__ is defined.

* libguile/filesys.c (do_readlink): Call freadlink for !__APPLE__.
* configure.ac (AC_CHECK_FUNCS): Add freadlink.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-20 21:22:23 +02:00
Tomas Volf
21e3e1c420
tests: Skip hole-related port tests on Darwin.
Hole are itself a file-system specific feature and they are not
mandated.  While APFS does support sparse files, they do not behave like
on Linux.  I did not discover exact rules, but the file needs to be
large (100s of kB at least) and the holes are not aligned as the test
code expects.  So just disable them.

* test-suite/tests/ports.test (skip-on-darwin): New procedure.
("size of sparse file", "SEEK_DATA while on data")
("SEEK_DATA while in hole", "SEEK_HOLE while in hole"): Skip on Darwin.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-20 21:22:22 +02:00
Tomas Volf
478f139d77
tests: Skip tests of abstract Unix sockets on Darwin.
Darwin does not support abstract Unix sockets, so mark the tests as
skipped.

* test-suite/tests/00-socket.test (skip-on-darwin): New procedure.
("bind abstract", "listen abstract", "connect abstract")
("accept abstract"): Skip on Darwin.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-20 21:22:22 +02:00
Tomas Volf
a8ce7f1f92
tests: Check TCP_NODELAY for non-zero instead of 1.
POSIX does not explicitly say that stored value using setsockopt will be
returned by getsockopt.  At least for TCP_NODELAY on Darwin they do
differ.  Darwin returns internal define TF_NODELAY (4) instead of 1 the
test expected.  Since for boolean flags "non-zero is true", rewrite the
test to check just that.

* test-suite/tests/00-socket.test ("setsockopt AF_INET")
["IPPROTO_TCP TCP_NODELAY"]: Check for non-zero value from getsockopt.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-20 21:22:22 +02:00
Andrew McNulty
b7bd440f22
Fix typo in dynamic wind documentation.
* doc/ref/api-control.texi: Fix typo in dynamic wind
documentation.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-20 21:22:22 +02:00
Brennan Vincent
0ace611196
Fix gbt command in gdbinit
In 2009 when this was written, SCM_UNDEFINED was 0x704. Now it's 0x904.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-20 21:22:22 +02:00
Tomas Volf
ad90f45a8c
Replace SRFI-64 with a new implementation.
The bundled (reference) implementation was of somewhat mixed quality and
it failed to follow standard in multiple places.  This commit replaces
it with a new one, written from scratch to follow the standard as close
as possible.

* module/srfi/srfi-64/testing.scm: Delete file.
* module/srfi/srfi-64.scm: Replace with new implementation.
* am/bootstrap.am (srfi/srfi-64.go): Remove extra dependencies.
(NOCOMP_SOURCES): Remove srfi/srfi-64/testing.scm.
* test-suite/tests/srfi-64-test.scm
("8.6.1. Simple (form 1) test-apply")
("8.6.2. Simple (form 2) test-apply"): Adjust tests to follow the
specification.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-20 19:11:42 +02:00
Michael Käppler
08e26836f1
Fix setjmp/longjmp-related crashes on Windows
* libguile/Makefile.am: add new header file setjump-win.h
* libguile/continuations.h, libguile/dynstack.c, libguile/dynstack.h,
  libguile/intrinsics.h, libguile/vm.h:
  supply custom `setjmp` macro on Windows

Mingw implements `setjmp (env)` as a macro that expands to

 _setjmp (env, faddr)

where `faddr` is set to the current frame address.

This address is then stored as first element in the jump buffer `env`.
When `longjmp` is called, it tries to unwind the stack up
to the saved address by calling `RtlUnwindEx` from MSVCRT,
which will fail, if the stack frames are interwoven with
JIT-generated code, that violate the Windows x64 calling conventions.

Thus implement the macro ourselves as

_setjmp (env, NULL)

which will toggle a code path in `longjmp` that does no unwinding.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-10-20 12:14:21 +02:00
Arne Babenhauserheide
c0bfa3219c fix typo in comment
module/ice-9/command-line.scm (compile-shell-switches): fix typo
2024-10-12 14:07:02 +02:00
Matthew Wette
8d21dd7eb8 Create procedure to enable silencing the Guile welcome message. * module/system/repl/repl.scm: add parameter %inhibit-welcome-message' * module/system/repl/repl.scm(run-repl*): add condition for calling procedure repl-welcome: if (%inhibit-welcome-message) is #t', don't 2024-10-12 13:16:35 +02:00
Matthew Wette
78e9e51065 Redirect diagnostice output messages (e.g., auto-compiling code) to a newly defined current-info-port, and add a command line argument -I' to set the current-info-port to a void-port. * libguile/ports.c: add cur_infoport_fluid, scm_current_info_port, scm_set_current_info_port; define default current-info-port to stderr * libguile/load.c(compiled_is_fresh,load_thunk_from_path, do_try_auto_compile,scm_sys_warn_auto_compilation_enabled, scm_primitive_load_path): direct output messages to current_info_port; was current_warning_port * libguile/init.c(scm_init_standard_ports): set default current_info_port * module/ice-9/ports.scm: define current-info-port and set-current-info-port * module/ice-9/command-line.scm(*usage*,compile-shell-switches): add argument -I' to silence diagnostics (or current-info-port to void-port) * doc/ref/guile-invoke.texi: add description for `-I' command argument 2024-10-12 13:16:25 +02:00
Matthew Wette
3d2fd7a262 Fix typo in naming function set-current-output-port * libguile/ports.c(scm_set_current_output_port): scheme name is set-current-output-port 2024-10-12 13:16:12 +02:00
Rob Browning
9b1effb585 Compile with -fexcess-precision=standard for i[3456]86 when we can
* configure.ac: when -fexcess-precision=standard is available and we're
building for i[3456]86, use it.  This fixes floating point precision
problems caused by x87 (80-bit) floating point, and detected by
numbers.test.

Closes: 43262
2024-10-05 19:19:57 -05:00
Rob Browning
1c96e4ab6d Ensure tests have guile-procedures.txt
The tests depend on libguile/guile-procedures.txt, for example via
documented? in bit-operations.test.  Previously "make check -j..." in a
clean tree would fail because libguile/guile-procedures.txt is built by
./Makefile.am (rather than libguile/Makefile.am) so that it will have a
built module/ available, but when "." is not listed in SUBDIRS, it
builds last, and so the test-suite runs before guile-procedures.txt is
built.

To fix the problem add "." to SUBDIRS before the test-suite so that the
tests will be able depend on everything else, and move the existing
guile-procedures.txt target into libguile/ next to its
guile-procedures.texi dependency.  That gives a better overview and
simplifies the recipe a bit.  It also allows us to drop the explict
"all-local:" dependency, and to let the existing libguile/ code handle
the cleanup.

* Makefile.am (SUBDIRS): add . just before the test-suite.
(libguile/guile-procedures.txt): rely on libguile/Makefile.am.
(CLEANFILES): Drop libguile/procedures.txt.
* libguile/Makefile.am: (all-local): drop.
(libguile/guile-procedures.txt): move Makefile.am recipe here.
2024-09-27 19:51:00 -05:00
Ludovic Courtès
e134a1a6b1
Update NEWS. 2024-09-27 22:50:52 +02:00
Andy Wingo
aff9ac9688 Run sigbits fixpoint based on use/def graph, not cfg
* module/language/cps/specialize-numbers.scm (sigbits-ref): New helper.
(invert-graph*): New helper.
(compute-significant-bits): When visiting a term changes computed
needed-bits for one of its definitions, we need to revisit the variables
that contributed to its result (the uses), because they might need more
bits as well.  Previously we were doing this by enqueueing predecessors
to the term, which worked if the uses were defined in predecessors, or
if all defining terms were already in the worklist, which is the case
without loops.  But with loops, when revisiting a term, you could see
that it causes sigbits to change, enqueue its predecessors, but then the
predecessors don't change anything and the fixpoint stops before
reaching the definitions of the variables we need.  So instead we
compute the use-def graph and enqueue defs directly.
2024-09-26 11:14:52 +02:00
Andy Wingo
30c3849092 Tighten up range inference for scm->u64/truncate
* module/language/cps/types.scm (scm->u64/truncate): Better range
analysis.
2024-09-25 17:27:17 +02:00
Andy Wingo
e45b70dcde Fix boxing of non-fixnum negative u64 values
* module/language/cps/specialize-numbers.scm (u64->fixnum/truncate): New
helper.
(specialize-operations): Fix specialized boxing of u64 values to
truncate possibly-negative values, to avoid confusing CSE.  Fixes
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71891.
2024-09-25 17:24:51 +02:00
Andy Wingo
0dab58fc2a Fix fixpoint needed-bits computation in specialize-numbers
* module/language/cps/specialize-numbers.scm (next-power-of-two): Use
integer-length.  No change.
(compute-significant-bits): Fix the fixpoint computation, which was
failing to complete in some cases with loops.
2024-09-25 17:23:06 +02:00
Andy Wingo
b04071cc57 Partially revert d579848cb5
* module/language/cps/specialize-numbers.scm (specialize-operations):
Accept any operand to logand/immediate, provided the result is a u64 in
the right range.
2024-09-24 09:24:15 +02:00
Andy Wingo
5e6288c930 Narrow parameter of logand/immediate if no bits used
* module/language/cps/specialize-numbers.scm (specialize-operations):
Narrow ulogand/immediate param according to used bits.
2024-09-23 16:00:54 +02:00
Andy Wingo
d6af34c0e0 Remove needless constraints in type/range analysis
* module/language/cps/types.scm
(ulogand, ulogand/immediate, ulogsub, ulogior, ulogxor): Where we have
u64 inputs, there's no need to `restrict!`; the range will come from the
definition.
2024-09-23 15:32:45 +02:00
Andy Wingo
90e1205018 Add a workaround for pre-3.0.10 incorrect inlinable exports
* module/language/tree-il/peval.scm (peval)
(inlinable-kwargs-bug-fixup): Before 3.0.10, the inlinable exports pass
was incorrectly serializing functions with keyword arguments.  This was
fixed in 2c645571b3, but that meant that
3.0.10 compiling against 3.0.9 binaries could raise an exception at
compile-time; whoops.  Add a workaround so that 3.0.9 binaries still
work.

Fixes https://issues.guix.gnu.org/72936.
2024-09-23 14:07:53 +02:00
Andy Wingo
a970ed5bd5 Update psyntax copyright notice
* module/ice-9/psyntax.scm: Use the newer LGPLv3 header.  Add FSF
copyright lines for each year the file was modified.  Remove inline
changelogs.  Remove some comments describing psyntax in other Scheme
implementations.
2024-08-26 09:51:53 +02:00
Andy Wingo
d0790d766b Fix intset-fold-right on transient intsets
* module/language/cps/intset.scm (make-intset-folder): intset-fold-right
on a transient intset would dispatch to left fold after making the
persistent set.  Sadness!
2024-08-15 12:18:02 +02:00
Andy Wingo
7aa4cfa9de More thorough lowering of lognot to CPS
* module/language/tree-il/compile-cps.scm (canonicalize): Lower to a
logxor with -1.
2024-08-13 13:40:45 +02:00
Andy Wingo
c2e7d834c2 Fix compilation with C23
* libguile/jit.c (is_unreachable): Rename from "unreachable", which is
apparently a new reserved word in C23.
2024-08-13 13:40:45 +02:00
Daniel Llorens
83d6d6afd9 Better error messages in array functions
* doc/ref/api-data.texi (Arrays as arrays of arrays): Clarify
  ambiguities, fix examples.
* libguile/arrays.c (make-shared-array): Make error messages specific to
  each error case, report relevant arguments.
  (array_from_pos): Return NULL on error instead of reporting error
  ourselves.
  (array_from_get_o): Handle the trivial case.
  (scm_array_slice, scm_array_cell_ref, scm_array_cell_set_x): Don't
  build error arguments before error happens. Let array_from_get_o
  handle the trivial case.
2024-08-12 14:24:58 +02:00
Rob Browning
c03115c39d basename: check suffix against basename, not full argument
* libguile/filesys: check suffix against basename, not full argument.

Closes: 69437
2024-08-03 14:39:26 -05:00
Rob Browning
9a57c237d2 basename: drop last_component null check
Prepare for fixes to the suffix pruning.  Since last_component doesn't
document a possible null result in lib/basename-lgpl.h, and the current
code also doesn't appear capable of producing one, drop the check.

libguile/filesys.c (basename): drop check for last_component null result.
2024-08-03 14:29:47 -05:00
Yuval Langer
2047b532fa api-data.texi: fix typo in "Real and Rational Numbers" section
* doc/ref/api-data.texi: fix typo in "Real and Rational Numbers" section

[rlb@defaultvalue.org: adjust commit message]

Closes: 59572
2024-08-03 14:25:10 -05:00
Rob Browning
b6125a0def NEWS: add some missing 3.0.11 entries 2024-08-03 14:25:10 -05:00
Rob Browning
bce91cebed Merge conversion of srfi-1.c to srfi-1.scm
Rewrite the srfi-1 C functions in Scheme and remove srfi-1.c as
planned (see the comments at the top of srfi-1.c).

The previous C code mutated intermediate results in some cases, even for
non-! functions (e.g. set-cdr! to build the result without stack growth
or a reverse!); some of the conversions preserve that approach for now.

Simple testing via https://github.com/ecraven/r7rs-benchmarks/ didn't
reveal any substantial performance regressions.

Thanks to David Thompson for reviewing the changes and suggesting
improvements.
2024-07-30 19:40:48 -05:00
Rob Browning
6338459159 Drop libguile srfi-1
...now that all of the C code has been migrated to Scheme.

* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES):
remove srfi-1.c.
(DOC_X_FILES): Remove srfi-1.x.
(DOT_DOC_FILES): Remove srfi-1.doc.
(modinclude_HEADERS): Remove srfi-1.h.
* libguile/init.c (scm_i_init_guile): Don't call scm_register_srfi_1.
* libguile/srfi-1.c: Remove.
* libguile/srfi-1.h: Remove.
* module/srfi/srfi-1.scm: Don't load srfi-1 from libguile.
2024-07-30 19:39:32 -05:00