[PATCH:xmag] Use lrint() from math library if available

Alan Coopersmith alan.coopersmith at oracle.com
Tue Jan 24 16:13:27 PST 2012

On 12/22/11 11:03 AM, James Cloos wrote:
>>>>>> "AC" == Alan Coopersmith<alan.coopersmith at oracle.com>  writes:
>>> Should the call to floor(3) when lrint(3) is unavailable include a cast?
> AC>  There's already casts at the call sites, though not always at the exact
> AC>  same place:
> AC>>  scale.table.x[(int) x] = (Position) myrint(sw->scale.scale_x * x);
> AC>  (so they're now casting long int to short int, instead of double to short int).
> I was thinking of the non-lrint(3) case; floor(3) returns a double, so
> (Position)floor(...) should give the same error, yes?

Finally got back to looking at this.   From what I can tell in testing with
gcc 4.5.2, the way to silence the warning in the non-lrint case would be to
remove the cast.

With #define myrint(x) floor(x + 0.5):

	short foo = myrint(strtod(argv[i], NULL));

generates no warning, while

	short foo = (short) myrint(strtod(argv[i], NULL));


float-test.c:11:14: warning: cast from function call of type ‘double’ to 
non-matching type ‘short int’

So were you trying to suggest we remove the casts to quiet the non-lrint case?

	-Alan Coopersmith-        alan.coopersmith at oracle.com
	 Oracle Solaris Platform Engineering: X Window System

More information about the xorg-devel mailing list