Subversion Repositories HelenOS

Rev

Rev 2927 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2927 Rev 4691
Line 24... Line 24...
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
/** @addtogroup generic
29
/** @addtogroup generic
30
 * @{
30
 * @{
31
 */
31
 */
32
/** @file
32
/** @file
33
 */
33
 */
34
 
34
 
Line 40... Line 40...
40
 
40
 
41
/** Return position of first non-zero bit from left (i.e. [log_2(arg)]).
41
/** Return position of first non-zero bit from left (i.e. [log_2(arg)]).
42
 *
42
 *
43
 * If number is zero, it returns 0
43
 * If number is zero, it returns 0
44
 */
44
 */
45
static inline int fnzb32(uint32_t arg)
45
static inline unsigned int fnzb32(uint32_t arg)
46
{
46
{
47
    int n = 0;
47
    unsigned int n = 0;
48
 
48
   
49
    if (arg >> 16) {
49
    if (arg >> 16) {
50
        arg >>= 16;
50
        arg >>= 16;
51
        n += 16;
51
        n += 16;
52
    }
52
    }
53
   
53
   
Line 72... Line 72...
72
    }
72
    }
73
   
73
   
74
    return n;
74
    return n;
75
}
75
}
76
 
76
 
77
static inline int fnzb64(uint64_t arg)
77
static inline unsigned int fnzb64(uint64_t arg)
78
{
78
{
79
    int n = 0;
79
    unsigned int n = 0;
80
 
80
   
81
    if (arg >> 32) {
81
    if (arg >> 32) {
82
        arg >>= 32;
82
        arg >>= 32;
83
        n += 32;
83
        n += 32;
84
    }
84
    }
85
   
85
   
86
    return n + fnzb32((uint32_t) arg);
86
    return (n + fnzb32((uint32_t) arg));
87
}
87
}
88
 
88
 
-
 
89
static inline unsigned int fnzb(size_t arg)
-
 
90
{
89
#define fnzb(x) fnzb32(x)
91
    return fnzb64(arg);
-
 
92
}
90
 
93
 
91
#endif
94
#endif
92
 
95
 
93
/** @}
96
/** @}
94
 */
97
 */