Re: Including in gmp-impl.h

2013-12-25 Thread Torbjorn Granlund
Vincent Lefevre  writes:

  I've tried to find something about that on Google, but couldn't
  find anything. Any reference?

Perhaps ChangeLog has some history.

Torbjörn
___
gmp-devel mailing list
gmp-devel@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-devel


Re: Including in gmp-impl.h

2013-12-25 Thread Vincent Lefevre
On 2013-12-25 13:28:20 +0100, Torbjorn Granlund wrote:
> IIRC, limits.h was unreliable for many years, and our workarounds
> allowed GMP to work on more systems.

I've tried to find something about that on Google, but couldn't
find anything. Any reference?

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
___
gmp-devel mailing list
gmp-devel@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-devel


Re: Including in gmp-impl.h

2013-12-25 Thread Torbjorn Granlund
Vincent Lefevre  writes:

  On 2013-12-25 12:13:39 +0100, Marc Glisse wrote:
  > Oups, looks like I already asked about that:
  > https://gmplib.org/list-archives/gmp-bugs/2011-November/002443.html
  > 
  > and the reply was to try including tests.h before gmp-impl.h.
  
  I'd say that it would be better to fix GMP. Reusing standard macros
  (even when there are not supposed to be defined under some conditions)
  is ugly. For instance, GMP_INT_MAX could be used instead of INT_MAX,
  and there would be no risk of clashes.
  
  Including tests.h before gmp-impl.h is probably not a good solution
  because in such tests,  (from tests.h) may be used instead
  of GMP's definitions. So, if don't trust , that's incorrect.
  
  I'd also say that if  is incorrect, lots of programs will
  fail to build correctly. So, GMP's trick to redefine limits will be
  useful only for users who use GMP in their own applications, without
  using  in their applications either.

IIRC, limits.h was unreliable for many years, and our workarounds
allowed GMP to work on more systems.

-- 
Torbjörn
___
gmp-devel mailing list
gmp-devel@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-devel


Re: Including in gmp-impl.h

2013-12-25 Thread Vincent Lefevre
On 2013-12-25 12:13:39 +0100, Marc Glisse wrote:
> Oups, looks like I already asked about that:
> https://gmplib.org/list-archives/gmp-bugs/2011-November/002443.html
> 
> and the reply was to try including tests.h before gmp-impl.h.

I'd say that it would be better to fix GMP. Reusing standard macros
(even when there are not supposed to be defined under some conditions)
is ugly. For instance, GMP_INT_MAX could be used instead of INT_MAX,
and there would be no risk of clashes.

Including tests.h before gmp-impl.h is probably not a good solution
because in such tests,  (from tests.h) may be used instead
of GMP's definitions. So, if don't trust , that's incorrect.

I'd also say that if  is incorrect, lots of programs will
fail to build correctly. So, GMP's trick to redefine limits will be
useful only for users who use GMP in their own applications, without
using  in their applications either.

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
___
gmp-devel mailing list
gmp-devel@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-devel


Re: Including in gmp-impl.h

2013-12-25 Thread Marc Glisse


Oups, looks like I already asked about that:
https://gmplib.org/list-archives/gmp-bugs/2011-November/002443.html

and the reply was to try including tests.h before gmp-impl.h.

--
Marc Glisse
___
gmp-devel mailing list
gmp-devel@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-devel


Including in gmp-impl.h

2013-12-25 Thread Marc Glisse

Hello,

trying to compile gmp with clang, I got this error in the C++ testsuite:

In file included from /usr/include/limits.h:152:
/usr/include/x86_64-linux-gnu/bits/xopen_lim.h:97:7: error: token is not a valid
  binary operator in a preprocessor subexpression
#  if INT_MAX == 2147483647
  ^~~
/data/repos/gmp/gmp-impl.h:579:31: note: expanded from macro 'INT_MAX'
#define INT_MAX(-(INT_MIN+1))
  ^~~
/data/repos/gmp/gmp-impl.h:576:35: note: expanded from macro 'INT_MIN'
#define INT_MIN((int) UINT_HIGHBIT)
~ ^
/data/repos/gmp/gmp-impl.h:564:28: note: expanded from macro 
'UINT_HIGHBIT'

#define UINT_HIGHBIT   (UINT_MAX ^ ((unsigned) UINT_MAX >> 1))
   ^

Something in the glibc headers doesn't like the gmp definitions of those 
macros. It is easily worked around by including limits.h in gmp-impl.h, 
but I see this comment:


/* limits.h is not used in general, since it's an ANSI-ism, and since on
   solaris gcc 2.95 under -mcpu=ultrasparc in ABI=32 ends up getting wrong
   values (the ABI=64 values).

   On Cray vector systems, however, we need the system limits.h since sizes
   of signed and unsigned types can differ there, depending on compiler
   options (eg. -hnofastmd), making our SHRT_MAX etc expressions fail.  For
   reference, int can be 46 or 64 bits, whereas uint is always 64 bits; and
   short can be 24, 32, 46 or 64 bits, and different for ushort.  */

#if defined _CRAY
#include 
#endif


So even using autoconf to check if limits.h exists may not be enough. Or 
can we ignore the old solaris issue?


--
Marc Glisse
___
gmp-devel mailing list
gmp-devel@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-devel