1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00
Commit graph

9431 commits

Author SHA1 Message Date
Michael Gran
0bebd7a327 Adds automake option for subdirs
Automake warns about the lack of subdir-objects in AUTOMAKE_OPTIONS
because lightening is in a subdirectory of libguile.

* libguile/Makefile.am (AUTOMAKE_OPTIONS): add subdir-objects
2022-10-08 06:20:02 -07:00
Michael Gran
c0feb578fb Presumes signal handler return void
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-08 06:20:02 -07:00
Mike Gran
e75b13d18a Remove special logic for the obscure CMU C library's libc.h
* 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-08 06:20:01 -07:00
Mike Gran
6bf4b89129 Presume time.h and sys/time.h don't conflict when included
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-08 06:20:00 -07:00
Mike Gran
dccc073a83 Presume ISO C90 functions are always available
* 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-08 06:19:40 -07:00
Mike Gran
5cb6a0faae Presume ISO C90 headers are always available
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-08 06:16:35 -07:00
Ludovic Courtès
df86a2a8c8 Finalization thread exits when it gets EOF on its pipe.
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-10-01 16:00:05 +02:00
Daniel Llorens
c0004442b7 Fix bad arguments to range_error() in numbers.c
Fixes https://debbugs.gnu.org/cgi/bugreport.cgi?bug=58154. Ouch.
2022-09-30 12:02:12 +02:00
Ludovic Courtès
1d313bf5f0 'pipe' now takes an optional 'flags' parameter.
This is the same strategy as used for the 'accept4' bindings introduced
in 6e0965104c.

* 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-19 22:30:16 +02:00
Ludovic Courtès
0aa1a9976f 'primitive-load' opens files with O_CLOEXEC.
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-07 18:00:30 +02:00
Ludovic Courtès
a356ceebee Add support for "e" flag (O_CLOEXEC) to 'open-file'.
* 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-09-07 18:00:30 +02:00
Ludovic Courtès
56b1ea9002 'system*' can no longer close file descriptor 2.
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-08-05 14:20:51 +02:00
Ludovic Courtès
abd39f3328 Define IPPROTO_IPV6 and IPV6_V6ONLY.
* libguile/socket.c (scm_init_socket): Define IPPROTO_IPV6 and IPV6_V6ONLY.
* doc/ref/posix.texi (Network Sockets and Communication): Document them.
2022-07-04 11:49:31 +02:00
Ludovic Courtès
6da4be170a Define IN6ADDR_ANY and IN6ADDR_LOOPBACK.
* libguile/socket.c (scm_init_socket): Define IN6ADDR_ANY and IN6ADDR_LOOPBACK.
* doc/ref/posix.texi (Network Address Conversion): Document them.
2022-07-04 11:39:14 +02:00
Liliana Marie Prikler
01b686b701 Allow null bytes in UNIX sockets.
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 09:54:29 +02:00
Ludovic Courtès
64449a835a 'connect' handles EAGAIN like EINPROGRESS.
* libguile/socket.c (scm_connect): Handle EAGAIN the same way as
EINPROGRESS (connect(2) returns EAGAIN for Unix-domain sockets and
socketpairs).
2022-06-16 09:31:36 +02:00
Mikael Djurfeldt
cc45597681 Find unidata_to_charset.awk from commit 9f8e05e5 in $(srcdir).
* libguile/Makefile.am: Find unidata_to_charset.awk in $(srcdir) in
order to support building in a separate directory.
2022-04-08 15:35:34 +02:00
Timothy Sample
9f8e05e513 Create 'srfi-14.i.c' during build.
* 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-24 14:28:46 +01:00
Timothy Sample
63886aeda2 Reimplement 'unidata_to_charset.pl' in Awk.
* 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-03-24 14:28:46 +01:00
Ludovic Courtès
24b30130ca build: When cross-compiling, get type sizes of the target system.
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
5e5afde06f but only became apparent with
717e787da6.

* 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-28 23:00:46 +01:00
Mikael Djurfeldt
27b86a6f32 Align argument type of scm_to_wchar with its declaration.
* 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-10 12:41:59 +01:00
Mikael Djurfeldt
2e10a1257f Align return type of scm_to_wchar with its declaration.
* 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-10 12:36:06 +01:00
Ludovic Courtès
032acdeac9 'string->symbol' avoids copying the underlying string.
* 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-07 12:23:35 +01:00
Andy Wingo
2f9bc7fe61 Update unicode tables to Unicode 14.0.0; initial charsets immutable
* 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-06 21:17:24 +01:00
Ludovic Courtès
8e2e2ceb17 Deprecate symbol properties.
* 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-04 11:12:28 +01:00
Ludovic Courtès
2ebf039707 Remove unused 'scm_i_c_make_symbol'.
* libguile/strings.c (scm_i_c_make_symbol): Remove.
* libguile/strings.h (scm_i_c_make_symbol): Remove declaration.
2022-02-03 23:23:59 +01:00
Andy Wingo
62fc44e6ee Slight bignum-fixnum multiplication optimization
* libguile/integers.c (scm_integer_mul_zi): Use mpn_mul_1.
2022-02-01 19:57:14 +01:00
Andy Wingo
222b320868 Remove dead code in scm_integer_inexact_sqrt_z
* libguile/integers.c (scm_integer_inexact_sqrt_z): Remove some dead
code.
2022-01-13 09:37:17 +01:00
Daniel Llorens
19bc021e34 Have log and log10(real nan) return real nan regardless of sign
* 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.
2022-01-13 09:37:17 +01:00
Daniel Llorens
4feff820be Don't use HAVE_COPYSIGN in libguile/numbers.c
* libguile/numbers.c (icmplx2str): As stated. copysign() is required by C99 and
  already used without guards elsewhere in this file.
