Clean up _fbOnes()

The implementation of _FbOnes in iccolor.c would not work on 64-bit
longs correctly.  Fortunately, it's only used on integers, so make it
explicit in the declaration.

Use an inline function for the gcc builtin implementation to make sure
that it's never used with arguments of incorrect size.

There is no __INT_MIN__ in gcc 4.1.1, but it's not an issue now because
the argument is 32-bit.

Signed-off-by: Pavel Roskin <proski@gnu.org>
This commit is contained in:
Pavel Roskin 2006-08-13 01:57:56 -04:00 committed by Carl Worth
parent 9e332eadad
commit a2ec383ff1
2 changed files with 8 additions and 8 deletions

View file

@ -26,9 +26,9 @@
#ifdef ICINT_NEED_IC_ONES
/* Fall back on HACKMEM 169. */
int
_FbOnes (unsigned long mask)
_FbOnes (unsigned int mask)
{
register unsigned long y;
register int y;
y = (mask >> 1) &033333333333;
y = mask - y - ((y >>1) & 033333333333);

View file

@ -804,15 +804,15 @@ fbRasterizeTrapezoid (pixman_image_t *pMask,
in libgcc in case a target does not have one, which should be just as
good as the static function below. */
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
# if __INT_MIN__ == 0x7fffffff
# define _FbOnes(mask) __builtin_popcount(mask)
# else
# define _FbOnes(mask) __builtin_popcountl((mask) & 0xffffffff)
# endif
static INLINE int
_FbOnes(unsigned int mask)
{
return __builtin_popcount(mask);
}
#else
# define ICINT_NEED_IC_ONES
pixman_private int
_FbOnes(unsigned long mask);
_FbOnes(unsigned int mask);
#endif
/* icformat.c */