diff mbox series

[ibdiags,03/16] ibdiags/ibping: Use clock_gettime instead of complib

Message ID 20190409131133.16140-4-jgg@ziepe.ca (mailing list archive)
State Not Applicable
Headers show
Series More warning fixes for infiniband-diags | expand

Commit Message

Jason Gunthorpe April 9, 2019, 1:11 p.m. UTC
From: Jason Gunthorpe <jgg@mellanox.com>

No reason to use a library for such a simple calculation.

Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
---
 src/ibping.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/src/ibping.c b/src/ibping.c
index ebcb581550f4f1..b463043ae73eb6 100644
--- a/src/ibping.c
+++ b/src/ibping.c
@@ -41,15 +41,23 @@ 
 #include <string.h>
 #include <signal.h>
 #include <getopt.h>
+#include <time.h>
 
 #include <infiniband/umad.h>
 #include <infiniband/mad.h>
-#include <complib/cl_timer.h>
 
 #include "ibdiag_common.h"
 
 struct ibmad_port *srcport;
 
+static uint64_t time_stamp(void)
+{
+	struct timespec ts;
+
+	clock_gettime(CLOCK_MONOTONIC, &ts);
+	return ((uint64_t)ts.tv_sec * 1000000ULL) + ts.tv_nsec / 10000ULL;
+}
+
 static char host_and_domain[IB_VENDOR_RANGE2_DATA_SIZE];
 static char last_host[IB_VENDOR_RANGE2_DATA_SIZE];
 
@@ -113,7 +121,7 @@  static uint64_t ibping(ib_portid_t * portid, int quiet)
 
 	DEBUG("Ping..");
 
-	start = cl_get_time_stamp();
+	start = time_stamp();
 
 	call.method = IB_MAD_METHOD_GET;
 	call.mgmt_class = IB_VENDOR_OPENIB_PING_CLASS;
@@ -126,7 +134,7 @@  static uint64_t ibping(ib_portid_t * portid, int quiet)
 	if (!ib_vendor_call_via(data, portid, &call, srcport))
 		return ~0ull;
 
-	rtt = cl_get_time_stamp() - start;
+	rtt = time_stamp() - start;
 
 	if (!last_host[0])
 		memcpy(last_host, data, sizeof last_host);
@@ -144,7 +152,7 @@  static ib_portid_t portid = { 0 };
 
 static void report(int sig)
 {
-	total_time = cl_get_time_stamp() - start;
+	total_time = time_stamp() - start;
 
 	DEBUG("out due signal %d", sig);
 
@@ -240,7 +248,7 @@  int main(int argc, char **argv)
 	signal(SIGINT, report);
 	signal(SIGTERM, report);
 
-	start = cl_get_time_stamp();
+	start = time_stamp();
 
 	while (count-- > 0) {
 		ntrans++;