* libguile/filesys.c (scm_readdir): Remove set-but-unused `namlen' variable.
* libguile/fports.c (fport_flush): Same for `written'.
* libguile/gc-segment.c (scm_i_initialize_heap_segment_data): Same
for `bvec_ptr'.
* libguile/posix.c (scm_nice): Same for `nice_value'.
* libguile/scmsigs.c (take_signal): Same for `count'.
* libguile/srfi-4.c (uvec_to_list): Same for `elts'.
* libguile/stacks.c (scm_stack_ref): Same for `c_index'.
* libguile/threads.c (scm_std_select): Same for `count'.
* libguile/throw.c (scm_ithrow): Same for `answer'.
* libguile/unif.c (scm_i_read_array): Same for `got_rank'.
As the Autoconf documentation says, "These days portable programs
[...] should not rely on `HAVE_RESTARTABLE_SYSCALLS', since nowadays
whether a system call is restartable is a dynamic issue, not a
configuration-time issue."
In other words, if we ever rely on HAVE_RESTARTABLE_SYSCALLS, we are
at the mercy of any code that Guile happens to be linked with, because
that code could install a signal handler without the SA_RESTART flag,
and then a Guile system call could unexpectedly return EINTR.
The readline part of this goes back to this problem report:
excellent example of the above paragraph. It was noted during the
discussion that undefining HAVE_RESTARTABLE_SYSCALLS would fix the
problem, but that solution wasn't adopted - I guess because Guile was
still using cooperative threads then (not pthreads) and so there was a
significant concern (whether founded or not) that not using
restartable syscalls (where available) could lead to a loss of
performance.
Now Guile's default mode of operation is with pthreads, where we
already don't assume that HAVE_RESTARTABLE_SYSCALLS is reliable, so
there is no possible further performance loss. And in any case we
really have no choice, if we want correct operation.
* configure.in (AC_SYS_RESTARTABLE_SYSCALLS): Removed.
* doc/ref/posix.texi (Signals): Remove statement that Guile always
sets SA_RESTART flag.
* guile-readline/configure.in (GUILE_SIGWINCH_SA_RESTART_CLEARED):
Remove this setting, together with its test code.
(HAVE_RL_PRE_INPUT_HOOK): Remove this setting and its code, as no
longer needed.
* guile-readline/readline.c (sigwinch_enable_restart): Removed.
(scm_init_readline): Remove setting of rl_pre_input_hook.
* libguile/_scm.h (SCM_SYSCALL): Remove the definition that relies on
HAVE_RESTARTABLE_SYSCALLS.
* libguile/scmsigs.c (scm_sigaction_for_thread): Don't always set the
SA_RESTART flag if available. Update docstring accordingly.
(scm_init_scmsigs): Remove code that sets SA_RESTART flag for all
signals.
This fixes the following helgrind report.
Thread #1: lock order "0x4114748 before 0x4331084" violated
at 0x40234F7: pthread_mutex_lock (hg_intercepts.c:408)
by 0x407A55F: deval (eval.c:4077)
by 0x407A071: scm_dapply (eval.c:5012)
by 0x407888A: scm_apply (eval.c:4811)
by 0x407E20C: scm_call_0 (eval.c:4666)
by 0x406BDF7: scm_dynamic_wind (dynwind.c:111)
by 0x407620C: ceval (eval.c:4571)
by 0x407E8D9: scm_primitive_eval_x (eval.c:5921)
by 0x407E934: scm_eval_x (eval.c:5956)
by 0x40B9140: scm_shell (script.c:737)
by 0x4095AC5: invoke_main_func (init.c:367)
by 0x4065A81: c_body (continuations.c:349)
Required order was established by acquisition of lock at 0x4114748
at 0x40234F7: pthread_mutex_lock (hg_intercepts.c:408)
by 0x40B7BE1: scm_sigaction_for_thread (scmsigs.c:339)
by 0x40911DE: scm_gsubr_apply (gsubr.c:223)
by 0x4079E36: scm_dapply (eval.c:4930)
by 0x407AB68: deval (eval.c:4378)
by 0x407A071: scm_dapply (eval.c:5012)
by 0x407888A: scm_apply (eval.c:4811)
by 0x407E1D0: scm_call_1 (eval.c:4672)
by 0x407FEEE: scm_map (eval.c:5489)
by 0x407BDCC: deval (eval.c:4367)
by 0x407D197: deval (eval.c:3698)
by 0x407A071: scm_dapply (eval.c:5012)
followed by a later acquisition of lock at 0x4331084
at 0x40234F7: pthread_mutex_lock (hg_intercepts.c:408)
by 0x40DC397: scm_enter_guile (threads.c:377)
by 0x40DC8F4: scm_pthread_mutex_lock (threads.c:1485)
by 0x4083FAA: scm_gc_for_newcell (gc.c:484)
by 0x40A9781: scm_cons (inline.h:115)
by 0x4079867: scm_dapply (eval.c:4850)
by 0x407888A: scm_apply (eval.c:4811)
by 0x40796D6: scm_call_3 (eval.c:4684)
by 0x409A7C2: module_variable (modules.c:302)
by 0x409A7EE: module_variable (modules.c:312)
by 0x409A962: scm_sym2var (modules.c:466)
by 0x40738F4: scm_lookupcar1 (eval.c:2874)
* libguile/scmsigs.c (close_1): Renamed `handler_to_async'; also
handle #f case and wrapping the async in a cons, if necessary.
(install_handler): Pass in async instead of constructing it; combine
two branches into one.
(scm_sigaction_for_thread): Allocate async upfront instead of inside
the critical section, and pass it to install_handler calls. Leave
critical section before signaling out-of-range error.
This fixes bug #24009 reported by Martin Pitt.
* libguile/threads.c (guilify_self_1): Check the return value of
pipe(2).
(scm_std_select): Store the return value of read(2) when reading
from WAKEUP_FD.
* libguile/async.c (scm_i_queue_async_cell): Store the return value
of write(2) when writing to SLEEP_FD.
* libguile/fports.c (fport_flush): Likewise.
* libguile/posix.c (getgroups): Use the return value of getgroups(2) as
NGROUPS.
(scm_nice): Get the return value of nice(2) to make glibc happy.
* libguile/scmsigs.c (take_signal): Store the return value of
write(2).
scm_ushort2num, scm_int2num, scm_uint2num, scm_long2num,
scm_ulong2num, scm_size2num, scm_ptrdiff2num, scm_num2short,
scm_num2ushort, scm_num2int, scm_num2uint, scm_num2long,
scm_num2ulong, scm_num2size, scm_num2ptrdiff, scm_long_long2num,
scm_ulong_long2num, scm_num2long_long, scm_num2ulong_long):
Discouraged by moving to discouraged.h and discouraged.c and
reimplementing in terms of scm_from_* and scm_to_*. Changed all uses
to the new scm_from_* and scm_to_* functions.
SCM_INUM): Deprecated by reenaming them to SCM_I_INUMP, SCM_I_NINUMP
and SCM_I_INUM, respectively and adding deprecated versions to
deprecated.h and deprecated.c. Changed all uses to either use the
SCM_I_ variants or scm_is_*, scm_to_*, or scm_from_*, as appropriate.
SCM_VALIDATE_BIGINT, SCM_VALIDATE_INUM_MIN,
SCM_VALIDATE_INUM_MIN_COPY,
SCM_VALIDATE_INUM_MIN_DEF_COPY,SCM_VALIDATE_INUM_DEF,
SCM_VALIDATE_INUM_DEF_COPY, SCM_VALIDATE_INUM_RANGE,
SCM_VALIDATE_INUM_RANGE_COPY): Deprecated because they make the
fixnum/bignum distinction visible. Changed all uses to scm_to_size_t
or similar.
SCM_NEGATE_BOOL, SCM_BOOLP): Deprecated by moving into "deprecated.h".
Replaced all uses with scm_is_false, scm_is_true, scm_from_bool, and
scm_is_bool, respectively.
scm_delq_spine_x, really_install_handler, install_handler): New
scheme for triggering signal handlers, to simplify take_signal.
(take_signal): Simplified, to avoid race conditions.
(scm_sigaction_for_thread): Use new Scheme. Validate that thread
hasn't exited yet.
scm_i_thread_root when USE_THREADS is defined. Use scm_root
otherwise.
* scmsigs.c (take_signal): Only call scm_i_thread_root when
USE_THREADS is defined. Use scm_root otherwise.
(scm_sigaction_for_thread): Ignore THREAD argument when
USE_THREADS is not defined. Also, move THREAD argument defaulting
out of HAVE_SIGACTION section, which was a bug.
cell to SCM_BOOL_F, not SCM_EOL.
(scm_i_queue_async_cell): Queue the cell at the end of the list,
and only if the handler procedure is not already present.
(scm_system_async_mark_for_thread): Initialize cdr of handler cell
with SCM_BOOL_F.
* scmsigs.c (scm_sigaction_for_thread): Likewise.
* scmsigs.c (got_signal): Removed.
(signal_handler_cells, signal_handler_threads): New.
(take_signal): Queue the cell of the signal for the specified
thread. Reset the signal handler on systems that don't have
sigaction.
(sys_deliver_signals): Removed.
(close_1): New.
(scm_sigaction_for_thread): Renamed from scm_sigaction and
extended to also set the thread of a signal and allocate a cell
for it. Keep the Scheme name "sigaction". Check that signum is
within range. Also, use SCM_VECTOR_REF instead of SCM_VELTS.
(scm_sigaction): Implement in terms of scm_sigaction_for_thread.
(scm_init_scmsigs): Allocate signal_handler_cells and
signal_handler_threads vectors.
* *.c: add space after commas everywhere.
* *.c: use SCM_VECTOR_SET everywhere, where a vector is written.
Document cases where SCM_WRITABLE_VELTS() is used.
* vectors.h (SCM_VELTS): prepare for write barrier, and let
SCM_VELTS() return a const pointer
(SCM_VECTOR_SET): add macro.
* autogen.sh (mscripts): find and check version number of
autoconf. Complain if 2.53 is not found.
* configure.in (guile_cv_have_uint32_t): Look also in
`stdint.h' for uint32_t.
2002-01-28 Stefan Jahn <stefan@lkcc.org>
* symbols.c (scm_c_symbol2str): New function, replacement for
`gh_scm2newsymbol()'.
* strings.c (scm_c_substring2str): New function. Proper
replacement for `gh_get_substr()'.
* socket.c: Include `stdint.h' if available for the `uint32_t'
declaration.
* scmsigs.c (s_scm_sigaction): Initialize `chandler' (inhibits
compiler warning).
* backtrace.c: Include `lang.h' for GUILE_DEBUG conditional.
scm_c_define_gsubr_with_generic): New functions. They replace
scm_make_gsubr and scm_make_gsubr_with_generic. The `make' variants
only create the gsubr object, while the `define' variants also put it
into the current module. Changed all callers. (scm_make_gsubr,
scm_make_gsubr_with_generic): Deprecated.
(scm_c_make_subr, scm_c_define_subr, scm_c_make_subr_with_generic,
scm_c_define_subr_with_generic): New functions. They replace
scm_make_subr, scm_make_subr_opt and scm_make_subr_with_generic. The
`make' variants only create the subr object, while the `define'
variants also put it into the current module. Changed all callers.
(scm_make_subr, scm_make_subr_opt, scm_make_subr_with_generic):
Deprecated.