Re: [AD] Borland C++ compilation errors |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
> Hmm... but this still doesn't work for negative inputs (they'll
> always cast to unsigned longs greater than the test value).
That's a bug of the original C version of fceil() I didn't detect (the x86
asm is ok)... Never trust the existing code ;-)
Do I have your approval for the following version ?
AL_INLINE(int, fceil, (fixed x))
{
if (x >= (long)(0x80000000 - 0xFFFF)) {
*allegro_errno = ERANGE;
return 0x7FFF;
}
x += 0xFFFF;
return (x >> 16);
})
I have a little concern though about the portability of this C version of
fceil() (and of fixtoi() too): it relies on x>>16 being an arithmetical
shift, isn't it ? According to my book on the C language: "The ANSI standard
does not specify whether a compiler should perform a logical or arithmetic
shift for signed objects".
--
Eric Botcazou
ebotcazou@xxxxxxxxxx