[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fts: expose dirent.d_type data when possible
From: |
Bruno Haible |
Subject: |
Re: fts: expose dirent.d_type data when possible |
Date: |
Sat, 6 Dec 2008 13:43:39 +0100 |
User-agent: |
KMail/1.9.9 |
Jim Meyering wrote:
> + /* Find the smallest power of two, P (e.g., 0010000) such that P & V == P.
> */
> + unsigned int p = v ^ (v & (v - 1));
This is equivalent to
unsigned int p = v & ~(v - 1);
This latter expression may be clearer (depending on the reader's mental model of
bitwise expressions).
> + /* Compute and return r = log2 (p), using code from
> + http://graphics.stanford.edu/~seander/bithacks.html#IntegerLogDeBruijn
> */
> + return MultiplyDeBruijnBitPosition[(uint32_t) (p * 0x077CB531UL) >> 27];
Why is this done at runtime? Is S_IFMT not guaranteed to be a compile-time
constant?
Bruno
- Re: fts: expose dirent.d_type data when possible,
Bruno Haible <=