2022-01-13 09:37:17 +01:00
Daniel Llorens
6058d9e05d Simplify scm_abs for the real case
* 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.
2022-01-13 09:37:17 +01:00
Andy Wingo
9e5aa173c7 Optimize logand against a positive inum
* libguile/integers.c (scm_integer_logand_zi): Optimize.
2022-01-13 09:37:17 +01:00
Andy Wingo
6fe43301aa Optimize integer-expt for fixnums
* libguile/integers.c (scm_integer_expt_ii): Add some optimizations for
cases in which we can avoid allocating an mpz.
2022-01-13 09:37:17 +01:00
Andy Wingo
2cf80ca238 Optimize scm_integer_mul_ii
* libguile/integers.c (make_bignum_2): Always include.
(scm_integer_mul_ii): Avoid making a temporary allocation.
2022-01-13 09:37:17 +01:00
Andy Wingo
210ab8ff76 Optimize bignum subtraction
* libguile/integers.c (scm_integer_sub_iz):
(scm_integer_sub_zi):
(scm_integer_sub_zz): Optimize to avoid temporary allocations.
2022-01-13 09:37:17 +01:00
Andy Wingo
cc52f01aba Optimize bignum add to avoid temporary allocations
* 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.
2022-01-13 09:37:17 +01:00
Andy Wingo
95350aae8c Avoid bignum clone in scm_integer_sub_zz
* 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.
2022-01-13 09:37:17 +01:00
Andy Wingo
cae8b30163 Start to optimize scm_integer_sub_iz
* libguile/integers.c (scm_integer_sub_iz): Avoid cloning bignum.
2022-01-13 09:37:17 +01:00
Andy Wingo
2723513712 Less pessimal scm_integer_sub_zi
* libguile/integers.c (scm_integer_sub_zi): Only delegate to
scm_integer_add_ii if y is negative.
2022-01-13 09:37:17 +01:00
Andy Wingo
ad6811a12b Optimize scm_integer_mul_zz.
* libguile/integers.c (scm_integer_mul_zz): Optimize to avoid temporary
allocations.
2022-01-13 09:37:17 +01:00
Andy Wingo
d89f75c535 Optimize scm_integer_mul_zi
* libguile/integers.c (bignum_trim1):
(bignum_negate_if): New helpers.
(scm_integer_mul_zi): Use the mpn API to avoid temporary allocation.
2022-01-13 09:37:17 +01:00
Andy Wingo
5481222670 Re-rewrite integer-expt in C
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.
2022-01-13 09:37:17 +01:00
Andy Wingo
eac47c3e45 Fix bug when making mpz from 0
* libguile/integers.c (make_bignum_0): New helper.
(make_bignum_from_uint64):
(ulong_to_bignum):
(long_to_bignum): Call new helper as appropriate.
2022-01-13 09:37:17 +01:00
Andy Wingo
443d239828 take_mpz optimization
* libguile/integers.c (take_mpz): Avoid making a bignum if the value is
fixable.
2022-01-13 09:37:17 +01:00
Andy Wingo
aa5455ea98 Bignums avoid both custom GMP allocator and finalizers
* 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.
2022-01-13 09:37:17 +01:00
Andy Wingo
a0765f564a scm_to_ipv6 uses scm_to_mpz
* libguile/socket.c (scm_to_ipv6): Use scm_to_mpz.
2022-01-13 09:37:17 +01:00
Andy Wingo
e78bcdc29a Finish srfi-60 port off old scm mpz API
* libguile/srfi-60.c (scm_srfi60_rotate_bit_field)
(scm_srfi60_reverse_bit_field, scm_srfi60_integer_to_list)
(scm_srfi60_list_to_integer): Update.
2022-01-13 09:37:17 +01:00
Andy Wingo
399d0c8745 Start porting srfi-60 off the bad bignum interfaces
* libguile/integers.h:
* libguile/integers.c (scm_integer_scan1_i):
(scm_integer_scan1_z): New internal functions.
* libguile/srfi-60.c (scm_srfi60_log2_binary_factors): Use scan1
functions.
(scm_srfi60_copy_bit): Use integers lib.
2022-01-13 09:37:17 +01:00
Andy Wingo
bdddef3cfd Avoid scm_i_mkbig outside numbers.c.
* libguile/random.c (scm_c_random_bignum):
* libguile/socket.c (scm_from_ipv6): Avoid scm_i_mkbig.
* libguile/numbers.h:
* libguile/numbers.c (scm_i_mkbig): Remove.
2022-01-13 09:37:17 +01:00
Andy Wingo
0c502a4d3c Use scm_integer_to_double_z in numbers.c instead of big2dbl
* libguile/numbers.c: Use internal function instead of big2dbl which we
will deprecate.
2022-01-13 09:37:17 +01:00