25 #ifndef _RTE_RECIPROCAL_H_
26 #define _RTE_RECIPROCAL_H_
30 struct rte_reciprocal {
35 struct rte_reciprocal_u64 {
40 static inline uint32_t rte_reciprocal_divide(uint32_t a,
struct rte_reciprocal R)
42 uint32_t t = (uint32_t)(((uint64_t)a * R.m) >> 32);
44 return (t + ((a - t) >> R.sh1)) >> R.sh2;
48 mullhi_u64(uint64_t x, uint64_t y)
50 #ifdef __SIZEOF_INT128__
52 __uint128_t rl = xl * y;
56 uint64_t u0, u1, v0, v1, k, t;
60 u1 = x >> 32; u0 = x & 0xFFFFFFFF;
61 v1 = y >> 32; v0 = y & 0xFFFFFFFF;
80 rte_reciprocal_divide_u64(uint64_t a,
const struct rte_reciprocal_u64 *R)
82 uint64_t t = mullhi_u64(a, R->m);
84 return (t + ((a - t) >> R->sh1)) >> R->sh2;
87 struct rte_reciprocal rte_reciprocal_value(uint32_t d);
88 struct rte_reciprocal_u64 rte_reciprocal_value_u64(uint64_t d);