1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
5 #ifndef __INCLUDE_RTE_SCHED_COMMON_H__
6 #define __INCLUDE_RTE_SCHED_COMMON_H__
13 #include <sys/types.h>
15 #define __rte_aligned_16 __attribute__((__aligned__(16)))
18 static inline uint32_t
19 rte_min_pos_4_u16(uint16_t *x)
23 pos0 = (x[0] <= x[1])? 0 : 1;
24 pos1 = (x[2] <= x[3])? 2 : 3;
26 return (x[pos0] <= x[pos1])? pos0 : pos1;
31 /* simplified version to remove branches with CMOV instruction */
32 static inline uint32_t
33 rte_min_pos_4_u16(uint16_t *x)
38 if (x[1] <= x[0]) pos0 = 1;
39 if (x[3] <= x[2]) pos1 = 3;
40 if (x[pos1] <= x[pos0]) pos0 = pos1;
48 * Compute the Greatest Common Divisor (GCD) of two numbers.
49 * This implementation uses Euclid's algorithm:
51 * gcd(a, b) = gcd(b, a mod b)
54 static inline uint32_t
55 rte_get_gcd(uint32_t a, uint32_t b)
80 * Compute the Lowest Common Denominator (LCD) of two numbers.
81 * This implementation computes GCD first:
82 * LCD(a, b) = (a * b) / GCD(a, b)
85 static inline uint32_t
86 rte_get_lcd(uint32_t a, uint32_t b)
88 return (a * b) / rte_get_gcd(a, b);
95 #endif /* __INCLUDE_RTE_SCHED_COMMON_H__ */