[m-rev.] for review: Work around isinf() link error on Solaris.
Julien Fischer
jfischer at opturion.com
Wed May 29 16:13:26 AEST 2013
Hi Peter,
On Wed, 29 May 2013, Peter Wang wrote:
> On Solaris, isinf() is detected by configure but we pass -fno-builtin
> for global registers on x86/x86-64, and that causes an undefined
> reference to `isinf' when linking.
Or is it because the C compiler is not in C99 mode? (Either way, that
behaviour seems pretty broken.)
> runtime/mercury_float.c:
> Don't use `isinf' or `isinff' on when __sun is defined.
>
> Add a better `isinf' fallback using finite().
IIRC, finite() is a BSD'ism. (C99 provides the equivalent isfinite.)
You probably shouldn't be assuming that any of them are present and
should certainly be checking that they are before attempting to use
them.
> diff --git a/runtime/mercury_float.c b/runtime/mercury_float.c
> index 2a31a2e..8088ae9 100644
> --- a/runtime/mercury_float.c
> +++ b/runtime/mercury_float.c
> @@ -119,11 +119,16 @@ MR_is_nan(MR_Float Flt)
> MR_bool
> MR_is_inf(MR_Float Flt)
> {
> -#if defined(MR_USE_SINGLE_PREC_FLOAT) && defined(MR_HAVE_ISINFF)
> + /*
> + ** On Solaris, isinf() is detected by configure but we pass -fno-builtin
> + ** for global registers on x86/x86-64, and that causes an undefined
> + ** reference to `isinf' when linking.
> + */
> +#if defined(MR_USE_SINGLE_PREC_FLOAT) && defined(MR_HAVE_ISINFF) && !defined(__sun)
> return isinff(Flt);
> -#elif defined(MR_HAVE_ISINF)
> +#elif defined(MR_HAVE_ISINF) && !defined(__sun)
> return isinf(Flt);
> #else
> - return (Flt == Flt / 2.0 && Flt != 0.0);
> + return !finite(Flt) && (Flt == Flt);
> #endif
I suggest adding
#if defined(__sun)
#define MR_SOLARIS)
#endif
in the runtime and using MR_SOLARIS instead of __sun directly.
Cheers,
Julien.
More information about the reviews
mailing list