Received: by 10.213.65.68 with SMTP id h4csp1741810imn; Sun, 1 Apr 2018 13:44:13 -0700 (PDT) X-Google-Smtp-Source: AIpwx48DL3AdH+t200xY6qrhNLB5OGOxHQ8Qmte5L83q2vSDnCZ9XLXS4HX3NVF0L4AILxDAQU0x X-Received: by 10.99.49.74 with SMTP id x71mr4600793pgx.160.1522615453718; Sun, 01 Apr 2018 13:44:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522615453; cv=none; d=google.com; s=arc-20160816; b=zejfOp5geOcmodTpi5jDFJCEEtczR2Cb1+vgppeE4jZDZsxniZrwykaEdZ3bGtcLmB hwtyBQ88jOYExJqsTDK9oMHhmsJtDRCKUIPZ26DFq2NR8E8fwyyM1Bkastho0POuCF5S 8eNIMg7hDHRRtWlxeDV9lZZ73KTskLh99kv2/KVJSciFsEzCw1so4CAcLhBB/S88n0hR 9od2MTYFUeWNPtf/++a3KUHZ8foFz9nr1V5Gk7dSwU7xAc3BHQYvtysxrBsza6bPRjmH HIzqd560Z4uCGbCRvh9G63YsyLa8rJB3sI8dvUTMBu/qdXAsvZ8wEKZ+MGaY7MBuGgaj AIHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:to:from:subject :organization:arc-authentication-results; bh=uUOgRcmWH1KCCd4SKxqdIIdYYo6sHiIabDFxkorjf7E=; b=DrcJkiqYiLTX/KnQGinu5k+HhBHUlA4OjP+5Gu+6ERPJB7JCiRDSvmo34gCaWo6cNg MZQDOeIzcZ1iEiAoV5OqXxhs5flx9lWrjKM94kLDlb6WmmuYjJtz2IK2kJvkOds4Prjt xNzdb5f8MzziGof4/AZ+oyHLvNNkZ0aZggAEznCylMgNOVfvvUuRIFTbTOSLLPIbPGrB QY+W2uXiEorpmN4wQP4wMtaGuyQbfw8pfjIwMkdRv+e8+rAulHxsdNqkQhlC4S0Gxidk bFk27Oc1xkpV6sFIEUOlxLTjwKryHZbAP2HbeXQUHt/MQ+ReaUeyJQNe02HImxDbBLcR 1i7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a3si4709987pgt.644.2018.04.01.13.43.59; Sun, 01 Apr 2018 13:44:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754448AbeDAUmo (ORCPT + 99 others); Sun, 1 Apr 2018 16:42:44 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38122 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754438AbeDAUml (ORCPT ); Sun, 1 Apr 2018 16:42:41 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 997D1406804A for ; Sun, 1 Apr 2018 20:42:40 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-120-59.rdu2.redhat.com [10.10.120.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A1BD2024CA1; Sun, 1 Apr 2018 20:42:40 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 24/45] C++: Fix BUILD_BUG_ON_ZERO() From: David Howells To: linux-kernel@vger.kernel.org Date: Sun, 01 Apr 2018 21:42:39 +0100 Message-ID: <152261535982.30503.18110930471409401085.stgit@warthog.procyon.org.uk> In-Reply-To: <152261521484.30503.16131389653845029164.stgit@warthog.procyon.org.uk> References: <152261521484.30503.16131389653845029164.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Sun, 01 Apr 2018 20:42:40 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Sun, 01 Apr 2018 20:42:40 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dhowells@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix BUILD_BUG_ON_ZERO() to work in C++. The construction format: (struct { ... }) is something C++ doesn't like. Signed-off-by: David Howells --- include/linux/build_bug.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/build_bug.h b/include/linux/build_bug.h index 43d1fd50d433..7445385cd26f 100644 --- a/include/linux/build_bug.h +++ b/include/linux/build_bug.h @@ -20,13 +20,16 @@ #define BUILD_BUG_ON_NOT_POWER_OF_2(n) \ BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0)) +extern int __build_bug_on_zero(void) + __compiletime_error("Build bug on zero"); + /* * Force a compilation error if condition is true, but also produce a * result (of value 0 and type size_t), so the expression can be used * e.g. in a structure initializer (or where-ever else comma expressions * aren't permitted). */ -#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); })) +#define BUILD_BUG_ON_ZERO(e) ((e) ? 0 : __build_bug_on_zero()) /* * BUILD_BUG_ON_INVALID() permits the compiler to check the validity of the