-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Jim Meyering on 6/18/2009 11:37 AM: >> + size_t val = data; >> + val = (val >> 3) | (val << (CHAR_BIT * sizeof val - 3)); >> + return val % n; > > That looks fine.
Added as: size_t val = (size_t) data; val = ((val >> 3) | (val << (CHAR_BIT * sizeof val - 3))) & SIZE_MAX; to address concerns about casting (I didn't get any warning with the implicit cast, but understand that void*->size_t is different than void*->intptr_t, so the cast makes it obvious), and to address the possibility that size_t might be less than int (is there such a platform?). > Though how about adding size_t variants to lib/bitrotate.h? > Then we can use this: > > val = rotr<something> (val, 3); For rotr64, it is probably superfluous; but for sizes smaller than int smaller sizes it makes a difference. I think that warrants a separate patch, since it also changes the dependencies for hash.c, as well as touching the bitrotate module. But it does sound like a nice idea. > > Then there's the question of the name. > rotr_sz? rotr_size_t is not kosher since it ends in _t, > which is reserved. I don't like rotr_sizet. > Maybe rotrsz, but I prefer with the underscore. I'm leaning towards rotr_sz. > - -- Don't work too hard, make some time for fun as well! Eric Blake e...@byu.net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAko6juEACgkQ84KuGfSFAYCHtACgv2mr8BcPhMD9jzBPaSx4e1mM oBUAoIuB4LvJH2dc8As7TJU78p4ML8tY =b3FU -----END PGP SIGNATURE-----