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

21100 commits

Author SHA1 Message Date
Arne Babenhauserheide
dce65edbaf
Add language/wisp, Wisp tests, and SRFI-119 documentation
* doc/ref/srfi-modules.texi (srfi-119): add node
* module/language/wisp.scm: New file.
* module/language/wisp/spec.scm: New file.
* test-suite/tests/srfi-119.test: New file.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-06-01 11:50:16 +02:00
Ludovic Courtès
7b92b22899
Don’t rely on integer wrapping in ‘scm_gc_register_allocation’.
* libguile/gc.c (scm_gc_register_allocation): Simplify condition.
2024-06-01 11:50:16 +02:00
Rob Browning
779a83d9c6 make-foreign-object-type: add #:super to provide superclasses
* module/system/foreign-object.scm (make-foreign-object-type): allow
specification of superclasses via #:super.
2024-05-17 12:53:39 -05:00
Daniel Llorens
34c13e7d94 Update NEWS. 2024-05-13 10:09:40 +02:00
Ludovic Courtès
f36342f9aa
guix: Use non-deprecated package name.
* .guix/modules/guile-package.scm (guile)[native-inputs]: Use
‘texlive-scheme-basic’ instead of the deprecated ‘texlive-base’.
2024-05-06 11:51:53 +02:00
Juliana Sims
a222503a89
Second argument of ‘unread-string’ is optional.
Fixes <https://bugs.gnu.org/67063>.

* doc/ref/api-io.texi (Venerable Port Interfaces): Bring unread-string
procedure documentation in line with other procedures in the section.
* libguile/ports.c (scm_unread_string): Make port argument optional.
* test-suite/tests/ports.test: Test unread-char and unread-string
without ports.
* NEWS: Update.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-05-06 11:51:53 +02:00
Michael Käppler
80d4055e42
Fix error messages containing format strings
The builtin primitive procedure `error` takes an optional message and
a list of arguments to include into the error message.
These args are formatted with `~S` and appended to the error message, so
that an example call of

`(error "Wrong argument: " 42)`

results in the output

"Wrong argument: 42"

If format strings occur in the message itself, however, they are
escaped. Thus a call like

`(error "Wrong argument: ~a" 42)`

is rendered as

"Wrong argument: ~a 42"

Some callers did not take this behavior into account, leading to
confusing error messages.
Changing the behavior of `error` to be
both backwards-compatible and accept also format strings inside messages
is not straightforward, because it would have to handle escaped `~`
characters as well. Therefore, fix `error` call sites using format
strings to use `format` before calling out to `error`.

The following files are affected:

* module/ice-9/format.scm (format)
* module/ice-9/r6rs-libraries.scm (resolve-r6rs-interface)
* module/oop/goops.scm (make)
* module/srfi/srfi-37.scm (Comment at the beginning of file)
* module/system/base/compile.scm (call-once)
* module/system/repl/command.scm (break, tracepoint)
* module/system/repl/common.scm (repl-default-options)
* module/system/vm/traps.scm (arg-check, trap-at-source-location)

There are a couple of further call sites that were left unchanged,
either because they are using their own `error` procedure:

* module/ice-9/read.scm
* module/ice-9/command-line.scm

or are not referenced from other modules:

* module/system/base/lalr.upstream.scm:
* module/sxml/upstream/assert.scm:
* module/sxml/sxml-match.ss:

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-05-06 11:51:53 +02:00
Jonas Hahnfeld
57a889b728
build: Fix cross-compilation in out-of-tree-builds
gen-scmconfig.h is generated in libguile, not $(top_builddir).

* libguile/Makefile.am: Add '-I.' when compiling gen-scmconfig.o.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-05-06 11:51:53 +02:00
Jonas Hahnfeld
ebcc9d1e3a
build: Make sed invocation fully portable
Commit 08041d216f attempted to make the "invocation compatible with
BSD sed", but moving '-i' first does not solve the problem because
it still requires to pass an argument. Instead just redirect the
instantiated output into a temporary file and install that.

