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

21380 commits

Author SHA1 Message Date
Michael Gran
2a7c9292bf Other test fixes 2025-03-30 21:17:40 -07:00
Michael Gran
2b5528847d MinGW: don't hand on unsupported popen tests 2025-03-30 20:54:06 -07:00
Michael Gran
59f3e1a881 MINGW: fix tmpnam giving filenames in the root directory
Window's tmpnam expects that you will prepend it with the temporary
directory.  Using _tempnam gives a path that is already prepended
with a temporary directory.

* NEWS: updated
* libguile/posix.c [_WIN32](scm_tmpnam): use _tempnam to create
    a temporary filename
* test-suite/tests/posix.test ("tmpnam"): new test
2025-03-30 20:15:21 -07:00
Michael Gran
12861e2bc2 Skip tests that require alarm or SIGALRM when not supported
* test-suite/tests/sandbox.test ("time limit"): skip if unsupported
* test-suite/tests/time.test ("gmtime"): skip if unsupported
2025-03-30 20:12:17 -07:00
Michael Gran
d512ec0657 Skip tests that require STATPROF when not supported
* test-suite/tests/statprof.test (when-implemented): throw unresolved
    when SIGPROF unavailable
2025-03-30 20:11:47 -07:00
Michael Gran
f187c46bd9 Skip tests that require SIGPIPE when not supported
On MINGW, and probably native Windows, closing a pipe does not
send SIGPIPE to a child process, so tests that need SIGPIPE to
close the child process are skipped.

* test-suite/tests/popen.test
  ("no duplicate", "open-process"): skip if SIGPIPE unsupported
* test-suite/tests/ports.test ("pipe: write"): modify to use and
   awk script that terminates without SIGPIPE
* test-suite/tests/posix.test
  ("wc with stdin and stdout redirects"): skip if SIGPIPE unsupported
  ("awk with stdin and stdout redirects"): new test that doesn't require SIGPIPE
2025-03-30 20:11:27 -07:00
Michael Gran
83cf9fa5c4 Sort goops class precedence tests to have a more reproducible check-guile.log
The GOOPS class precedence tests had been running in random order. This
sorts the tests before execution.

* test-suite/tests/goops.test ("class-precedence-list"): sort tests
2025-03-30 20:02:35 -07:00
Michael Gran
196f6fca44 popen.test: add shell on mingw 2025-03-30 20:01:25 -07:00
Michael Gran
76efca9929 Bad cherry-picks 2025-03-30 19:49:42 -07:00
Michael Gran
e371906dac Fix scm_to_mpz
Another change of long to intptr_t in numbers.c

* libguile/numbers.c (scm_to_mpz): long to intptr_t fix
2025-03-30 19:05:51 -07:00
Michael Gran
dee2ac91df Special case the CPUTF-8 encoding in scm_to_stringn scm_from_stringn 2025-03-30 18:51:30 -07:00
Michael Gran
1d1fde4ba1 Prefer LTLIBGNU to gnulib_library in Makefile.am 2025-03-30 18:51:27 -07:00
Michael Gran
decd4d25b9 explicitly add the gnulib library in LD_ADD 2025-03-30 18:51:20 -07:00
Michael Gran
08e1876d71 Add compiled guile-tools program
For systems that do not have a posix shell.

* configure.ac (GUILE_TOOLS_EXE): new conditional
* libguile/Makefile.am (guile-tools)[GUILE_TOOLS_EXE]: new binary target
* libguile/guile-tools.c: new file
* meta/Makefile.am (guile.scm): new data
  [!GUILE_TOOLS_EXE](install-exec-hook): don't alias guile-tools to guild
  (CLEANFILES): add guild.exe
