Root/
Source at commit 1277 created 12 years 11 months ago. By meklort, Begin arch specific module changes | |
---|---|
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 | ␊ |
10 | uint32_t __clzsi2(uint32_t v)␊ |
11 | {␊ |
12 | ␉int p = 31;␊ |
13 | ␊ |
14 | ␉if (v & 0xffff0000) {␊ |
15 | ␉␉p -= 16;␊ |
16 | ␉␉v >>= 16;␊ |
17 | ␉}␊ |
18 | ␉if (v & 0xff00) {␊ |
19 | ␉␉p -= 8;␊ |
20 | ␉␉v >>= 8;␊ |
21 | ␉}␊ |
22 | ␉if (v & 0xf0) {␊ |
23 | ␉␉p -= 4;␊ |
24 | ␉␉v >>= 4;␊ |
25 | ␉}␊ |
26 | ␉if (v & 0xc) {␊ |
27 | ␉␉p -= 2;␊ |
28 | ␉␉v >>= 2;␊ |
29 | ␉}␊ |
30 | ␉if (v & 0x2) {␊ |
31 | ␉␉p -= 1;␊ |
32 | ␉␉v >>= 1;␊ |
33 | ␉}␊ |
34 | ␊ |
35 | ␉return p;␊ |
36 | }␊ |
37 |