diff mbox series

[v2,1/2] sched: adds function to get 64 bits greatest common divisor

Message ID 20210923081122.176735-2-xuemingl@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers show
Series sched: adds function to get 64 bits greatest common divisor | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Xueming Li Sept. 23, 2021, 8:11 a.m. UTC
This patch adds new function that compute the greatest common
divisor of 64 bits, also changes the original 32 bits function to call
this new 64 bits version.

Signed-off-by: Xueming Li <xuemingl@nvidia.com>
Cc: stable@dpdk.org
---
 lib/sched/rte_sched_common.h | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Comments

Kevin Traynor Sept. 23, 2021, 9:53 a.m. UTC | #1
On 23/09/2021 09:11, Xueming Li wrote:
> This patch adds new function that compute the greatest common
> divisor of 64 bits, also changes the original 32 bits function to call
> this new 64 bits version.
> 
> Signed-off-by: Xueming Li <xuemingl@nvidia.com>
> Cc: stable@dpdk.org
> ---

lgtm.

Acked-by: Kevin Traynor <ktraynor@redhat.com>
diff mbox series

Patch

diff --git a/lib/sched/rte_sched_common.h b/lib/sched/rte_sched_common.h
index 96706df7bd..340a0df312 100644
--- a/lib/sched/rte_sched_common.h
+++ b/lib/sched/rte_sched_common.h
@@ -51,10 +51,10 @@  rte_min_pos_4_u16(uint16_t *x)
  *    gcd(a, b) = gcd(b, a mod b)
  *
  */
-static inline uint32_t
-rte_get_gcd(uint32_t a, uint32_t b)
+static inline uint64_t
+rte_get_gcd64(uint64_t a, uint64_t b)
 {
-	uint32_t c;
+	uint64_t c;
 
 	if (a == 0)
 		return b;
@@ -76,6 +76,15 @@  rte_get_gcd(uint32_t a, uint32_t b)
 	return a;
 }
 
+/*
+ * 32bit version of Compute the Greatest Common Divisor (GCD).
+ */
+static inline uint32_t
+rte_get_gcd(uint32_t a, uint32_t b)
+{
+	return rte_get_gcd64(a, b);
+}
+
 /*
  * Compute the Lowest Common Denominator (LCD) of two numbers.
  * This implementation computes GCD first: