[Mesa-dev] [PATCH] glsl: Use INFINITY instead of std::numeric_limits<float>::infinity().

Brian Paul brianp at vmware.com
Wed Mar 18 10:39:50 PDT 2015


On 03/18/2015 11:21 AM, Matt Turner wrote:
> On Wed, Mar 18, 2015 at 10:18 AM, Matt Turner <mattst88 at gmail.com> wrote:
>> diff --git a/src/glsl/s_expression.cpp b/src/glsl/s_expression.cpp
>> index 7eaa491..f82e155 100644
>> --- a/src/glsl/s_expression.cpp
>> +++ b/src/glsl/s_expression.cpp
>> @@ -70,7 +70,7 @@ read_atom(void *ctx, const char *&src, char *&symbol_buffer)
>>      // requires strtof to parse '+INF' as +Infinity, but we still support some
>>      // non-C99-compliant compilers (e.g. MSVC).
>>      if (n == 4 && strncmp(src, "+INF", 4) == 0) {
>> -      expr = new(ctx) s_float(std::numeric_limits<float>::infinity());
>> +      expr = new(ctx) s_float(INFINITY);
>>      } else {
>>         // Check if the atom is a number.
>>         char *float_end = NULL;
>> --
>
> There's a comment here seen at the top of this hunk that says
>
> // Check for the special symbol '+INF', which means +Infinity.  Note: C99
> // requires strtof to parse '+INF' as +Infinity, but we still support some
> // non-C99-compliant compilers (e.g. MSVC).
>
> could an MSVC user test if strof properly parses +INF with the
> required versions of MSVC?

I had to fix that problem in piglit a while ago:

commit dc2e8e59819beee6018770272761c136063c3e0b
Author: Brian Paul <brianp at vmware.com>
Date:   Tue Jul 15 08:17:29 2014 -0600

     shader_runner: wrap strtod() to parse "inf" with MSVC

     MSVC's strtod() function does not parse "inf" or "-inf" so add a
     wrapper function to do that.  Several generated shader tests use
     inf uniforms.


And Jose had a follow-on patch:
commit 4fbad1b5b5cc99f4118b5840d758e21f9dd5829d
Author: José Fonseca <jfonseca at vmware.com>
Date:   Fri Nov 7 12:37:05 2014 +0000

     tests/util: INFINITY/NAN are defined on MSVC 2013.

     Reviewed-by: Emil Velikov <emil.l.velikov at gmail.com>

But I think the underlying strtod() problem (and I bet strtof()) remains 
AFIAK.

-Brian



More information about the mesa-dev mailing list