[dpdk-stable] patch 'examples/performance-thread: fix return type of threads' has been queued to LTS release 16.11.7

luca.boccassi at gmail.com luca.boccassi at gmail.com
Tue May 15 19:19:20 CEST 2018


Hi,

FYI, your patch has been queued to LTS release 16.11.7

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 05/16/18. So please
shout if anyone has objections.

Thanks.

Luca Boccassi

---
>From c1368ebb17ae5aa0c5a6ed7e18708723558ddf50 Mon Sep 17 00:00:00 2001
From: David Hunt <david.hunt at intel.com>
Date: Mon, 14 May 2018 03:53:15 +0100
Subject: [PATCH] examples/performance-thread: fix return type of threads

[ upstream commit 803ee2ebd32d019d54011f185819f3b76b113c4f ]

The function pthread_create() expects void *(*func) (void *)
for function pointer, however, lthread_func_t was defined as
void (*func) (void *), so now gcc 8.1 warns that the cast is
incorrect, causing a compilation failure. This patch changes
the declaration of lthread_func_t from returning a void to
returning a void*, and then changes the sample app in the
relevant places that are affected by the typedef change.

Fixes: 116819b9ed0d ("examples/performance-thread: add lthread subsystem")

Signed-off-by: David Hunt <david.hunt at intel.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch at intel.com>
---
 examples/performance-thread/common/lthread.c         |  3 ++-
 examples/performance-thread/common/lthread_api.h     |  2 +-
 examples/performance-thread/l3fwd-thread/main.c      | 20 +++++++++++++-------
 examples/performance-thread/pthread_shim/main.c      |  6 ++----
 .../performance-thread/pthread_shim/pthread_shim.c   |  4 ++--
 5 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/examples/performance-thread/common/lthread.c b/examples/performance-thread/common/lthread.c
index 062275a43..77c870fcc 100644
--- a/examples/performance-thread/common/lthread.c
+++ b/examples/performance-thread/common/lthread.c
@@ -327,13 +327,14 @@ struct lthread *lthread_current(void)
 /*
  * Tasklet to cancel a thread
  */
-static void
+static void *
 _cancel(void *arg)
 {
 	struct lthread *lt = (struct lthread *) arg;
 
 	lt->state |= BIT(ST_LT_CANCELLED);
 	lthread_detach();
+	return NULL;
 }
 
 
diff --git a/examples/performance-thread/common/lthread_api.h b/examples/performance-thread/common/lthread_api.h
index ec976103f..903ca7c0d 100644
--- a/examples/performance-thread/common/lthread_api.h
+++ b/examples/performance-thread/common/lthread_api.h
@@ -139,7 +139,7 @@ struct lthread_mutex;
 struct lthread_condattr;
 struct lthread_mutexattr;
 
-typedef void (*lthread_func_t) (void *);
+typedef void *(*lthread_func_t) (void *);
 
 /*
  * Define the size of stack for an lthread
diff --git a/examples/performance-thread/l3fwd-thread/main.c b/examples/performance-thread/l3fwd-thread/main.c
index dd403ca86..125d976cf 100644
--- a/examples/performance-thread/l3fwd-thread/main.c
+++ b/examples/performance-thread/l3fwd-thread/main.c
@@ -1981,17 +1981,18 @@ cpu_load_collector(__rte_unused void *arg) {
  *
  * This loop is used to start empty scheduler on lcore.
  */
-static void
+static void *
 lthread_null(__rte_unused void *args)
 {
 	int lcore_id = rte_lcore_id();
 
 	RTE_LOG(INFO, L3FWD, "Starting scheduler on lcore %d.\n", lcore_id);
 	lthread_exit(NULL);
+	return NULL;
 }
 
 /* main processing loop */
-static void
+static void *
 lthread_tx_per_ring(void *dummy)
 {
 	int nb_rx;
@@ -2036,6 +2037,7 @@ lthread_tx_per_ring(void *dummy)
 			lthread_cond_wait(ready, 0);
 
 	}
