From patchwork Tue Jun 2 09:16:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 11583447 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 7839C739 for ; Tue, 2 Jun 2020 09:17:03 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5E2F0206C3 for ; Tue, 2 Jun 2020 09:17:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E2F0206C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jg31t-0004eW-NM; Tue, 02 Jun 2020 09:16:17 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jg31s-0004eM-KX for xen-devel@lists.xenproject.org; Tue, 02 Jun 2020 09:16:16 +0000 X-Inumbo-ID: b5c946c0-a4b1-11ea-81bc-bc764e2007e4 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id b5c946c0-a4b1-11ea-81bc-bc764e2007e4; Tue, 02 Jun 2020 09:16:15 +0000 (UTC) Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: ObfmshO7MUpzAWv2u8Tp58LY3B3Q9QKxgtTNAyWosXS7LDQCkbivotRG3MRGwc+YNaAvaZvWTQ 5Sx0/JXs6y6vG60NaqS8glmGLtcyhleJSLD+//uB3jYxqM4rBfgwQPsZXyn/coQAs2X+Qs75DU QwaqDRnYYvMjbFBSG6Rw4YDXOlNAg0Hj9At2jCVA31Y9EApJaLXm+i6HqkrNa/6mzVHrVNzYDu +W3G5BpR6V/0uXSZJM3KLUYlopxLX/YmBKMOq//9QX9K/M5U9ZRt6FfL60/D56WrtVyjatdI6N HI8= X-SBRS: 2.7 X-MesageID: 19254563 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.73,463,1583211600"; d="scan'208";a="19254563" From: Roger Pau Monne To: Subject: [PATCH for-4.14] compilers/clang: always use _Static_assert with clang Date: Tue, 2 Jun 2020 11:16:02 +0200 Message-ID: <20200602091602.38422-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , paul@xen.org, Andrew Cooper , Ian Jackson , George Dunlap , Jan Beulich , Roger Pau Monne Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" All versions of clang used by Xen support _Static_assert, so use it unconditionally when building Xen with clang. No functional change expected. Signed-off-by: Roger Pau Monné Reviewed-by: Wei Liu Acked-by: Andrew Cooper --- Not sure whether this fully qualifies as a bugfix, as the current behavior should also work fine under clang. Note that all versions of clang from 3.5 to trunk (11) seem to return __GNUC__ == 4 and __GNUC_MINOR__ == 2. --- xen/include/xen/lib.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index e5b0a007b8..076bcfb67d 100644 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -25,7 +25,9 @@ #define BUG_ON(p) do { if (unlikely(p)) BUG(); } while (0) #define WARN_ON(p) do { if (unlikely(p)) WARN(); } while (0) -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) +/* All clang versions supported by Xen have _Static_assert. */ +#if defined(__clang__) || \ + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) /* Force a compilation error if condition is true */ #define BUILD_BUG_ON(cond) ({ _Static_assert(!(cond), "!(" #cond ")"); })