2025-03-30 18:50:51 -07:00
Michael Gran
9ae3069437 In posix test, skip AT_SYMLINK_NOFOLLOW test if symlinks unsupported
* test-suite/tests/posix.test ("AT_SYMLINK_NOFOLLOW"): skip if unsupported
2025-03-30 18:40:55 -07:00
Michael Gran
7aa3b482fb In posix test, skip ttyname test if not supported
* test-suite/tests/posix.test ("ttyname"): skip if unsupported
2025-03-30 18:40:37 -07:00
Michael Gran
e33dd7bfd8 In i18n test, modify locale testing to focus on UTF-8
fr_FR was mostly being tested as an 8-bit locale.  This changes
the tests to focus on fr_FR.utf8.  But it adds a section for fr_FR 8-bit
currency.  Divergence in vendor-supplied locales often occurs
in currency.

MINGW, which only handles 8-bit locales when using MSVCRT, was being tested
as if its 8-bit CP1252 locale was UTF-8.  While the tests were included
as better than nothing, it is technically incorrect. These tests are
no longer run. Soon, Guile's MINGW build will link to UCRT, and it will
have UTF-8 locales.

The responses for some tests were modified to allow reasonable responses
from Cygwin/MSYS/MinGW locales and to skip on unreasonable responses.

* test-suite/tests/i18n.test (mingw?): rename to old-ms?
  (old-ms?): new helper
  (%french-locale-name): use platform's default 8-bit locale
  (%french-utf8-locale-name, %turkish-utf8-locale-name, %german-utf8-locale-name)
  (%greek-utf8-locale-name): don't use 8-bit locales on MINGW
  ("text collation (French)"): use utf-8
  ("locale-digit-grouping (French)"): use utf-8
  (french-number-string=?): modify to make symmetric and to handle
     U+2024 as a valid spacer
  ("French: integer", "negative integer" "fraction", "fraction, 1 digit"):
  ("French"): rename to "French UTF-8"
  ("French UTF-8: 12345.678", "Fraction"): use utf-8, allow U+2024
  ("French UTF-8: positive inexact zero"): expect euro sign
  ("French 8-bit"): new currency tests
2025-03-30 18:39:31 -07:00
Michael Gran
1e0cf93a0a handle different errors messages for unbound variables 2025-03-30 18:33:23 -07:00
Michael Gran
993ac2fd74 Modify http header parser to use new read-line "\r\n" handling
* module/web/http.scm (read-header-line): modify for new read-line
2025-03-30 18:32:02 -07:00
Michael Gran
9bb8793a6c Allow read-line to handle "\r\n" as a line terminator
Adds CRLF as a line ending. %read-line will return
these. In the case of CRLF, %read-line will return a string "\r\n"
as the line ending.

* libguile/rdelim.c (scm_read_line): handle CRLF line delimiter
* module/ice-9/suspendable-ports.scm (%read-line): modify to handle CRLF
    line delimiter
  (read-line): use modified %read-line
* test-suite/tests/rdelim.test ("two lines, split, CRLF"): new test
   ("two long lines, split, CRLF"): new test
* doc/ref/api-io.texi: update read-line documentation
2025-03-30 18:31:36 -07:00
Michael Gran
8d388c97e7 Add option to disable time limit in eval-in-sandbox
On systems without SIGALRM, the other features of eval-in-sandbox
may still be useful.  This adds the option to set #:time-limit to
#f to indicate no timeout.

* NEWS: updated
* module/ice-9/sandbox.scm (eval-in-sandbox): allow #:time-limit key
    to be #f to disable time limit
* doc/ref/api-evaluation.texi (eval-in-sandbox): update documentation
* test-suite/tests/sandbox.scm ("eval-in-sandbox"): throw unsupported
    if no SIGALARM
  ("eval-in-sandbox no timeout"): new tests for eval-in-sandbox
2025-03-30 18:30:09 -07:00
Michael Gran
68af1c93e7 In i18n test, add more reasonable test passes for french currency
* test-suite/tests/i18n.test ("french utf-8: number" "fraction"):
  ("positive inexact zero", "one cent", "very little money"): more
    success and failure conditions
2025-03-30 18:27:47 -07:00
Michael Gran
c8e0454692 WIN32: new internal define %UCRT when compiled with UCRT C library
This variable will help indicate if, on Win32, the C library is
closer to C99 capable.

