summaryrefslogtreecommitdiff
path: root/libguile
Commit message (Collapse)AuthorAgeFilesLines
* Use SCM_GSUBR_MAX in place of the hardcoded numberDaniel Llorens2023-04-272-4/+4
| | | | | | * libguile/gsubr.c (scm_apply_subr): Reference the limit. (get_subr_stub_code): As stated. * libguile/jit.c (compile_subr_call): As stated.
* Fix typo in append procedure documentationJorge Gomez2023-04-051-1/+1
| | | | | | Fixes <https://bugs.gnu.org/62456>. Signed-off-by: Mikael Djurfeldt <mikael@djurfeldt.com>
* Use 'posix_spawn_file_actions_addclosefrom_np' where available.Ludovic Courtès2023-04-021-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'.
* Remove racy optimized file descriptor closing loop in 'spawn'.Ludovic Courtès2023-04-021-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.
* 'spawn' closes only open file descriptors on non-GNU/Linux systems.Ludovic Courtès2023-04-021-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.
* scm_i_utf8_string_hash: compute u8 chars not bytesRob Browning2023-03-182-3/+3
| | | | | | | | | | | | | | | | | | Noticed while investigating a migration to utf-8 strings. After making changes that routed non-ascii symbol hashing through this function, encoding-iso88597.test began intermittently failing because it would traverse trailing garbage when u8_strnlen reported 8 chars instead of 4. Change the scm_i_str2symbol and scm_i_str2uninterned_symbol internal hash type to unsigned long to explicitly match the scm_i_string_hash result type. * libguile/hash.c (scm_i_utf8_string_hash): Call u8_mbsnlen not u8_strnlen. * libguile/symbols.c (scm_i_str2symbol, scm_i_str2uninterned_symbol): Use unsigned long for scm_i_string_hash result. * test-suite/standalone/.gitignore: Add test-hashing. * test-suite/standalone/Makefile.am: Add test-hashing. * test-suite/standalone/test-hashing.c: Add.
* 'spawn' ensures it is passed open file ports.Ludovic Courtès2023-01-261-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.
* Verify 'W_EXITCODE' only when we provide our own definition.v3.0.9Ludovic Courtès2023-01-231-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.
* Remove 'extern' from 'scm_i_current_thread' definition, except on macOS.v3.0.9rc1Ludovic Courtès2023-01-201-2/+4
| | | | | | | | | | This is a followup to f859e0f58b211eedcb0dce4f2382cfebf37010d7, which led to warnings on GNU/Linux: threads.c:358:43: warning: 'scm_i_current_thread' initialized and declared 'extern' * libguile/threads.c (scm_i_current_thread): Make 'SCM_INTERNAL' conditional.
* Add Gnulib 'sys_select' module, needed for MinGW.Ludovic Courtès2023-01-191-1/+2
| | | | | | | This is again from Gnulib v0.1-5703-g356a414e8c. * m4/gnulib-cache.m4: Add 'sys_select'. * libguile/threads.c: Include <sys/select.h>.
* Adjust 'W_EXITCODE' for Windows.Ludovic Courtès2023-01-181-1/+5
| | | | * libguile/posix.c (W_EXITCODE) [_WIN32]: New specialized definition.
* Fix argument number in 'spawn' type check.Ludovic Courtès2023-01-181-1/+1
| | | | | * libguile/posix.c (scm_spawn_process): Fix argument number in 'SCM_VALIDATE_NONEMPTYLIST'.
* Add 'bytevector-slice'.Ludovic Courtès2023-01-142-2/+64
| | | | | | | | | * module/rnrs/bytevectors/gnu.scm: New file. * am/bootstrap.am (SOURCES): Add it. * libguile/bytevectors.c (scm_bytevector_slice): New function. * libguile/bytevectors.h (scm_bytevector_slice): New declaration. * test-suite/tests/bytevectors.test ("bytevector-slice"): New tests. * doc/ref/api-data.texi (Bytevector Slices): New node.
* Reduce redundant 'close' calls when forking on some systems.Andrew Whatson2023-01-131-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.
* Make 'system*' and 'piped-process' internally use 'spawn'.Josselin Poiret2023-01-131-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>
* Add 'spawn'.Josselin Poiret2023-01-132-3/+156
| | | | | | | | | | | | | * 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>
* Patch for bug #60234Daniel Llorens2022-12-211-1/+2
| | | | | | | See https://debbugs.gnu.org/60234. gcc warns about the extra extern, but we get rid of the tls model mismatch error.
* fix Apple Silicon JIT compilationAleix Conchillo Flaqué2022-12-201-1/+24
| | | | | | | | * configure.ac: check for pthread_jit_write_protect_np. * libguile/jit.c: add support for Apple Silicon JIT compilation. Fixes https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44505
* Fix possible deadlock in 'lock-mutex'.Olivier Dion2022-11-201-9/+10
| | | | | | | | | | | | | | | If we got interrupted while waiting on our condition variable, we unlock the kernel mutex momentarily while executing asynchronous operations before putting us back into the waiting queue. However, we have to retry acquiring the mutex before getting back into the queue, otherwise it's possible that we wait indefinitely since nobody could be the owner for a while. * libguile/threads.c (lock_mutex): Try acquring the mutex after signal interruption. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* Work around unwanted stack retention when using prompts.Ludovic Courtès2022-11-201-5/+12
| | | | | | | | | | Fixes <https://bugs.gnu.org/59021>. Previously, the stack allocated in 'capture_stack' and stored in 'p->stack_bottom' could be retained, leading to heap growth. * libguile/vm.c (capture_stack): Make a single 'scm_gc_malloc' call instead of two.
* Define Scheme bindings to ‘openat’ when available.Maxime Devos2022-10-213-20/+79
| | | | | | | | | | | | | | | | * configure.ac: Detect if ‘openat’ is defined. * libguile/filesys.c (flags_to_mode): Extract from ... (scm_mode): ... here. (scm_open_fdes_at, scm_openat): Define the Scheme bindings. * libguile/filesys.h (scm_open_fdes_at, scm_openat): Make them part of the API. * doc/ref/posix.texi (File System): Document them. * test-suite/tests/filesys.test ("openat"): Test ‘openat’. * libguile/syscalls.h (openat_or_openat64): Decide between ‘openat’ and ‘openat64’. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* Define a Scheme binding to ‘fstatat’ when available.Maxime Devos2022-10-213-0/+41
| | | | | | | | | | | * configure.ac: Detect if ‘fstatat’ is defined. * libguile/filesys.c (scm_statat): Define a Scheme binding to ‘fstatat’. * libguile/filesys.h (scm_statat): Make it part of the C API. * doc/ref/posix.texi (File System): Document it. * libguile/syscalls.h (fstatat_or_fstatat64): Choose between ‘fstatat’ and ‘fstatat64’. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* Define a Scheme binding to ‘fchownat’ when it exists.Maxime Devos2022-10-212-0/+36
| | | | | | | | | | * configure.ac: Detect whether ‘fchownat’ is available. * libguile/filesys.c (scm_chownat): Define a Scheme binding to ‘fchownat’ when available. * libguile/filesys.h (scm_chownat): Make it part of the API. * doc/ref/posix.texi (File System): Document it. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* Define a Scheme binding to ‘unlinkat’ when it exists.Maxime Devos2022-10-212-0/+33
| | | | | | | | | | | | | | | | ‘unlinkat’ is used for both unlinking regular files and removing empty directories. * configure.ac: Detect if ‘unlinkat’ exists. * doc/ref/posix.texi (File System): Document why there is no ‘rmdirat’ procedure, and document the ‘delete-file-at’ procedure. * libguile/filesys.c (scm_rmdir): Adjust the docstring here as well. (scm_delete_file_at): Define a Scheme binding to ‘unlinkat’. * libguile/filesys.h (scm_delete_file_at): Make ‘scm_delete_file_at’ part of the C API. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* Define a Scheme binding to ‘fchmodat’ when it exists.Maxime Devos2022-10-212-0/+37
| | | | | | | | | * configure.ac: Detect existence of fchmodat. * libguile/filesys.c (scm_chmodat): New procedure. * libguile/filesys.h (scm_chmodat): Make it part of the API. * test-suite/tests/filesys.test ("chmodat"): Test it. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* Define a Scheme binding to ‘renameat’ when it exists.Maxime Devos2022-10-212-0/+35
| | | | | | | | | | | * configure.ac: Detect if ‘renameat’ is defined. * libguile/filesys.c (scm_renameat): Define a Scheme binding to the ‘renameat’ system call. * doc/ref/posix.texi (File System): Document it. * libguile/filesys.h (scm_renameat): Make it part of the C API. * test-suite/tests/filesys.test ("rename-file-at"): New tests. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* Define AT_REMOVEDIR and others when available.Maxime Devos2022-10-211-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>
* Define bindings to ‘mkdirat’ when the C function exists.Maxime Devos2022-10-212-0/+26
| | | | | | | | * configure.ac: Detect if ‘mkdirat’ exists. * libguile/filesys.c (scm_mkdirat): Define the Scheme binding. * doc/ref/posix.texi (File System): Document it. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* Define ‘symlinkat’ wrapper when supported.Maxime Devos2022-10-212-0/+24
| | | | | | | | | | | * configure.ac: Detect whether ‘symlinkat’ exists. * libguile/filesys.c (scm_symlinkat): Define a Scheme binding when it exists. * libguile/filesys.h: Make the binding part of the public C API. * doc/ref/posix.texi (File System): Document the binding. * test-suite/tests/filesys.test ("symlinkat"): Test it. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* Allow file ports in ‘utime’.Maxime Devos2022-10-212-7/+23
| | | | | | | | | | | | 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>
* Allow file ports in ‘readlink’.Maxime Devos2022-10-211-9/+43
| | | | | | | | | | | * configure.ac: Detect whether ‘readlinkat’ is defined. * libguile/filesys.c (scm_readlink): Support file ports when ‘readlinkat’ exists. (scm_init_filesys): Provide ‘chdir-ports’ when it exists. * doc/ref/posix.texi (File System): Document it. * test-suite/tests/filesys.test ("readlink"): Test it. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* Allow file ports in ‘chdir’ when supported.Maxime Devos2022-10-211-1/+22
| | | | | | | | | | | | | * configure.ac: Check for ‘fchdir’. * libguile/filesys.c (scm_chdir): Support file ports. (scm_init_filesys): Report support of file ports. * doc/ref/posix.texi (Processes): Update accordingly. * doc/ref/guile.texi: Add copyright line for new documentation in this patch and later patches. * test-suite/tests/filesys.test ("chdir"): Test it. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* Fixes arg type for scm_integer_from_mpzMichael Gran2022-10-151-1/+1
| | | | | | | | The definition and the declaration for scm_integer_from_mpz do not match * libguile/integers.c (scm_integer_from_mpz): takes const mpz_t arg No callers need to be changed.
* Presumes signal handler return voidMichael Gran2022-10-141-17/+7
| | | | | | | | | | Since Guile requires a C99 compiler, we can rely on signal handlers returning void, not int. * configure.ac: remove AC_TYPE_SIGNAL * libguile/scmsigs.c (SIGRETTYPE): remove SIGRETTYPE (take_signal): returns void (scm_sigaction_for_thread): presumes handlers return void
* Remove special logic for the obscure CMU C library's libc.hMike Gran2022-10-142-8/+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
* Presume time.h and sys/time.h don't conflict when includedMike Gran2022-10-142-16/+4
| | | | | | | | | | | | 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
* Presume ISO C90 functions are always availableMike Gran2022-10-143-16/+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
* Presume ISO C90 headers are always availableMike Gran2022-10-1410-56/+12
| | | | | | | | | | | | | | | | | | | | | | | | This includes <assert.h>, <ctype.h>, <errno.h>, <float.h>, <iso646.h>, <limits.h>, <locale.h>, <math.h>, <setjmp.h>, <signal.h>, <stdarg.h>, <stddef.h>, <stdio.h>, <stdlib.h>, <string.h>, <time.h>, <wchar.h>, and <wctype.h>. * configure.ac: don't check for <limits.h>, <string.h>, <time.h>, <assert.h>. Remove AC_INCLUDES_DEFAULT macro * libguile/bytevectors.c: include <limits.h>, remove HAVE_LIMITS_H * libguile/filesys.c: include <string.h>, remove HAVE_STRING_H * libguile/fports.c: include <string.h>, remove HAVE_STRING_H * libguile/gen-scmconfig.c: remove HAVE_LIMITS_H, HAVE_TIME_H, STDC_HEADERS Remove SCM_HAVE_STDC_HEADERS * libguile/hash.c: include <wchar.h>, remove HAVE_WCHAR_H * libguile/net_db.c: include <string.h>, remove HAVE_STRING_H * libguile/numbers.h: remove SCM_HAVE_STDC_HEADERS * libguile/regex-posix.c: include <wchar.h>, remove HAVE_WCHAR_H (fixup_multibyte_match): always defined (scm_regexp_exec): use fixup_multibyte_match * libguile/scmsigs.c: remove STDC_HEADERS * libguile/socket.c: include <string.h>, remove HAVE_STRING_H * test-suite/standalone/test-unwind.c: include <string.h>, remove HAVE_STRING_H
* Define SO_RCVTIMEO and SO_SNDTIMEO.Christopher Baines2022-10-121-0/+44
| | | | | | | | | | | | | These are important for reliable networking, since they prevent network operations from hanging indefinitely. * libguile/socket.c (scm_init_socket): Define SO_RCVTIMEO and SO_SNDTIMEO. (scm_getsockopt, scm_setsockopt): Include SO_RCVTIMEO and SO_SNDTIMEO in docstring and handle them. * doc/ref/posix.texi (Network Sockets and Communication): Document them. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* Finalization thread exits when it gets EOF on its pipe.Ludovic Courtès2022-10-011-3/+6
| | | | | | | | Avoids spurious "error in finalization thread: Success" messages when the finalization pipe gets closed. * libguile/finalizers.c (finalization_thread_proc): Return when 'data.n' is zero.
* Fix bad arguments to range_error() in numbers.cDaniel Llorens2022-09-301-2/+2
| | | | Fixes https://debbugs.gnu.org/cgi/bugreport.cgi?bug=58154. Ouch.
* 'pipe' now takes an optional 'flags' parameter.Ludovic Courtès2022-09-192-7/+47
| | | | | | | | | | | | | 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.
* 'primitive-load' opens files with O_CLOEXEC.Ludovic Courtès2022-09-071-2/+2
| | | | | | | | Fixes <https://bugs.gnu.org/57567>. * libguile/load.c (scm_primitive_load): Add "e" flag to 'scm_open_file_with_encoding' argument. * NEWS: Update.
* Add support for "e" flag (O_CLOEXEC) to 'open-file'.Ludovic Courtès2022-09-071-1/+7
| | | | | | | | | * libguile/fports.c (scm_i_mode_to_open_flags): Add 'e' case. (scm_open_file_with_encoding): Document it. * test-suite/standalone/test-close-on-exec: New file. * test-suite/standalone/Makefile.am (check_SCRIPTS, TESTS): Add it. * doc/ref/api-io.texi (File Ports): Document it. * NEWS: Update.
* 'system*' can no longer close file descriptor 2.Ludovic Courtès2022-08-051-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.
* Define IPPROTO_IPV6 and IPV6_V6ONLY.Ludovic Courtès2022-07-041-0/+7
| | | | | * libguile/socket.c (scm_init_socket): Define IPPROTO_IPV6 and IPV6_V6ONLY. * doc/ref/posix.texi (Network Sockets and Communication): Document them.
* Define IN6ADDR_ANY and IN6ADDR_LOOPBACK.Ludovic Courtès2022-07-041-0/+2
| | | | | * libguile/socket.c (scm_init_socket): Define IN6ADDR_ANY and IN6ADDR_LOOPBACK. * doc/ref/posix.texi (Network Address Conversion): Document them.
* Allow null bytes in UNIX sockets.Liliana Marie Prikler2022-06-161-6/+14
| | | | | | | | | | | | | | | | | | | | | | The current socket address constructors all assume, that there are no null bytes in the socket path. This assumption does not hold in Linux, which uses an initial null byte to demarcate abstract sockets and ignores all further null bytes [1]. [1] https://www.man7.org/linux/man-pages/man7/unix.7.html * libguile/sockets.c (scm_fill_sockaddr)[HAVE_UNIX_DOMAIN_SOCKETS]: Use scm_to_locale_stringn to construct c_address. Use memcpy instead of strcpy and calculate size directly instead of using SUN_LEN. (_scm_from_sockaddr): Copy the entire path up to the limits imposed by addr_size. * test-suite/tests/00-socket.test: ("make-socket-address"): Add case for abstract unix sockets. ("AF_UNIX/SOCK_STREAM"): Add abstract socket versions of bind, listen, connect and accept. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* 'connect' handles EAGAIN like EINPROGRESS.Ludovic Courtès2022-06-161-1/+1
| | | | | | * libguile/socket.c (scm_connect): Handle EAGAIN the same way as EINPROGRESS (connect(2) returns EAGAIN for Unix-domain sockets and socketpairs).
* Find unidata_to_charset.awk from commit 9f8e05e5 in $(srcdir).Mikael Djurfeldt2022-04-081-2/+2
| | | | | * libguile/Makefile.am: Find unidata_to_charset.awk in $(srcdir) in order to support building in a separate directory.