25 #ifndef _RTE_RECIPROCAL_H_ 26 #define _RTE_RECIPROCAL_H_ 36 struct rte_reciprocal {
41 struct rte_reciprocal_u64 {
46 static inline uint32_t rte_reciprocal_divide(uint32_t a,
struct rte_reciprocal R)
48 uint32_t t = (uint32_t)(((uint64_t)a * R.m) >> 32);
50 return (t + ((a - t) >> R.sh1)) >> R.sh2;
54 mullhi_u64(uint64_t x, uint64_t y)
56 #ifdef __SIZEOF_INT128__ 58 __uint128_t rl = xl * y;
62 uint64_t u0, u1, v0, v1, k, t;
66 u1 = x >> 32; u0 = x & 0xFFFFFFFF;
67 v1 = y >> 32; v0 = y & 0xFFFFFFFF;
86 rte_reciprocal_divide_u64(uint64_t a,
const struct rte_reciprocal_u64 *R)
88 uint64_t t = mullhi_u64(a, R->m);
90 return (t + ((a - t) >> R->sh1)) >> R->sh2;
93 struct rte_reciprocal rte_reciprocal_value(uint32_t d);
94 struct rte_reciprocal_u64 rte_reciprocal_value_u64(uint64_t d);
#define __rte_always_inline