* libguile/posix.c (scm_init_posix): new define %UCRT
* test-suite/tests/i18n.test (old-ms?): use new define allow UTF-8
    tests on MINGW
2025-03-30 18:25:41 -07:00
Michael Gran
0f748b32aa Avoid writing nulls in check-guile.log
Null characters in check-guile.log confuse grep.

* test-suite/tests/strings.test ("string-utf8-length"): add test names
* test-suite/tests/web-uri.test ("encode"): add test names
2025-03-30 18:20:36 -07:00
Michael Gran
153be2e6a5 In web-server test, skip server test if no threads provided
* test-suite/tests/web-server.test ("server is listening"): skip if no threads
2025-03-30 18:19:36 -07:00
Michael Gran
ba4939e31f MINGW: in ports test, use binary mode for line counter tests
The line counter tests presumes newline-only line endings.  Use binary
mode to avoid CRLF endings.

* test-suite/tests/ports.test ("line endings"): write test file in binary
    mode
2025-03-30 18:19:02 -07:00
Michael Gran
1838ef8ef6 In ports.test, convert some pass-if tests to pass-if-equal
* test-suite/tests/ports.test ("line counter"): convert several tests to
    use pass-if-equal
2025-03-30 18:18:20 -07:00
Michael Gran
50371bc6ed Replace SCM_INLINE_GC_KIND_* enums with libgc's GC_I_* defines
Guile has an enum scm_inline_gc_kind used to replace GC constants
that were private.  Those defines were made public in 2015, so it
is should be safe to use them now.

Replace SCM_INLINE_GC_KIND_POINTERLESS with GC_I_PTRFREE.
Replace SCM_INLINE_GC_KIND_NORMAL with GC_I_NORMAL.

* libguile/gc-inline.h (scm_inline_gc_kind): remove type
  (scm_inline_gc_alloc): kind argument is now int
  (scm_inline_gc_malloc_pointerless): use GC_I_PTRFREE
  (scm_inline_gc_malloc): use GC_I_NORMAL
* libguile/intrinsics.c (allocate_words_with_freelist): use GC_I_NORMAL
  (allocate_pointerless_words): use GC_I_PTRFREE
2025-03-30 18:13:03 -07:00
Michael Gran
c214a15e47 libgc's GC_REDIRECT_TO_LOCAL is obsolete.
Removed in v7.2g in 2016.

* libguile/bdw-gc.h (GC_REDIRECT_TO_LOCAL): remove
2025-03-30 18:12:52 -07:00
Michael Gran
5d4373248f allow webserver to run when SIGPIPE not defined
* module/web/server/http.scm (http-open): only set SIGPIPE sigaction when
    SIGPIPE is defined.
2025-03-30 18:12:32 -07:00
Michael Gran
69e1f96a93 Win32: don't setjmp to Guile frames
For 64-bit Windows, there was an existing special setjmp handling
to avoid jumping into Guile frames.  Expand this handling to 32-bit
Windows as well.

*
2025-03-30 18:11:03 -07:00
Michael Gran
4cac137b01 Lightening: _WIN32 updates from upstream lightning
Pulls in a few updates for WIN32 from upstream GNU lightning.
Based on patches from GNU Lightning.
2025-03-30 18:10:58 -07:00
Michael Gran
0b70769247 Win32: add replacement for mkdtemp
* libguile/posix-w32.c (mkdtemp): new win32 replacement procedure
* libguile/posix-w32.h: add declaration for mkdtemp
  (HAVE_MKDTEMP): new define
* libguile/filesys.c: include posix-w32.h
2025-03-30 18:10:48 -07:00
Michael Gran
c08debbd39 In lightening, don't use visibility hidden on DLL using systems
* libguile/lightening/lightening.h
  [!_WIN32 && !__CYGWIN__] (JIT_API): don't define to visiblity hidden
2025-03-30 18:10:35 -07:00
Michael Gran
faa6b8cf82 WIN32: use GCC builtin ffs to replace missing function
FFS is missing on MINGW.

* libguile/lightening/lightening/x86-cpu.c
  [__GNUC__ && _WIN32](USE_BUILTIN_FFS): new macro
  (__ffs): wrapper function
  (ffsw): use __ffs;
