Received: by 10.223.164.202 with SMTP id h10csp2659061wrb; Mon, 27 Nov 2017 22:17:29 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ1nvovwbuUdC8lWt5gMpb7Xq85c06evbr5IQucip776fYod6qlf+l9/eh+fOyymOKL2nvi X-Received: by 10.101.83.67 with SMTP id w3mr21539887pgr.322.1511849849379; Mon, 27 Nov 2017 22:17:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511849849; cv=none; d=google.com; s=arc-20160816; b=F4eIPsABMMApbH4GC2SPP7gv0pwnPzjGJTOonfdZ4yHyUZapXzZin4sGCvt1bk+nJ4 JF154jwsql1+knxF+o9fIqQwXiQHjpGh/0X+w9vnYQul/9daHgL0ldLJgQn0jZR6IQh/ 7m5LwVhb9bm9Q8yrpQcKKtjAc7w3J1cH+bBRJmjKTLmgG5RI1cAaTxwZDhrQcpv9cOwg IdkLM7HbxJzHbswt8HABGWyZcCFvgcIjTuaZg6HCZ8a9KituN54Rm0vRqz8ReSx76CQg geSjIR/gK/qKuu+5bYO0IDV3bKy1PS4obKDJAXqS0QGb60F1zRsEu73mFKTCalF0pQb5 5/aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=TEXUIrhNv84omDyZaAM61JErTuIp10Ra7IVkB7qIKJU=; b=EwUvmuJy3IT9h9zA9pqVW3fof3EsMfnophAMaJ9pT/Zk80iX7HpSiIOsEHlUjqobFi GAkDeLLWVXzV52eNJDhYR3gaQxjvODUcKT712MY+f/0CSUcPOwat9CE2Xq83QeGWsMJN ZMB03JsVhFuRjogyHxjnMUNZXecJZh1YL1MkTAHIhs8heBxBdEJzFt9sEXgZwj1y2xGc U058sllQ9uaD0PAontAXozdjjlTv/C5TA2fXb7y6K2+ESzSxRBzvsRXCRWraJWy2UcvO WzGc1YadcFuNyxI3EdSL5YSkjaVU5mvWhmG7Sg7QvecsuuwiYNFFzWX3WSYPWb5o+SnI pSxA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p7si23776456pgs.362.2017.11.27.22.17.17; Mon, 27 Nov 2017 22:17:29 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751378AbdK1GQR (ORCPT + 77 others); Tue, 28 Nov 2017 01:16:17 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:3170 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751041AbdK1GQQ (ORCPT ); Tue, 28 Nov 2017 01:16:16 -0500 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="30505905" Received: from localhost (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 28 Nov 2017 14:16:14 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id 52444489C476; Tue, 28 Nov 2017 14:16:09 +0800 (CST) Received: from [10.167.226.45] (10.167.226.45) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.361.1; Tue, 28 Nov 2017 14:16:07 +0800 Subject: Re: [PATCH] tools include: define READ_ONCE/WRITE_ONCE for C++ To: CC: , , References: <1511849622-3683-1-git-send-email-lizhijian@cn.fujitsu.com> From: Li Zhijian Message-ID: Date: Tue, 28 Nov 2017 14:16:07 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <1511849622-3683-1-git-send-email-lizhijian@cn.fujitsu.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [10.167.226.45] X-yoursite-MailScanner-ID: 52444489C476.AAED9 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: lizhijian@cn.fujitsu.com X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org add Arnaldo Carvalho de Melo On 11/28/2017 02:13 PM, Li Zhijian wrote: > since 6aa7de0, we failed to build perf with C++(clang) > to fix the following compile errors > -------------- > lizhijian@haswell-OptiPlex-9020:~/lkp/linux/tools/perf$ make LLVM_CONFIG=/usr/bin/llvm-config-3.9 LIBCLANGLLVM=1 > ... > CC util/probe-finder.o > In file included from /home/lizj/linux/tools/perf/util/util.h:13:0, > from /home/lizj/linux/tools/perf/util/util-cxx.h:20, > from util/c++/clang-c.h:5, > from util/c++/clang-test.cpp:2: > /home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h: In function ‘int atomic_read(const atomic_t*)’: > /home/lizj/linux/tools/include/linux/compiler.h:157:45: error: use of deleted function ‘atomic_read(const atomic_t*)::::()’ > ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), __u.__c, sizeof(x)); __u.__val; }) > ^ > /home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: note: in expansion of macro ‘READ_ONCE’ > return READ_ONCE((v)->counter); > ^ > /home/lizj/linux/tools/include/linux/compiler.h:157:11: note: ‘atomic_read(const atomic_t*)::::()’ is implicitly deleted because the default definition would be ill-formed: > ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), __u.__c, sizeof(x)); __u.__val; }) > ^ > /home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: note: in expansion of macro ‘READ_ONCE’ > return READ_ONCE((v)->counter); > ^ > /home/lizj/linux/tools/include/linux/compiler.h:157:11: error: uninitialized const member in ‘union atomic_read(const atomic_t*)::’ > ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), __u.__c, sizeof(x)); __u.__val; }) > ^ > /home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: note: in expansion of macro ‘READ_ONCE’ > return READ_ONCE((v)->counter); > ^ > /home/lizj/linux/tools/include/linux/compiler.h:157:23: note: ‘const int atomic_read(const atomic_t*)::::__val’ should be initialized > ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), __u.__c, sizeof(x)); __u.__val; }) > ^ > /home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: note: in expansion of macro ‘READ_ONCE’ > return READ_ONCE((v)->counter); > ^ > LD tests/perf-in.o > ... > -------------- > > Signed-off-by: Li Zhijian > --- > tools/include/linux/compiler.h | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h > index 07fd03c..e4c8a0d 100644 > --- a/tools/include/linux/compiler.h > +++ b/tools/include/linux/compiler.h > @@ -86,6 +86,10 @@ > > #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) > > +#ifdef __cplusplus > +#define READ_ONCE(x) ACCESS_ONCE(x) > +#define WRITE_ONCE(x, val) ACCESS_ONCE(x) = val > +#else > #include > > /* > @@ -160,6 +164,7 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s > #define WRITE_ONCE(x, val) \ > ({ union { typeof(x) __val; char __c[1]; } __u = { .__val = (val) }; __write_once_size(&(x), __u.__c, sizeof(x)); __u.__val; }) > > +#endif /* __cplusplus */ > > #ifndef __fallthrough > # define __fallthrough From 1585289320077919715@xxx Tue Nov 28 06:15:08 +0000 2017 X-GM-THRID: 1585289320077919715 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread