From patchwork Mon Feb 10 16:20:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 65708 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id ABFBEA04B3; Mon, 10 Feb 2020 17:24:00 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E5F281BFA1; Mon, 10 Feb 2020 17:21:36 +0100 (CET) Received: from new4-smtp.messagingengine.com (new4-smtp.messagingengine.com [66.111.4.230]) by dpdk.org (Postfix) with ESMTP id EA0331BF7C for ; Mon, 10 Feb 2020 17:21:33 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id 94C0B8B33; Mon, 10 Feb 2020 11:21:33 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 10 Feb 2020 11:21:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=mesmtp; bh=DzePxwxRlB HggXc/nOBIL5ABOUPzfcRoB0nerqQe7cg=; b=ZT4C9QcCwyYuKvoDH1vfThIPlm YRwPCPKW4ohOv83rc1uJBRDK0sCI1w3A/GOY0QsPugNPI2ZlAfS7/26G09mQnhnW eMS9e9ZV4OW8EaBi1AkZBqgLqE0y9PaSI2Ki2LOQQjFxbKXsyDl2IdFGtlZiTYpl LCAHN+br8ianf+5yE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=DzePxwxRlBHggXc/nOBIL5ABOUPzfcRoB0nerqQe7cg=; b=2uWdem+7 iHvKZVjm+a70o20GUCEAqE6ZCBKLp6yTWl9KJUlS5T4Ghx2wr+fVvlHEmkaQt5F0 M2r8sslW3Ebk8GC0uias/KOpU/uZND2P9wktbjLJPI579umKPQe2GarxRuV+WG7u /koGdwX5C5lcMMja+h9qET0FSXXDKivrBxCdZjncrSpOecU/H26QocldS+5CMcK7 GdpdXrNt/PNb4TogJBVejzChZDkLDC+53WPBkN1XevCggCiBwCOEVPApHK5yxYrb npkPgbhoySaWSWDgCX/PxGzRvAotWOeYhyU3hqKe5gxLUkuwXA3FSgSBmeytbG/y f+tp5YaGbqg54Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedriedugdektdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucfkph epjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuihiivgepuddunecurfgr rhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id A7365328005E; Mon, 10 Feb 2020 11:21:31 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: Bernard Iremonger , John McNamara , Marko Kovacevic , David Hunt , Kirill Rybalchenko , Bruce Richardson , Harry van Haaren , Xiaoyun Li , Ori Kam , Radu Nicolau , Akhil Goyal , Tomasz Kantecki , Sunil Kumar Kori , Pavan Nikhilesh , Cristian Dumitrescu , Robert Sanford , Erik Gabriel Carrillo Date: Mon, 10 Feb 2020 17:20:30 +0100 Message-Id: <20200210162032.1177478-14-thomas@monjalon.net> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210162032.1177478-1-thomas@monjalon.net> References: <20200210162032.1177478-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 20.05 13/15] replace no-return attributes X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The new macro __rte_noreturn, for compiler hinting, is now used where appropriate for consistency. Signed-off-by: Thomas Monjalon --- 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(-) 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;