diff mbox

[v3,5/9] linux-generic: odp_generator.c use odp_atomic.h

Message ID 1416868730-26140-6-git-send-email-ola.liljedahl@linaro.org
State Accepted
Commit 6d2d4d957ea9ee5a71e93a141811fb2eafb9bca6
Headers show

Commit Message

Ola Liljedahl Nov. 24, 2014, 10:38 p.m. UTC
Signed-off-by: Ola Liljedahl <ola.liljedahl@linaro.org>
---
Updated to use odp_atomic.h functions with atomic types.

 example/generator/odp_generator.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c
index e2e0ba4..7d1c237 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -338,11 +338,14 @@  static void *gen_send_thread(void *arg)
 
 		if (args->appl.interval != 0) {
 			printf("  [%02i] send pkt no:%ju seq %ju\n",
-			       thr, counters.seq, counters.seq%0xffff);
+			       thr,
+			       odp_atomic_load_u64(&counters.seq),
+			       odp_atomic_load_u64(&counters.seq)%0xffff);
 			/* TODO use odp timer */
 			usleep(args->appl.interval * 1000);
 		}
-		if (args->appl.number != -1 && counters.seq
+		if (args->appl.number != -1 &&
+		    odp_atomic_load_u64(&counters.seq)
 		    >= (unsigned int)args->appl.number) {
 			break;
 		}
@@ -351,7 +354,8 @@  static void *gen_send_thread(void *arg)
 	/* receive number of reply pks until timeout */
 	if (args->appl.mode == APPL_MODE_PING && args->appl.number > 0) {
 		while (args->appl.timeout >= 0) {
-			if (counters.icmp >= (unsigned int)args->appl.number)
+			if (odp_atomic_load_u64(&counters.icmp) >=
+			    (unsigned int)args->appl.number)
 				break;
 			/* TODO use odp timer */
 			sleep(1);
@@ -361,10 +365,12 @@  static void *gen_send_thread(void *arg)
 
 	/* print info */
 	if (args->appl.mode == APPL_MODE_UDP) {
-		printf("  [%02i] total send: %ju\n", thr, counters.seq);
+		printf("  [%02i] total send: %ju\n",
+		       thr, odp_atomic_load_u64(&counters.seq));
 	} else if (args->appl.mode == APPL_MODE_PING) {
 		printf("  [%02i] total send: %ju total receive: %ju\n",
-		       thr, counters.seq, counters.icmp);
+		       thr, odp_atomic_load_u64(&counters.seq),
+		       odp_atomic_load_u64(&counters.icmp));
 	}
 	return arg;
 }