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
- ubuntu resolute: dpdk-doc 25.11.3-0ubuntu0.26.04.1 Β· BSD-3-Clause
- ubuntu stonking: dpdk-doc 25.11.3-1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms