[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 67/85: scm_to_ipv6 uses scm_to_mpz
From: |
Andy Wingo |
Subject: |
[Guile-commits] 67/85: scm_to_ipv6 uses scm_to_mpz |
Date: |
Thu, 13 Jan 2022 03:40:24 -0500 (EST) |
wingo pushed a commit to branch main
in repository guile.
commit a0765f564afd56c7a42385d2a3790b3ec2295e3f
Author: Andy Wingo <wingo@pobox.com>
AuthorDate: Fri Jan 7 13:39:33 2022 +0100
scm_to_ipv6 uses scm_to_mpz
* libguile/socket.c (scm_to_ipv6): Use scm_to_mpz.
---
libguile/socket.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/libguile/socket.c b/libguile/socket.c
index e9c658ed7..77cdd74ef 100644
--- a/libguile/socket.c
+++ b/libguile/socket.c
@@ -255,10 +255,16 @@ scm_to_ipv6 (uint8_t dst[16], SCM src)
else if (SCM_BIGP (src))
{
size_t count;
+ mpz_t z;
- if ((mpz_sgn (SCM_I_BIG_MPZ (src)) < 0)
- || mpz_sizeinbase (SCM_I_BIG_MPZ (src), 2) > 128)
- scm_out_of_range (NULL, src);
+ mpz_init (z);
+ scm_to_mpz (src, z);
+
+ if (mpz_sgn (z) < 0 || mpz_sizeinbase (z, 2) > 128)
+ {
+ mpz_clear (z);
+ scm_out_of_range (NULL, src);
+ }
memset (dst, 0, 16);
mpz_export (dst,
@@ -267,8 +273,8 @@ scm_to_ipv6 (uint8_t dst[16], SCM src)
16, /* chunks are 16 bytes long */
1, /* big-endian byte ordering */
0, /* "nails" -- leading unused bits per chunk */
- SCM_I_BIG_MPZ (src));
- scm_remember_upto_here_1 (src);
+ z);
+ mpz_clear (z);
}
else
scm_wrong_type_arg_msg ("scm_to_ipv6", 0, src, "integer");
- [Guile-commits] 31/85: Implement scm_logcount with new integer library, (continued)
- [Guile-commits] 31/85: Implement scm_logcount with new integer library, Andy Wingo, 2022/01/13
- [Guile-commits] 33/85: Implement scm_integer_length with new integer library, Andy Wingo, 2022/01/13
- [Guile-commits] 35/85: Simplify scm_bigprint, Andy Wingo, 2022/01/13
- [Guile-commits] 34/85: Implement integer-to-string with new integer library, Andy Wingo, 2022/01/13
- [Guile-commits] 36/85: Build scm_integer_p on scm_is_integer, not vice versa, Andy Wingo, 2022/01/13
- [Guile-commits] 37/85: Reimplement = on integer lib, clean up scm_num_eq_p, Andy Wingo, 2022/01/13
- [Guile-commits] 40/85: Simplify implementation of min, max, Andy Wingo, 2022/01/13
- [Guile-commits] 42/85: Simplify scm_difference, use integer lib, Andy Wingo, 2022/01/13
- [Guile-commits] 47/85: Fix scm_integer_to_double_z to always round; clean ups, Andy Wingo, 2022/01/13
- [Guile-commits] 50/85: Reimplement scm_{to,from}_{int32,uint32}, Andy Wingo, 2022/01/13
- [Guile-commits] 67/85: scm_to_ipv6 uses scm_to_mpz,
Andy Wingo <=
- [Guile-commits] 68/85: Bignums avoid both custom GMP allocator and finalizers, Andy Wingo, 2022/01/13
- [Guile-commits] 69/85: take_mpz optimization, Andy Wingo, 2022/01/13
- [Guile-commits] 71/85: Re-rewrite integer-expt in C, Andy Wingo, 2022/01/13
- [Guile-commits] 73/85: Optimize scm_integer_mul_zz., Andy Wingo, 2022/01/13
- [Guile-commits] 84/85: Have log and log10(real nan) return real nan regardless of sign, Andy Wingo, 2022/01/13
- [Guile-commits] 85/85: Remove dead code in scm_integer_inexact_sqrt_z, Andy Wingo, 2022/01/13
- [Guile-commits] 24/85: Implement scm_logtest with new integer library, Andy Wingo, 2022/01/13
- [Guile-commits] 13/85: Implement centered-quotient with new integer lib, Andy Wingo, 2022/01/13
- [Guile-commits] 23/85: Implement scm_logxor with new integer library, Andy Wingo, 2022/01/13
- [Guile-commits] 19/85: Implement gcd with new integer lib, Andy Wingo, 2022/01/13