Revision: | 1.3 |
Committed: | Sat Dec 10 11:58:38 2011 UTC (13 years, 2 months ago) by root |
Branch: | MAIN |
CVS Tags: | rel-9_14, rxvt-unicode-rel-9_15 |
Changes since 1.2: | +11 -0 lines |
Log Message: | add bitrev |
# | Content |
---|---|
1 | TODO: ffs/clz |
2 | 64 bit variants of everything |
3 | TODO: examples from X for clz/ctz |
4 | TODO: arithmetic right shift |
5 | TODO: bit reversal |
6 | TODO: template/generic functions for x32/x64 and so on |
7 | TODO: generalised shift |
8 | unsigned long gensh(unsigned long v, int x) { |
9 | int a, b; |
10 | a = (v << x) & -(((unsigned int)x) < 32); |
11 | x = -x; |
12 | b = (v >> x) & -(((unsigned int)x) < 32); |
13 | return a|b; |
14 | } |