diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 20 |
1 files changed, 8 insertions, 12 deletions
@@ -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; |