From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Paul E. McKenney" Subject: Re: [RFC PATCH] lib: Introduce generic __cmpxchg_u64() and use it where needed Date: Fri, 2 Nov 2018 06:38:37 -0700 Message-ID: <20181102133837.GS4170@linux.ibm.com> References: <20181031220253.GA15505@roeck-us.net> <20181031233235.qbedw3pinxcuk7me@pburton-laptop> <4e2438a23d2edf03368950a72ec058d1d299c32e.camel@hammerspace.com> <20181101131846.biyilr2msonljmij@lakrids.cambridge.arm.com> <20181101145926.GE3178@hirez.programming.kicks-ass.net> <20181101163212.GF3159@hirez.programming.kicks-ass.net> <20181101170146.GQ4170@linux.ibm.com> <7d1ecd21c4c249138dfdd42b9aaa1cea@AcuMS.aculab.com> <20181102122328.GM3178@hirez.programming.kicks-ass.net> Reply-To: paulmck@linux.ibm.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: David Laight , Trond Myklebust , "mark.rutland@arm.com" , "linux-kernel@vger.kernel.org" , "ralf@linux-mips.org" , "jlayton@kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "bfields@fieldses.org" , "linux-mips@linux-mips.org" , "linux@roeck-us.net" , "linux-nfs@vger.kernel.org" , "akpm@linux-foundation.org" , "will.deacon@arm.com" , "boqun.feng@gmail.com" , "paul.burton@mips.com" , "anna.schumaker@netapp.com" Return-path: Content-Disposition: inline In-Reply-To: <20181102122328.GM3178@hirez.programming.kicks-ass.net> Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org On Fri, Nov 02, 2018 at 01:23:28PM +0100, Peter Zijlstra wrote: > On Fri, Nov 02, 2018 at 10:56:31AM +0000, David Laight wrote: > > From: Paul E. McKenney > > > Sent: 01 November 2018 17:02 > > ... > > > And there is a push to define C++ signed arithmetic as 2s complement, > > > but there are still 1s complement systems with C compilers. Just not > > > C++ compilers. Legacy... > > > > Hmmm... I've used C compilers for DSPs where signed integer arithmetic > > used the 'data registers' and would saturate, unsigned used the 'address > > registers' and wrapped. > > That was deliberate because it is much better to clip analogue values. > > Seems a dodgy heuristic if you ask me. > > > Then there was the annoying cobol run time that didn't update the > > result variable if the result wouldn't fit. > > Took a while to notice that the sum of a list of values was even wrong! > > That would be perfectly valid for C - if unexpected. > > That's just insane ;-) > > > > > But for us using -fno-strict-overflow which actually defines signed > > > > overflow > > > > I wonder how much real code 'strict-overflow' gets rid of? > > IIRC gcc silently turns loops like: > > int i; for (i = 1; i != 0; i *= 2) ... > > into infinite ones. > > Which is never what is required. > > Nobody said C was a 'safe' language. But less UB makes a better language > IMO. Ideally we'd get all UBs filled in -- but I realise C has a few > very 'interesting' ones that might be hard to get rid of. There has been an effort to reduce UB, but not sure how far they got. Thanx, Paul