My conclusion that the problem with ffs() described below was a problem with
gcc turns out to be flawed.  For S/390, gcc does not provide its own version
of ffs() but it rather makes the builtin fall through to the C library anyway.

Digging deeper into this issue (after noticing some discrepancies), it seems
like the SuSE 7.0 distribution was shipped with a glibc-2.1.3 that has an
older S/390 patch version than what developerWorks currently offers.  The
one on developerWorks is dated 2000-12-07, and after applying it to the glibc
sources for 2.1.3, it actually provides a correct ffs() implementation.

After updating the SuSE 7.0 install with the latest shlibs-2.1.3-217 rpm on
the SuSE website, the problem was resolved.

        Kris

On Thu, Feb 07, 2002 at 09:25:24AM -0500, Kris Van Hees wrote:
> While digging through a problem with OpenAFS on Linux S/390, I found that gcc
> uses a builtin version of the ffs() (find-first-set bit in a word) function,
> unless -ansi or -fno-builtin is used as option.  That builtin version of the
> ffs() function seems to be inconsistent with versions found in the Linux
> kernel (asm-s390/bitops.h) and in the C library (verified against glibc-2.2.4).
> It is supposed to return the bit position of the first bit that is set in the
> given word, with LSB being 1, and MSB being 32.
>
> The implementation that is used for the gcc builtin version returns 32 when
> 0x80000001 is passed in as word, whereas both the kernel implementation and
> the C library version return 1 as expected.
>
> Is there a specific reason for the current implementation in gcc, or is it an
> actual bug?  If so, who can fix it? :-)
>
>       Kris

Reply via email to