2025-03-30 18:10:30 -07:00
Michael Gran
2177f3f6c5 filesys.test: fixes for copy-file test on MinGW
In the copy-file test, is uses call-with-input-file and get-string-all
to retrieve file contents. Since the file is not opened in binary mode,
CRLF line ending may be added when writing and then reading the string
back from the filesystem.

* test-suite/tests/filesys.test (normalize-newlines): new helper function
  ("copy file: copy-file dest content"): pass even if CRLF line endings
  are added
  ("copy file: read only dest"): handle posibility of geteuid not
  being defined
2025-03-30 18:10:24 -07:00
Michael Gran
6b4d829d40 in filesys test, add helper function for deleting files and symlinks
On Windows, a file needs to have write permission to be deleted.
This adds a helper to handle that case, but, is used generally.

* test-suite/tests/filesys.test (%delete-file): new helper function
  Replace every delete-file call with %delete-file.
2025-03-30 18:10:16 -07:00
Michael Gran
cc1c79ae34 In test suite, ensure file ports are closed before deletion
On Windows, open file ports cannot be deleted.

* test-suite/tests/ports.test ("relative canonicalization with common prefixes"):
    close port before deletion
* test-suite/tests/posix.test (utime-unless-unsupported): take a port arg
  ("file port"): use new utime-unless-unsupported. Close port before deletion.
* test-suite/tests/filesys.test ("port representing a regular file"):
    throw unsupported before creating file
2025-03-30 18:10:07 -07:00
Michael Gran
1174e1eb9d Allows modification of shell used by open-pipe
open-pipe executes a shell command in a subprocess. This commit adds
the ability to modify the shell used for executing commands.
The default "/bin/sh -c" can be inspected and modified by the
new procedure-with-setter 'pipe-shell-command-transformer'.

This useful in MinGW since its "sh" is not in "/bin".

* module/ice-9/popen.scm (%command-transformer): new procedure
  (pipe-shell-command-transformer): new procedure-with-setter
  (open-pipe): use new command transformer
* doc/ref/posix.texi (open-pipe): mention pipe-shell-command-transformer
  (pipe-shell-command-transformer): document new procedure
* test-suite/tests/popen.test ("pipe-shell-command-transformer"): new tests
  Also, modify open-pipe shell for MinGW
* NEWS: updated
* test-suite/tests/ports.test (mingw?): new variable
    Also, modify open-pipe shell for MinGW
2025-03-30 18:09:37 -07:00
Michael Gran
9d625278f7 fixes for chmodat test
* test-suite/tests/filesys.test (chmodat): some chmodat tests don't test if it
   exists. Mark unwritable file writable before deleting.
  ("port representing a regular file"): reorder to avoid unclosed
     port on exception.
2025-03-30 18:02:21 -07:00
Michael Gran
afda13e4ac For MinGW, use native signal func in sigaction
For MinGW, there is a native signal function in UCRT. It handles
a limited set of signals.

* libguile/scmsigs.c (scm_sigaction_for_thread)[__MINGW32__]: removed
  (scm_sigaction_for_thread)[!__MINGW32__]: use for MinGW as well.
    For signals outside UCRT's native signal set, always return SIG_IGN.
2025-03-30 18:02:02 -07:00
Jan (janneke) Nieuwenhuizen
70f434111b guix: Add guile-patched, guile-mingw.
Build it:

    GUIX_PACKAGE_PATH=guix guix build --target=x86_64-w64-mingw32 guile-mingw

Run it:

    WINEPATH=$(guix shell wine64 -- winepath -w                                     \
        $(echo $(guix gc -R                                                         \
                      $(GUIX_PACKAGE_PATH=guix guix build                           \
                                         --target=x86_64-w64-mingw32 guile-mingw))) \
                   | sed 's,$,/bin,g' | tr '\n' ';')                                \
            guix shell wine64 -- wine                                               \
            $(GUIX_PACKAGE_PATH=guix guix build --target=x86_64-w64-mingw32         \
                               guile-mingw)/bin/guile.exe                           \
            -c '(format #t "Hello  ~a world!\n" %host-type)'

