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

20859 commits

Author SHA1 Message Date
Andy Wingo
025c7c8045 Implement round-divide with new integer lib
* libguile/integers.c (scm_integer_round_divide_ii)
(scm_integer_round_divide_iz, scm_integer_round_divide_zi)
(scm_integer_round_divide_zz): New internal functions.
(integer_round_divide_zz): New helper.
* libguile/integers.h: Declare internal functions.
* libguile/numbers.c (scm_round_divide): Use the new functions.
(scm_i_bigint_round_divide): Remove unused helper.
2022-01-13 09:37:16 +01:00
Andy Wingo
b114642640 Implement round-remainder with new integer lib
* libguile/integers.c (scm_integer_round_remainder_ii)
(scm_integer_round_remainder_iz, scm_integer_round_remainder_zi)
(scm_integer_round_remainder_zz): New internal functions.
(integer_round_remainder_zz): New helper.
(long_sign, bignum_cmp_long): New helpers.
* libguile/integers.h: Declare internal functions.
* libguile/numbers.c (scm_round_remainder): Use the new functions.
(scm_i_bigint_round_remainder): Remove unused helper.
2022-01-13 09:37:16 +01:00
Andy Wingo
9a358a9632 Implement round-quotient with new integer lib
* libguile/integers.c (scm_integer_round_quotient_ii)
(scm_integer_round_quotient_iz, scm_integer_round_quotient_zi)
(scm_integer_round_quotient_zz): New internal functions.
(integer_round_quotient_zz): New helper.
(long_sign, bignum_cmp_long): New helpers.
* libguile/integers.h: Declare internal functions.
* libguile/numbers.c (scm_round_quotient): Use the new functions.
(scm_i_bigint_round_quotient): Remove unused helper.
2022-01-13 09:37:16 +01:00
Andy Wingo
ccb78fc7b1 Implement centered-divide with new integer lib
* libguile/integers.c (scm_integer_centered_divide_ii)
(scm_integer_centered_divide_iz, scm_integer_centered_divide_zi)
(scm_integer_centered_divide_zz): New internal functions.
(integer_centered_divide_zz): New helper.
* libguile/integers.h: Declare internal functions.
* libguile/numbers.c (scm_centered_divide): Use the new functions.
(scm_i_bigint_centered_divide): Remove unused helper.
2022-01-13 09:37:16 +01:00
Andy Wingo
99b046d58b Implement centered-remainder with new integer lib
* libguile/integers.c (scm_integer_centered_remainder_ii)
(scm_integer_centered_remainder_iz, scm_integer_centered_remainder_zi)
(scm_integer_centered_remainder_zz): New internal functions.
* libguile/integers.h: Declare internal functions.
* libguile/numbers.c (scm_centered_remainder): Use the new functions.
(scm_i_bigint_centered_remainder): Remove helper.
2022-01-13 09:37:16 +01:00
Andy Wingo
0ccdf06c81 Implement centered-quotient with new integer lib
* libguile/integers.c (scm_integer_centered_quotient_ii)
(scm_integer_centered_quotient_iz, scm_integer_centered_quotient_zi)
(scm_integer_centered_quotient_zz): New internal functions.
* libguile/integers.h: Declare internal functions.
* libguile/numbers.c (scm_centered_quotient): Use the new functions.
(scm_i_bigint_centered_quotient): Remove unused helper.
2022-01-13 09:37:16 +01:00
Andy Wingo
f8a92773ac Implement truncate-divide with new integer lib
* libguile/integers.c (scm_integer_truncate_divide_ii)
(scm_integer_truncate_divide_iz, scm_integer_truncate_divide_zi)
(scm_integer_truncate_divide_zz): New internal functions.
* libguile/integers.h: Declare internal functions.
* libguile/numbers.c (scm_truncate_divide): Use the new functions.
2022-01-13 09:37:16 +01:00
Andy Wingo
cbd62a0ef3 Implement truncate-remainder with new integer lib
* libguile/integers.c (scm_integer_truncate_remainder_ii)
(scm_integer_truncate_remainder_iz, scm_integer_truncate_remainder_zi)
(scm_integer_truncate_remainder_zz): New internal functions.
* libguile/integers.h: Declare internal functions.
* libguile/numbers.c (scm_truncate_remainder): Use the new functions.
2022-01-13 09:37:16 +01:00
Andy Wingo
ff636774b4 Implement truncate-quotient with new integer lib
* libguile/integers.c (scm_integer_truncate_quotient_ii)
(scm_integer_truncate_quotient_iz, scm_integer_truncate_quotient_zi)
(scm_integer_truncate_quotient_zz): New internal functions.
* libguile/integers.h: Declare internal functions.
* libguile/numbers.c (scm_truncate_quotient): Use the new functions.
2022-01-13 09:37:16 +01:00
Andy Wingo
1e1b230223 Implement ceiling-divide with new integer lib
* libguile/integers.c (scm_integer_ceiling_divide_ii)
(scm_integer_ceiling_divide_iz, scm_integer_ceiling_divide_zi)
(scm_integer_ceiling_divide_zz): New internal functions.
* libguile/integers.h: Declare internal functions.
* libguile/numbers.c (scm_ceiling_divide): Use the new functions.
2022-01-13 09:37:16 +01:00
Andy Wingo
55f93d7d29 Implement ceiling-remainder with new integer lib
* libguile/integers.c (scm_integer_ceiling_remainder_ii)
(scm_integer_ceiling_remainder_iz, scm_integer_ceiling_remainder_zi)
(scm_integer_ceiling_remainder_zz): New internal functions.
(bignum_is_positive): New helper.
* libguile/integers.h: Declare internal functions.
* libguile/numbers.c (scm_ceiling_remainder): Use the new functions.
2022-01-13 09:37:16 +01:00
Andy Wingo
c1d8dd5e6a Implement ceiling-quotient with new integer lib
* libguile/integers.c (scm_integer_ceiling_quotient_ii)
(scm_integer_ceiling_quotient_iz, scm_integer_ceiling_quotient_zi)
(scm_integer_ceiling_quotient_zz): New internal functions.
(take_bignum_from_mpz): Change to also normalize the mpz, as all callers
required.
(long_sign, bignum_cmp_long): New helpers.
* libguile/integers.h: Declare internal functions.
* libguile/numbers.c (scm_ceiling_quotient): Use the new functions.
2022-01-13 09:37:16 +01:00
Andy Wingo
8a63537458 Implement floor-divide with new integer lib
* libguile/integers.c (scm_integer_floor_divide_ii)
(scm_integer_floor_divide_iz, scm_integer_floor_divide_zi)
(scm_integer_floor_divide_zz): New internal functions.
* libguile/integers.h: Declare internal functions.
* libguile/numbers.c (scm_floor_divide): Use the new functions.
2022-01-13 09:37:16 +01:00
Andy Wingo
2e8036ff0f Implement floor-remainder with new integer lib
* libguile/integers.c (scm_integer_floor_remainder_ii)
(scm_integer_floor_remainder_iz, scm_integer_floor_remainder_zi)
(scm_integer_floor_remainder_zz): New internal functions.
* libguile/integers.h: Declare internal functions.
* libguile/numbers.c (scm_floor_remainder): Use the new functions.
2022-01-13 09:37:16 +01:00
Andy Wingo
31da9be6c4 Implement floor-quotient with new integer lib
* libguile/integers.c (scm_integer_floor_quotient_ii)
(scm_integer_floor_quotient_iz, scm_integer_floor_quotient_zi)
(scm_integer_floor_quotient_zz): New internal functions.
(long_to_scm, ulong_to_scm, take_bignum_from_mpz): New helpers.
* libguile/integers.h: Declare internal functions.
* libguile/numbers.c (scm_floor_quotient): Use the new functions.
2022-01-13 09:37:16 +01:00
Andy Wingo
44c654aa3e Implement abs with new integer lib
* libguile/integers.c (scm_integer_abs_i, scm_integer_abs_z): New
internal functions.
* libguile/integers.h: Declare internal functions.
* libguile/numbers.c (scm_abs): Use the new functions.
2022-01-13 09:37:16 +01:00
Andy Wingo
5321899b9a Implement odd? and even? with new integer lib
* libguile/integers.c (scm_is_integer_odd_i):
(scm_is_integer_odd_z): New internal functions.  Add a number of
internal support routines.
* libguile/integers.h: Declare internal functions.
* libguile/numbers.c (scm_odd_p, scm_even_p): Use the new functions.
2022-01-13 09:37:16 +01:00
Andy Wingo
c768115d93 Add new integers.[ch]
The goal is to factor out some fixnum/bignum code here from
numbers.[ch].

