summaryrefslogtreecommitdiff
path: root/libguile
AgeCommit message (Collapse)AuthorFilesLines
2023-01-14Add 'bytevector-slice'.Ludovic Courtès2-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.
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 Poiret2-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>
2022-12-21Patch for bug #60234Daniel Llorens1-1/+2
See https://debbugs.gnu.org/60234. gcc warns about the extra extern, but we get rid of the tls model mismatch error.
2022-12-20fix Apple Silicon JIT compilationAleix Conchillo Flaqué1-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
2022-11-20Fix possible deadlock in 'lock-mutex'.Olivier Dion1-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>
2022-11-20Work around unwanted stack retention when using prompts.Ludovic Courtès1-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.
2022-10-21Define Scheme bindings to ‘openat’ when available.Maxime Devos3-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>
2022-10-21Define a Scheme binding to ‘fstatat’ when available.Maxime Devos3-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>
2022-10-21Define a Scheme binding to ‘fchownat’ when it exists.Maxime Devos2-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>
2022-10-21Define a Scheme binding to ‘unlinkat’ when it exists.Maxime Devos2-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>
2022-10-21Define a Scheme binding to ‘fchmodat’ when it exists.Maxime Devos2-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>
2022-10-21Define a Scheme binding to ‘renameat’ when it exists.Maxime Devos2-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>
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-21Define bindings to ‘mkdirat’ when the C function exists.Maxime Devos2-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>
2022-10-21Define ‘symlinkat’ wrapper when supported.Maxime Devos2-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>
2022-10-21Allow file ports in ‘utime’.Maxime Devos2-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>
2022-10-21Allow file ports in ‘readlink’.Maxime Devos1-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>
2022-10-21Allow file ports in ‘chdir’ when supported.Maxime Devos1-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>
2022-10-15Fixes arg type for scm_integer_from_mpzMichael Gran1-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.
2022-10-14Presumes signal handler return voidMichael Gran1-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
2022-10-14Remove special logic for the obscure CMU C library's libc.hMike Gran2-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
2022-10-14Presume time.h and sys/time.h don't conflict when includedMike Gran2-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
2022-10-14Presume ISO C90 functions are always availableMike Gran3-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
2022-10-14Presume ISO C90 headers are always availableMike Gran10-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
2022-10-12Define SO_RCVTIMEO and SO_SNDTIMEO.Christopher Baines1-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>
2022-10-01Finalization thread exits when it gets EOF on its pipe.Ludovic Courtès1-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.
2022-09-30Fix bad arguments to range_error() in numbers.cDaniel Llorens1-2/+2
Fixes https://debbugs.gnu.org/cgi/bugreport.cgi?bug=58154. Ouch.
2022-09-19'pipe' now takes an optional 'flags' parameter.Ludovic Courtès2-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.
2022-09-07'primitive-load' opens files with O_CLOEXEC.Ludovic Courtès1-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.
2022-09-07Add support for "e" flag (O_CLOEXEC) to 'open-file'.Ludovic Courtès1-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.
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.
2022-07-04Define IPPROTO_IPV6 and IPV6_V6ONLY.Ludovic Courtès1-0/+7
* libguile/socket.c (scm_init_socket): Define IPPROTO_IPV6 and IPV6_V6ONLY. * doc/ref/posix.texi (Network Sockets and Communication): Document them.
2022-07-04Define IN6ADDR_ANY and IN6ADDR_LOOPBACK.Ludovic Courtès1-0/+2
* libguile/socket.c (scm_init_socket): Define IN6ADDR_ANY and IN6ADDR_LOOPBACK. * doc/ref/posix.texi (Network Address Conversion): Document them.
2022-06-16Allow null bytes in UNIX sockets.Liliana Marie Prikler1-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>
2022-06-16'connect' handles EAGAIN like EINPROGRESS.Ludovic Courtès1-1/+1
* libguile/socket.c (scm_connect): Handle EAGAIN the same way as EINPROGRESS (connect(2) returns EAGAIN for Unix-domain sockets and socketpairs).
2022-04-08Find unidata_to_charset.awk from commit 9f8e05e5 in $(srcdir).Mikael Djurfeldt1-2/+2
* libguile/Makefile.am: Find unidata_to_charset.awk in $(srcdir) in order to support building in a separate directory.
2022-03-24Create 'srfi-14.i.c' during build.Timothy Sample4-5190/+34674
* libguile/srfi-14.i.c: Delete file. * libguile/UnicodeData.txt: New file. * libguile/unidata_to_charset.awk: Skip comments. * libguile/Makefile.am (EXTRA_DIST): Add 'UnicodeData.txt'. (srfi-14.i.c): New rule. (noinst_HEADERS): Remove 'srfi-14.i.c'. (BUILT_INCLUDES, CLEANFILES): Add 'srfi-14.i.c'. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2022-03-24Reimplement 'unidata_to_charset.pl' in Awk.Timothy Sample3-402/+410
* libguile/unidata_to_charset.pl: Delete file. * libguile/unidata_to_charset.awk: New file. * libguile/Makefile.am (EXTRA_DIST): Adjust accordingly. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2022-02-28build: When cross-compiling, get type sizes of the target system.Ludovic Courtès1-16/+16
Fixes <https://issues.guix.gnu.org/54198>. As noted in the comment at the top, 'SIZEOF_TYPE' must be used instead of 'sizeof (TYPE)' to support cross-compilation. The regression was introduced in 5e5afde06fd9dd0992294d6c7dc9f9966c0caa37 but only became apparent with 717e787da6ae75bbaa53139c0ef3791cd758a9d8. * libguile/gen-scmconfig.c (main): Replace uses of 'sizeof' by references to the SIZEOF_* macros. * configure.ac: Add 'AC_CHECK_SIZEOF' call for 'intmax_t'.
2022-02-10Align argument type of scm_to_wchar with its declaration.Mikael Djurfeldt1-1/+1
* libguile/numbers.c (scm_from_wchar): Change argument type from wchar_t to scm_t_wchar which is the argument type in numbers.h.
2022-02-10Align return type of scm_to_wchar with its declaration.Mikael Djurfeldt1-1/+1
* libguile/numbers.c (scm_t_wchar): Change return type from wchar_t to scm_t_wchar which is the return type in numbers.h.
2022-02-07'string->symbol' avoids copying the underlying string.Ludovic Courtès1-3/+9
* libguile/strings.c (scm_i_make_symbol): Reuse NAME's stringbuf unless it's mutable or NAME starts at a non-zero offset or has a different length.
2022-02-06Update unicode tables to Unicode 14.0.0; initial charsets immutableAndy Wingo3-9993/+5182
* libguile/srfi-14.i.c: Update from Unicode 14.0.0. * libguile/unidata_to_charset.pl (compute): Write arrays as static const data, to avoid polluting the namespace and to avoid adding these to the GC root set. * libguile/srfi-14.c (SCM_CODEPOINT_F_IMMUTABLE): New flag. (scm_charset_is_immutable): New internal predicate. (SCM_VALIDATE_MUTABLE_CHARSET): New internal validator. (cs_full_ranges, cs_full_ranges_len): Re-express as separate ranges and len, because the ranges pointer in scm_t_char_set is mutable. (scm_char_set_unfold_x, scm_list_to_char_set_x) (scm_string_to_char_set_x, scm_char_set_filter_x) (scm_i_ucs_range_to_char_set, scm_char_set_adjoin_x) (scm_char_set_delete_x, scm_char_set_complement_x) (scm_char_set_unfold_x, scm_char_set_intersection_x) (scm_char_set_difference_x, scm_char_set_xor_x): Require mutable charsets. (define_charset): Add immutable flag. (scm_init_srfi_14): Adapt initial charset definitions.
2022-02-04Deprecate symbol properties.Ludovic Courtès6-68/+76
* libguile/strings.c (scm_i_make_symbol): Remove 'props' argument. Use 3 words instead of 'scm_double_cell'. * libguile/strings.h: Adjust accordingly. * libguile/symbols.c (scm_i_str2symbol, scm_i_str2uninterned_symbol): Likewise. (scm_symbol_fref, scm_symbol_pref, scm_symbol_fset_x, scm_symbol_pset_x): Move to... * libguile/deprecated.c: ... here. Rewrite in terms of object properties. (symbol_function_slot, symbol_property_slot): New variables. * libguile/symbols.h (SCM_SYMBOL_FUNC, SCM_SET_SYMBOL_FUNC) (SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS) (scm_symbol_fref, scm_symbol_pref, scm_symbol_fset_x) (scm_symbol_pset_x): Move to... * libguile/deprecated.h: ... here. Mark declarations as 'SCM_DEPRECATED'. * module/system/base/types.scm (cell->object): Remove 'props' field for %TC7-SYMBOL. * doc/ref/api-data.texi (Symbol Props): Remove. * NEWS: Update.
2022-02-03Remove unused 'scm_i_c_make_symbol'.Ludovic Courtès2-14/+0
* libguile/strings.c (scm_i_c_make_symbol): Remove. * libguile/strings.h (scm_i_c_make_symbol): Remove declaration.
2022-02-01Slight bignum-fixnum multiplication optimizationAndy Wingo1-4/+8
* libguile/integers.c (scm_integer_mul_zi): Use mpn_mul_1.
2022-01-13Remove dead code in scm_integer_inexact_sqrt_zAndy Wingo1-4/+0
* libguile/integers.c (scm_integer_inexact_sqrt_z): Remove some dead code.
2022-01-13Have log and log10(real nan) return real nan regardless of signDaniel Llorens1-8/+9
* libguile/numbers.c (log_of_shifted_double, scm_log10): Avoid complex extension when the argument is a real nan. * test-suite/tests/numbers.test: Tests for nans of either sign.