jhash.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* jhash.h: Jenkins hash support.
  2. *
  3. * Copyright (C) 1996 Bob Jenkins (bob_jenkins@burtleburtle.net)
  4. *
  5. * http://burtleburtle.net/bob/hash/
  6. *
  7. * These are the credits from Bob's sources:
  8. *
  9. * lookup2.c, by Bob Jenkins, December 1996, Public Domain.
  10. * hash(), hash2(), hash3, and mix() are externally useful functions.
  11. * Routines to test the hash are included if SELF_TEST is defined.
  12. * You can use this free for any purpose. It has no warranty.
  13. *
  14. * Copyright (C) 2003 David S. Miller (davem@redhat.com)
  15. *
  16. * I've modified Bob's hash to be useful in the Linux kernel, and
  17. * any bugs present are surely my fault. -DaveM
  18. */
  19. #ifndef _QUAGGA_JHASH_H
  20. #define _QUAGGA_JHASH_H
  21. /* The most generic version, hashes an arbitrary sequence
  22. * of bytes. No alignment or length assumptions are made about
  23. * the input key.
  24. */
  25. extern u_int32_t jhash(const void *key, u_int32_t length, u_int32_t initval);
  26. /* A special optimized version that handles 1 or more of u_int32_ts.
  27. * The length parameter here is the number of u_int32_ts in the key.
  28. */
  29. extern u_int32_t jhash2(const u_int32_t *k, u_int32_t length, u_int32_t initval);
  30. /* A special ultra-optimized versions that knows they are hashing exactly
  31. * 3, 2 or 1 word(s).
  32. *
  33. * NOTE: In partilar the "c += length; __jhash_mix(a,b,c);" normally
  34. * done at the end is not done here.
  35. */
  36. extern u_int32_t jhash_3words(u_int32_t a, u_int32_t b, u_int32_t c, u_int32_t initval);
  37. extern u_int32_t jhash_2words(u_int32_t a, u_int32_t b, u_int32_t initval);
  38. extern u_int32_t jhash_1word(u_int32_t a, u_int32_t initval);
  39. #endif /* _QUAGGA_JHASH_H */