Received: by 10.213.65.68 with SMTP id h4csp352820imn; Tue, 3 Apr 2018 22:46:11 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/SXmq+dp8zDQZijlMlOe525fK4bJdPrTj3KQajquyD4fwUrZi3cyffr5zDyTfD8CK56/Iu X-Received: by 2002:a17:902:b103:: with SMTP id q3-v6mr17312455plr.181.1522820771046; Tue, 03 Apr 2018 22:46:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522820771; cv=none; d=google.com; s=arc-20160816; b=UWfjQM+FfOXSDGtX+If6qT+KipoWVD8Kqxu3ImkGdqaVqwwi6E0MjwYxLQt3ALexcM Jn9Rsjszt2OgwmyBz9tuXjYKJh9tWuE09QSTBUScCyVkV0stVRW1tLYoug9KgU1dOteI liW3UsAFcSeTVfM0dhcW4vLPmxIEz3AwHPgYZnn/QPidYG4Vjmxhqha+1rEq+upYAaiK 3wam7m8OXmOoCGi7KVvyvzNma31ucZl80OykPUtwIzHQkS7ez8v4iyVHdFlTWRCk9Wt1 PwTNqlbKymavxEnZnlLBnC42My026dRjvAZjNwF3k8j4NO0VUA7ERWEDMZf7Qe3eD7oH +aYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:date:subject:cc:to:from:arc-authentication-results; bh=MnqjFhmxeZhlsTik2Rh2lpwO90YmJU0NMfqTTgS/o3k=; b=Cd/OiHbF1eqQ3DcTDEZaI8pp3O+DVSX1Cu/JwnJyrCEmIDBhTxgNLHrRqROt/B41g6 zXAvWYcm6mVwb+KGBk8ykgVBUoKVj8rVqo2otmTdPZwtXzYDGKIZi3Rlz8INjMl83mqZ fgNMb5xbvoySHXWuGaErCF/yuwbu9nkolBL9uGqT5m34w7BQXC688tbvV/XG6xLEhJ8C G3B1vy9c+n9EsStxG2gzNR2RnIoheCjvyYE/u4oPf6VMAEqkWJlnVrtMFpeK4Yayyg9C qfmrEqq5BZyAH3pqLaKu+tA5AsoQDZradoQTTpaPLysv8sDbt+r5hg8PFyueVm+G7TFd v9Tw== 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=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v14si3176308pgq.266.2018.04.03.22.45.55; Tue, 03 Apr 2018 22:46:11 -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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752012AbeDDFol (ORCPT + 99 others); Wed, 4 Apr 2018 01:44:41 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:44388 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751236AbeDDFok (ORCPT ); Wed, 4 Apr 2018 01:44:40 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w345iNnQ050326 for ; Wed, 4 Apr 2018 01:44:40 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2h4puhv69u-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 04 Apr 2018 01:44:40 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 4 Apr 2018 06:44:37 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 4 Apr 2018 06:44:34 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w345iYMx11731274; Wed, 4 Apr 2018 05:44:34 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DF7AA4C050; Wed, 4 Apr 2018 06:37:23 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EC4274C044; Wed, 4 Apr 2018 06:37:22 +0100 (BST) Received: from localhost.localdomain (unknown [9.40.193.84]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 4 Apr 2018 06:37:22 +0100 (BST) From: Sandipan Das To: sandipan@linux.vnet.ibm.com, cme@redhat.com Cc: Li Zhijian , linux-kernel@vger.kernel.org, philip.li@intel.com, mark.rutland@arm.com Subject: tools include: define READ_ONCE/WRITE_ONCE for C++ Date: Wed, 4 Apr 2018 11:14:31 +0530 X-Mailer: git-send-email 2.14.3 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-Patchwork-Id: 10078733 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 18040405-0012-0000-0000-000005C6CB8D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18040405-0013-0000-0000-00001942DC07 Message-Id: <1511849622-3683-1-git-send-email-lizhijian@cn.fujitsu.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-04-04_01:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804040060 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Li Zhijian 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