File lparstat-Add-helper-function-to-calculate-delta.patch of Package powerpc-utils.21082

From cac06c8ef3e94892c226a09c35f10221cd17e401 Mon Sep 17 00:00:00 2001
From: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
Date: Fri, 15 May 2020 11:13:04 +0530
Subject: [PATCH] lparstat: Add helper function to calculate delta

Patch-mainline: v1.3.8
Git-commit: 30231beaba58a175e776597a1f07b35bc26fcfce

Add a helper function for one of the most often used arithmetics of
calculating delta of a sysentry.

Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com>
---
 src/lparstat.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/lparstat.c b/src/lparstat.c
index ffb2cfa4f5e1..350155b1cd26 100644
--- a/src/lparstat.c
+++ b/src/lparstat.c
@@ -73,6 +73,21 @@ void get_sysdata(char *name, char **descr, char *value)
 	*descr = se->descr;
 }
 
+long long get_delta_value(char *se_name)
+{
+	long long value, old_value;
+	struct sysentry *se;
+
+	se = get_sysentry(se_name);
+	if (se->value[0] == '\0')
+		return 0LL;
+
+	value = strtoll(se->value, NULL, 0);
+	old_value = strtoll(se->old_value, NULL, 0);
+
+	return (value - old_value);
+}
+
 void get_time()
 {
 	struct timeval t;
-- 
2.26.2

openSUSE Build Service is sponsored by