summaryrefslogtreecommitdiff
path: root/libguile/posix.c
AgeCommit message (Collapse)AuthorFilesLines
2025-03-22In piped_process, replace dprintf with more portable functionsMichael Gran1-2/+15
dprint is missing on many non-glic platforms * libguile/posix.c (piped_process): replace dprintf with sprintf+write
2025-03-22Allow piped-process and system* to exist when fork is undefinedMichael Gran1-5/+4
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-22MinGW32: cast arguments to execvpMichael Gran1-1/+13
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-18piped_process: silence spurious -Wmaybe-uninitialized warningsRob Browning1-2/+2
libguile/posix.c: initialize pipes to silence spurious warnings.
2025-02-28Warn about mutation of ‘environ’ when multi-threaded.Olivier Dion1-12/+19
This is an amendment to 84bf84032208e21d20ad13f3033d4fca3a512014. 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-01-22Don't hold lock during scm_async_tick in readdir and ttynameRob Browning1-25/+12
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.
2024-10-20posix.c: Set errno when pipe2 is not available and flags provided.Tomas Volf1-1/+1
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-05-06Fix typos throughout codebase.Morgan Smith1-3/+3
* 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‘system*’ no longer changes SIGINT and SIGQUIT handlers.Ludovic Courtès1-35/+3
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 527c257d6e0ad0480a859f69e9dcf3b0c7aad76e, 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-01-05Stop signal thread before forking, restart it afterwards.Ludovic Courtès1-0/+6
Fixes <https://bugs.gnu.org/68087>. * libguile/scmsigs.h (scm_i_signals_pre_fork, scm_i_signals_post_fork): New declarations. (scm_i_signal_delivery_thread): Change type to SCM.. * libguile/threads.c (scm_all_threads): Adjust accordingly and exclude threads that have ‘t->exited’. Access ‘thread_count’ after grabbing ‘thread_admin_mutex’. * libguile/posix.c (scm_fork): Add calls to ‘scm_i_signals_pre_fork’ and ‘scm_i_signals_post_fork’. * libguile/scmsigs.c (signal_delivery_thread): Close signal_pipe[0] upon exit and set it to -1. (once): New file-global variable, moved from… (scm_i_ensure_signal_delivery_thread): … here. (stop_signal_delivery_thread, scm_i_signals_pre_fork) (scm_i_signals_post_fork): New functions. * test-suite/standalone/test-sigaction-fork: New file. * test-suite/standalone/Makefile.am (check_SCRIPTS, TESTS): Add it.
2023-07-17Test for clearenv functionMichael Gran1-0/+4
clearenv() may not be provided by non-glibc systems. As a fallback, just set environ to NULL. * libguile/posix.c (scm_environ)[!HAVE_CLEARENV]: add fallback logic for clearenv()
2023-07-17Check return value of niceMichael Gran1-2/+2
'nice' is marked as 'warn_unused_result' on some versions of Ubuntu which causes make distcheck to fail. This implements the error checking logic exactly as POSIX suggests to silence the warning. * libguile/posix.c (scm_nice): new error checking logic.
2023-07-16Fix dangling pointers in `environ'.Olivier Dion1-1/+20
When calling `environ', Guile set the global variable `environ' to a list allocated with the GC. Strings in it are also allocated with the GC. However, if an user call the Scheme setenv() procedure, the resulting call to putenv() in libc might reallocate `environ' to a new pointer while copying sub-pointers owned by Guile in it. This results in the GC marking these strings for reclamation when they are actually still present in `environ'. Thus, the values in the environment are now undefined. To fix this, Guile should only manipulate the `environ' using the standard libc functions. This ensures that concurrent modification of it is safe in multi-threaded program. Therefore, the procedure `environ' now call the libc clearenv() procedure to purge the environment. Then, the desired values are put in `environ' using scm_putenv(). At the end, no GC allocated memory is put in `environ'. Also, since `environ' can be changed at anytime in a multi-thread program, emit a warning stipulating that the result is undefined behavior if multiple threads are created in the program. Consider for example a thread iterating over `environ' while another one do a call to putenv(). The latter would do a realloc() on `environ' and thus the old array read by the former now contains garbage. On system where clearenv() is not present, an atomic store of NULL with sequential consistency to `environ' should be sufficient but see the NOTES of clearenv(3). * libguile/posix.c (scm_environ): Do not store GC allocated memory in environ. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2023-05-08Use /dev/null in 'piped-process' if port is not backed by a fdes.Josselin Poiret1-4/+16
In Guile 3.0.9, 'system*' would no longer open /dev/null for file descriptors 0, 1, and 2 when its 'current-input-port', 'current-output-port', or 'current-output-port' is not bound to a file port. This patch reinstates that behavior. Fixes <https://bugs.gnu.org/63024>. * libguile/posix.c (piped_process): Open /dev/null to use as in/out/err if the corresponding port is not backed by a file descriptor. * test-suite/tests/posix.test ("system*")["https://bugs.gnu.org/63024"]: New test. * NEWS: Update. Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2023-05-08Add error handling for spawn's posix_spawn_file_actions_adddup2.Josselin Poiret1-6/+13
* libguile/posix.c (do_spawn): Add error handling if posix_spawn_file_actions_adddup2 fails. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2023-04-02Use 'posix_spawn_file_actions_addclosefrom_np' where available.Ludovic Courtès1-0/+14
* configure.ac: Check for 'posix_spawn_file_actions_addclosefrom_np'. * libguile/posix.c (HAVE_ADDCLOSEFROM): New macro. (close_inherited_fds): Wrap in #ifdef HAVE_ADDCLOSEFROM. (do_spawn) [HAVE_ADDCLOSEFROM]: Use 'posix_spawn_file_actions_addclosefrom_np'.
2023-04-02Remove racy optimized file descriptor closing loop in 'spawn'.Ludovic Courtès1-29/+1
This reverts 9332b632407894c2e1951cce1bc678f19e1fa8e4, thereby reinstating the performance issue in <https://bugs.gnu.org/59321>. This optimization was subject to race conditions in multi-threaded code: new file descriptors could pop up at any time and thus leak in the child. * libguile/posix.c (close_inherited_fds): Remove. (close_inherited_fds_slow): Rename to... (close_inherited_fds): ... this.
2023-04-02'spawn' closes only open file descriptors on non-GNU/Linux systems.Ludovic Courtès1-1/+18
Fixes <https://bugs.gnu.org/61095>. Reported by Omar Polo <op@omarpolo.com>. * libguile/posix.c (close_inherited_fds_slow): On systems other than GNU/Linux, call 'addclose' only when 'fcntl' succeeds on MAX_FD. * NEWS: Update.
2023-01-26'spawn' ensures it is passed open file ports.Ludovic Courtès1-5/+13
Fixes <https://bugs.gnu.org/61073>. * libguile/posix.c (FDES_FROM_PORT_OR_INTEGER): When OBJ is not an integer, use 'SCM_VALIDATE_OPFPORT' before using 'SCM_FPORT_FDES'. * test-suite/tests/posix.test ("spawn")["non-file port argument"]: New test.
2023-01-23Verify 'W_EXITCODE' only when we provide our own definition.v3.0.9Ludovic Courtès1-1/+1
Fixes <https://bugs.gnu.org/60971>. Reported by lloda <lloda@sarc.name> and Greg Troxel <gdt@lexort.com>. On macOS and NetBSD, 'WEXITSTATUS' expects an lvalue so the expression passed to 'verify' would be invalid. * libguile/posix.c: Move 'verify' assertion within #ifdef.
2023-01-18Adjust 'W_EXITCODE' for Windows.Ludovic Courtès1-1/+5
* libguile/posix.c (W_EXITCODE) [_WIN32]: New specialized definition.
2023-01-18Fix argument number in 'spawn' type check.Ludovic Courtès1-1/+1
* libguile/posix.c (scm_spawn_process): Fix argument number in 'SCM_VALIDATE_NONEMPTYLIST'.
2023-01-13Reduce redundant 'close' calls when forking on some systems.Andrew Whatson1-3/+38
Fixes <https://bugs.gnu.org/59321>. Reported by <hylophile@posteo.de>. Some systems provide "/proc/self/fd" which is a directory containing an entry for each open file descriptor in the current process. We use this to limit the number of close() calls needed to ensure file descriptors aren't leaked to the child process when forking. * libguile/posix.c (close_inherited_fds_slow): (close_inherited_fds): New static helper functions. (scm_spawn_process): Attempt to close inherited file descriptors efficiently using 'close_inherited_fds', falling back to the brute-force approach in 'close_inherited_fds_slow'. * NEWS: Update.
2023-01-13Make 'system*' and 'piped-process' internally use 'spawn'.Josselin Poiret1-154/+78
Fixes <https://bugs.gnu.org/52835>. * libguile/posix.c (scm_system_star, scm_piped_process): Use do_spawn. (start_child): Remove function. * test-suite/tests/posix.test ("system*")["https://bugs.gnu.org/52835"]: New test. * NEWS: Update. Co-authored-by: Ludovic Courtès <ludo@gnu.org> Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2023-01-13Add 'spawn'.Josselin Poiret1-2/+154
* libguile/posix.c: Include spawn.h from Gnulib. (do_spawn, scm_spawn_process): New functions. (kw_environment, hw_input, kw_output, kw_error, kw_search_path): New variables. * doc/ref/posix.texi (Processes): Document it. * test-suite/tests/posix.test ("spawn"): New test prefix. * NEWS: Update. Co-authored-by: Ludovic Courtès <ludo@gnu.org> Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2022-10-21Define AT_REMOVEDIR and others when available.Maxime Devos1-0/+6
* libguile/posix.c (scm_init_posix): Define (in Scheme) AT_REMOVEDIR and AT_EACCESS when defined (in C). Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2022-10-21Allow file ports in ‘utime’.Maxime Devos1-6/+22
Ports representing symbolic links are currently unsupported. * configure.ac: Detect 'futimens'. * doc/ref/posix.texi (utime): Update documentation. * libguile/posix.c (scm_utime): Support ports. * libguile/posix.h (scm_utime): Rename argument. * test-suite/tests/posix.test ("utime"): Add more tests. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2022-10-14Remove special logic for the obscure CMU C library's libc.hMike Gran1-4/+0
* acinclude.m4 (GUILE_HEADER_LIBC_WITH_UNISTD): removed * configure.ac: remove GUILE_HEADER_LIBC_WITH_UNISTD, don't check for libc.h * libguile/filesys.c [LIBC_H_WITH_UNISTD_H]: remove libc.h inclusion * libguile/posix.c [LIBC_H_WITH_UNISTD_H]: remove libc.h inclusion
2022-10-14Presume time.h and sys/time.h don't conflict when includedMike Gran1-8/+2
Systems on which time.h and sys/time.h conflicted are obsolescent. * configure.ac: remove AC_HEADER_TIME. remove conditional in tm.tm_gmtoff test. * libguile/filesys.c [TIME_WITH_SYS_TIME]: remove conditional * libguile/posix.c [TIME_WITH_SYS_TIME]: remove conditional # Conflicts: # libguile/filesys.c
2022-10-14Presume ISO C90 functions are always availableMike Gran1-5/+0
* configure.ac: don't check for rename, setlocale, system, memcpy, and strcoll * libguile/i18n.c [HAVE_SETLOCALE] (setlocale): remove static setlocale Don't use HAVE_SETLOCALE * libguile/posix.c: include <locale.h>, remove HAVE_SETLOCALE (scm_setlocale): always include. remove HAVE_SETLOCALE * libguile/simpos.c (scm_system): always include. remove HAVE_SYSTEM
2022-09-19'pipe' now takes an optional 'flags' parameter.Ludovic Courtès1-6/+45
This is the same strategy as used for the 'accept4' bindings introduced in 6e0965104c579431e5a786b60e1a964a112c73b8. * libguile/posix.c (scm_pipe): Rename to... (scm_pipe2): ... this. Add an optional 'flags' parameter and honor it. (scm_pipe): Rewrite as a call to 'scm_pipe2'. * libguile/posix.h (scm_pipe2): New declaration. * test-suite/tests/posix.test ("pipe"): New tests. * configure.ac: Look for 'pipe2'. * NEWS: Update.
2022-08-05'system*' can no longer close file descriptor 2.Ludovic Courtès1-2/+3
Fixes <https://bugs.gnu.org/55596>. Reported by Hugo Nobrega <hugonobrega@ic.ufrj.br> and Jack Hill <jackhill@jackhill.us>. * libguile/posix.c (start_child): Close OUT only if it's greater than 2. * test-suite/tests/posix.test ("system*")["exit code for nonexistent file"] ["https://bugs.gnu.org/55596"]: New tests.
2021-11-03Const qualify return of strerrorPhilipp Klaus Krause1-2/+2
Closes https://debbugs.gnu.org/cgi/bugreport.cgi?bug=43987
2021-05-08'primitive-fork' closes and recreates the current thread's 'sleep_pipe'.Ludovic Courtès1-1/+28
Partly fixes <https://bugs.gnu.org/41948>. Previously, the child process could end up using the same 'sleep_pipe' as its parent, leading to a race condition handling signals. * libguile/posix.c (do_fork): New function. (scm_fork): Call 'do_fork' via 'scm_without_guile'. * test-suite/standalone/test-signal-fork: New test. * test-suite/standalone/Makefile.am (check_SCRIPTS, TESTS): Add it.
2021-03-10Add mkstemp; undocument mkstemp!Andy Wingo1-3/+3
* doc/ref/posix.texi (File System): Update to document mkstemp only. * libguile/filesys.c: Make a mkstemp that doesn't modify the input template. Instead the caller has to get the file name from port-filename. (scm_mkstemp): Use the new mkstemp to implement mkstemp!. Can't deprecate yet though as the replacement hasn't been there for long enough. * libguile/posix.c (scm_tempnam): Update to mention mkstemp instead. * module/system/base/compile.scm (call-with-output-file/atomic): Use mkstemp. * test-suite/tests/posix.test: * test-suite/tests/r6rs-files.test: Use mkstemp. * NEWS: Update.
2020-05-16popen: Add 'pipeline' procedure.Rutger van Beusekom1-48/+18
* libguile/posix.c (scm_open_process): Remove. (scm_piped_process): Add to replace open_process. * module/ice-9/popen.scm (pipe->fdes): Add to convert pipe pair to fdes pair. (open-process): Add open-process for backwards compatibility. (pipeline): Add to implement a pipeline using piped-process. * doc/ref/posix.texi (Pipes): Document it. * test-suite/tests/popen.test ("open-process") ("piped-process", "piped-process: with output") ("pipeline"): New tests. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2020-04-14bitvector-set-bit! / bitvector-clear-bit! replace bitvector-set!Andy Wingo1-1/+1
* NEWS: Add entry. * doc/ref/api-data.texi (Bit Vectors): Update. * libguile/array-handle.h (bitvector_set_x, scm_array_get_handle): Adapt to bitvector changes. * libguile/bitvectors.h: * libguile/bitvectors.c (scm_c_bitvector_set_bit_x) (scm_c_bitvector_clear_bit_x): New functions. * libguile/deprecated.h: * libguile/deprecated.c (scm_bitvector_set_x): Deprecate. * module/ice-9/sandbox.scm (mutable-bitvector-bindings): Replace bitvector-set! with bitvector-set-bit! / bitvector-clear-bit!. * module/system/vm/disassembler.scm (static-opcode-set): Use bitvector-set-bit!. * module/system/vm/frame.scm (compute-defs-by-slot, available-bindings): Use bitvector-set-bit!. * test-suite/tests/bitvectors.test: Update.
2020-03-22Deprecate 'tmpnam' and add '--disable-tmpnam' configure option.Matt Wette1-0/+11
* configure.ac: Add '--disable-tmpnam'. * libguile/posix.c (tmpnam): Conditionalize on 'SCM_ENABLE_DEPRECATED' and 'ENABLE_TMPNAM'. Call 'scm_c_issue_deprecation_warning'. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2019-08-02Merge from stable-2.2Andy Wingo1-9/+38
2019-06-18open-process: Fix dup(2) and execvp(2) error handling.Mark H Weaver1-9/+38
Previously, in the case where OUT is 0, or ERR is 0 or 1, e.g. when (current-error-port) points to STDOUT, the code in 'start_child' to relocate OUT/ERR out of the way to another file descriptor had multiple bugs: (1) It neglected to close the original file descriptor. (2) It checked 'errno' without first checking the return value of dup(2). This doesn't work because dup(2) leaves 'errno' unchanged if there's no error. (3) In case 'errno' contained EINTR, the retry code failed because OUT (or ERR) was overwritten by the result of the previous failed dup(2) call. This commit fixes these problems, as well as another problem with 'execvp' error reporting. * libguile/posix.c (renumber_file_descriptor): New static helper function. (start_child): Use 'renumber_file_descriptor'. If 'execvp' fails, write the error message to file descriptor 2. Previously, we wrote the error message to ERR, which was the old file descriptor before being relocated to 2.
2019-05-23Use 'scm_from_utf8_{string,symbol,keyword}' for C string literals.Mark H Weaver1-2/+2
Partial fix for <https://bugs.gnu.org/33044>. Reported by Tom de Vries <tdevries@suse.de>. Fix several instances of the mistake of using 'scm_from_locale_*' for C strings that originally came from a C string literal. Change several uses of 'scm_from_latin1_*' as well, to promote the practice of writing code that works for arbitrary C string literals. Also add missing years to the copyright notices of changed files, based on the git history. * libguile/debug-malloc.c, libguile/deprecation.c, libguile/error.c, libguile/eval.c, libguile/expand.c, libguile/extensions.c, libguile/filesys.c, libguile/init.c, libguile/load.c, libguile/modules.c, libguile/pairs.c, libguile/posix.c, libguile/print.c, libguile/random.c, libguile/read.c, libguile/regex-posix.c, libguile/snarf.h, libguile/srfi-13.c, libguile/stacks.c, libguile/stime.c, libguile/strports.c, libguile/values.c: Use 'scm_from_utf8_*' where appropriate.
2019-05-23Define AT_SYMLINK_NOFOLLOW et al.Ludovic Courtès1-2/+18
* libguile/posix.c (scm_init_posix): Define AT_SYMLINK_NOFOLLOW, AT_SYMLINK_FOLLOW, AT_NO_AUTOMOUNT, and AT_EMPTY_PATH when available. (scm_utime): Mention AT_SYMLINK_NOFOLLOW. * doc/ref/posix.texi (File System): Update accordingly. * test-suite/tests/posix.test ("utime")["AT_SYMLINK_NOFOLLOW"]: New test.
2018-10-17Use 'scm_from_utf8_{string,symbol,keyword}' for C string literals.Mark H Weaver1-5/+3
Partial fix for <https://bugs.gnu.org/33044>. Reported by Tom de Vries <tdevries@suse.de>. Fix several instances of the mistake of using 'scm_from_locale_*' for C strings that originally came from a C string literal. Change several uses of 'scm_from_latin1_*' as well, to promote the practice of writing code that works for arbitrary C string literals. Also add missing years to the copyright notices of changed files, based on the git history. * libguile/debug-malloc.c, libguile/deprecation.c, libguile/error.c, libguile/eval.c, libguile/expand.c, libguile/extensions.c, libguile/filesys.c, libguile/init.c, libguile/load.c, libguile/modules.c, libguile/pairs.c, libguile/posix.c, libguile/print.c, libguile/random.c, libguile/read.c, libguile/regex-posix.c, libguile/snarf.h, libguile/srfi-13.c, libguile/stacks.c, libguile/stime.c, libguile/strports.c, libguile/values.c: Use 'scm_from_utf8_*' where appropriate.
2018-10-07Fix use of uninstalled header by installed headersAndy Wingo1-0/+1
* libguile/Makefile.am (libpath.h): Remove definition of SCM_EFFECTIVE_VERSION, which is defined in version.h. * libguile/extensions.h: Remove libpath.h inclusion, as it's not installed. * libguile/atomic.c: * libguile/bytevectors.c: * libguile/control.c: * libguile/fdes-finalizers.c: * libguile/foreign-object.c: * libguile/foreign.c: * libguile/fports.c: * libguile/frames.c: * libguile/goops.c: * libguile/i18n.c: * libguile/instructions.c: * libguile/intrinsics.c: * libguile/ioext.c: * libguile/load.c: * libguile/loader.c: * libguile/poll.c: * libguile/ports.c: * libguile/posix.c: * libguile/programs.c: * libguile/r6rs-ports.c: * libguile/srfi-1.c: * libguile/srfi-60.c: * libguile/threads.c: * libguile/unicode.c: * libguile/vm.c: * libguile/weak-vector.c: Include version.h for the SCM_EFFECTIVE_VERSION definition.
2018-09-23Define AT_SYMLINK_NOFOLLOW et al.Ludovic Courtès1-1/+17
* libguile/posix.c (scm_init_posix): Define AT_SYMLINK_NOFOLLOW, AT_SYMLINK_FOLLOW, AT_NO_AUTOMOUNT, and AT_EMPTY_PATH when available. (scm_utime): Mention AT_SYMLINK_NOFOLLOW. * doc/ref/posix.texi (File System): Update accordingly. * test-suite/tests/posix.test ("utime")["AT_SYMLINK_NOFOLLOW"]: New test.
2018-08-07Make sure the return value of 'scm_crypt' is always initialized.Ludovic Courtès1-4/+7
* libguile/posix.c (scm_crypt): Always initialize 'ret'; error out even when ERR is zero.
2018-08-07Fix 'crypt' deadlock upon error.Ludovic Courtès1-4/+21
* libguile/posix.c (scm_crypt): Take 'scm_i_misc_mutex' right before calling 'crypt'. Move 'SCM_SYSERROR' call after 'scm_dynwind_end'. * test-suite/tests/posix.test ("crypt"): New test prefix.
2018-06-25Give multiple-values objects a tc7Andy Wingo1-7/+5
* libguile/scm.h (scm_tc7_values): New tc7. Never seen by Scheme, so we don't need to update it anywhere else. * libguile/values.h (scm_is_values): New public static inline function. (scm_i_nvalues, scm_i_value_ref): New private static inline functions. (SCM_VALUESP): Use scm_is_value. (scm_values_2, scm_values_3): New functions. (scm_values_vtable): Remove; values objects are not structs any more. * libguile/values.c (scm_i_extract_values_2): Adapt to new values representation. (print_values): Remove now-unused function. (scm_c_nvalues): Use scm_i_nvalues. (scm_c_value_ref): Use scm_i_value_ref. (scm_values, scm_c_values): Make the new-style objects, which store their values inline. (scm_values_2, scm_values_3): New helpers, to avoid consing little useless lists. * libguile/vm-engine.c (halt, subr-call) * libguile/eval.c (eval): Adapt to new values representation. * libguile/i18n.c (scm_locale_string_to_integer) (scm_locale_string_to_integer) * libguile/numbers.c (scm_i_floor_divide, scm_i_ceiling_divide) (scm_i_truncate_divide, scm_i_centered_divide, scm_i_round_divide) (scm_i_exact_integer_sqrt) * libguile/r6rs-ports.c (make_bytevector_output_port) * libguile/srfi-1.c (scm_srfi1_partition, scm_srfi1_partition_x) * libguile/srfi-14.c (scm_char_set_diff_plus_intersection) (scm_char_set_diff_plus_intersection_x) * libguile/posix.c (scm_getrlimit, scm_open_process): Adapt to use scm_values_2 or scm_values_3. * libguile/print.c (iprin1): Add printer for values objects.
2018-06-21Replace uses of scm_t_int8, scm_t_uintmax, etc with stdint typesAndy Wingo1-3/+3
* libguile/bitvectors.c: * libguile/bitvectors.h: * libguile/bytevectors.c: * libguile/bytevectors.h: * libguile/chars.c: * libguile/continuations.c: * libguile/control.c: * libguile/conv-integer.i.c: * libguile/conv-uinteger.i.c: * libguile/dynstack.c: * libguile/dynstack.h: * libguile/foreign.c: * libguile/frames.c: * libguile/frames.h: * libguile/gc-inline.h: * libguile/gc.h: * libguile/gsubr.c: * libguile/gsubr.h: * libguile/hash.c: * libguile/i18n.c: * libguile/instructions.c: * libguile/intrinsics.c: * libguile/intrinsics.h: * libguile/loader.c: * libguile/loader.h: * libguile/numbers.c: * libguile/numbers.h: * libguile/pairs.c: * libguile/ports-internal.h: * libguile/ports.c: * libguile/ports.h: * libguile/posix.c: * libguile/print.c: * libguile/print.h: * libguile/programs.c: * libguile/programs.h: * libguile/r6rs-ports.c: * libguile/random.c: * libguile/random.h: * libguile/scm.h: * libguile/socket.c: * libguile/srfi-4.c: * libguile/srfi-4.h: * libguile/stacks.c: * libguile/stime.c: * libguile/strings.c: * libguile/struct.c: * libguile/struct.h: * libguile/symbols.c: * libguile/threads.c: * libguile/threads.h: * libguile/uniform.c: * libguile/vm-engine.c: * libguile/vm.c: * libguile/vm.h: * libguile/vports.c: * test-suite/standalone/test-conversion.c: * test-suite/standalone/test-ffi-lib.c: * test-suite/standalone/test-scm-take-u8vector.c: * test-suite/standalone/test-srfi-4.c: Replace e.g. scm_t_uint8 with uint8_t.
2018-06-20Update license notices in all C filesAndy Wingo1-17/+17
Update to newest recommended license notices from the FSF. Everything stays LGPLv3+ except guile-readline which is GPLv3+.