Various patches against gmp-4.3.0

Torbjorn Granlund tg at gmplib.org
Mon May 4 11:21:02 CEST 2009


Marc Glisse <marc.glisse at normalesup.org> writes:

  I don't have Forte 6 (or anything older) at hand, but for C++
  (__SUNPRO_CC) I have a feeling that "inline" is safer than "static
  inline". At least we know it worked with previous versions of gmp and
  adding "static" should not provide any functionality improvement.
  
OK.

  Anyway as I have no way of checking this, I'll let you decide if it is
  worth removing the || defined (__SUNPRO_CC).
  
  For C, I just checked a bit what happens with a recent version of Sun
  Studio. I compiled several files that include the same header with a
  static inline function and all use it. I then used nm to look at the
  result. With optimization, the function disappears. Without
  optimization, I end up with 2 copies of the function (not exported).
  
2 copies in same object file?!?

  If I replace static with extern, I always end up with one single copy
  of the function, and the symbol is exported (although I can prevent
  that if I add __hidden in front).
  
  If I write just "inline", without optimization the function is
  undefined and an implementation is expected to be found elsewhere, and
  with optimization it is usually inlined.
  
  Note that this C99 meaning of "inline" and "extern inline" is only
  available for __SUNPRO_C>=0x560.
  
  Now I don't know exactly what behavior is wanted in GMP... (just
  "inline" looks nice)

I'll use the following:

/* Recent enough Sun C compilers accept "extern inline" */
#if defined (__SUNPRO_C) && __SUNPRO_C >= 0x560
#define __GMP_EXTERN_INLINE  extern inline
#endif

/* Somewhat older Sun C compilers accept "static inline" */
#if defined (__SUNPRO_C) && __SUNPRO_C >= 0x540
#define __GMP_EXTERN_INLINE  static inline
#endif

Thanks for the feedback!

-- 
Torbjörn


More information about the gmp-devel mailing list