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

9583 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
Michael Gran
af96820e07 Windows 11: for fport input from the console, ignore terminal returns
There is an apparent bug in Windows 11 (not Windows 10) where,
when reading from an fd backed by the Console, a single
return character will always be available.

* libguile/posix-w32.c (console_has_return_keyevent_w32): new procedure
* libguile/posix-w32.h: declare console_has_return_keyevent_w32
* libguile/fports.c [__MINGW32__](fport_input_waiting): ignore return keyevent
2025-03-23 10:26:40 -07:00
Michael Gran
adbf2156ab Remove posix-w32 subsitutes that require access to process handles
Now that Guile uses the posix_spawn gnulib module, several of Guile's
custom w32 functions substitutes no longer work. Some functions
relied on populating and maintaining an internal PID-to-Handle database,
which is no longer possible.

kill, getpriority, setpriority, getaffinity and setaffinity
are removed. waitpid is simplified and does not handle ENOHANG.

* NEWS: updated
* libguile/posix-w32.c (struct proc_record, find_proc, proc_handle): removed
  (record_proc, delete_proc, prepare_child_handle, compenv): removed
  (prepare_envblk, lookup_cmd, prepare_cmdline, start_child): removed
  (kill, getpriority, setpriority, sched_getaffinity): removed
  (sched_setaffinity): removed
  (waitpid): modified to just use _cwait. ENOHANG emlation removed.
* libguile/posix-w32.h (CPU_ZERO, CPU_ISSET, CPU_SET, CPU_SETSIZE): removed
  (cpu_set_t, PRIO_PROCESS, PRIO_PGRP, PRIO_USER): removed
  (HAVE_START_CHILD, HAVE_KILL, HAVE_GETPRIORITY): removed
  (HAVE_SETPRIORITY, HAVE_SCHED_GETAFFINITY, HAVE_SCHED_SETAFFINITY): removed
  declarations for waitpid, start_child, kill, getpriority: removed
  declarations for setpriority, sched_getaffinity, sched_set_affinity: Removed
2025-03-22 21:57:59 -07:00
Michael Gran
2e51d3fa26 In piped_process, replace dprintf with more portable functions
dprint is missing on many non-glic platforms

* libguile/posix.c (piped_process): replace dprintf with sprintf+write
2025-03-22 21:33:33 -07:00
Michael Gran
9c86c5936e Allow piped-process and system* to exist when fork is undefined
piped-process only uses fork to match legacy behavior, but on systems
that never had fork, there is no need to match that behavior.
piped-process and system* can be provided without fork.

* libguile/posix.c (piped_process): allow function definition without HAVE_FORK,
    but stub out internal dummy process with HAVE_FORK
  (restore_sigaction, scm_dynwind_sigaction, scm_system_star): don't
    require HAVE_FORK
  (scm_init_popen): don't require HAVE_FORK
  (scm_init_posix): don't require HAVE_FORK to add posix feature or
    register popen extension
2025-03-22 21:32:45 -07:00
Michael Gran
87402c849e MinGW32: cast arguments to execvp
MinGW32's MSVCRT library requires strict casting for exec family functions

* libguile/posix.c (scm_execl, scm_execlp, scm_execle) [__MINGW32__]: cast
  arguments
2025-03-22 21:02:42 -07:00
Michael Gran
0f2125e66f Add missing #include in syscalls.h
SCM_SYSCALL uses scm_async_tick.

* libguile/syscalls.h: include async.h
2025-03-22 14:17:41 -07:00
Michael Gran
0e20c0c8c6 Add replacement for missing getpagesize() on MINGW
* libguile/posix-w32.c (getpagesize_w32): new procedure
* libguile/posix-w32.h: declaration of getpagesize_w32
* libguile/loader.c [__MINGW32__](scm_bootstrap_loader): use new procedure
* libguile/vm.c [__MINGW32__](scm_i_vm_prepare_stack): use new procedure
2025-03-22 14:17:30 -07:00
Ludovic Courtès
462d3c85ed
Provide ‘scm_i_is_finalizer_thread’ when building ‘--without-threads’.
Fixes a regression in ‘--without-threads’ builds introduced in
b8031fc965.

* libguile/finalizers.c (scm_i_is_finalizer_thread) [!SCM_USE_PTHREAD_THREADS]:
New function.
2025-03-21 18:10:07 +01:00
Rob Browning
c6e0826667 libguile/Makefile.am: move date -d arg before format string
This fixes a problem on at least NetBSD.

* libguile/Makefile.am (libpath.h): move date -d argument before format
string.

Thanks to Thomas Klausner for reporting the problem and proposing the
fix.

Closes: 26121
2025-03-20 13:22:14 -05:00
Tomas Volf
4f39181b2f filesys.c: Use scm_sendfile to copy files
Use scm_sendfile instead of read-write loop.  This moves the work into
the kernel, improving performance.  This implements Ludovic's suggestion
from https://debbugs.gnu.org/68504

* libguile/filesys.c (scm_copy_file2): Use scm_sendfile.

