* [dpdk-dev] [PATCH] examples: fix typdef in performance thread app
@ 2018-05-10 5:31 David Hunt
2018-05-11 15:47 ` De Lara Guarch, Pablo
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: David Hunt @ 2018-05-10 5:31 UTC (permalink / raw)
To: dev; +Cc: john.mcnamara, David Hunt
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@intel.com>
---
examples/performance-thread/common/lthread.c | 3 ++-
examples/performance-thread/common/lthread_api.h | 2 +-
examples/performance-thread/l3fwd-thread/main.c | 15 ++++++++-------
examples/performance-thread/pthread_shim/main.c | 4 ++--
.../pthread_shim/pthread_shim.c | 4 ++--
5 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/examples/performance-thread/common/lthread.c b/examples/performance-thread/common/lthread.c
index 7d76c8c46..0b60a42a8 100644
--- a/examples/performance-thread/common/lthread.c
+++ b/examples/performance-thread/common/lthread.c
@@ -320,13 +320,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 ff245a082..a74680bf7 100644
--- a/examples/performance-thread/common/lthread_api.h
+++ b/examples/performance-thread/common/lthread_api.h
@@ -143,7 +143,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 f51e6b0fd..852965de9 100644
--- a/examples/performance-thread/l3fwd-thread/main.c
+++ b/examples/performance-thread/l3fwd-thread/main.c
@@ -1990,7 +1990,7 @@ 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();
@@ -2000,7 +2000,7 @@ lthread_null(__rte_unused void *args)
}
/* main processing loop */
-static void
+static void *
lthread_tx_per_ring(void *dummy)
{
int nb_rx;
@@ -2053,7 +2053,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;
@@ -2100,7 +2100,7 @@ lthread_tx(void *args)
}
}
-static void
+static void *
lthread_rx(void *dummy)
{
int ret;
@@ -2124,7 +2124,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());
@@ -2204,8 +2204,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;
diff --git a/examples/performance-thread/pthread_shim/main.c b/examples/performance-thread/pthread_shim/main.c
index 964ea252d..b64ca8b60 100644
--- a/examples/performance-thread/pthread_shim/main.c
+++ b/examples/performance-thread/pthread_shim/main.c
@@ -119,8 +119,8 @@ 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);
+static void *initial_lthread(void *args __attribute__((unused)))
{
int lcore = (int) rte_lcore_id();
/*
diff --git a/examples/performance-thread/pthread_shim/pthread_shim.c b/examples/performance-thread/pthread_shim/pthread_shim.c
index c31de4e9d..53f12437f 100644
--- a/examples/performance-thread/pthread_shim/pthread_shim.c
+++ b/examples/performance-thread/pthread_shim/pthread_shim.c
@@ -365,7 +365,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) {
@@ -390,7 +390,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.17.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] examples: fix typdef in performance thread app
2018-05-10 5:31 [dpdk-dev] [PATCH] examples: fix typdef in performance thread app David Hunt
@ 2018-05-11 15:47 ` De Lara Guarch, Pablo
2018-05-13 21:37 ` Thomas Monjalon
2018-05-14 2:53 ` [dpdk-dev] [PATCH v2] " David Hunt
2 siblings, 0 replies; 6+ messages in thread
From: De Lara Guarch, Pablo @ 2018-05-11 15:47 UTC (permalink / raw)
To: Hunt, David, dev; +Cc: Mcnamara, John, Hunt, David, stable
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of David Hunt
> Sent: Thursday, May 10, 2018 6:31 AM
> To: dev@dpdk.org
> Cc: Mcnamara, John <john.mcnamara@intel.com>; Hunt, David
> <david.hunt@intel.com>
> Subject: [dpdk-dev] [PATCH] examples: fix typdef in performance thread app
>
> 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@intel.com>
Missing "Cc: stable@dpdk.org"
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] examples: fix typdef in performance thread app
2018-05-10 5:31 [dpdk-dev] [PATCH] examples: fix typdef in performance thread app David Hunt
2018-05-11 15:47 ` De Lara Guarch, Pablo
@ 2018-05-13 21:37 ` Thomas Monjalon
2018-05-14 10:01 ` Hunt, David
2018-05-14 2:53 ` [dpdk-dev] [PATCH v2] " David Hunt
2 siblings, 1 reply; 6+ messages in thread
From: Thomas Monjalon @ 2018-05-13 21:37 UTC (permalink / raw)
To: David Hunt; +Cc: dev, john.mcnamara
10/05/2018 07:31, David Hunt:
> 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@intel.com>
> ---
[...]
> -static void initial_lthread(void *args);
> -static void initial_lthread(void *args __attribute__((unused)))
> +static void *initial_lthread(void *args);
This declaration can be removed.
> +static void *initial_lthread(void *args __attribute__((unused)))
> {
The function must return a pointer (like NULL) at the end.
Please check that all threads are returning something.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] [PATCH v2] examples: fix typdef in performance thread app
2018-05-10 5:31 [dpdk-dev] [PATCH] examples: fix typdef in performance thread app David Hunt
2018-05-11 15:47 ` De Lara Guarch, Pablo
2018-05-13 21:37 ` Thomas Monjalon
@ 2018-05-14 2:53 ` David Hunt
2018-05-14 10:25 ` Thomas Monjalon
2 siblings, 1 reply; 6+ messages in thread
From: David Hunt @ 2018-05-14 2:53 UTC (permalink / raw)
To: dev; +Cc: john.mcnamara, thomas, stable, David Hunt
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@intel.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
Changes in v2
1. Removed a couple of un-needed function declarations
(they are now static).
2. Ensure each thread returns something (i.e. NULL) nows
that their declarations have changed to returning void *.
---
examples/performance-thread/common/lthread.c | 3 ++-
.../performance-thread/common/lthread_api.h | 2 +-
.../performance-thread/l3fwd-thread/main.c | 20 ++++++++++++-------
.../performance-thread/pthread_shim/main.c | 6 ++----
.../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 7d76c8c46..0b60a42a8 100644
--- a/examples/performance-thread/common/lthread.c
+++ b/examples/performance-thread/common/lthread.c
@@ -320,13 +320,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 ff245a082..a74680bf7 100644
--- a/examples/performance-thread/common/lthread_api.h
+++ b/examples/performance-thread/common/lthread_api.h
@@ -143,7 +143,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 f51e6b0fd..40d807239 100644
--- a/examples/performance-thread/l3fwd-thread/main.c
+++ b/examples/performance-thread/l3fwd-thread/main.c
@@ -1990,17 +1990,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;
@@ -2045,6 +2046,7 @@ lthread_tx_per_ring(void *dummy)
lthread_cond_wait(ready, 0);
}
+ return NULL;
}
/*
@@ -2053,7 +2055,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;
@@ -2098,9 +2100,10 @@ lthread_tx(void *args)
}
}
+ return NULL;
}
-static void
+static void *
lthread_rx(void *dummy)
{
int ret;
@@ -2124,7 +2127,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());
@@ -2196,6 +2199,7 @@ lthread_rx(void *dummy)
lthread_yield();
}
}
+ return NULL;
}
/*
@@ -2204,8 +2208,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;
@@ -2246,6 +2251,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 964ea252d..7d0d58116 100644
--- a/examples/performance-thread/pthread_shim/main.c
+++ b/examples/performance-thread/pthread_shim/main.c
@@ -119,8 +119,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();
/*
@@ -195,6 +194,7 @@ static void initial_lthread(void *args __attribute__((unused)))
/* shutdown the lthread scheduler */
lthread_scheduler_shutdown(rte_lcore_id());
lthread_detach();
+ return NULL;
}
@@ -205,8 +205,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 c31de4e9d..53f12437f 100644
--- a/examples/performance-thread/pthread_shim/pthread_shim.c
+++ b/examples/performance-thread/pthread_shim/pthread_shim.c
@@ -365,7 +365,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) {
@@ -390,7 +390,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.17.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] examples: fix typdef in performance thread app
2018-05-13 21:37 ` Thomas Monjalon
@ 2018-05-14 10:01 ` Hunt, David
0 siblings, 0 replies; 6+ messages in thread
From: Hunt, David @ 2018-05-14 10:01 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: dev, Mcnamara, John
Hi Thomas,
On 13/5/2018 10:37 PM, Thomas Monjalon wrote:
> 10/05/2018 07:31, David Hunt:
>> 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@intel.com>
>> ---
> [...]
>> -static void initial_lthread(void *args);
>> -static void initial_lthread(void *args __attribute__((unused)))
>> +static void *initial_lthread(void *args);
> This declaration can be removed.
>
>> +static void *initial_lthread(void *args __attribute__((unused)))
>> {
> The function must return a pointer (like NULL) at the end.
>
> Please check that all threads are returning something.
>
Sure, Thomas, I've made updates based on your suggestions and pushed up
a v2.
Rgds,
Dave.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH v2] examples: fix typdef in performance thread app
2018-05-14 2:53 ` [dpdk-dev] [PATCH v2] " David Hunt
@ 2018-05-14 10:25 ` Thomas Monjalon
0 siblings, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2018-05-14 10:25 UTC (permalink / raw)
To: David Hunt; +Cc: dev, john.mcnamara, stable
14/05/2018 04:53, David Hunt:
> 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@intel.com>
> Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Title: examples/performance-thread: fix return type of threads
Applied, thanks
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-05-14 10:26 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-10 5:31 [dpdk-dev] [PATCH] examples: fix typdef in performance thread app David Hunt
2018-05-11 15:47 ` De Lara Guarch, Pablo
2018-05-13 21:37 ` Thomas Monjalon
2018-05-14 10:01 ` Hunt, David
2018-05-14 2:53 ` [dpdk-dev] [PATCH v2] " David Hunt
2018-05-14 10:25 ` Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).