aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Hawthorn <jhawthor@uvic.ca>2008-06-16 16:35:23 -0700
committerJohn Hawthorn <jhawthor@uvic.ca>2008-06-16 16:35:23 -0700
commitf5b1ed2faf007ac9c8ef12b2db2ea4bb725f19b0 (patch)
tree1703121c0c860b763c2b2afb14ba5a2e868b471f
parente97407561d66bf0aa4d02905e0b2693455b34a6b (diff)
downloadmirror-meh-f5b1ed2faf007ac9c8ef12b2db2ea4bb725f19b0.tar.gz
mirror-meh-f5b1ed2faf007ac9c8ef12b2db2ea4bb725f19b0.tar.bz2
mirror-meh-f5b1ed2faf007ac9c8ef12b2db2ea4bb725f19b0.zip
replace popcount with ctz
-rw-r--r--src/main.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/main.c b/src/main.c
index e67792f..f093b91 100644
--- a/src/main.c
+++ b/src/main.c
@@ -34,23 +34,19 @@ void usage(){
exit(1);
}
-static int popcount(unsigned long mask){
+unsigned int getshift(unsigned int mask){
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
- return __builtin_popcount(mask);
+ return __builtin_ctz(mask);
#else
- int y;
-
- y = (mask >> 1) & 033333333333;
- y = mask - y - ((y >> 1) & 033333333333);
- return (((y + (y >> 3)) & 030707070707) % 077);
+ int i = 0;
+ while((mask & 1) == 0){
+ i++;
+ mask >>= 1;
+ }
+ return i;
#endif
}
-
-unsigned int getshift(unsigned int mask){
- return popcount((mask - 1) & ~mask) & 31;
-}
-
void setaspect(int w, int h){
XSizeHints *hints = XAllocSizeHints();
hints->flags = PAspect;