* Return the rounded-up log2 of a 64-bit integer. * * @note Contrary to the logarithm mathematical operation, * rte_log2_u64(0) == 0 and not -inf. * * @param v * The input parameter. * @return * The rounded-up log2 of the input, or 0 if the input is 0. */
| 710 | * The rounded-up log2 of the input, or 0 if the input is 0. |
| 711 | */ |
| 712 | static inline uint32_t |
| 713 | rte_log2_u64(uint64_t v) |
| 714 | { |
| 715 | if (v == 0) |
| 716 | return 0; |
| 717 | v = rte_align64pow2(v); |
| 718 | /* we checked for v being 0 already, so no undefined behavior */ |
| 719 | return rte_bsf64(v); |
| 720 | } |
| 721 | |
| 722 | #ifdef __cplusplus |
| 723 | } |