mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Li Zhijian <lizhijian@cn.fujitsu.com>
To: <acme@redhat.com>
Cc: <linux-kernel@vger.kernel.org>, <philip.li@intel.com>,
	<mark.rutland@arm.com>, <paulmck@linux.vnet.ibm.com>,
	<mingo@kernel.org>
Subject: Re: [PATCH v2] tools include: define READ_ONCE/WRITE_ONCE for C++
Date: Fri, 15 Dec 2017 09:20:37 +0800	[thread overview]
Message-ID: <6d8bf2ab-5b72-4b09-a72f-cfaf5d6f6454@cn.fujitsu.com> (raw)
In-Reply-To: <1512005772-27112-1-git-send-email-lizhijian@cn.fujitsu.com>

ping


On 11/30/2017 09:36 AM, 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*)::<anonymous union>::<constructor>()’
>    ({ 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*)::<anonymous union>::<constructor>()’ 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*)::<anonymous>’
>    ({ 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*)::<anonymous union>::__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 <lizhijian@cn.fujitsu.com>
> ---
>   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..d6675c5 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) (*(volatile typeof(x) *)&(x))
> +#define WRITE_ONCE(x, val) (*(volatile typeof(x) *)&(x)) = (val)
> +#else
>   #include <linux/types.h>
>   
>   /*
> @@ -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

-- 
Best regards.
Li Zhijian (8528)

  reply	other threads:[~2017-12-15  1:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-30  1:36 Li Zhijian
2017-12-15  1:20 ` Li Zhijian [this message]
2018-04-04  6:16 ` Sandipan Das

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6d8bf2ab-5b72-4b09-a72f-cfaf5d6f6454@cn.fujitsu.com \
    --to=lizhijian@cn.fujitsu.com \
    --cc=acme@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=philip.li@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®