trace-cmd: Move the Knuth functions out of trace-filter-hash.h
PATCH 3/5 trace-cmd: Move the Knuth functions out of trace-filter-hash.h
From: "Steven Rostedt (VMware)" <[email protected]>
Now that trace-filter-hash is part of the libtracecmd.a set, we can only export functions that are of the "tracecmd_" prefix. We need to remove the Knuth hash function helpers out of the include file. Since they are only used by trace-filter-hash.c, move them there.
Signed-off-by Steven Rostedt (VMware) <[email protected]>
--- include/trace-cmd/trace-filter-hash.h | 35 --------------------------- lib/trace-cmd/trace-filter-hash.c | 35 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 35 deletions(-)
include/trace-cmd/trace-filter-hash.h +0 -35
@@ -48,39 +48,4 @@ static inline int filter_task_count(struct filter_id *hash) return hash->count; } -/* -* Hashing functions, based on Donald E. Knuth's Multiplicative hashing. -* See The Art of Computer Programming (TAOCP). -*/ - -static inline uint8_t knuth_hash8 (uint32_t val) -{ -/* -* Multiplicative hashing function. -* Multiplication by the Prime number, closest to the golden -* ratio of 2^8. -*/ -return UINT8_C (val) *UINT8_C (157 ); -} - -static inline uint16_t knuth_hash16 (uint32_t val) -{ -/* -* Multiplicative hashing function. -* Multiplication by the Prime number, closest to the golden -* ratio of 2^16. -*/ -return UINT16_C (val) *UINT16_C (40507 ); -} - -static inline uint32_t knuth_hash (uint32_t val) -{ -/* -* Multiplicative hashing function. -* Multiplication by the Prime number, closest to the golden -* ratio of 2^32. -*/ -return val *UINT32_C (2654435761 ); -} -#endif /* _TRACE_FILTER_HASH_H */
lib/trace-cmd/trace-filter-hash.c +35 -0
@@ -28,6 +28,41 @@#define FILTER_HASH_SIZE 256 +/* +* Hashing functions, based on Donald E. Knuth's Multiplicative hashing. +* See The Art of Computer Programming (TAOCP). +*/ + +static inline uint8_t knuth_hash8 (uint32_t val) +{ +/* +* Multiplicative hashing function. +* Multiplication by the Prime number, closest to the golden +* ratio of 2^8. +*/ +return UINT8_C (val) *UINT8_C (157 ); +} + +static inline uint16_t knuth_hash16 (uint32_t val) +{ +/* +* Multiplicative hashing function. +* Multiplication by the Prime number, closest to the golden +* ratio of 2^16. +*/ +return UINT16_C (val) *UINT16_C (40507 ); +} + +static inline uint32_t knuth_hash (uint32_t val) +{ +/* +* Multiplicative hashing function. +* Multiplication by the Prime number, closest to the golden +* ratio of 2^32. +*/ +return val *UINT32_C (2654435761 ); +} +struct filter_id_item *filter_id_find (struct filter_id *hash,int id) {
Signature · 1 line
2.17.1