summaryrefslogtreecommitdiff
path: root/libguile
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Create 'srfi-14.i.c' during build.Timothy Sample2022-03-244-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>
* Reimplement 'unidata_to_charset.pl' in Awk.Timothy Sample2022-03-243-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>
* build: When cross-compiling, get type sizes of the target system.Ludovic Courtès2022-02-281-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'.
* Align argument type of scm_to_wchar with its declaration.Mikael Djurfeldt2022-02-101-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.
* Align return type of scm_to_wchar with its declaration.Mikael Djurfeldt2022-02-101-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.
* 'string->symbol' avoids copying the underlying string.Ludovic Courtès2022-02-071-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.
* Update unicode tables to Unicode 14.0.0; initial charsets immutableAndy Wingo2022-02-063-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.
* Deprecate symbol properties.Ludovic Courtès2022-02-046-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.
* Remove unused 'scm_i_c_make_symbol'.Ludovic Courtès2022-02-032-14/+0
| | | | | * libguile/strings.c (scm_i_c_make_symbol): Remove. * libguile/strings.h (scm_i_c_make_symbol): Remove declaration.
* Slight bignum-fixnum multiplication optimizationAndy Wingo2022-02-011-4/+8
| | | | * libguile/integers.c (scm_integer_mul_zi): Use mpn_mul_1.
* Remove dead code in scm_integer_inexact_sqrt_zAndy Wingo2022-01-131-4/+0
| | | | | * libguile/integers.c (scm_integer_inexact_sqrt_z): Remove some dead code.
* Have log and log10(real nan) return real nan regardless of signDaniel Llorens2022-01-131-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.
* Don't use HAVE_COPYSIGN in libguile/numbers.cDaniel Llorens2022-01-131-4/+0
| | | | | * libguile/numbers.c (icmplx2str): As stated. copysign() is required by C99 and already used without guards elsewhere in this file.
* Simplify scm_abs for the real caseDaniel Llorens2022-01-131-11/+1
| | | | | | * libguile/numbers.c (scm_abs): As stated. When x is a nan with the sign bit set, this changes the behavior of (magnitude x) back to what it was in 3.0.7, to clear that bit.
* Optimize logand against a positive inumAndy Wingo2022-01-131-0/+12
| | | | * libguile/integers.c (scm_integer_logand_zi): Optimize.
* Optimize integer-expt for fixnumsAndy Wingo2022-01-131-0/+21
| | | | | * libguile/integers.c (scm_integer_expt_ii): Add some optimizations for cases in which we can avoid allocating an mpz.
* Optimize scm_integer_mul_iiAndy Wingo2022-01-131-11/+17
| | | | | * libguile/integers.c (make_bignum_2): Always include. (scm_integer_mul_ii): Avoid making a temporary allocation.
* Optimize bignum subtractionAndy Wingo2022-01-131-29/+47
| | | | | | * libguile/integers.c (scm_integer_sub_iz): (scm_integer_sub_zi): (scm_integer_sub_zz): Optimize to avoid temporary allocations.
* Optimize bignum add to avoid temporary allocationsAndy Wingo2022-01-131-26/+106
| | | | | | | * libguile/integers.c (do_add_1, do_add, do_sub_1, do_sub, do_cmp): New helpers. (scm_integer_add_zi): (scm_integer_add_zz): Use new helpers.
* Avoid bignum clone in scm_integer_sub_zzAndy Wingo2022-01-131-2/+10
| | | | | | * libguile/integers.c (scm_integer_abs_z): Just call scm_integer_negate_z if negation is needed. (scm_integer_sub_zz): Use mpz_sub instead of cloning bignum.
* Start to optimize scm_integer_sub_izAndy Wingo2022-01-131-1/+13
| | | | * libguile/integers.c (scm_integer_sub_iz): Avoid cloning bignum.
* Less pessimal scm_integer_sub_ziAndy Wingo2022-01-131-4/+16
| | | | | * libguile/integers.c (scm_integer_sub_zi): Only delegate to scm_integer_add_ii if y is negative.
* Optimize scm_integer_mul_zz.Andy Wingo2022-01-131-6/+18
| | | | | * libguile/integers.c (scm_integer_mul_zz): Optimize to avoid temporary allocations.
* Optimize scm_integer_mul_ziAndy Wingo2022-01-131-5/+25
| | | | | | * libguile/integers.c (bignum_trim1): (bignum_negate_if): New helpers. (scm_integer_mul_zi): Use the mpn API to avoid temporary allocation.
* Re-rewrite integer-expt in CAndy Wingo2022-01-133-13/+134
| | | | | | | | | | | Calling out to Scheme was a performance regression. * libguile/integers.h: * libguile/integers.c (scm_integer_expt_ii, scm_integer_expt_zi): New internal functions. * libguile/numbers.c (scm_integer_expt): Go back to C. But, include fast cases for inums and doubles. * module/ice-9/boot-9.scm: Revert addition of integer-expt.
* Fix bug when making mpz from 0Andy Wingo2022-01-131-3/+9
| | | | | | | * libguile/integers.c (make_bignum_0): New helper. (make_bignum_from_uint64): (ulong_to_bignum): (long_to_bignum): Call new helper as appropriate.
* take_mpz optimizationAndy Wingo2022-01-131-2/+6
| | | | | * libguile/integers.c (take_mpz): Avoid making a bignum if the value is fixable.
* Bignums avoid both custom GMP allocator and finalizersAndy Wingo2022-01-134-183/+111
| | | | | | | | | | | | | | | | | | | | | * libguile/deprecated.c (make_bignum): Move here from numbers.c, to support scm_i_long2big etc. (scm_i_big2dbl): (scm_i_long2big): (scm_i_ulong2big): (scm_i_clonebig): (scm_i_normbig): Deprecate. (scm_install_gmp_memory_functions): Deprecate, happily! SCM bignums now have digits allocated inline with the bignum itself, so they are completely transparent to the GC already. The price is that if GMP ever allocates digits via the MPZ API, those digits then have to be copied back into managed memory. But we avoid having to install finalizers and we avoid having to muck with GMP's allocator. * libguile/numbers.c (scm_from_mpz): Use scm_integer_from_mpz. (scm_init_numbers): Never muck with GMP's allocators. * doc/ref/guile-invoke.texi (Environment Variables): Remove note about GUILE_INSTALL_GMP_MEMORY_FUNCTIONS. * meta/build-env.in: No need to set GUILE_INSTALL_GMP_MEMORY_FUNCTIONS.
* scm_to_ipv6 uses scm_to_mpzAndy Wingo2022-01-131-5/+11
| | | | * libguile/socket.c (scm_to_ipv6): Use scm_to_mpz.