+	return NULL;
 }
 
 /*
@@ -2044,7 +2046,7 @@ lthread_tx_per_ring(void *dummy)
  * This lthread is used to spawn one new lthread per ring from producers.
  *
  */
-static void
+static void *
 lthread_tx(void *args)
 {
 	struct lthread *lt;
@@ -2089,9 +2091,10 @@ lthread_tx(void *args)
 		}
 
 	}
+	return NULL;
 }
 
-static void
+static void *
 lthread_rx(void *dummy)
 {
 	int ret;
@@ -2114,7 +2117,7 @@ lthread_rx(void *dummy)
 
 	if (rx_conf->n_rx_queue == 0) {
 		RTE_LOG(INFO, L3FWD, "lcore %u has nothing to do\n", rte_lcore_id());
-		return;
+		return NULL;
 	}
 
 	RTE_LOG(INFO, L3FWD, "Entering main Rx loop on lcore %u\n", rte_lcore_id());
@@ -2185,6 +2188,7 @@ lthread_rx(void *dummy)
 			lthread_yield();
 		}
 	}
+	return NULL;
 }
 
 /*
@@ -2193,8 +2197,9 @@ lthread_rx(void *dummy)
  * This lthread loop spawns all rx and tx lthreads on master lcore
  */
 
-static void
-lthread_spawner(__rte_unused void *arg) {
+static void *
+lthread_spawner(__rte_unused void *arg)
+{
 	struct lthread *lt[MAX_THREAD];
 	int i;
 	int n_thread = 0;
@@ -2235,6 +2240,7 @@ lthread_spawner(__rte_unused void *arg) {
 	for (i = 0; i < n_thread; i++)
 		lthread_join(lt[i], NULL);
 
+	return NULL;
 }
 
 /*
diff --git a/examples/performance-thread/pthread_shim/main.c b/examples/performance-thread/pthread_shim/main.c
index febae39be..5811cff8d 100644
--- a/examples/performance-thread/pthread_shim/main.c
+++ b/examples/performance-thread/pthread_shim/main.c
@@ -149,8 +149,7 @@ void *helloworld_pthread(void *arg)
  */
 __thread pthread_t tid[HELLOW_WORLD_MAX_LTHREADS];
 
-static void initial_lthread(void *args);
-static void initial_lthread(void *args __attribute__((unused)))
+static void *initial_lthread(void *args __attribute__((unused)))
 {
 	int lcore = (int) rte_lcore_id();
 	/*
@@ -225,6 +224,7 @@ static void initial_lthread(void *args __attribute__((unused)))
 	/* shutdown the lthread scheduler */
 	lthread_scheduler_shutdown(rte_lcore_id());
 	lthread_detach();
+	return NULL;
 }
 
 
@@ -235,8 +235,6 @@ static void initial_lthread(void *args __attribute__((unused)))
  * in the core mask
  */
 static int
-lthread_scheduler(void *args);
-static int
 lthread_scheduler(void *args __attribute__((unused)))
 {
 	/* create initial thread  */
diff --git a/examples/performance-thread/pthread_shim/pthread_shim.c b/examples/performance-thread/pthread_shim/pthread_shim.c
index 113bafa00..7e6d7230e 100644
--- a/examples/performance-thread/pthread_shim/pthread_shim.c
+++ b/examples/performance-thread/pthread_shim/pthread_shim.c
@@ -397,7 +397,7 @@ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
 int
 pthread_create(pthread_t *__restrict tid,
 		const pthread_attr_t *__restrict attr,
-		void *(func) (void *),
+		lthread_func_t func,
 	       void *__restrict arg)
 {
 	if (override) {
@@ -422,7 +422,7 @@ pthread_create(pthread_t *__restrict tid,
 			}
 		}
 		return lthread_create((struct lthread **)tid, lcore,
-				      (void (*)(void *))func, arg);
+				      func, arg);
 	}
 	return _sys_pthread_funcs.f_pthread_create(tid, attr, func, arg);
 }
-- 
2.14.2



More information about the stable mailing list