bug-gmp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GMP small/big number inputs


From: Hans Aberg
Subject: GMP small/big number inputs
Date: Wed, 9 May 2001 13:13:12 +0200

Here is another input:

One current problem with the use of GMP is that people want to compile it
with different allocator functions. Then the different version become
binary incompatible, and it is not possible, for example, to load it as a
DLL.

But if these only versions differ in that one wants to reserve some memory
for other use in the _mp_d allocation, then one might build that into GMP.

The representation would the be something like:
  typedef struct  {
    _mp_int _mp_s;     /* Small number representation. */
    mp_limb_t *_mp_d;  /* Pointer to the limbs and all other data.  */
  } __mpz_struct;
where _mp_d is set to NULL if one is using the small number representation
as before.

The _mp_d allocation, when non-NULL, also contains _mp_alloc and _mp_size
as before, but in additions has information about the reserved memory
offset. Thus it looks like this
     ------------
    |   ......   |    // Actual _mp_d number.
     ------------
    |   ......   |    // Block of reserved offset limbs.
     ------------
    | _mp_offset |
     ------------
    |  _mp_size  |
     ------------
    | _mp_alloc  |
     ------------   <--- Base (_start of mp_d)

  Hans Aberg





reply via email to

[Prev in Thread] Current Thread [Next in Thread]