Branch: Tag:

2008-05-02

2008-05-02 04:03:46 by Martin Stjernholm <mast@lysator.liu.se>

Amended temporary brain short circuit.

Rev: src/modules/Gmp/mpz_glue.c:1.177

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: mpz_glue.c,v 1.176 2008/05/01 21:14:04 mast Exp $ + || $Id: mpz_glue.c,v 1.177 2008/05/02 04:03:46 mast Exp $   */      #include "global.h"
250: Inside #if SIZEOF_LONG >= SIZEOF_LONGEST
  #if SIZEOF_LONG >= SIZEOF_LONGEST    mpz_set_ui (mpz, i);   #else - #error LONGEST should always be at least the same size as long. - #endif +  { + #ifdef HAVE_MPZ_IMPORT +  mpz_import (mpz, 1, 1, SIZEOF_LONGEST, 0, 0, &i); + #else +  { +  size_t n = +  ((SIZEOF_LONGEST + SIZEOF_LONG - 1) / SIZEOF_LONG - 1) +  /* The above is the position of the top unsigned long in the INT64. */ +  * ULONG_BITS; +  mpz_set_ui (mpz, (unsigned long) (i >> n)); +  while (n) { +  n -= ULONG_BITS; +  mpz_mul_2exp (mpz, mpz, ULONG_BITS); +  mpz_add_ui (mpz, mpz, (unsigned long) (i >> n));    }    } -  + #endif /* !HAVE_MPZ_IMPORT */ +  } + #endif /* SIZEOF_LONG < SIZEOF_LONGEST */ +  } + }      static int gmp_ulongest_from_bignum (unsigned LONGEST *i, struct object *bignum)   {