rte_jhash.h(3)

πŸ’– rte_jhash.h β€” the girlies' guide to jhash (Library Functions Manual) πŸ’–

okay bestie, so this is a manual page from DPDK for the header rte_jhash.h, and it's literally just a pile of hashing functions that go brrr. if you've ever needed to turn some bytes into a number that looks completely random but is actually deterministic, this is your moment. slay.


✨ NAME ✨

rte_jhash.h β€” the header that's giving "hash everything you love" πŸ’…


🌸 SYNOPSIS 🌸

#include <stdint.h> #include <string.h> #include <limits.h> #include <rte_config.h> #include <rte_log.h> #include <rte_byteorder.h>

πŸŽ€ Macros

#define RTE_JHASH_GOLDEN_RATIO   0xdeadbeef

πŸ¦‹ Functions

static void rte_jhash_2hashes (const void *key, uint32_t length,
    uint32_t *pc, uint32_t *pb)
static void rte_jhash_32b_2hashes (const uint32_t *k, uint32_t length,
    uint32_t *pc, uint32_t *pb)
static uint32_t rte_jhash (const void *key, uint32_t length, uint32_t
    initval)
static uint32_t rte_jhash_32b (const uint32_t *k, uint32_t length,
    uint32_t initval)
static uint32_t rte_jhash_3words (uint32_t a, uint32_t b, uint32_t c,
    uint32_t initval)
static uint32_t rte_jhash_2words (uint32_t a, uint32_t b, uint32_t
    initval)
static uint32_t rte_jhash_1word (uint32_t a, uint32_t initval)

πŸ”₯ DETAILED DESCRIPTION πŸ”₯

jhash functions. that's it. that's the description. no notes, we love a header that knows exactly what it is.

Definition in file rte_jhash.h.


πŸ‘‘ MACRO DEFINITION DOCUMENTATION πŸ‘‘

✨ #define RTE_JHASH_GOLDEN_RATIO 0xdeadbeef

The golden ratio: an arbitrary value.

Definition at line 68 of file rte_jhash.h.


πŸ’œ FUNCTION DOCUMENTATION πŸ’œ

🫢 void rte_jhash_2hashes (const void * key, uint32_t length, uint32_t * pc, uint32_t * pb) [inline], [static]

Same as rte_jhash, but it takes two seeds and returns two uint32_ts. pc and pb must be non-null, and both *pc and *pb must be initialized with seeds. and here's the little trick bestie: if you pass in (*pb)=0, the output (*pc) will be the same as the return value from rte_jhash. iconic behavior ngl.

Parameters

  • key β€” Key to calculate hash of.
  • length β€” Length of key in bytes.
  • pc β€” IN: seed OUT: primary hash value.
  • pb β€” IN: second seed OUT: secondary hash value.

Definition at line 236 of file rte_jhash.h.


πŸ’« void rte_jhash_32b_2hashes (const uint32_t * k, uint32_t length, uint32_t * pc, uint32_t * pb) [inline], [static]

Same as rte_jhash_32b, but with two seeds and two uint32_ts out. pc and pb must be non-null, and *pc and *pb must both be initialized with seeds. if you pass in (*pb)=0, the output (*pc) will be the same as the return value from rte_jhash_32b. same energy, different function, we love consistency πŸŽ€

Parameters

  • k β€” Key to calculate hash of.
  • length β€” Length of key in units of 4 bytes.
  • pc β€” IN: seed OUT: primary hash value.
  • pb β€” IN: second seed OUT: secondary hash value.

Definition at line 257 of file rte_jhash.h.


🌈 uint32_t rte_jhash (const void * key, uint32_t length, uint32_t initval) [inline], [static]

The most generic version, hashes an arbitrary sequence of bytes. No alignment or length assumptions are made about the input key. BUT listen β€” for keys not aligned to four byte boundaries, or a length that isn't a multiple of four bytes, the memory region just after may be read (but not used in the computation). and yes, that read may cross a page boundary. so mind your buffers, bestie πŸ’€

Parameters

  • key β€” Key to calculate hash of.
  • length β€” Length of key in bytes.
  • initval β€” Initialising value of hash.

Returns

  • Calculated hash value.

Definition at line 280 of file rte_jhash.h.


πŸ’… uint32_t rte_jhash_32b (const uint32_t * k, uint32_t length, uint32_t initval) [inline], [static]

A special optimized version that handles 1 or more of uint32_ts. the length parameter here is the number of uint32_ts in the key (not bytes!! don't get it twisted).

Parameters

  • k β€” Key to calculate hash of.
  • length β€” Length of key in units of 4 bytes.
  • initval β€” Initialising value of hash.

Returns

  • Calculated hash value.

Definition at line 303 of file rte_jhash.h.


⭐ uint32_t rte_jhash_3words (uint32_t a, uint32_t b, uint32_t c, uint32_t initval) [inline], [static]

A special ultra-optimized version that knows it is hashing exactly 3 words. it said main character energy only, no guessing.

Parameters

  • a β€” First word to calculate hash of.
  • b β€” Second word to calculate hash of.
  • c β€” Third word to calculate hash of.
  • initval β€” Initialising value of hash.

Returns

  • Calculated hash value.

Definition at line 340 of file rte_jhash.h.


πŸ“ uint32_t rte_jhash_2words (uint32_t a, uint32_t b, uint32_t initval) [inline], [static]

A special ultra-optimized version that knows it is hashing exactly 2 words. two words, zero hesitation ✨

Parameters

  • a β€” First word to calculate hash of.
  • b β€” Second word to calculate hash of.
  • initval β€” Initialising value of hash.

Returns

  • Calculated hash value.

Definition at line 359 of file rte_jhash.h.


🧚 uint32_t rte_jhash_1word (uint32_t a, uint32_t initval) [inline], [static]

A special ultra-optimized version that knows it is hashing exactly 1 word. one singular word. she's lowkey the simplest of the whole squad.

Parameters

  • a β€” Word to calculate hash of.
  • initval β€” Initialising value of hash.

Returns

  • Calculated hash value.

Definition at line 376 of file rte_jhash.h.


🌟 AUTHOR 🌟

Generated automatically by Doxygen for DPDK from the source code. yeah, no human author to tag here, the robot did it πŸ™ˆ


okay that's the whole page bestie, you ate it πŸ’– this was DPDK, Version 25.11.3, and it's the rte_jhash.h(3) page β€” go forth and hash responsibly, no cap πŸ«Άβœ¨πŸ‘‘

πŸ“¦ where this page comes from