Various patches against gmp-4.3.0
marc.glisse at normalesup.org
Mon May 4 11:53:17 CEST 2009
On Mon, 4 May 2009, Torbjorn Granlund wrote:
> 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?!?
Only one in each .o file. But when I link several .o files together (in a
.so for instance), with static they remain distinct, and with extern they
get merged. It is not very surprising that static functions don't get
merged, gcc+binutiles don't merge them either. I think I heard that MSVC
does though, as long as the compiler generated the exact same code for
both (nice optimization).
I am actually more surprised by extern inline, where depending on the
options gcc either generates no function or generates functions that cause
a multiple definition error at link time (where with sunpro the multiple
definitions get merged).
Plain "inline" seems to be the sunpro (and C99) equivalent of the gcc
"extern inline attribute((gnu_inline))".
> 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
> /* Somewhat older Sun C compilers accept "static inline" */
> #if defined (__SUNPRO_C) && __SUNPRO_C >= 0x540
> #define __GMP_EXTERN_INLINE static inline
I guess you mean in the reverse order, or with a
More information about the gmp-devel