[PATCH:xmag] Use lrint() from math library if available
Alan Coopersmith
alan.coopersmith at oracle.com
Wed Dec 21 17:15:27 PST 2011
On 12/20/11 22:30, James Cloos wrote:
>>>>>> "AC" == Alan Coopersmith<alan.coopersmith at oracle.com> writes:
>
> AC> Moves -lm from being hardcoded in Makefile.am to being added via
> AC> AC_SEARCH_LIBS in configure.ac setting it in $(LIBS)
>
> AC> Using lrint() [returns long int] instead of rint() [returns double]
> AC> clears a bunch of gcc warnings of the form:
> AC> "cast from function call of type ‘double’ to non-matching type ‘short int’"
>
> AC> Signed-off-by: Alan Coopersmith<alan.coopersmith at oracle.com>
>
> Should the call to floor(3) when lrint(3) is unavailable include a cast?
There's already casts at the call sites, though not always at the exact
same place:
sw->scale.table.x[(int) x] = (Position) myrint(sw->scale.scale_x * x);
sw->scale.table.width[(int) x] = (Dimension)
myrint(sw->scale.scale_x *(x + 1)) - myrint(sw->scale.scale_x * x);
sw->scale.table.y[(int) y] = (Position) myrint(sw->scale.scale_y * y);
sw->scale.table.height[(int) y] = (Dimension)
myrint(sw->scale.scale_y *(y + 1)) - myrint(sw->scale.scale_y * y);
sw->scale.width = (Dimension)
max(myrint(sw->scale.scale_x * sw->scale.image->width), 1);
sw->scale.height = (Dimension)
max(myrint(sw->scale.scale_y * sw->scale.image->height), 1);
where Dimension & Position are typedefs from <X11/Intrinsic.h>:
typedef unsigned short Dimension; /* Size in pixels */
typedef short Position; /* Offset from 0 coordinate */
(so they're now casting long int to short int, instead of double to short int).
--
-Alan Coopersmith- alan.coopersmith at oracle.com
Oracle Solaris Platform Engineering: X Window System
More information about the xorg-devel
mailing list