Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 May 2021 12:46:19 GMT
From:      Lutz Donnerhacke <donner@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: ccac04cae538 - main - test/libalias: Fix build errors on various platforms
Message-ID:  <202105231246.14NCkJ2Q070196@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by donner:

URL: https://cgit.FreeBSD.org/src/commit/?id=ccac04cae538a625cbce224e4005360fa85e1b9d

commit ccac04cae538a625cbce224e4005360fa85e1b9d
Author:     Lutz Donnerhacke <donner@FreeBSD.org>
AuthorDate: 2021-05-23 12:43:00 +0000
Commit:     Lutz Donnerhacke <donner@FreeBSD.org>
CommitDate: 2021-05-23 12:43:00 +0000

    test/libalias: Fix build errors on various platforms
    
    struct timeval has an unspecified integral type, which needs to be
    canonfied before beeing usable by printf(3).
---
 tests/sys/netinet/libalias/perf.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/tests/sys/netinet/libalias/perf.c b/tests/sys/netinet/libalias/perf.c
index ac4796cf9649..fadbb439774a 100644
--- a/tests/sys/netinet/libalias/perf.c
+++ b/tests/sys/netinet/libalias/perf.c
@@ -15,7 +15,7 @@ static struct in_addr ext  = { htonl(0x12000000) };
 	 ? ((tv).tv_usec cmp (uv).tv_usec)	\
 	 : ((tv).tv_sec cmp (uv).tv_sec))
 
-#define timevaldiff(n, o)			\
+#define timevaldiff(n, o) (float)		\
 	(((n).tv_sec - (o).tv_sec)*1000000l +	\
 	 ((n).tv_usec - (o).tv_usec))
 
@@ -69,7 +69,7 @@ int main(int argc, char ** argv)
 	gettimeofday(&timeout, NULL);
 	timeout.tv_sec += max_seconds;
 
-	printf("RND SEC NAT RND ATT UNA\n");
+	printf("RND SECND NAT RND ATT UNA\n");
 	for (round = 0; ; round++) {
 		int i, res;
 		struct timeval now, start;
@@ -77,7 +77,7 @@ int main(int argc, char ** argv)
 		printf("%3d ", round+1);
 
 		gettimeofday(&start, NULL);
-		printf("%3ld ", max_seconds - (timeout.tv_sec - start.tv_sec));
+		printf("%5.1f ", max_seconds - timevaldiff(timeout, start)/1000000.0f);
 		for (cnt = i = 0; i < batch_size; i++, cnt++) {
 			batch[i].src.s_addr = prv.s_addr | htonl(rand_range(0, 0xffff));
 			batch[i].dst.s_addr = ext.s_addr | htonl(rand_range(0, 0xffff));
@@ -104,7 +104,7 @@ int main(int argc, char ** argv)
 				goto out;
 		}
 		if (cnt > 0)
-			printf("%3lu ", timevaldiff(now, start) / cnt);
+			printf("%3.0f ", timevaldiff(now, start) / cnt);
 
 		start = now;
 		for (cnt = i = 0; i < random_size; i++, cnt++) {
@@ -125,7 +125,7 @@ int main(int argc, char ** argv)
 				goto out;
 		}
 		if (cnt > 0)
-			printf("%3lu ", timevaldiff(now, start) / cnt);
+			printf("%3.0f ", timevaldiff(now, start) / cnt);
 
 		start = now;
 		p->ip_src.s_addr = ext.s_addr & htonl(0xfff00000);
@@ -145,7 +145,7 @@ int main(int argc, char ** argv)
 				goto out;
 		}
 		if (cnt > 0)
-			printf("%3lu ", timevaldiff(now, start) / cnt);
+			printf("%3.0f ", timevaldiff(now, start) / cnt);
 
 		qsort(batch, batch_size, sizeof(*batch), randcmp);
 
@@ -172,7 +172,7 @@ int main(int argc, char ** argv)
 				goto out;
 		}
 		if (cnt > 0)
-			printf("%3lu\n", timevaldiff(now, start) / cnt);
+			printf("%3.0f\n", timevaldiff(now, start) / cnt);
 	}
 out:
 	printf("\n\n");



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105231246.14NCkJ2Q070196>