* guix/guile-patched.scm,
guix/mingw.scm: New files.
2025-03-30 18:01:15 -07:00
Rutger van Beusekom
12ad1a9ad2 DRAFT Add partial `scm_fcntl' support for MinGW.
* libguile/filesys.c (_mingw_debug_p)[__MINGW32__: New function.
(scm_fcntl)[__MINGW32__]: Add support creating non-blocking sockets.
2025-03-30 17:59:44 -07:00
Jan (janneke) Nieuwenhuizen
2b86a3b1cb Add `scm_sigaction_for_thread' stub for MinGW.
* libguile/scmsigs.c (scm_sigaction_for_thread)[__MINGW32__]: New stub.
(SIGHUP, SIGPIPE)[__MINGW32__]: New defines.
2025-03-30 17:59:38 -07:00
Jan (janneke) Nieuwenhuizen
eaa38d6381 Install 'mingw_take_signal' on MinGW.
After installing a signal handler, these are handled

    * C-c
    * kill -SIGINT <guile.exe-pid> (the wine process) works

these result in a direct terminate (or kill even?)

    - kill <guile.exe-pid>
    - wine cmd /c guile -c '(kill <guile-exe.pid> SIGINT)'
    - wine cmd /c guile -c '(kill <guile-exe.pid> SIGTERM)'