* libguile/Makefile.am: Add new files.
* libguile/integers.c:
* libguile/integers.h: New files
2022-01-13 09:37:16 +01:00
Andy Wingo
52e310a2ac Avoid quadratic behavior in id-var-name
* module/ice-9/psyntax.scm (id-var-name): Avoid list-ref.
* module/ice-9/psyntax-pp.scm: Regenerate.
2022-01-13 09:35:53 +01:00
Andy Wingo
1148eb5051 -Oresolve-free-vars pass gracefully handles failed autoloads.
* module/language/tree-il/resolve-free-vars.scm (make-resolver):
Gracefully handle failed autoloads.
2022-01-11 21:32:40 +01:00
Andy Wingo
0e505b7036 Fix type confusion in heap-numbers-equal? calls from VM
When heap-numbers-equal? is called from eqv?, we have already ensured
that the both objects have the same heap type.  However when called by
the VM, the precondition is just that both are heap numbers -- not
necessarily of the same type.  Fix to add an additional check in
heap-numbers-equal?.  Could cause crashers!

* libguile/eq.c (scm_i_heap_numbers_equal_p): Add additional check.
2022-01-07 14:18:22 +01:00
Daniel Llorens
d70c1dbebf New function bitvector-copy (scm_bitvector_copy)
* libguile/bitvectors.h:
* libguile/bitvectors.c: As stated.
* test-suite/tests/bitvectors.test: Tests.
* doc/ref/api-data.texi: Update "Bit vectors" section.
* NEWS: Update.
2022-01-04 12:28:41 +01:00
Daniel Llorens
dc7f1b403b Review REFFIXME
H/t t20kdc on #guile.
2021-12-13 08:11:29 +01:00
Daniel Llorens
5759e37181 New function srfi-4-vector-type-size in (srfi srfi-4 gnu)
This patch removes the undocumented function make-srfi-4-vector from
(guile). That function is still exported from (srfi srfi-4 gnu).

