Bignum support still broken on powerpc (ping: Jerry James)

Jerry James james at xemacs.org
Fri Apr 7 11:29:07 EDT 2006


robert delius royar <xemacs at frinabulax.org> wrote:
> Thu, 6 Apr 2006 (10:08 -0600 UTC) Jerry James wrote:
>
>> Well, then, I don't understand those compiler warnings at all.  They
>> appear to be claiming that mpz_get_ui() is somehow broken; i.e., that
>> the function can return without returning a value.  If that is true,
>> then you are fundamentally screwed, because we use that function in
>> several places.  In my version of the headers, the inline version of
>> that function is defined like this:
>>
>> #if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_get_ui)
>> #if ! defined (__GMP_FORCE_mpz_get_ui)
>> __GMP_EXTERN_INLINE
>> #endif
>> unsigned long
>> mpz_get_ui (mpz_srcptr __gmp_z) __GMP_NOTHROW
>> {
>>  mp_ptr __gmp_p = __gmp_z->_mp_d;
>>  mp_size_t __gmp_n = __gmp_z->_mp_size;
>>  mp_limb_t __gmp_l = __gmp_p[0];
>>  if (__GMP_ULONG_MAX <= GMP_NUMB_MASK)
>>    return __gmp_l & (-(mp_limb_t) (__gmp_n != 0));
>> #if GMP_NAIL_BITS != 0  /* redundant #if, shuts up compiler warnings */
>>  else                  /* happens for nails, but not if LONG_LONG_LIMB */
>>    {                   /* assume two limbs are enough to fill an ulong */
>>      __gmp_n = __GMP_ABS (__gmp_n);
>>      if (__gmp_n <= 1)
>>        return __gmp_l & (-(mp_limb_t) (__gmp_n != 0));
>>      else
>>        return __gmp_l + (__gmp_p[1] << GMP_NUMB_BITS);
>>    }
>> #endif
>> }
>> #endif
>>
>> Hmmmmmm....  If __GMP_ULONG_MAX > GMP_NUMB_MASK and GMP_NAIL_BITS == 0,
>> that function CAN fall off the end.  The comment implies that that can't
>> happen, but even so, could you compile and run this please and tell me
>> the results?
>>
>> #include <stdio.h>
>> #include <gmp.h>
>>
>> int main()
>> {
>>  printf ("__GMP_ULONG_MAX == %lu\n", __GMP_ULONG_MAX);
>>  printf ("GMP_NUMB_MASK == %lu\n", GMP_NUMB_MASK);
>>  printf ("GMP_NAIL_BITS == %d\n", GMP_NAIL_BITS);
>>  return 0;
>> }
>
> % gcc -o /tmp/gmptest -I/opt/local/include -L/opt/local/lib ~/scratch/gmptest.c
> % /tmp/gmptest
> __GMP_ULONG_MAX == 4294967295
> GMP_NUMB_MASK == 4294967295
> GMP_NAIL_BITS == 0

Then I think that the compiler warnings are a red herring.  For some
reason, your gcc seems unable to determine that (__GMP_ULONG_MAX <=
GMP_NUMB_MASK) is a constant expression evaluating to true.

At this point, I don't know how to proceed.  The bug appears to be
specific to code generated by gcc4 on a specific platform I don't have
access to.  This looks like a bug to report to your vendor, rather than
a problem with XEmacs.  I'm afraid I don't even have any clues that
might lead to a workaround for the problem. :-(
-- 
Jerry James, Assistant Professor        james at xemacs.org
Computer Science Department             http://www.cs.usu.edu/~jerry/
Utah State University




More information about the XEmacs-Beta mailing list