* libguile/Makefile.am: Remove '-i' from INSTANTIATE.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-05-06 11:51:53 +02:00
Morgan Smith
f27e8b855f
Fix typos throughout codebase.
* NEWS:
* doc/ref/api-control.texi:
* doc/ref/api-data.texi:
* doc/ref/api-debug.texi:
* doc/ref/api-deprecated.texi:
* doc/ref/api-evaluation.texi:
* doc/ref/api-foreign.texi:
* doc/ref/api-i18n.texi:
* doc/ref/api-io.texi:
* doc/ref/api-languages.texi:
* doc/ref/api-macros.texi:
* doc/ref/api-memory.texi:
* doc/ref/api-modules.texi:
* doc/ref/api-options.texi:
* doc/ref/api-peg.texi:
* doc/ref/api-procedures.texi:
* doc/ref/api-scheduling.texi:
* doc/ref/api-undocumented.texi:
* doc/ref/api-utility.texi:
* doc/ref/expect.texi:
* doc/ref/goops.texi:
* doc/ref/misc-modules.texi:
* doc/ref/posix.texi:
* doc/ref/repl-modules.texi:
* doc/ref/scheme-ideas.texi:
* doc/ref/scheme-scripts.texi:
* doc/ref/srfi-modules.texi:
* gc-benchmarks/larceny/dynamic.sch:
* gc-benchmarks/larceny/twobit-input-long.sch:
* gc-benchmarks/larceny/twobit.sch:
* libguile/gc.h:
* libguile/ioext.c:
* libguile/list.c:
* libguile/options.c:
* libguile/posix.c:
* libguile/threads.c:
* module/ice-9/boot-9.scm:
* module/ice-9/optargs.scm:
* module/ice-9/ports.scm:
* module/ice-9/pretty-print.scm:
* module/ice-9/psyntax.scm:
* module/language/elisp/parser.scm:
* module/language/tree-il/compile-bytecode.scm:
* module/srfi/srfi-37.scm:
* module/srfi/srfi-43.scm:
* module/statprof.scm:
* module/texinfo/reflection.scm:
* test-suite/tests/eval.test:
* test-suite/tests/fluids.test:
Fix typos.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-05-06 11:51:53 +02:00
Ludovic Courtès
5fcf6ff17a
Update NEWS. 2024-05-06 11:51:53 +02:00
Ludovic Courtès
4ae33f76d6
‘system*’ no longer changes SIGINT and SIGQUIT handlers.
Fixes <https://bugs.gnu.org/70144>.

Fixes a bug whereby ‘system*’ would change the handler of SIGINT and
SIGQUIT to SIG_IGN in a racy fashion, possibly competing with calls to
‘sigaction’ in Scheme in another thread.

This is a followup to 527c257d6e, which
witch to ‘posix_spawn’, ensuring signals are properly dealt with when
creating child processes.

* libguile/posix.c (restore_sigaction, scm_dynwind_sigaction): Remove.
(scm_system_star): Remove sigaction dynwind around call to
‘piped_process’.
* NEWS: Update.

Reported-by: Christopher Baines <mail@cbaines.net>
2024-05-06 11:51:52 +02:00
Andy Wingo
3b76a30e3c Tree-IL lowerer has #:dump-optimized-tree-il? option
* module/language/tree-il/optimize.scm (make-optimizer): If the keyword
argument #:dump-optimized-tree-il? is present, print the Tree-IL that
will be handed to the next compiler.  Also re-enable #:verify-tree-il?.
2024-04-23 13:06:34 +02:00
Andy Wingo
e2fad20257 Merge Lightening update branch 2024-04-22 15:18:57 +02:00
Andy Wingo
6b99eb5212 Fix compilation when SCM_I_PTHREAD_ONCE_INIT is not aggregate
* libguile/scmsigs.c (scm_i_signals_post_fork): It's possible for
SCM_I_PTHREAD_ONCE_INIT to be a braced initializer.  In that case when
this initializer is re-used as an assignment, it needs the type to
instead be treated as a C11 literal.  Fixes compilation on Mac OS.

