From patchwork Mon Jun 22 21:37:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hauke Mehrtens X-Patchwork-Id: 11619169 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B17F113B1 for ; Mon, 22 Jun 2020 21:38:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A43402076A for ; Mon, 22 Jun 2020 21:38:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730565AbgFVVia (ORCPT ); Mon, 22 Jun 2020 17:38:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730567AbgFVVia (ORCPT ); Mon, 22 Jun 2020 17:38:30 -0400 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [IPv6:2001:67c:2050::465:101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CECB3C061795 for ; Mon, 22 Jun 2020 14:38:29 -0700 (PDT) Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 49rN7l60bFzKmfK; Mon, 22 Jun 2020 23:38:27 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter02.heinlein-hosting.de (spamfilter02.heinlein-hosting.de [80.241.56.116]) (amavisd-new, port 10030) with ESMTP id 7-Ken4A_re9W; Mon, 22 Jun 2020 23:38:24 +0200 (CEST) From: Hauke Mehrtens To: backports@vger.kernel.org Cc: johannes@sipsolutions.net, Hauke Mehrtens Subject: [PATCH 2/7] backports: Add fallthrough attribute Date: Mon, 22 Jun 2020 23:37:59 +0200 Message-Id: <20200622213804.26477-3-hauke@hauke-m.de> In-Reply-To: <20200622213804.26477-1-hauke@hauke-m.de> References: <20200622213804.26477-1-hauke@hauke-m.de> MIME-Version: 1.0 X-MBO-SPAM-Probability: 0 X-Rspamd-Score: -4.21 / 15.00 / 15.00 X-Rspamd-Queue-Id: B30951784 X-Rspamd-UID: 732f02 Sender: backports-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: backports@vger.kernel.org This adds the fallthrough attribute from Linux commit 294f69e662d1 ("compiler_attributes.h: Add 'fallthrough' pseudo keyword for switch/case use") This also adds the __has_attribute() define for older compilers like GCC < 5. linux/compiler_attributes.h needs to be included, this file was only added in more recent kernel versions. Signed-off-by: Hauke Mehrtens --- backport/backport-include/linux/compiler.h | 2 ++ .../linux/compiler_attributes.h | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 backport/backport-include/linux/compiler_attributes.h diff --git a/backport/backport-include/linux/compiler.h b/backport/backport-include/linux/compiler.h index 53c069df..51a6ec2c 100644 --- a/backport/backport-include/linux/compiler.h +++ b/backport/backport-include/linux/compiler.h @@ -2,6 +2,8 @@ #define __BACKPORT_LINUX_COMPILER_H #include_next +#include + #ifndef __rcu #define __rcu #endif diff --git a/backport/backport-include/linux/compiler_attributes.h b/backport/backport-include/linux/compiler_attributes.h new file mode 100644 index 00000000..31ddc163 --- /dev/null +++ b/backport/backport-include/linux/compiler_attributes.h @@ -0,0 +1,34 @@ +#ifndef _BACKPORTS_LINUX_COMPILER_ATTRIBUTES_H +#define _BACKPORTS_LINUX_COMPILER_ATTRIBUTES_H 1 + +#if LINUX_VERSION_IS_GEQ(4,20,0) +#include_next +#endif + +#ifndef __has_attribute +# define __has_attribute(x) __GCC4_has_attribute_##x +#endif + +#ifndef __GCC4_has_attribute___fallthrough__ +# define __GCC4_has_attribute___fallthrough__ 0 +#endif /* __GCC4_has_attribute___fallthrough__ */ + +#ifndef fallthrough +/* + * Add the pseudo keyword 'fallthrough' so case statement blocks + * must end with any of these keywords: + * break; + * fallthrough; + * goto