[20.05,13/15] replace no-return attributes
diff mbox series

Message ID 20200210162032.1177478-14-thomas@monjalon.net
State Accepted, archived
Delegated to: David Marchand
Headers show
Series
  • clean-up use of __attribute__
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch warning coding style issues

Commit Message

Thomas Monjalon Feb. 10, 2020, 4:20 p.m. UTC
The new macro __rte_noreturn, for compiler hinting,
is now used where appropriate for consistency.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 doc/guides/sample_app_ug/flow_classify.rst              | 2 +-
 doc/guides/sample_app_ug/l3_forward_power_man.rst       | 2 +-
 doc/guides/sample_app_ug/performance_thread.rst         | 2 +-
 doc/guides/sample_app_ug/skeleton.rst                   | 2 +-
 examples/flow_classify/flow_classify.c                  | 2 +-
 examples/l2fwd-cat/l2fwd-cat.c                          | 2 +-
 examples/performance-thread/l3fwd-thread/main.c         | 4 ++--
 examples/performance-thread/pthread_shim/pthread_shim.h | 2 +-
 examples/ptpclient/ptpclient.c                          | 2 +-
 examples/qos_meter/main.c                               | 2 +-
 examples/rxtx_callbacks/main.c                          | 2 +-
 examples/skeleton/basicfwd.c                            | 2 +-
 examples/timer/main.c                                   | 2 +-
 lib/librte_eal/common/eal_thread.h                      | 2 +-
 lib/librte_eal/common/include/rte_common.h              | 8 ++++++--
 lib/librte_eal/common/include/rte_debug.h               | 2 +-
 lib/librte_eal/freebsd/eal/eal_thread.c                 | 2 +-
 lib/librte_eal/linux/eal/eal_interrupts.c               | 2 +-
 lib/librte_eal/linux/eal/eal_thread.c                   | 2 +-
 19 files changed, 25 insertions(+), 21 deletions(-)

Patch
diff mbox series

diff --git a/doc/guides/sample_app_ug/flow_classify.rst b/doc/guides/sample_app_ug/flow_classify.rst
index bc234b50a7..dc40b4d6f9 100644
--- a/doc/guides/sample_app_ug/flow_classify.rst
+++ b/doc/guides/sample_app_ug/flow_classify.rst
@@ -422,7 +422,7 @@  following:
             .stats = (void *)&ntuple_stats
     };
 
