Skip to content

Instantly share code, notes, and snippets.

@takikawa
Created March 27, 2014 19:37
Show Gist options
  • Save takikawa/9816339 to your computer and use it in GitHub Desktop.
Save takikawa/9816339 to your computer and use it in GitHub Desktop.
/* from libxcb, see license there */
int xcb_popcount(uint32_t mask)
{
uint32_t y;
y = (mask >> 1) & 033333333333;
y = mask - y - ((y >> 1) & 033333333333);
return ((y + (y >> 3)) & 030707070707) % 077;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment