Exemple #1
0
unsigned int
opr_uuid_hash(const opr_uuid_t *uuid)
{
   /* uuid->data is a (unsigned char *), so there's every danger that this
    * may cause an unaligned access on some platforms */
   return opr_jhash((const afs_uint32 *)uuid->data, 4, 0);
}
Exemple #2
0
int
main(int argc, char **argv)
{
   plan(8);
   uint32_t test[] = {3526055646, 2064483663, 3234460805, 3963629775};

   is_int(256, opr_jhash_size(8), "opr_jhash_size returns expected value");
   is_int(255, opr_jhash_mask(8), "opr_jhash_mask returns expected value");

   is_int(0xdeadbeef, opr_jhash(test, 0, 0), "empty array hashes as expected");
   is_int(766530906, opr_jhash(test, 4, 0), "simple array works");
   is_int(3782684773, opr_jhash(test, 4, 1), "changing initval works");

   test[2]++;
   is_int(1977082159, opr_jhash(test, 4, 0), "modifying value works");

   is_int(1100796964, opr_jhash(test, 1, 0),
	  "single value works through jhash");
   is_int(1100796964, opr_jhash_int(test[0], 0),
          "single value works through jhash_int");

   return 0;
}