[m-rev.] diff: speed up is_finite/1 and is_nan/1 in C grades
Julien Fischer
jfischer at opturion.com
Fri Sep 19 20:22:40 AEST 2014
On Fri, 19 Sep 2014, Peter Wang wrote:
> On Wed, 17 Sep 2014 12:01:14 +1000 (EST), Julien Fischer <jfischer at opturion.com> wrote:
>> @@ -136,7 +136,7 @@ MR_is_nan(MR_Float Flt)
>> }
>>
>> MR_bool
>> -MR_is_inf(MR_Float Flt)
>> +MR_is_inf_func(MR_Float Flt)
>> {
>> /*
>> ** On Solaris, isinf() is detected by configure but we pass -fno-builtin
>
> Fixed the name.
>
> isinf/isnan/finite are not C89 so I get these warnings due to
> --no-ansi-c.
finite is not C anything (IIRC it's a BSD thing). The problem here is
that while we compile runtime/mercury_float.c with --no-ansi, we
compiler library/float.c with -ansi. For GCC (which is what it looks
like you are using here), -ansi puts the C compiler into C90 mode.
The problem is being exacerbated by the fact that the configure checks
for isnan and friends pass because we don't pass -ansi to the C compiler
when we run them.
Finally, the problem didn't show up on my machine because I was using
clang and we use clang in C99 mode due to the fact that -ansi for clang
puts it into C89 mode and that broke inline functions in the runtime.
> float.m: In function ‘float_module22’:
> float.m:718:5: warning: implicit declaration of function ‘isinf’ [-Wimplicit-function-declaration]
> float.m: In function ‘float_module23’:
> float.m:680:5: warning: implicit declaration of function ‘isnan’ [-Wimplicit-function-declaration]
> float.m: In function ‘float_module26’:
> float.m:753:5: warning: implicit declaration of function ‘finite’ [-Wimplicit-function-declaration]
>
> Not sure what the fix should be.
The immediate fix is to only use the macro versions if we are using C99.
I think we should also stop using -ansi with GCC by default. Requiring
a version of C from over 20 years ago is just silly.
Cheers,
Julien.
More information about the reviews
mailing list