[rlb@defaultvalue.org: add NEWS]
2025-03-19 21:25:40 -05:00
Rob Browning
11b027d7e2 piped_process: silence spurious -Wmaybe-uninitialized warnings
libguile/posix.c: initialize pipes to silence spurious warnings.
2025-03-18 14:34:49 -05:00
Michael Gran
4af6331a65 Fixes potential buffer overflow in getsockopt for timevals
struct timeval is a possible return value of getsockopt (e.g. SO_RCVTIMEO
and SO_SNDTIMEO), but it is not included in the scm_t_getsockopt_result
union, which may then be too small (and is on Debian amd64).
* libguile/socket.c: add struct timeval to scm_t_getsockopt union

[rlb@defaultvalue.org: adjust commit message; add NEWS]

Closes: 76907
2025-03-18 12:24:31 -05:00
Olivier Dion
7b7340b2d9
Warn about mutation of ‘environ’ when multi-threaded.
This is an amendment to 84bf840322.

The warning was only emitted for calling `environ', even if only reading
and no mutation occurred.

However, it is correct to read the environment in a multi-threaded
process.  It is however unsafe to mutate it.

The same logic also applies to `putenv'.

* libguile/posix.c
  (maybe_warn_about_environ_mutation): New private procedure ...
  (scm_environ): ... called here when mutating the environment ...
  (scm_putenv): ... and here.
* NEWS: Update.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2025-02-28 22:12:04 +01:00
Ludovic Courtès
b8031fc965
Exclude the finalizer thread from the ‘all-threads’ result.
Fixes <https://bugs.gnu.org/76343>.

Fixes a bug whereby “echo '(environ)' | guile” would wrongfully trigger
the multiple-thread warning.

* libguile/finalizers.c (finalizer_thread): New variable.
(finalization_thread_proc): Set it.
(scm_i_is_finalizer_thread): New function.
(run_finalization_thread): Clear FINALIZER_THREAD.
* libguile/finalizers.h (scm_i_is_finalizer_thread): New declaration.
* libguile/threads.c (scm_all_threads): Use it.
* NEWS: Update.

Reported-by: Simon Josefsson <simon@josefsson.org>
2025-02-28 22:12:03 +01:00
Hannes Müller
ff4d79074c
libguile/scm.h: Allow compilation with ‘-Werror=undef’.
* libguile/scm.h: BUILDING_LIBGUILE is not always defined. This is
signaled by -Werror=undef in code using libguile. This patch fixes
commit dc3a3a84f9
* NEWS: Update.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2025-02-28 22:12:03 +01:00
Andy Wingo
5d3f561d7d Merge remote-tracking branch 'lightening/main' 2025-01-29 16:52:29 +01:00
Rob Browning
48b1c4eff4 fport_print: handle ttyname ENODEV
In some situations, ttyname may return ENODEV even though isatty is
true.  From ttyname(3):

  A process that keeps a file descriptor that refers to a pts(4) device
  open when switching to another mount namespace that uses a different
  /dev/ptmx instance may still accidentally find that a device path of
  the same name for that file descriptor exists.  However, this device
  path refers to a different device and thus can't be used to access the
  device that the file descriptor refers to.  Calling ttyname() or
  ttyname_r() on the file descriptor in the new mount namespace will
  cause these functions to return NULL and set errno to ENODEV.

Observed in a Debian riscv64 porterbox schroot.

When ttyname fails with ENODEV, just include the file descriptor integer
value instead.  Call ttyname() directly to avoid having to catch the
ENODEV.

* libguile/fports.c (fport_print): fall back to the integer fd when
ttyname() fails with ENODEV.
2025-01-23 12:49:33 -06:00
Rob Browning
63756efbc5 Don't hold lock during scm_async_tick in readdir and ttyname
Only hold scm_i_misc_mutex while making the C calls.  This also avoids
the need for a dynamic-wind.  Add SCM_I_LOCKED_SYSCALL (similar to
SCM_SYSCALL) to handle the locking and EINTR loop.

libguile/filesys.c (scm_readdir): rely on SCM_I_LOCKED_SYSCALL to limit
locking.
libguile/filesys.c (scm_ttyname): rely on SCM_I_LOCKED_SYSCALL to limit
locking.
libguile/syscalls.h: add SCM_I_LOCKED_SYSCALL.
2025-01-22 19:24:07 -06:00
Rob Browning
35f13806af scm_i_utf8_string_hash: don't overrun when len is zero
When the length is zero, the previous code would include the byte after
the end of the string in the hash.  Fix that (the wide and narrow
hashers also guard against it via "case 0"), and don't bother mutating
length for the trailing bytes.

Since we already compute the char length, use that to detect all ASCII
strings and follow the same narrow string path that we do for latin-1.

libguile/hash.c (scm_i_utf8_string_hash): avoid overrun when len == 0.
2024-12-11 11:46:40 -06:00
Rob Browning
c45e1f57ec scm_i_utf8_string_hash: switch to u8_mbtouc
libguile/hash.c (scm_i_utf8_string_hash): Switch from u8_mbtouc_unsafe
to u8_mbtouc since the unsafe variant is now the same (see the info
pages).
2024-12-11 11:21:47 -06:00
Rob Browning
76afb429ee Eight byte align statically allocated stringbufs
Previously they were unaligned, unlike their parent strings, and so
could end up with the wrong pointer tag.  Observed on i686-linux-gnu,
where they ended up tagged as immediates (SCM_IMP()), causing failures
in TYP7 related checks.

* libguile/strings.h (SCM_IMMUTABLE_STRINGBUF): align resulting buffer
  via SCM_ALIGNED(8).
2024-11-29 12:24:57 -06: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
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
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
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
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