* libguile/srfi-14.c (char_ranges_insert, char_ranges_delete): New
helpers.
(scm_i_charset_set, scm_i_charset_set_range, scm_i_charset_unset): Use
the new helpers.
* libguile/r6rs-ports.c (grow_byte_buffer, shrink_byte_buffer): New
helpers.
* libguile/r6rs-ports.c (bytevector_output_port_buffer_grow):
(bytevector_output_port_procedure): Use new helpers.
* libguile/gc-malloc.c (do_realloc, do_calloc): Remove.
(scm_gc_malloc): Dispatch to scm_inline_gc_malloc.
(scm_gc_calloc): Dispatch to scm_gc_malloc.
(scm_gc_realloc): Mark for removal. The issue is that the realloc'd
object should have the same kind. We could add Whippet API but it would
be nice to not do that.
* libguile/jit.c (compile_allocate_words_immediate):
(compile_allocate_words_immediate_slow):
(compile_allocate_pointerless_words_immediate):
(compile_allocate_pointerless_words_immediate_slow): Update for new API.
* libguile/gc-malloc.c: Trim set of includes.
(do_gc_malloc_atomic): Remove.
(scm_gc_malloc_pointerless): Call scm_inline_gc_malloc_pointerless.
(scm_gc_strndup): Call scm_gc_malloc_pointerless.
* libguile/gc.h:
* libguile/gc.c (scm_gc_after_nonlocal_exit): Give it a scm_thread
argument, and cause GC with whippet API.
(scm_init_gc): Set alloc failure handler using Whippet API instead of
BDW.
(scm_oom_fn): Add heap argumnet.
* libguile/eval.c (eval):
* libguile/exceptions.c (scm_c_with_exception_handler):
* libguile/vm.c (scm_call_n): Adapt.
Headed towards a 4.0. The binary format will change slightly but
incompatibly (e.g. renumbering of intrinsics). Having a new GC is
enough of a change to warrant a minor version bump, and it's been 5
years so why not go major.
* GUILE-VERSION (GUILE_EFFECTIVE_VERSION): Bump to 4.0.
(GUILE_MICRO_VERSION, GUILE_MINOR_VERSION): Bump to 3.9.0.
(LIBGUILE_INTERFACE_CURRENT, LIBGUILE_INTERFACE_AGE): Reset.
* meta/guile-4.0.pc.in:
* meta/guile-4.0-uninstalled.pc.in: Rename from guile-3.0.
* .gitignore: Ignore pkg-config files with 4.0 effective version.
* README: Update slightly.
* doc/ref/api-evaluation.texi (Load Paths):
* doc/ref/api-options.texi (Build Config):
* doc/ref/guile-invoke.texi (Environment Variables):
* doc/ref/history.texi (A Timeline of Selected Guile Releases):
* doc/ref/libguile-parallel.texi (Parallel Installations):
* doc/ref/srfi-modules.texi (SRFI-0): Update references to stable
version in paths.
* module/system/vm/assembler.scm (*bytecode-minor-version*):
* libguile/loader.h (SCM_OBJCODE_MAJOR_VERSION):
(SCM_OBJCODE_MINIMUM_MINOR_VERSION):
(SCM_OBJCODE_MINOR_VERSION): Use the same major objcode version for now
but bump the minor to 99.
* meta/guile.m4 (GUILE_PKG, GUILE_PROGS): Check for Guile 4.0.
* module/ice-9/boot-9.scm (%cond-expand-features): Add new cond-expand
features.
* libguile/scm.h (scm_tc7_thread): Give threads their own tc7.
* libguile/threads.h (struct scm_thread): Add a tag, so that struct
thread can be a SCM directly. Add a struct gc_mutator* member.
(scm_thread_handle): New inline function.
(SCM_I_IS_THREAD, SCM_I_THREAD_DATA, SCM_VALIDATE_THREAD): Update to use
tc7 instead of SMOB tags.
* libguile/continuations.c (scm_i_with_continuation_barrier)
* libguile/finalizers.c (queue_finalizer_async)
* libguile/jit.c (compile_current_thread)
* libguile/threads.c (block_self, guilify_self_2)
(lock_mutex, unlock_mutex, timed_wait scm_current_thread)
(scm_all_threads)
* libguile/vm-engine.c (current-thread): Use scm_thread_handle instead
of thread->handle.
* libguile/evalext.c (scm_self_evaluating_p):
* libguile/goops.c (class_thread, scm_class_of, scm_sys_goops_early_init)
* libguile/print.c (iprin1)
* module/language/cps/compile-bytecode.scm (compile-function)
* module/oop/goops.scm (<thread>)
* module/system/base/types.scm (cell->object)
* module/system/base/types/internal.scm (heap-tags)
* module/system/vm/assembler.scm: (emit-thread?): Adapt to
scm_tc7_thread.
* libguile/gc-internal.h: Move init functions that take "struct
gc_stack_addr" here, so that internal Whippet uses don't cause Whippet
to be added to public headers.
* libguile/gc.c (scm_storage_prehistory): Take struct gc_stack_addr as
arg, and pass to gc_init. Return a mutator pointer.
* libguile/init.c (scm_i_init_guile): Pass mutator and stack base to GC
and thread init routines.
* libguile/threads.c (scm_trace_dynstack, scm_trace_thread)
(scm_trace_thread_mutator_roots): New infra for marking threads in terms
of Whippet API.
* libguile/threads.c (guilify_self_1): Since we don't use a separate GC
kind for threads any more, and thread marking is keyed off
gc_mutator_set_roots, we can avoid some of the gnarly synchronization.
(on_thread_exit): Arrange to gc_finish_for_thread.
(scm_i_init_thread_for_guile): Use gc_init_for_thread.
(init_main_thread, with_guile, scm_i_with_guile): Use Whippet API.
(scm_threads_prehistory): Take main-thread mutator and the stack base as
arguments.
* libguile/vm.c (scm_trace_vm): Rework in terms of Whippet API.
* libguile/whippet-embedder.h (gc_trace_mutator_roots): Arrange to trace
the current mutator's SCM thread object.
* libguile/trace.h: New file, to declare implementations of trace
routines.
* libguile/Makefile.am (noinst_HEADERS): Add trace.h.
* libguile/gc.c: Define an event listener that collects basic
statistics, runs C hooks, and arranges to run the Scheme hook if it is
nonempty.
(scm_gc_stats): Fetch statistics from the gathered event data.
(scm_gc_dump): Use scm_basic_stats_print.
(scm_storage_prehistory): Fix indentation.
(scm_init_gc_protect_object): Remove dead code.
(queue_after_gc_hook): Not really needed, as we have an after-GC C event
to run the C hooks. Scheme hook activation is inlined into the event
listener.
(start_gc_timer, accumulate_gc_timer): No need any more.
(scm_init_gc): Simplify hook registration.
* libguile/Makefile.am (WHIPPET_EMBEDDER_H): Define this variable
instead of using -include; otherwise we don't get the chance to set
_LARGEFILE64_SOURCE before including Whippet files.
(AM_CPPFLAGS): Simplify.
(libguile_@GUILE_EFFECTIVE_VERSION@_la_DEPENDENCIES): Explicitly add
libwhippet.la as a dependency.
(noinst_HEADERS): Add gc-internal.h
* libguile/gc-internal.h: New file.
* libguile/gc.c: Include gc-internal.h.
* configure.ac: Add subdir-objects Makefile.am option, to prevent
accidental collision between object file names.
* libguile/Makefile.am: Include whippet/embed.am, and add the
appropriate hooks to the Makefile.
* libguile/whippet-embedder.h: New file.
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
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
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
* 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
Fixes a regression in ‘--without-threads’ builds introduced in
b8031fc965.
* libguile/finalizers.c (scm_i_is_finalizer_thread) [!SCM_USE_PTHREAD_THREADS]:
New function.
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
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]
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
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>
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>
* 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>
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.
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.
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.