Thanks to Tony Garnock-Jones for the patch.
2024-04-22 15:09:45 +02:00
Andy Wingo
57c5018b3a Merge remote-tracking branch 'lightening/main' 2024-04-22 15:05:46 +02:00
Andy Wingo
43262c0962 aarch64: Add support for LSE atomics
* lightening/aarch64-cpu.c (SWPAL, CASAL): New instructions.
(swap_atomic, cas_atomic): Use better instructions if we have LSE.
* lightening/aarch64.c (get_hwcap, jit_get_cpu): Arrange to detect LSE
availability on GNU/Linux and Darwin.

Based on a patch by Tony Garnock-Jones.  Thanks!
2024-04-22 15:03:01 +02:00
Tony Garnock-Jones
2c0126e3ef aarch64: Fix swap_atomic retry
* lightening/aarch64-cpu.c (swap_atomic): If the swap fails, and the dst
register was the same as the val, we would stomple val during the retry.
Fixes https://github.com/wingo/fibers/issues/83#issuecomment-2068847127.
2024-04-22 15:03:01 +02:00
Andy Wingo
d759faa27a Fix CI 2024-04-22 15:03:01 +02:00
Ludovic Courtès
112b617f59
linker: Create a sparse file only when writing to a file port.
Fixes a regression introduced in
4a0c2433d9: the strategy wouldn’t work
when writing to, say, a bytevector output port.

* module/system/vm/linker.scm (link-elf)[write-padding]: Reintroduce
loop for when PORT is not a file port.  Remove first argument.
2024-04-16 00:34:01 +02:00
Ludovic Courtès
696acfc9e5
‘seek’ now accepts ‘SEEK_DATA’ and ‘SEEK_HOLE’ where supported.
* libguile/ports.c (scm_seek): Let SEEK_DATA and SEEK_HOLE through.
(scm_init_ice_9_ports): Define ‘SEEK_DATA’ and ‘SEEK_HOLE’.
* module/ice-9/ports.scm: Export ‘SEEK_DATA’ and ‘SEEK_HOLE’ when
defined.
* test-suite/tests/ports.test ("size of sparse file")
("SEEK_DATA while on data", "SEEK_DATA while in hole")
("SEEK_HOLE while in hole"): New tests.
* NEWS: Update.
2024-04-15 19:58:25 +02:00
Ludovic Courtès
4a0c2433d9
linker: Create sparse files for padding.
Since ‘*lcm-page-size*’ is 64 KiB, this saves disk space for small ‘.go’
files.

