Merge tag 'upstream/16.11.9' into 16.11.x
[deb_dpdk.git] / lib / librte_sched / rte_reciprocal.c
index 652f023..385109c 100644 (file)
 
 #include "rte_reciprocal.h"
 
-/* find largest set bit.
- * portable and slow but does not matter for this usage.
- */
-static inline int fls(uint32_t x)
-{
-       int b;
-
-       for (b = 31; b >= 0; --b) {
-               if (x & (1u << b))
-                       return b + 1;
-       }
-
-       return 0;
-}
-
 struct rte_reciprocal rte_reciprocal_value(uint32_t d)
 {
        struct rte_reciprocal R;
        uint64_t m;
        int l;
 
-       l = fls(d - 1);
+       l = rte_fls_u32(d - 1);
        m = ((1ULL << 32) * ((1ULL << l) - d));
        m /= d;