]> git.pld-linux.org Git - packages/smalltalk.git/blob - gmp5.patch
d269017f34fc3585679e5feeda3ff001d041f296
[packages/smalltalk.git] / gmp5.patch
1 From 04ac00a8126a0b328e231e01ab4b257b28c5da3c Mon Sep 17 00:00:00 2001
2 From: Paolo Bonzini <bonzini@gnu.org>
3 Date: Fri, 8 Jan 2010 16:00:36 +0100
4 Subject: [PATCH] hack to build with GMP 5
5
6 libgst:
7 2010-01-08  Paolo Bonzini  <bonzini@gnu.org>
8
9         * libgst/mpz.c: Hack to build with GMP 5.
10 ---
11  libgst/ChangeLog |    4 ++++
12  libgst/mpz.c     |   20 ++++++++++++++++++--
13  2 files changed, 22 insertions(+), 2 deletions(-)
14
15 diff --git a/libgst/mpz.c b/libgst/mpz.c
16 index eaee0e8..d8e8b6b 100644
17 --- a/libgst/mpz.c
18 +++ b/libgst/mpz.c
19 @@ -1513,13 +1513,21 @@ _gst_mpz_xor (gst_mpz *res, const gst_mpz *op1, const gst_mpz *op2)
20    }
21  }
22  
23 +#if __GNU_MP_VERSION >= 5
24 +extern void __gmpn_divexact (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t);
25 +#endif
26 +
27  void
28  _gst_mpz_divexact (gst_mpz *quot, const gst_mpz *num, const gst_mpz *den)
29  {
30 -  mp_ptr qp, tp;
31 +  mp_ptr qp;
32    mp_srcptr np, dp;
33 -  mp_size_t nsize, dsize, qsize, d_zero_limbs;
34 +  mp_size_t nsize, dsize, qsize;
35 +#if __GNU_MP_VERSION < 5
36 +  mp_ptr tp;
37 +  mp_size_t d_zero_limbs;
38    int d_zero_bits;
39 +#endif
40  
41    nsize = ABS (num->size);
42    dsize = ABS (den->size);
43 @@ -1542,6 +1550,7 @@ _gst_mpz_divexact (gst_mpz *quot, const gst_mpz *num, const gst_mpz *den)
44        return;
45      }
46  
47 +#if __GNU_MP_VERSION < 5
48    /* Avoid quadratic behaviour, but do it conservatively.  */
49    if (nsize - dsize > 1500)
50      {
51 @@ -1560,6 +1569,7 @@ _gst_mpz_divexact (gst_mpz *quot, const gst_mpz *num, const gst_mpz *den)
52    dsize -= d_zero_limbs;
53    np += d_zero_limbs;
54    nsize -= d_zero_limbs;
55 +#endif
56  
57    /* Allocate where we place the result.  It must be nsize limbs big
58       because it also acts as a temporary area.  */
59 @@ -1567,6 +1577,7 @@ _gst_mpz_divexact (gst_mpz *quot, const gst_mpz *num, const gst_mpz *den)
60      gst_mpz_realloc (quot, nsize);
61    qp = quot->d;
62  
63 +#if __GNU_MP_VERSION < 5
64    if (d_zero_bits != 0)
65      {
66        tp = (mp_ptr) alloca (dsize * SIZEOF_MP_LIMB_T);
67 @@ -1579,9 +1590,14 @@ _gst_mpz_divexact (gst_mpz *quot, const gst_mpz *num, const gst_mpz *den)
68      }
69    else
70      MPN_COPY(qp, np, nsize);
71 +#endif
72  
73    qsize = nsize - dsize + 1;
74 +#if __GNU_MP_VERSION < 5
75    mpn_bdivmod (qp, qp, nsize, dp, dsize, qsize * GMP_NUMB_BITS);
76 +#else
77 +  __gmpn_divexact (qp, np, nsize, dp, dsize);
78 +#endif
79    quot->size = (num->size ^ den->size) >= 0 ? qsize : -qsize;
80  }
81  
82 -- 
83 1.6.5
84
This page took 0.048074 seconds and 2 git commands to generate.