[Piglit] [PATCH 1/5] util: Wrapper to load exact hex patterns for ints

Andres Gomez agomez at igalia.com
Thu Jun 30 09:19:17 UTC 2016

On Wed, 2016-06-29 at 17:46 +0100, Emil Velikov wrote:
> On 14 June 2016 at 22:36, Andres Gomez <agomez at igalia.com> wrote:
> > For some cases we want to have shaders where we load an exact bit
> > pattern into a signed int.
> > 
> > This fixes the errno-based range validation that was broken when
> > the
> > integer vbo attribute parsing on 32-bit systems was recently fixed.
> > 
> Is this because strtol{,l} requires the '-' sign to prefix the
> negative values, while we feed it a unsigned encoded signed value ?
> I.e. function throws an error if we give it 0x8000 0000, as it
> expects
> -0x7fff ffff.
> Or is that due to sizeof(long) varying between 32 and 64bit systems ?

I would say, both.

As you say, for negative values we would have to pass the hex values
as -0x7fff ffff while we want to pass the exact bit
representation: 0x8000 0000 ...

... and, because of that, in order to allow it without problems in
32bit systems, in the previous implementation we were using strtoll,
which was then making useless its internal validation for values inside
the range of long.




More information about the Piglit mailing list