* libguile/srfi-4.h (scm_init_srfi_4): Split into scm_bootstrap_srfi_4()
  and scm_init_srfi_4(), after the pattern of scm_init_bytevectors() and
  scm_bootstrap_bytevectors().
* libguile/init.c: Replace scm_init_srfi_4() call by scm_bootstrap_srfi_4().
* module/srfi/srfi-4.scm: Load newly defined srfi-4 extension. This
  provides undocumented make-srfi-4-vector.
* module/srfi/srfi-4/gnu.scm: Export srfi-4-vector-type-size.
* doc/ref/srfi-modules.texi: Document srfi-4-vector-type-size.
2021-12-06 14:00:03 +01:00
Mikael Djurfeldt
6af3362b05 Support C99 complex types conditionally in (system foreign)
496f69dba2 introduced C99 complex types in
libguile/foreign.h and (system foreign). Since these types are provided
conditionally in foreign.h based on autoconf tests they need to be used
conditionally in (system foreign) based on their presence.
2021-12-01 18:40:19 +01:00
Mikael Djurfeldt
3badbb71c6 Mention package GNU Autopoint in README.
* README: Mention GNU Autopoint. Needed when building from a Git checkout.
2021-11-25 17:49:57 +01:00
Daniel Llorens
0b136c3098 Fix doc typo
H/t to Damien Mattei in guile-devel.
2021-11-22 16:32:59 +01:00
Andy Wingo
6f1b620b82 Add -Ooptimize-known-return-types at -O2
* module/language/cps/optimize.scm (optimize-first-order-cps):
* module/system/base/optimize.scm (available-optimizations): Add
optimize-known-return-types at -O2.
2021-11-15 15:32:54 +01:00
Andy Wingo
dad113d80f Add new pass to optimize away return value count checks
* module/language/cps/return-types.scm: New file.
* module/Makefile.am (SOURCES):
* am/bootstrap.am (SOURCES): Add new file.
* module/language/tree-il/compile-cps.scm (sanitize-meta): Strip
  "noreturn" and "return-type" properties -- these should only be
  computed by Guile.
