[m-rev.] for review: implement is_nan/1 and is_inf/1 for MSVC

Julien Fischer jfischer at opturion.com
Fri May 31 17:36:44 AEST 2013


On Fri, 31 May 2013, Peter Wang wrote:

> On Fri, 31 May 2013 16:56:21 +1000 (EST), Julien Fischer <jfischer at opturion.com> wrote:
>>
>> For review by anyone.
>>
>> Branches: 13.05, master
>>
>> -------------------
>>
>> Implement is_nan/1 and is_inf/1 installations using MSVC.
>>
>> runtime/mercury_float.c:
>>  	Provide MSVC specific definitions for MR_is_nan
>>  	and MR_is_inf.
>>
>> Julien.
>>
>> diff --git a/NEWS b/NEWS
>> index 1f50052..8ba2bd7 100644
>> --- a/NEWS
>> +++ b/NEWS
>> @@ -20,6 +20,8 @@ This is a bug-fix release.
>>     (Bug #257)
>>   * A bug that caused a compiler abort in the low-level C backend has been
>>     fixed.
>> +* The functions float.is_nan/1 and float.is_inf/1 now work when using
>> +  Microsoft Visual C++ as the C compiler.
>>
>>   Changes to the Mercury standard library:
>>
>
> Did the fallbacks not work before?

Ah yes, I imagine they did. I'll remove that from the NEWS file.

>> diff --git a/runtime/mercury_float.c b/runtime/mercury_float.c
>> index 798cc30..49d319e 100644
>> --- a/runtime/mercury_float.c
>> +++ b/runtime/mercury_float.c
>> @@ -111,6 +111,8 @@ MR_is_nan(MR_Float Flt)
>>       return isnanf(Flt);
>>   #elif defined(MR_HAVE_ISNAN)
>>       return isnan(Flt);
>> +#elif defined(MR_MSVC)
>> +    return _isnan(Flt);
>>   #else
>>       return (Flt != Flt);
>>   #endif
>> @@ -130,6 +132,10 @@ MR_is_inf(MR_Float Flt)
>>       return isinf(Flt);
>>   #elif defined(MR_HAVE_FINITE)
>>       return !finite(Flt) && (Flt == Flt);
>> +#elif defined(MR_MSVC)
>> +    int sw;
>> +    sw = _fpclassify(Flt);
>> +    return (sw == _FPCLASS_NINF) || (sw == _FPCLASS_INF);
>
> What does sw stand for?

sw == status word (which is what the documentation calls it).

Cheers,
Julien.



More information about the reviews mailing list