X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fcount-one-bits.h;h=093165c1544cd6f9e135863970fba5cbfa6837e2;hb=4af188706f5b07a9e57ccdc83ec6e347aa4d27b6;hp=ae8a5a89bf30bb7a9b00868739d710864928d3ce;hpb=d8965b7823ae5167a60fa39ad91b9fdc26280513;p=gnulib.git diff --git a/lib/count-one-bits.h b/lib/count-one-bits.h index ae8a5a89b..093165c15 100644 --- a/lib/count-one-bits.h +++ b/lib/count-one-bits.h @@ -1,5 +1,5 @@ /* count-one-bits.h -- counts the number of 1-bits in a word. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,13 +30,15 @@ return BUILTIN (x); #else #define COUNT_ONE_BITS(BUILTIN, TYPE) \ + /* This condition is written so as to avoid shifting by more than \ + 31 bits at once, and also avoids a random HP-UX cc bug. */ \ verify (((TYPE) -1 >> 31 >> 31 >> 2) == 0); /* TYPE has at most 64 bits */ \ int count = count_one_bits_32 (x); \ if (1 < (TYPE) -1 >> 31) /* TYPE has more than 32 bits? */ \ count += count_one_bits_32 (x >> 31 >> 1); \ return count; -/* Compute and return the the number of 1-bits set in the least +/* Compute and return the number of 1-bits set in the least significant 32 bits of X. */ static inline int count_one_bits_32 (unsigned int x)