* libguile/scmsigs.c (mingw_take_signal)[__MINGW32__]: New function.
install_mingw_take_signal)[__MINGW32__]: New function.
(scm_init_scmsigs)[__MINGW32__]: Use it.
2025-03-30 17:59:22 -07:00
Jan (janneke) Nieuwenhuizen
b55397ea5d Make `read-bytes' suspendable for socket reads on MinGW.
On MinGW, port-read will block on sockets if no data is available.
Avoid blocking by using select first.

* module/ice-9/suspendable-ports.scm (read-bytes): For socket ports,
guard port-read with select.
2025-03-30 17:59:11 -07:00
Jan (janneke) Nieuwenhuizen
a043eaf349 Support for x86_64-w64-mingw32.
On x86-64-MinGW the size of long is 4.  As long is used for
SCM_FIXNUM_BIT, that would mean incompatible .go files, and waste of
cell space.  So we would like to use long long, but the GMP interface
uses long.

To get around this, the x86-64-MinGW port now requires the use of
mini-GMP.  Mini-GMP has been changed to use intptr_t and uintptr_t.

Likewise, "integers.{h,c}" and "numbers.{h,c}" now use intptr_t instead
of scm_t_inum or long, and uintptr_t instead of unsigned long.

* configure.ac: When x86_64-w64-mingw32, require mini-GMP.
* libguile/mini-gmp.h: Use intptr_t instead of long, uintptr_t instead
of unsigned long throughout.
* libguile/mini-gmp.c: Likewise.
* libguile/scm.h (SCM_INTPTR_T_BIT): New define.
* libguile/numbers.h (SCM_FIXNUM_BIT): Use it.
* libguile/numbers.c (L1, UL1): New macros.  Use them thoughout instead
of 1L, 1UL.
(verify): Use SCM_INTPTR_T_BIT.
(verify): Use SCM_INTPTR_T_MAX and SCM_INTPTR_T_MIN.
(scm_from_inum): Remove macro.
Use intptr_t and uintptr_t instead of scm_t_inum or long, and unsigned
long.
* libguile/numbers.h (scm_from_intptr, scm_from_uintptr, scm_to_intptr,
scm_to_uintptr): New defines.
* libguile/integers.h: Use intptr_t and uintptr_t instead of scm_t_inum
and unsigned long.
* libguile/integers.c (L1) : New macro.  Use it thoughout instead of 1L.
Use intptr_t and uintptr_t instead of long and unsigned long.
(long_magnitude): Rename to...
(intptr_t_magnitude): ...this.  Use intptr_t, uintptr_t.
(negative_long): Rename to...
(negative_t_intptr): ...this.  Use uintptr_t, INTPTR_MIN.
(inum_magnitude): Use intptr_t.
(ulong_to_bignum): Rename to...
(uintptr_t_to_bignum): ...this.  Use uintptr_t.
(long_to_bignum): Rename to...
(intptr_t_to_bignum): ...this.  Use intptr_t.
(long_to_scm): Rename to...
(intptr_t_to_scm): ...this.  Use intptr_to_bignum.
(ulong_to_scm): Rename to...
(uintptr_t_to_scm): ...this.  Use uintptr_to_bignum.
(long_sign): Rename to..
(intptr_t_sign): ...this.  Use SCM_SIZEOF_INTPTR_T.
(bignum_cmp_long): Rename to...
(bignum_cmp_intptr_t): ...this.  Use uintptr_t.
* libguile/array-map.c (array_compare): Use uintptr_t instead of
unsigned long and intptr_t instead of long.
* libguile/arrays.c (make-shared-array): Use ssize_t instead of long.
* libguile/bytevectors.c (is_signed_int32, is_unsigned_int32)
[MINGW32 && __x86_64__]: Use ULL.
(twos_complement): Use uintptr_t instead of unsigned long.
* libguile/hash.c (JENKINS_LOOKUP3_HASHWORD2): Likewise.
(narrow_string_hash, wide_string_hash, scm_i_string_hash,
scm_i_locale_string_hash, scm_i_latin1_string_hash,
scm_i_utf8_string_hash, scm_i_struct_hash, scm_raw_ihashq,
scm_raw_ihash): Use and return uintptr_t instead of unsigned long.
(scm_hashv, scm_hash): Use SCM_UINTPTR_T_MAX.
* libguile/hash.h (scm_i_locale_string_hash, scm_i_latin1_string_hash,
scm_i_utf8_string_hash): update prototypes.
* libguile/scmsigs.c (sigaction): Use intptr_t instead of long.
* libguile/strings.c (scm_i_make_symbol, (scm_i_c_make_symbol): Use
uintptr_t instead of unsigned long.
* libguile/strings.h (scm_i_make_symbol, (scm_i_c_make_symbol): Update
declacations.
* libguile/srfi-60.c: Use scm_to_uintptr, scm_from_intptr and variants
throughout.
* libguile/symbols.c (symbol-hash): Use scm_from_uintptr.

Co-authored-by: Mike Gran <spk121@yahoo.com>
Co-authored-by: Andy Wingo <wingo@pobox.com>
2025-03-30 17:57:12 -07:00
Jan (janneke) Nieuwenhuizen
5caf66a51a Add 'set-port-binary/text-mode!' procedure for MinGW.
* libguile/ports.c (scm_init_ports)[O_BINARY]: Define 'O_BINARY'.
[O_TEXT]: Define 'O_TEXT'.
(scm_c_set_port_binary_text_mode_x): New function.
* libguile/ports.h (scm_set_binary_text_mode_x): Declare it.
* module/ice-9/ports.scm (ice-9): Export it as
'set-port-binary/text-mode!'.
* doc/ref/api-io.texi (File Ports): Document it.
2025-03-30 16:38:05 -07:00
Jan (janneke) Nieuwenhuizen
a3018d6d0e mingw: canonicalize-path: Also canonicalize drive letter and '/'.
* libguile/posix-w32.c (canonicalize_device_name,
slashify_file_name): New static functions.
(canonicalize_file_name_mingw): Use them in new function.
* libguile/posix-w32.h (canonicalize_file_name_mingw): Declare it.
(canonicalize_file_name): New define.
* libguile/filesys.c[__MINGW32__]: Include posix-w32.h to use it.
* libguile/fports.c[__MINGW32__]: Likewise.
2025-03-30 16:38:00 -07:00
Jan (janneke) Nieuwenhuizen
79ea1082d0 Link fix for MinGW.
This fixes

    libguile/threads.c:1502: undefined reference to `select_used_without_including_sys_select_h'

* libguile/threads.c: Include sys/select.h.
2025-03-30 16:34:17 -07:00