Chameleon

Chameleon Svn Source Tree

Root/trunk/i386/modules/klibc/__clzsi2.c

1/*
2 * libgcc/__clzsi2.c
3 *
4 * Returns the leading number of 0 bits in the argument
5 */
6
7#include <stdint.h>
8#include <stddef.h>
9
10uint32_t __clzsi2(uint32_t v)
11{
12int p = 31;
13
14if (v & 0xffff0000) {
15p -= 16;
16v >>= 16;
17}
18if (v & 0xff00) {
19p -= 8;
20v >>= 8;
21}
22if (v & 0xf0) {
23p -= 4;
24v >>= 4;
25}
26if (v & 0xc) {
27p -= 2;
28v >>= 2;
29}
30if (v & 0x2) {
31p -= 1;
32v >>= 1;
33}
34
35return p;
36}
37

Archive Download this file

Revision: HEAD