replace no-return attributes

The new macro __rte_noreturn, for compiler hinting,
is now used where appropriate for consistency.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
This commit is contained in:
Thomas Monjalon 2020-02-09 21:24:18 +01:00
parent ce6427ddca
commit ddcd7640ca
19 changed files with 25 additions and 21 deletions
doc/guides/sample_app_ug
examples
flow_classify
l2fwd-cat
performance-thread
l3fwd-thread
pthread_shim
ptpclient
qos_meter
rxtx_callbacks
skeleton
timer
lib/librte_eal

@ -422,7 +422,7 @@ following:
.stats = (void *)&ntuple_stats .stats = (void *)&ntuple_stats
}; };
static __attribute__((noreturn)) void static __rte_noreturn void
lcore_main(cls_app) lcore_main(cls_app)
{ {
uint16_t port; uint16_t port;

@ -206,7 +206,7 @@ to generate hints based on recent network load trends.
.. code-block:: c .. code-block:: c
static static
attribute ((noreturn)) int main_loop(__rte_unused void *dummy) __rte_noreturn int main_loop(__rte_unused void *dummy)
{ {
// ... // ...

@ -1097,7 +1097,7 @@ invokes the genuine pthread function.
The function ``pthread_exit()`` has additional special handling. The standard The function ``pthread_exit()`` has additional special handling. The standard
system header file pthread.h declares ``pthread_exit()`` with 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 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 handling of stack and protection of registers since the function is not
expected to return, and in fact the thread is being destroyed. These expected to return, and in fact the thread is being destroyed. These

@ -191,7 +191,7 @@ looks like the following:
.. code-block:: c .. code-block:: c
static __attribute__((noreturn)) void static __rte_noreturn void
lcore_main(void) lcore_main(void)
{ {
uint16_t port; uint16_t port;

@ -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 * 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. * 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) lcore_main(struct flow_classifier *cls_app)
{ {
uint16_t port; uint16_t port;

@ -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 * The lcore main. This is the main thread that does the work, reading from
* an input port and writing to an output port. * an input port and writing to an output port.
*/ */
static __attribute__((noreturn)) void static __rte_noreturn void
lcore_main(void) lcore_main(void)
{ {
uint16_t port; uint16_t port;

@ -1877,7 +1877,7 @@ process_burst(struct rte_mbuf *pkts_burst[MAX_PKT_BURST], int nb_rx,
/* /*
* CPU-load stats collector * CPU-load stats collector
*/ */
static int __attribute__((noreturn)) static int __rte_noreturn
cpu_load_collector(__rte_unused void *arg) { cpu_load_collector(__rte_unused void *arg) {
unsigned i, j, k; unsigned i, j, k;
uint64_t hits; uint64_t hits;
@ -2299,7 +2299,7 @@ sched_spawner(__rte_unused void *arg) {
} }
/* main processing loop */ /* main processing loop */
static int __attribute__((noreturn)) static int __rte_noreturn
pthread_tx(void *dummy) pthread_tx(void *dummy)
{ {
struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; struct rte_mbuf *pkts_burst[MAX_PKT_BURST];

@ -55,7 +55,7 @@
* An exiting lthread must not terminate the pthread it is running in * An exiting lthread must not terminate the pthread it is running in
* since this would mean terminating the lthread scheduler. * since this would mean terminating the lthread scheduler.
* We override pthread_exit() with a macro because it is typically declared with * We override pthread_exit() with a macro because it is typically declared with
* __attribute__((noreturn)) * __rte_noreturn
*/ */
void pthread_exit_override(void *v); void pthread_exit_override(void *v);

@ -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 * The lcore main. This is the main thread that does the work, reading from an
* input port and writing to an output port. * input port and writing to an output port.
*/ */
static __attribute__((noreturn)) void static __rte_noreturn void
lcore_main(void) lcore_main(void)
{ {
uint16_t portid; uint16_t portid;

@ -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) main_loop(__rte_unused void *dummy)
{ {
uint64_t current_time, last_time = rte_rdtsc(); uint64_t current_time, last_time = rte_rdtsc();

@ -215,7 +215,7 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
* Main thread that does the work, reading from INPUT_PORT * Main thread that does the work, reading from INPUT_PORT
* and writing to OUTPUT_PORT * and writing to OUTPUT_PORT
*/ */
static __attribute__((noreturn)) void static __rte_noreturn void
lcore_main(void) lcore_main(void)
{ {
uint16_t port; uint16_t port;

@ -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 * The lcore main. This is the main thread that does the work, reading from
* an input port and writing to an output port. * an input port and writing to an output port.
*/ */
static __attribute__((noreturn)) void static __rte_noreturn void
lcore_main(void) lcore_main(void)
{ {
uint16_t port; uint16_t port;

@ -55,7 +55,7 @@ timer1_cb(__rte_unused struct rte_timer *tim,
rte_timer_reset(tim, hz/3, SINGLE, lcore_id, timer1_cb, NULL); 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) lcore_mainloop(__rte_unused void *arg)
{ {
uint64_t prev_tsc = 0, cur_tsc, diff_tsc; uint64_t prev_tsc = 0, cur_tsc, diff_tsc;

@ -13,7 +13,7 @@
* @param arg * @param arg
* opaque pointer * 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 * Init per-lcore info for master thread

@ -89,7 +89,7 @@ void eal_thread_init_master(unsigned lcore_id)
} }
/* main loop of threads */ /* main loop of threads */
__attribute__((noreturn)) void * __rte_noreturn void *
eal_thread_loop(__rte_unused void *arg) eal_thread_loop(__rte_unused void *arg)
{ {
char c; char c;

@ -182,6 +182,11 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
#define RTE_FINI(func) \ #define RTE_FINI(func) \
RTE_FINI_PRIO(func, LAST) RTE_FINI_PRIO(func, LAST)
/**
* Hint never returning function
*/
#define __rte_noreturn __attribute__((noreturn))
/** /**
* Force a function to be inlined * Force a function to be inlined
*/ */
@ -826,9 +831,8 @@ rte_str_to_size(const char *str)
* printf format characters which will be expanded using any further parameters * printf format characters which will be expanded using any further parameters
* to the function. * to the function.
*/ */
void __rte_noreturn void
rte_exit(int exit_code, const char *format, ...) rte_exit(int exit_code, const char *format, ...)
__attribute__((noreturn))
__rte_format_printf(2, 3); __rte_format_printf(2, 3);
#ifdef __cplusplus #ifdef __cplusplus

@ -72,7 +72,7 @@ void __rte_panic(const char *funcname , const char *format, ...)
__rte_cold __rte_cold
#endif #endif
#endif #endif
__attribute__((noreturn)) __rte_noreturn
__rte_format_printf(2, 3); __rte_format_printf(2, 3);
#ifdef __cplusplus #ifdef __cplusplus

@ -1042,7 +1042,7 @@ eal_intr_handle_interrupts(int pfd, unsigned totalfds)
* @return * @return
* never return; * never return;
*/ */
static __attribute__((noreturn)) void * static __rte_noreturn void *
eal_intr_thread_main(__rte_unused void *arg) eal_intr_thread_main(__rte_unused void *arg)
{ {
/* host thread, never break out */ /* host thread, never break out */

@ -89,7 +89,7 @@ void eal_thread_init_master(unsigned lcore_id)
} }
/* main loop of threads */ /* main loop of threads */
__attribute__((noreturn)) void * __rte_noreturn void *
eal_thread_loop(__rte_unused void *arg) eal_thread_loop(__rte_unused void *arg)
{ {
char c; char c;