Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752987AbaBXSOF (ORCPT ); Mon, 24 Feb 2014 13:14:05 -0500 Received: from mail-ve0-f178.google.com ([209.85.128.178]:44417 "EHLO mail-ve0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751867AbaBXSOC (ORCPT ); Mon, 24 Feb 2014 13:14:02 -0500 MIME-Version: 1.0 In-Reply-To: <20140224172110.GO8264@linux.vnet.ibm.com> References: <1392922421.28840.36.camel@triegel.csb> <1393095223.28840.4914.camel@triegel.csb> <20140223003933.GQ4250@linux.vnet.ibm.com> <20140223063426.GT4250@linux.vnet.ibm.com> <20140224172110.GO8264@linux.vnet.ibm.com> Date: Mon, 24 Feb 2014 10:14:01 -0800 X-Google-Sender-Auth: mfeWOHpqZX4vwgO83MtBh-gf5k0 Message-ID: Subject: Re: [RFC][PATCH 0/5] arch: atomic rework From: Linus Torvalds To: Paul McKenney Cc: Torvald Riegel , Will Deacon , Peter Zijlstra , Ramana Radhakrishnan , David Howells , "linux-arch@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "akpm@linux-foundation.org" , "mingo@kernel.org" , "gcc@gcc.gnu.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 24, 2014 at 9:21 AM, Paul E. McKenney wrote: > > 4. Bitwise operators ("&", "|", "^", and I suppose also "~") > applied to a chained pointer and an integer results in another > chained pointer in that same pointer chain. No. You cannot define it this way. Taking the value of a pointer and doing a bitwise operation that throws away all the bits (or even *most* of the bits) results in the compiler easily being able to turn the "chain" into a non-chain. The obvious example being "val & 0", but things like "val & 1" are in practice also something that compilers easily turn into control dependencies instead of data dependencies. So you can talk about things like "aligning the pointer value to object boundaries" etc, but it really cannot and *must* not be about the syntactic operations. The same goes for "adding and subtracting an integer". The *syntax* doesn't matter. It's about remaining information. Doing "p-(int)p" or "p+(-(int)p)" doesn't leave any information despite being "subtracting and adding an integer" at a syntactic level. Syntax is meaningless. Really. > 8. Applying any of the following operators to a chained pointer > results in something that is not a chained pointer: > "()", sizeof, "!", "*", "/", "%", ">>", "<<", "<", ">", "<=", > ">=", "==", "!=", "&&", and "||". Parenthesis? I'm assuming that you mean calling through the chained pointer. Also, I think all of /, * and % are perfectly fine, and might be used for that "aligning the pointer" operation that is fine. Linus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/