2021-11-15 15:32:54 +01:00
Andy Wingo
5c76381625 Allow callk to continue to kargs
* module/language/cps/verify.scm (check-arities): If a callk continues
to kargs, the caller knows the number of return values that the callee
provides and no number-of-values check is needed.
* module/language/cps/contification.scm (apply-contification): Allow
contification of known-return-values calls.
* module/language/cps/reify-primitives.scm (uniquify-receive)
(reify-primitives): No need for uniquify-receive any more as receive
shuffles are attached to the call, not the continuation.
* module/language/cps/compile-bytecode.scm (compile-function): Add kargs
case.
2021-11-15 15:32:54 +01:00
Andy Wingo
4fcd643adb Refactor send and receive shuffles in slot allocation
* module/language/cps/slot-allocation.scm (lookup-send-parallel-moves):
Rename from `lookup-parallel-moves'.
(lookup-receive-parallel-moves): New function.  Now we attach "receive
moves" to call and prompt conts instead of to their continuations.
(compute-shuffles): Refactor to allow a continuation to have both send
and receive shuffles.
(compute-frame-size): Refactor for new shuffles mechanism
(allocate-slots): Allow calls to proceed directly to kargs.
2021-11-15 15:32:54 +01:00
Andy Wingo
a227c84a76 Refactor compile-bytecode
* module/language/cps/compile-bytecode.scm (compile-function): Treat
$kreceive as a forwarding cont, and refactor the treatment of calls and
$values.
2021-11-15 15:32:54 +01:00
Daniel Llorens
496f69dba2 Support C99 complex types in (system foreign)
* libguile/foreign.h (SCM_FOREIGN_TYPE_COMPLEX_FLOAT,
  SCM_FOREIGN_TYPE_COMPLEX_DOUBLE): New enums.
* module/system/foreign.scm (complex-float, complex-double): Export new types.
  (make-c-struct, parse-c-struct): Support the new types.
* libguile/foreign.c (complex-float, complex-double): Define new types.
  (alignof, sizeof, pack, unpack): Support the new types.
* test-suite/tests/foreign.test: Test.
2021-11-15 11:34:09 +01:00
Daniel Llorens
24116be822 Fix brace style for bf9d30f3c3 2021-11-05 13:46:38 +01:00
Daniel Llorens
c6b1171c6b Avoid ash with arguments that might overflow in (language cps types)
Fixes https://debbugs.gnu.org/50609

* module/languages/cps/types.scm (ulsh): As stated.
2021-11-05 10:26:57 +01:00
Daniel Llorens
bf9d30f3c3 Limit the range of ash, round-ash count argument to INT32
This avoids gmp aborting e.g. with (ash 1 (expt 2 37)). The new limit is
such that (ash 1 (expt 30)) is accepted but (ash 1 (expt 31)) throws.

Fixes https://bugs.gnu.org/48150

* libguile/numbers.c (ash, round-ash): As stated.
* test-suite/tests/numbers.test: Test a case known to make gmp abort before.
2021-11-05 10:26:43 +01:00
Fabrice Fontaine
ffb33fd66b module/system/base/target.scm: support riscv32
Fix the following build failure on riscv32:

system/base/target.scm:132:16: In procedure triplet-pointer-size:
unknown CPU word size "riscv32"

Fixes:
 - http://autobuild.buildroot.org/results/6705630c1484239ec8b73d57ebc2e2570fbfc8f8

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2021-11-05 10:15:26 +01:00
d4ryus
1a8294f495 Fix bounds check in recvfrom!
Closes https://debbugs.gnu.org/cgi/bugreport.cgi?bug=45595.

NB: Amended by the committer to allow an empty range.

* libguile/socket.c: As stated.
2021-11-03 13:01:28 +01:00
Arun Isaac
c5f443de79 Fix typos in SRFI docs
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=50127

* doc/ref/api-foreign.texi, doc/ref/srfi-modules.texi: Fix typos.
2021-11-03 12:15:42 +01:00
Philipp Klaus Krause
ab9c0c9ca7 Const qualify return of strerror
Closes https://debbugs.gnu.org/cgi/bugreport.cgi?bug=43987
2021-11-03 11:59:15 +01:00
Vineet Gupta
492bd63883 Add support for arc
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

NB: closes https://debbugs.gnu.org/cgi/bugreport.cgi?bug=48816
2021-11-03 10:59:03 +01:00
Taylan Kammer
a960d7869b Improve support for R6/R7 SRFI module name formats.
Fixes <https://bugs.gnu.org/39601>.

Partly fixes <https://bugs.gnu.org/40371>.

It was already possible to import an SRFI module by referencing it
as (srfi :n) which is automatically translated to (srfi srfi-n), but
this conversion was only done during import.  After this change, it's
also possible to define a library as (srfi :n) which is automatically
translated to (srfi srfi-n) during definition.

It was not possible at all to define or import SRFI module names in the
R7RS format, (srfi n), where n is a non-negative exact integer.  It is
now possible both to define and import them as such, realized through
the same kind of conversion to a canonical (srfi srfi-n) name.

* module/ice-9/r6rs-libraries.scm: Numerous changes.
2021-11-02 10:02:29 +01:00
Daniel Llorens
708df04f3b Update NEWS 2021-10-27 10:09:59 +02:00
Ludovic Courtès
b1bbafa500 Update NEWS. 2021-10-22 13:52:40 +02:00
Ludovic Courtès
3b42b1eb52 sxml: Make parser thread-safe.
Fixes <https://bugs.gnu.org/51264>.

Lack of thread-safety would also affect the parser in (texinfo) because
it uses 'next-token-of'.

* module/sxml/upstream/input-parse.scm (input-parse:init-buffer): Always
return a fresh buffer.
2021-10-22 13:52:40 +02:00
Daniel Llorens
06de31ecb7 Fix doc typo 2021-10-21 16:02:59 +02:00
Daniel Llorens
6be51f9bbf Provide xxvector-copy and xxvector-copy! for srfi-4 vectors
These use the argument conventions of vector-copy!, string-copy!,
etc. and not that of bytevector-copy! (which is from r6rs).

* module/srfi/srfi-4/gnu.scm: As stated.
* test-suite/tests/srfi-4.test: Tests.
* doc/ref/srfi-modules.texi: Documentation.
* libguile/bytevectors.c (bytevector-copy!): Add overlap note to
  docstring.
* libguile/vectors.c (vector-copy!): Reuse text for the overlap note.
2021-10-21 15:05:46 +02:00
Timothy Sample
c85724bd0a (ice-9 format): Fix scaling floats with leading zeros 2021-10-19 02:52:15 +02:00
Mikael Djurfeldt
98dff7a75e Mention package GNU Gperf in README.
* README: Mention GNU Gperf. Needed when building from a Git checkout.
2021-10-13 22:00:40 +02:00
Andy Wingo
e60469c8b6 Add primitive alias analysis to CSE
* module/language/cps/effects-analysis.scm (compute-known-allocations):
(compute-clobber-map): Add "conts" parameter, and use it to compute
primcalls that access known allocations.  A write to a known allocation
only clobbers a read to a known allocation if they are the same.
* module/language/cps/cse.scm (eliminate-common-subexpressions-in-fun):
Pass conts also to compute-clobber-map.
2021-10-03 21:39:46 +02:00