Hi Jim, sorry for not looking earier.
* Jim Meyering wrote on Sat, Nov 29, 2008 at 12:00:34PM CET: > +/* Return the number of bits by which a d_type value must be shifted > + left in order to put it into the S_IFMT bits of stat.st_mode. */ > +static int > +s_ifmt_shift_bits (void) > +{ > + unsigned int v = S_IFMT; /* usually, 0170000 */ > + static const int MultiplyDeBruijnBitPosition[32] = > + { > + 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, > + 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 > + }; > + > + /* Find the smallest power of two, P (e.g., 0010000) such that P & V == P. > */ > + unsigned int p = v ^ (v & (v - 1)); > + > + /* Compute and return r = log2 (p), using code from > + http://graphics.stanford.edu/~seander/bithacks.html#IntegerLogDeBruijn > */ > + return MultiplyDeBruijnBitPosition[(uint32_t) (p * 0x077CB531UL) >> 27]; > +} This is a constant you could compute at configure time, no? See AC_COMPUTE_INT. Cheers, Ralf