-    static __attribute__((noreturn)) void
+    static __rte_noreturn void
     lcore_main(cls_app)
     {
         uint16_t port;
diff --git a/doc/guides/sample_app_ug/l3_forward_power_man.rst b/doc/guides/sample_app_ug/l3_forward_power_man.rst
index 475a866cfb..0cc6f2e62e 100644
--- a/doc/guides/sample_app_ug/l3_forward_power_man.rst
+++ b/doc/guides/sample_app_ug/l3_forward_power_man.rst
@@ -206,7 +206,7 @@  to generate hints based on recent network load trends.
 .. code-block:: c
 
     static
-    attribute ((noreturn)) int main_loop(__rte_unused void *dummy)
+    __rte_noreturn int main_loop(__rte_unused void *dummy)
     {
         // ...
 
diff --git a/doc/guides/sample_app_ug/performance_thread.rst b/doc/guides/sample_app_ug/performance_thread.rst
index 5fed46465f..b04d0ba444 100644
--- a/doc/guides/sample_app_ug/performance_thread.rst
+++ b/doc/guides/sample_app_ug/performance_thread.rst
@@ -1097,7 +1097,7 @@  invokes the genuine pthread function.
 
 The function ``pthread_exit()`` has additional special handling. The standard
 system header file pthread.h declares ``pthread_exit()`` with
-``__attribute__((noreturn))`` this is an optimization that is possible because
+``__rte_noreturn`` this is an optimization that is possible because
 the pthread is terminating and this enables the compiler to omit the normal
 handling of stack and protection of registers since the function is not
 expected to return, and in fact the thread is being destroyed. These
diff --git a/doc/guides/sample_app_ug/skeleton.rst b/doc/guides/sample_app_ug/skeleton.rst
index 1d0a2760d4..34f6f9aea7 100644
--- a/doc/guides/sample_app_ug/skeleton.rst
+++ b/doc/guides/sample_app_ug/skeleton.rst
@@ -191,7 +191,7 @@  looks like the following:
 
 .. code-block:: c
 
-    static __attribute__((noreturn)) void
+    static __rte_noreturn void
     lcore_main(void)
     {
         uint16_t port;
diff --git a/examples/flow_classify/flow_classify.c b/examples/flow_classify/flow_classify.c
index 1c12bbb2fd..433e64d3f9 100644
--- a/examples/flow_classify/flow_classify.c
+++ b/examples/flow_classify/flow_classify.c
@@ -265,7 +265,7 @@  port_init(uint8_t port, struct rte_mempool *mbuf_pool)
  * The lcore main. This is the main thread that does the work, reading from
  * an input port classifying the packets and writing to an output port.
  */
-static __attribute__((noreturn)) void
+static __rte_noreturn void
 lcore_main(struct flow_classifier *cls_app)
 {
 	uint16_t port;
diff --git a/examples/l2fwd-cat/l2fwd-cat.c b/examples/l2fwd-cat/l2fwd-cat.c
index 6838f288c6..45a497c082 100644
--- a/examples/l2fwd-cat/l2fwd-cat.c
+++ b/examples/l2fwd-cat/l2fwd-cat.c
@@ -97,7 +97,7 @@  port_init(uint16_t port, struct rte_mempool *mbuf_pool)
  * The lcore main. This is the main thread that does the work, reading from
  * an input port and writing to an output port.
  */
-static __attribute__((noreturn)) void
+static __rte_noreturn void
 lcore_main(void)
 {
 	uint16_t port;
diff --git a/examples/performance-thread/l3fwd-thread/main.c b/examples/performance-thread/l3fwd-thread/main.c
index 8a1560b503..43a5b9248d 100644
--- a/examples/performance-thread/l3fwd-thread/main.c
+++ b/examples/performance-thread/l3fwd-thread/main.c
@@ -1877,7 +1877,7 @@  process_burst(struct rte_mbuf *pkts_burst[MAX_PKT_BURST], int nb_rx,
 /*
  * CPU-load stats collector
  */
-static int __attribute__((noreturn))
+static int __rte_noreturn
 cpu_load_collector(__rte_unused void *arg) {
 	unsigned i, j, k;
 	uint64_t hits;
@@ -2299,7 +2299,7 @@  sched_spawner(__rte_unused void *arg) {
 }
 
 /* main processing loop */
-static int __attribute__((noreturn))
+static int __rte_noreturn
 pthread_tx(void *dummy)
 {
 	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
diff --git a/examples/performance-thread/pthread_shim/pthread_shim.h b/examples/performance-thread/pthread_shim/pthread_shim.h
index bba8ed00e4..e90fb15fc1 100644
--- a/examples/performance-thread/pthread_shim/pthread_shim.h
+++ b/examples/performance-thread/pthread_shim/pthread_shim.h
@@ -55,7 +55,7 @@ 
  * An exiting lthread must not terminate the pthread it is running in
  * since this would mean terminating the lthread scheduler.
  * We override pthread_exit() with a macro because it is typically declared with
- * __attribute__((noreturn))
+ * __rte_noreturn
  */
 void pthread_exit_override(void *v);
 
diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c
index 6fcd1aa26e..bfa86eec5a 100644
--- a/examples/ptpclient/ptpclient.c
+++ b/examples/ptpclient/ptpclient.c
@@ -596,7 +596,7 @@  parse_ptp_frames(uint16_t portid, struct rte_mbuf *m) {
  * The lcore main. This is the main thread that does the work, reading from an
  * input port and writing to an output port.
  */
-static __attribute__((noreturn)) void
+static __rte_noreturn void
 lcore_main(void)
 {
 	uint16_t portid;
diff --git a/examples/qos_meter/main.c b/examples/qos_meter/main.c
index 4dade4ca2f..6d057abfe3 100644
--- a/examples/qos_meter/main.c
+++ b/examples/qos_meter/main.c
@@ -166,7 +166,7 @@  app_pkt_handle(struct rte_mbuf *pkt, uint64_t time)
 }
 
 
-static __attribute__((noreturn)) int
+static __rte_noreturn int
 main_loop(__rte_unused void *dummy)
 {
 	uint64_t current_time, last_time = rte_rdtsc();
diff --git a/examples/rxtx_callbacks/main.c b/examples/rxtx_callbacks/main.c
index 07e95e8d1a..54d124b00b 100644
--- a/examples/rxtx_callbacks/main.c
+++ b/examples/rxtx_callbacks/main.c
@@ -215,7 +215,7 @@  port_init(uint16_t port, struct rte_mempool *mbuf_pool)
  * Main thread that does the work, reading from INPUT_PORT
  * and writing to OUTPUT_PORT
  */
-static  __attribute__((noreturn)) void
+static  __rte_noreturn void
 lcore_main(void)
 {
 	uint16_t port;
diff --git a/examples/skeleton/basicfwd.c b/examples/skeleton/basicfwd.c
index 73d313b84e..72ba85fa1f 100644
--- a/examples/skeleton/basicfwd.c
+++ b/examples/skeleton/basicfwd.c
@@ -112,7 +112,7 @@  port_init(uint16_t port, struct rte_mempool *mbuf_pool)
  * The lcore main. This is the main thread that does the work, reading from
  * an input port and writing to an output port.
  */
-static __attribute__((noreturn)) void
+static __rte_noreturn void
 lcore_main(void)
 {
 	uint16_t port;
diff --git a/examples/timer/main.c b/examples/timer/main.c
index 00c251c409..0259022f10 100644
--- a/examples/timer/main.c
+++ b/examples/timer/main.c
@@ -55,7 +55,7 @@  timer1_cb(__rte_unused struct rte_timer *tim,
 	rte_timer_reset(tim, hz/3, SINGLE, lcore_id, timer1_cb, NULL);
 }
 
-static __attribute__((noreturn)) int
+static __rte_noreturn int
 lcore_mainloop(__rte_unused void *arg)
 {
 	uint64_t prev_tsc = 0, cur_tsc, diff_tsc;
diff --git a/lib/librte_eal/common/eal_thread.h b/lib/librte_eal/common/eal_thread.h
index 0d0bad06bd..b40ed249ed 100644
--- a/lib/librte_eal/common/eal_thread.h
+++ b/lib/librte_eal/common/eal_thread.h
@@ -13,7 +13,7 @@ 
  * @param arg
  *   opaque pointer
  */
-__attribute__((noreturn)) void *eal_thread_loop(void *arg);
+__rte_noreturn void *eal_thread_loop(void *arg);
 
 /**
  * Init per-lcore info for master thread
diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
index 5a451e4ca2..575183e944 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -152,6 +152,11 @@  static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
 #define RTE_FINI(func) \
 	RTE_FINI_PRIO(func, LAST)
 
+/**
+ * Hint never returning function
+ */
+#define __rte_noreturn __attribute__((noreturn))
+
 /**
  * Force a function to be inlined
  */
@@ -796,9 +801,8 @@  rte_str_to_size(const char *str)
  *     printf format characters which will be expanded using any further parameters
  *     to the function.
  */
-void
+__rte_noreturn void
 rte_exit(int exit_code, const char *format, ...)
-	__attribute__((noreturn))
 	__attribute__((format(printf, 2, 3)));
 
 #ifdef __cplusplus
diff --git a/lib/librte_eal/common/include/rte_debug.h b/lib/librte_eal/common/include/rte_debug.h
index 3ae467211d..eb06c835f7 100644
--- a/lib/librte_eal/common/include/rte_debug.h
+++ b/lib/librte_eal/common/include/rte_debug.h
@@ -72,7 +72,7 @@  void __rte_panic(const char *funcname , const char *format, ...)
 	__rte_cold
 #endif
 #endif
-	__attribute__((noreturn))
+	__rte_noreturn
 	__attribute__((format(printf, 2, 3)));
 
 #ifdef __cplusplus
diff --git a/lib/librte_eal/freebsd/eal/eal_thread.c b/lib/librte_eal/freebsd/eal/eal_thread.c
index 925737d34d..f21eddd93c 100644
--- a/lib/librte_eal/freebsd/eal/eal_thread.c
+++ b/lib/librte_eal/freebsd/eal/eal_thread.c
@@ -89,7 +89,7 @@  void eal_thread_init_master(unsigned lcore_id)
 }
 
 /* main loop of threads */
-__attribute__((noreturn)) void *
+__rte_noreturn void *
 eal_thread_loop(__rte_unused void *arg)
 {
 	char c;
diff --git a/lib/librte_eal/linux/eal/eal_interrupts.c b/lib/librte_eal/linux/eal/eal_interrupts.c
index cb8e107098..3893e4065e 100644
--- a/lib/librte_eal/linux/eal/eal_interrupts.c
+++ b/lib/librte_eal/linux/eal/eal_interrupts.c
@@ -1042,7 +1042,7 @@  eal_intr_handle_interrupts(int pfd, unsigned totalfds)
  * @return
  *  never return;
  */
-static __attribute__((noreturn)) void *
+static __rte_noreturn void *
 eal_intr_thread_main(__rte_unused void *arg)
 {
 	/* host thread, never break out */
diff --git a/lib/librte_eal/linux/eal/eal_thread.c b/lib/librte_eal/linux/eal/eal_thread.c
index 575c96089b..2fa5806b88 100644
--- a/lib/librte_eal/linux/eal/eal_thread.c
+++ b/lib/librte_eal/linux/eal/eal_thread.c
@@ -89,7 +89,7 @@  void eal_thread_init_master(unsigned lcore_id)
 }
 
 /* main loop of threads */
-__attribute__((noreturn)) void *
+__rte_noreturn void *
 eal_thread_loop(__rte_unused void *arg)
 {
 	char c;