On Wed, Dec 19, 2012 at 01:34:34PM -0800, Teresa Johnson wrote: > +#if IN_LIBGCOV > + /* When building libgcov we don't include system.h, which includes > + hwint.h (where floor_log2 is declared). However, libgcov.a > + is built by the bootstrapped compiler and therefore the builtins > + are always available. */ > + r = 63 - __builtin_clzll (v);
Perhaps it would be more portable to use r = sizeof (long long) * __CHAR_BIT__ - 1 - __builtin_clzll (v); here. > +#else > + /* We use floor_log2 from hwint.c, which takes a HOST_WIDE_INT > + that is either 32 or 64 bits, and gcov_type_unsigned may be 64 bits. > + Need to check for the case where gcov_type_unsigned is 64 bits > + and HOST_WIDE_INT is 32 bits and handle it specially. */ > +#if LONG_LONG_TYPE_SIZE <= HOST_BITS_PER_WIDE_INT If not in libgcov.a, we have typedef unsigned HOST_WIDEST_INT gcov_type_unsigned; in gcov-io.h. LONG_LONG_TYPE_SIZE is target long long size, you are interested about the size of host gcov_type_unsigned. So perhaps test HOST_BITS_PER_WIDEST_INT instead of LONG_LONG_TYPE_SIZE? > + r = floor_log2 (v); > +#else > +#if LONG_LONG_TYPE_SIZE == 2 * HOST_BITS_PER_WIDE_INT Likewise. Can't you use #elif above and get rid of one of the #endif lines? > + HOST_WIDE_INT hwi_v = v >> HOST_BITS_PER_WIDE_INT; > + if (hwi_v) > + r = floor_log2 (hwi_v) + HOST_BITS_PER_WIDE_INT; > + else > + r = floor_log2 ((HOST_WIDE_INT)v); > +#else > + gcc_unreachable (); > +#endif > +#endif > +#endif > + } > Jakub