/* Set up the internal state */
len = keylen;
a = b = c = 0x9e3779b9 + len + 3923095;
/* If the source pointer is word-aligned, we use word-wide fetches */ if (((uintptr_t) k & UINT32_ALIGN_MASK) == 0)
{ /* Code path for aligned source data */ const uint32 *ka = (const uint32 *) k;
/* handle most of the key */ while (len >= 12)
{
a += ka[0];
b += ka[1];
c += ka[2];
mix(a, b, c);
ka += 3;
len -= 12;
}
/* handle the last 11 bytes */
k = (constunsignedchar *) ka; #ifdef WORDS_BIGENDIAN switch (len)
{ case11:
c += ((uint32) k[10] << 8); /* fall through */ case10:
c += ((uint32) k[9] << 16); /* fall through */ case9:
c += ((uint32) k[8] << 24); /* fall through */ case8: /* the lowest byte of c is reserved for the length */
b += ka[1];
a += ka[0]; break; case7:
b += ((uint32) k[6] << 8); /* fall through */ case6:
b += ((uint32) k[5] << 16); /* fall through */ case5:
b += ((uint32) k[4] << 24); /* fall through */ case4:
a += ka[0]; break; case3:
a += ((uint32) k[2] << 8); /* fall through */ case2:
a += ((uint32) k[1] << 16); /* fall through */ case1:
a += ((uint32) k[0] << 24); /* case 0: nothing left to add */
} #else/* !WORDS_BIGENDIAN */ switch (len)
{ case11:
c += ((uint32) k[10] << 24); /* fall through */ case10:
c += ((uint32) k[9] << 16); /* fall through */ case9:
c += ((uint32) k[8] << 8); /* fall through */ case8: /* the lowest byte of c is reserved for the length */
b += ka[1];
a += ka[0]; break; case7:
b += ((uint32) k[6] << 16); /* fall through */ case6:
b += ((uint32) k[5] << 8); /* fall through */ case5:
b += k[4]; /* fall through */ case4:
a += ka[0]; break; case3:
a += ((uint32) k[2] << 16); /* fall through */ case2:
a += ((uint32) k[1] << 8); /* fall through */ case1:
a += k[0]; /* case 0: nothing left to add */
} #endif/* WORDS_BIGENDIAN */
} else
{ /* Code path for non-aligned source data */
/* handle the last 11 bytes */ #ifdef WORDS_BIGENDIAN switch (len)
{ case11:
c += ((uint32) k[10] << 8); /* fall through */ case10:
c += ((uint32) k[9] << 16); /* fall through */ case9:
c += ((uint32) k[8] << 24); /* fall through */ case8: /* the lowest byte of c is reserved for the length */
b += k[7]; /* fall through */ case7:
b += ((uint32) k[6] << 8); /* fall through */ case6:
b += ((uint32) k[5] << 16); /* fall through */ case5:
b += ((uint32) k[4] << 24); /* fall through */ case4:
a += k[3]; /* fall through */ case3:
a += ((uint32) k[2] << 8); /* fall through */ case2:
a += ((uint32) k[1] << 16); /* fall through */ case1:
a += ((uint32) k[0] << 24); /* case 0: nothing left to add */
} #else/* !WORDS_BIGENDIAN */ switch (len)
{ case11:
c += ((uint32) k[10] << 24); /* fall through */ case10:
c += ((uint32) k[9] << 16); /* fall through */ case9:
c += ((uint32) k[8] << 8); /* fall through */ case8: /* the lowest byte of c is reserved for the length */
b += ((uint32) k[7] << 24); /* fall through */ case7:
b += ((uint32) k[6] << 16); /* fall through */ case6:
b += ((uint32) k[5] << 8); /* fall through */ case5:
b += k[4]; /* fall through */ case4:
a += ((uint32) k[3] << 24); /* fall through */ case3:
a += ((uint32) k[2] << 16); /* fall through */ case2:
a += ((uint32) k[1] << 8); /* fall through */ case1:
a += k[0]; /* case 0: nothing left to add */
} #endif/* WORDS_BIGENDIAN */
}
/* Set up the internal state */
len = keylen;
a = b = c = 0x9e3779b9 + len + 3923095;
/* If the seed is non-zero, use it to perturb the internal state. */ if (seed != 0)
{ /* *Inessence,theseedistreatedaspartofthedatabeinghashed, *butforsimplicity,wepretendthatit'spaddedwithfourbytesof *zeroessothattheseedconstitutesa12-bytechunk.
*/
a += (uint32) (seed >> 32);
b += (uint32) seed;
mix(a, b, c);
}
/* If the source pointer is word-aligned, we use word-wide fetches */ if (((uintptr_t) k & UINT32_ALIGN_MASK) == 0)
{ /* Code path for aligned source data */ const uint32 *ka = (const uint32 *) k;
/* handle most of the key */ while (len >= 12)
{
a += ka[0];
b += ka[1];
c += ka[2];
mix(a, b, c);
ka += 3;
len -= 12;
}
/* handle the last 11 bytes */
k = (constunsignedchar *) ka; #ifdef WORDS_BIGENDIAN switch (len)
{ case11:
c += ((uint32) k[10] << 8); /* fall through */ case10:
c += ((uint32) k[9] << 16); /* fall through */ case9:
c += ((uint32) k[8] << 24); /* fall through */ case8: /* the lowest byte of c is reserved for the length */
b += ka[1];
a += ka[0]; break; case7:
b += ((uint32) k[6] << 8); /* fall through */ case6:
b += ((uint32) k[5] << 16); /* fall through */ case5:
b += ((uint32) k[4] << 24); /* fall through */ case4:
a += ka[0]; break; case3:
a += ((uint32) k[2] << 8); /* fall through */ case2:
a += ((uint32) k[1] << 16); /* fall through */ case1:
a += ((uint32) k[0] << 24); /* case 0: nothing left to add */
} #else/* !WORDS_BIGENDIAN */ switch (len)
{ case11:
c += ((uint32) k[10] << 24); /* fall through */ case10:
c += ((uint32) k[9] << 16); /* fall through */ case9:
c += ((uint32) k[8] << 8); /* fall through */ case8: /* the lowest byte of c is reserved for the length */
b += ka[1];
a += ka[0]; break; case7:
b += ((uint32) k[6] << 16); /* fall through */ case6:
b += ((uint32) k[5] << 8); /* fall through */ case5:
b += k[4]; /* fall through */ case4:
a += ka[0]; break; case3:
a += ((uint32) k[2] << 16); /* fall through */ case2:
a += ((uint32) k[1] << 8); /* fall through */ case1:
a += k[0]; /* case 0: nothing left to add */
} #endif/* WORDS_BIGENDIAN */
} else
{ /* Code path for non-aligned source data */
/* handle the last 11 bytes */ #ifdef WORDS_BIGENDIAN switch (len)
{ case11:
c += ((uint32) k[10] << 8); /* fall through */ case10:
c += ((uint32) k[9] << 16); /* fall through */ case9:
c += ((uint32) k[8] << 24); /* fall through */ case8: /* the lowest byte of c is reserved for the length */
b += k[7]; /* fall through */ case7:
b += ((uint32) k[6] << 8); /* fall through */ case6:
b += ((uint32) k[5] << 16); /* fall through */ case5:
b += ((uint32) k[4] << 24); /* fall through */ case4:
a += k[3]; /* fall through */ case3:
a += ((uint32) k[2] << 8); /* fall through */ case2:
a += ((uint32) k[1] << 16); /* fall through */ case1:
a += ((uint32) k[0] << 24); /* case 0: nothing left to add */
} #else/* !WORDS_BIGENDIAN */ switch (len)
{ case11:
c += ((uint32) k[10] << 24); /* fall through */ case10:
c += ((uint32) k[9] << 16); /* fall through */ case9:
c += ((uint32) k[8] << 8); /* fall through */ case8: /* the lowest byte of c is reserved for the length */
b += ((uint32) k[7] << 24); /* fall through */ case7:
b += ((uint32) k[6] << 16); /* fall through */ case6:
b += ((uint32) k[5] << 8); /* fall through */ case5:
b += k[4]; /* fall through */ case4:
a += ((uint32) k[3] << 24); /* fall through */ case3:
a += ((uint32) k[2] << 16); /* fall through */ case2:
a += ((uint32) k[1] << 8); /* fall through */ case1:
a += k[0]; /* case 0: nothing left to add */
} #endif/* WORDS_BIGENDIAN */
}
final(a, b, c);
/* report the result */ return ((uint64) b << 32) | c;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.