* module/system/vm/linker.scm (link-elf)[write-padding]: Rewrite in
terms of ‘seek’.
2024-04-15 19:58:25 +02:00
Rob Browning
6495b4d578 check-guile.in: improve quoting (e.g. paths with spaces)
* check-guile.in: improve shell quoting.
2024-04-14 16:15:10 -05:00
Rob Browning
fc62dba31b guile-test: set module declarative #f to eliminate warning
* test-suite/guile-test: set module declarative #f to eliminate warning
2024-04-14 16:15:10 -05:00
Rob Browning
6059c99fc2 interp.test: add missing (test-suite lib) dependency
* test-suite/tests/interp.test: use (test-suite lib)
2024-04-14 16:15:10 -05:00
Rob Browning
d0301eac2c srfi-10.test: add missing (test-suite lib) dependency
* test-suite/tests/srfi-10.test: use (test-suite lib)
2024-04-14 16:15:10 -05:00
Rob Browning
3ff8836e64 test-bad-identifiers: ignore *.[hc] dotfiles
When generating the list of test files, ignore any whose names begin
with a dot.  If nothing else, this avoids crashing on the symlinks that
Emacs creates for files with pending changes.  In that case it creates a
symlink to nowhere until the content is saved or reverted, and those
symlinks produce test failures like this:

  Backtrace:
             3 (primitive-load "/home/rlb/src/guile/utf8-debug/test-su?")
  In ice-9/eval.scm:
      619:8  2 (_ #(#(#(#<directory (guile-user) 7f0239b32c80> #) #) #))
  In ice-9/ports.scm:
     450:11  1 (call-with-input-file "../../libguile/.#strings.c" #<p?> ?)
  In unknown file:
             0 (open-file "../../libguile/.#strings.c" "r" #:encoding # ?)

  ERROR: In procedure open-file:
  In procedure open-file: No such file or directory: "../../libguile/.#strings.c"
  FAIL: test-bad-identifiers

* test-suite/standalone/test-bad-identifiers: ignore files with names
beginning with a dot.
2024-04-14 15:59:31 -05:00
Rob Browning
6bb6c89f89 guile-test: ignore *.test dotfiles by default
Adjust guile-test to ignore any test files with names beginning with a
dot.

If nothing else, this avoids make check and ./check-guile failures when
Emacs has unsaved changes to a test file.  In that case Emacs creates a
symlink to nowhere until the content is saved or reverted.

* test-suite/guile-test: ignore test files whose names begin with a dot.
2024-04-14 15:51:33 -05:00
Rob Browning
c665e18705 check-guile: add example invoking a test via gdb
* check-guile.in: add example invoking a test via gdb.
2024-04-14 13:24:23 -05:00
Rob Browning
0b259e98f8 r6rs-unicode.test: add emacs scheme mode marker
* test-suite/tests/r6rs-unicode.test add emacs scheme mode marker.
2024-04-14 13:24:23 -05:00
Denis 'GNUtoo' Carikli
bc2c612b89 SRFI-19: Add support for ISO 8601 zones with a colon.
* module/srfi/srfi-19.scm (zone-reader): handle a colon in the zone.

* test-suite/tests/srfi-19.test (SRFI date/time library test): Add test.

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>

[rlb@defaultvalue.org: adjust commit message; add NEWS]
2024-04-13 14:35:29 -05:00
Rob Browning
e6587c14dd NEWS: move eval-string news out of hashing entry
cf. 0ffa802be2
2024-04-13 14:33:09 -05:00
Rob Browning
db7efa5d20 api-procedures.texi: remove make-binding, binding:name/boxed?/...
* doc/ref/api-procedures.texi: remove make-binding, binding:name,
binding:boxed?, binding:index, binding:start, and binding:end since they
no longer exist.

cf. 1a2711a848
2024-04-05 17:58:20 -05:00
Rob Browning
0ffa802be2 eval-string.test: check source properties
* test-suite/tests/eval-string.test: add properties test.

cf. 025bb024ae
2024-04-05 17:51:48 -05:00
Nikita Domnitskii
025bb024ae eval-string: set port column to column, not line
* module/ice-9/eval-string.scm: set column to column, not line.
2024-04-05 17:51:33 -05:00
Andy Wingo
48548df91e Fix effects analysis: field writes clobber object reads
* module/language/cps/effects-analysis.scm (compute-clobber-map):
Previously a whole-object read would not be clobbered by a specific
field write.  This crops up for the &read introduced at the site of
`cons` for the synthetic car and cdr definitions.  This error was there
before but didn't cause bugs before 3.0.10 because cons got eagerly
lowered to separate allocation and initialization instructions.
2024-03-20 11:50:53 +01:00
Andy Wingo
b012c80875 Add test: writes to specific fields clobber reads of whole objects
* test-suite/tests/compiler.test ("cse auxiliary definitions"): New
test.
2024-03-20 11:50:53 +01:00
Daniel Llorens
54c4753dd3 Add missing branch in scm_is_less_than()
Fixes https://debbugs.gnu.org/69725.

* libguile/numbers.c (scm_is_less_than): Add branch for (< fraction real).
* test-suite/tests/numbers.test (<): New test.
2024-03-19 16:03:09 +01:00
Andy Wingo
2c645571b3 Fix inlinable-exports serialization for kwargs
* module/language/tree-il/inlinable-exports.scm (inlinable-exp): Call
assq-ref in the right order.  Embarrassing!
* module/language/tree-il/peval.scm (peval): Print the symbols so that
we can diagnose later failures.
2024-03-18 16:40:32 +01:00
Andy Wingo
e15617dc0e Expose read-c-struct, write-c-struct syntax
* module/system/foreign.scm (read-c-struct): Rename from read-fields.
Export.
(write-c-struct): Rename from write-fields.  Export.
(%write-c-struct, %read-c-struct): Add % prefix to these private
bindings.
2024-03-17 21:40:58 +01:00
Andy Wingo
d7ae468c17 Rework read-fields, write-fields to not return offset
* module/system/foreign.scm (read-fields, write-fields): Don't return
the final offset, as the offset after the final field is not necessarily
the end of the struct, because of padding.
2024-03-17 21:40:58 +01:00
Andy Wingo
7fef214f6e Remove vestigial code from srfi-9
* module/srfi/srfi-9.scm (%define-record-type): No need to define
record-layout.
2024-03-17 21:40:58 +01:00
Andy Wingo
88e0933450 Rework make-c-struct, parse-c-struct
* module/system/foreign.scm (bytevector-complex-single-native-ref)
(bytevector-complex-single-native-set!)
(bytevector-complex-double-native-ref)
(bytevector-complex-double-native-set!): Be more static in our
definitions.
(compile-time-eval):
(switch/compile-time-keys): New helpers.
(align): Make available at compile-time.
(read-field, read-fields, write-field, write-fields): New helpers.  More
efficient than the alist.
(write-c-struct, read-c-struct): Rework in terms of new helpers.
(parse-c-struct): Just use sizeof to get the size.
2024-03-17 21:40:58 +01:00
Andy Wingo
2b58dea2d2 (scheme foreign): API is less configuration-dependent
* libguile/foreign.h:
* libguile/foreign.c: Always define complex-float and complex-double.
Fall back to alignof float / 2*sizeof float if no complex numbers.  (But
with C99 surely it exists everywhere.)
* module/system/foreign.scm (*writers*, *readers*): Always include
complex-float and complex-double readers and writers.
* test-suite/tests/foreign.test: Always run the complex tests.
2024-03-17 21:40:58 +01:00
Andy Wingo
137b0e85b9 (system base target) doesn't load (system foreign)
* module/system/base/target.scm (%native-word-size): Use
most-positive-fixnum instead of importing (system foreign).
2024-03-17 21:40:58 +01:00
Arne Babenhauserheide
5bbc2d41d9 guile-test: define as non-declarative
* test-suite/guile-test (define-module): add #:declarative? #f because
  it uses load
2024-03-14 22:08:46 +01:00
Andy Wingo
17e8d7530f peval: Indenting. NFC.
* module/language/tree-il/peval.scm (peval): Reindent.
2024-03-13 20:28:43 +01:00
Andy Wingo
f95bf6921e peval: Enable inlining for functions with kwargs
* module/language/tree-il/peval.scm (peval): Handle all lambda inlining
the same, and extend with support for multiple clauses and keyword
arguments.
* test-suite/tests/peval.test ("case-lambda"): Enable kwarg inlining.
2024-03-13 20:19:59 +01:00
Andy Wingo
c758c99b5e New optimization: demux-lambda
Can help reduce case-lambda* / lambda* at Tree-IL optimization-time.

* module/language/tree-il/demux-lambda.scm: New file.
* am/bootstrap.am (SOURCES): Add new file.
* module/language/tree-il/optimize.scm (make-optimizer):
* module/system/base/optimize.scm (available-optimizations): Enable
demux-lambda at level 2.
2024-03-13 13:11:14 +01:00
Tomas Volf
e1690f3fd2
Add copy-on-write support to scm_copy_file.
On modern file-systems (BTRFS, ZFS) it is possible to copy a file using
copy-on-write method.  For large files it has the advantage of being
much faster and saving disk space (since identical extents are not
duplicated).  This feature is stable and for example coreutils' `cp'
does use it automatically (see --reflink).

This commit adds support for this feature into our copy-file procedure.
Same as `cp', it defaults to 'auto, meaning the copy-on-write is
attempted, and in case of failure the regular copy is performed.

No tests are provided, because the behavior depends on the system,
underlying file-system and its configuration.  That makes it challenging
to write a test for it.  Manual testing was performed instead:

    $ btrfs filesystem du /tmp/cow*
         Total   Exclusive  Set shared  Filename
      36.00KiB    36.00KiB       0.00B  /tmp/cow

    $ cat cow-test.scm
    (copy-file "/tmp/cow" "/tmp/cow-unspecified")
    (copy-file "/tmp/cow" "/tmp/cow-always" #:copy-on-write 'always)
    (copy-file "/tmp/cow" "/tmp/cow-auto" #:copy-on-write 'auto)
    (copy-file "/tmp/cow" "/tmp/cow-never" #:copy-on-write 'never)
    (copy-file "/tmp/cow" "/dev/shm/cow-unspecified")
    (copy-file "/tmp/cow" "/dev/shm/cow-auto" #:copy-on-write 'auto)
    (copy-file "/tmp/cow" "/dev/shm/cow-never" #:copy-on-write 'never)
    $ ./meta/guile -s cow-test.scm

    $ btrfs filesystem du /tmp/cow*
         Total   Exclusive  Set shared  Filename
      36.00KiB       0.00B    36.00KiB  /tmp/cow
      36.00KiB       0.00B    36.00KiB  /tmp/cow-always
      36.00KiB       0.00B    36.00KiB  /tmp/cow-auto
      36.00KiB    36.00KiB       0.00B  /tmp/cow-never
      36.00KiB       0.00B    36.00KiB  /tmp/cow-unspecified

    $ sha1sum /tmp/cow* /dev/shm/cow*
    4c665f87b5dc2e7d26279c4b48968d085e1ace32  /tmp/cow
    4c665f87b5dc2e7d26279c4b48968d085e1ace32  /tmp/cow-always
    4c665f87b5dc2e7d26279c4b48968d085e1ace32  /tmp/cow-auto
    4c665f87b5dc2e7d26279c4b48968d085e1ace32  /tmp/cow-never
    4c665f87b5dc2e7d26279c4b48968d085e1ace32  /tmp/cow-unspecified
    4c665f87b5dc2e7d26279c4b48968d085e1ace32  /dev/shm/cow-auto
    4c665f87b5dc2e7d26279c4b48968d085e1ace32  /dev/shm/cow-never
    4c665f87b5dc2e7d26279c4b48968d085e1ace32  /dev/shm/cow-unspecified

This commit also adds to new failure modes for (copy-file).

Failure to copy-on-write when 'always was passed in:

    scheme@(guile-user)> (copy-file "/tmp/cow" "/dev/shm/cow" #:copy-on-write 'always)
    ice-9/boot-9.scm:1676:22: In procedure raise-exception:
    In procedure copy-file: copy-on-write failed: Invalid cross-device link

Passing in invalid value for the #:copy-on-write keyword argument:

    scheme@(guile-user)> (copy-file "/tmp/cow" "/dev/shm/cow" #:copy-on-write 'nevr)
    ice-9/boot-9.scm:1676:22: In procedure raise-exception:
    In procedure copy-file: invalid value for #:copy-on-write: nevr

* NEWS: Add note for copy-file supporting copy-on-write.
* configure.ac: Check for linux/fs.h.
* doc/ref/posix.texi (File System)[copy-file]: Document the new
signature.
* libguile/filesys.c (clone_file): New function cloning a file using
FICLONE, if supported.
(k_copy_on_write): New keyword.
(sym_always, sym_auto, sym_never): New symbols.
(scm_copy_file2): Renamed from scm_copy_file.  New #:copy-on-write
keyword argument.  Attempt copy-on-write copy by default.
(scm_copy_file): Call scm_copy_file2.
* libguile/filesys.h: Add scm_copy_file2 as SCM_INTERNAL.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-03-12 14:04:41 +01:00