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>
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>
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>
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>
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>
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.
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>
`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>
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>
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>
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>
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>
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>
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>
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>
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>
* 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>
* 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
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.
* 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.
* 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.
* module/language/cps/specialize-numbers.scm (specialize-operations):
Accept any operand to logand/immediate, provided the result is a u64 in
the right range.
* 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.
* 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.
* 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.
* 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!
* 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.
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.
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.
...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.