From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751017AbaKXUpi (ORCPT ); Mon, 24 Nov 2014 15:45:38 -0500 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:59112 "EHLO e06smtp15.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750875AbaKXUpg (ORCPT ); Mon, 24 Nov 2014 15:45:36 -0500 Message-ID: <547398E8.9070905@de.ibm.com> Date: Mon, 24 Nov 2014 21:45:28 +0100 From: Christian Borntraeger User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Alexei Starovoitov CC: Linus Torvalds , David Howells , "linux-kernel@vger.kernel.org" , "linux-arch@vger.kernel.org" , linux-mips , linux-x86_64@vger.kernel.org, linux-s390 , Paolo Bonzini , Paul McKenney , Ingo Molnar , Catalin Marinas , Will Deacon Subject: Re: [PATCH/RFC 7/7] kernel: Force ACCESS_ONCE to work only on scalar types References: In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14112420-0021-0000-0000-000001E553F6 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 24.11.2014 um 21:29 schrieb Alexei Starovoitov: > On Mon, Nov 24, 2014 at 11:07 AM, Christian Borntraeger > wrote: >> >> Anyone with a new propopal? ;-) ^ > > one more proposal :) > #define __ACCESS_ONCE(x) ({ typeof(x) __var = 0; (volatile typeof(x) *)&(x); }) > #define ACCESS_ONCE(x) (*__ACCESS_ONCE(x)) This seems to work. I only had to add an __always_unused to __var. > > works as lvalue... > the basic idea is the same: > constant zero can be used to initialize any scalar > (including pointers), but unions and structs will fail to compile as: > "error: invalid initializer" > > If I'm reading pr58145 gcc bug report correctly, it > miscompiles only structs, so we can let ACCESS_ONCE > to work on unions. Then the following will rejects structs only: > #define __ACCESS_ONCE(x) ({ (typeof(x))0; (volatile typeof(x) *)&(x); }) > #define ACCESS_ONCE(x) (*__ACCESS_ONCE(x)) > -- > To unsubscribe from this list: send the line "unsubscribe linux-s390" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >