mini-gmp mpz_{get,set}_d not fully compatible with GMP

Marco Bodrato bodrato at mail.dm.unipi.it
Mon Mar 12 17:53:37 UTC 2018


Ciao,

Il Lun, 12 Marzo 2018 4:57 pm, Torbjörn Granlund ha scritto:
>   > ... if the compiler inlines the static gmp_tests_dbl_mant_bits
>   > function, and optimizes away the local variable n, directly
>   > updating c in the loop, then it can be a problem...

> Only the sensitive target variable would seem to need a volatile decl.

You mean we should declare
static volatile int c = 0;

Sounds like and oxymoron to me :-)

Or should we use another variable, similar in some way to the fat code?

double
mpz_get_d (const mpz_t u)
{
  static int c = 0;
  static int __initialized = 0;

  if (__initialized != 1) {
    c = gmp_tests_dbl_mant_bits ();
    *((volatile int *) &__initialized) = 1;
  }

...


Ĝis,
m

-- 
http://bodrato.it/



More information about the gmp-devel mailing list