25 #ifndef _RTE_RECIPROCAL_H_
26 #define _RTE_RECIPROCAL_H_
32 struct rte_reciprocal {
37 struct rte_reciprocal_u64 {
42 static inline uint32_t rte_reciprocal_divide(uint32_t a,
struct rte_reciprocal R)
44 uint32_t t = (uint32_t)(((uint64_t)a * R.m) >> 32);
46 return (t + ((a - t) >> R.sh1)) >> R.sh2;
50 mullhi_u64(uint64_t x, uint64_t y)
52 #ifdef __SIZEOF_INT128__
54 __uint128_t rl = xl * y;
58 uint64_t u0, u1, v0, v1, k, t;
62 u1 = x >> 32; u0 = x & 0xFFFFFFFF;
63 v1 = y >> 32; v0 = y & 0xFFFFFFFF;
82 rte_reciprocal_divide_u64(uint64_t a,
const struct rte_reciprocal_u64 *R)
84 uint64_t t = mullhi_u64(a, R->m);
86 return (t + ((a - t) >> R->sh1)) >> R->sh2;
89 struct rte_reciprocal rte_reciprocal_value(uint32_t d);
90 struct rte_reciprocal_u64 rte_reciprocal_value_u64(uint64_t d);
#define __rte_always_inline