diff mbox

[PATCHv6,34/38] example: switch: using agnostic function for ODP threads

Message ID 1462984942-53326-35-git-send-email-christophe.milard@linaro.org
State Superseded
Headers show

Commit Message

Christophe Milard May 11, 2016, 4:42 p.m. UTC
odp_switch is changed to use the implementation agnostic ODP thread
create and join functions, from helpers.
odp_switch is hence no longer aware on how the odpthread is
implemented.

Signed-off-by: Christophe Milard <christophe.milard@linaro.org>
---
 example/switch/odp_switch.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
diff mbox

Patch

diff --git a/example/switch/odp_switch.c b/example/switch/odp_switch.c
index 96229ff..9358c2c 100644
--- a/example/switch/odp_switch.c
+++ b/example/switch/odp_switch.c
@@ -574,7 +574,7 @@  static void bind_workers(void)
  *
  * @param arg  Thread arguments of type 'thread_args_t *'
  */
-static void *run_worker(void *arg)
+static int run_worker(void *arg)
 {
 	thread_args_t *thr_args = arg;
 	odp_packet_t pkt_tbl[MAX_PKT_BURST];
@@ -652,7 +652,7 @@  static void *run_worker(void *arg)
 	/* Make sure that latest stat writes are visible to other threads */
 	odp_mb_full();
 
-	return NULL;
+	return 0;
 }
 
 /*
@@ -878,7 +878,7 @@  static void gbl_args_init(args_t *args)
 
 int main(int argc, char **argv)
 {
-	odph_linux_pthread_t thread_tbl[MAX_WORKERS];
+	odph_odpthread_t thread_tbl[MAX_WORKERS];
 	int i, j;
 	int cpu;
 	int num_workers;
@@ -890,7 +890,7 @@  int main(int argc, char **argv)
 	stats_t (*stats)[MAX_PKTIOS];
 	int if_count;
 	odp_instance_t instance;
-	odph_linux_thr_params_t thr_params;
+	odph_odpthread_params_t thr_params;
 
 	/* Init ODP before calling anything else */
 	if (odp_init_global(&instance, NULL, NULL)) {
@@ -1003,8 +1003,7 @@  int main(int argc, char **argv)
 
 		odp_cpumask_zero(&thd_mask);
 		odp_cpumask_set(&thd_mask, cpu);
-		odph_linux_pthread_create(&thread_tbl[i], &thd_mask,
-					  &thr_params);
+		odph_odpthreads_create(&thread_tbl[i], &thd_mask, &thr_params);
 		cpu = odp_cpumask_next(&cpumask, cpu);
 	}
 
@@ -1026,7 +1025,8 @@  int main(int argc, char **argv)
 	exit_threads = 1;
 
 	/* Master thread waits for other threads to exit */
-	odph_linux_pthread_join(thread_tbl, num_workers);
+	for (i = 0; i < num_workers; ++i)
+		odph_odpthreads_join(&thread_tbl[i]);
 
 	free(gbl_args->appl.if_names);
 	free(gbl_args->appl.if_str);