From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423355AbcFHJl0 (ORCPT ); Wed, 8 Jun 2016 05:41:26 -0400 Received: from terminus.zytor.com ([198.137.202.10]:55786 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424081AbcFHJlU (ORCPT ); Wed, 8 Jun 2016 05:41:20 -0400 Subject: Re: [PATCH 02/10] x86, asm: use bool for bitops and other assembly outputs To: Ingo Molnar References: <1465342269-492350-1-git-send-email-hpa@linux.intel.com> <1465342269-492350-3-git-send-email-hpa@linux.intel.com> <20160608074956.GO30154@twins.programming.kicks-ass.net> <20160608082835.GB9645@gmail.com> <20160608083340.GC9645@gmail.com> <02ee64ce-257a-ba93-1f49-6877f5e4f6db@zytor.com> <20160608090111.GA11390@gmail.com> <88387994-fbf1-83dd-d58d-343498776a11@zytor.com> <20160608092040.GA17389@gmail.com> Cc: Peter Zijlstra , "H. Peter Anvin" , Thomas Gleixner , Linux Kernel Mailing List , Andy Lutomirski , Borislav Petkov , Linus Torvalds , Arnd Bergmann From: "H. Peter Anvin" Message-ID: Date: Wed, 8 Jun 2016 02:40:21 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: <20160608092040.GA17389@gmail.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/08/16 02:20, Ingo Molnar wrote: > > Also, unless I'm missing something it's not really 'hard' or dangerous per se to > do that change for every architecture, just incredibly boring! ;-) > > I'm not sure how much it matters though, given other asymmetries in the bitops API > signatures - does anyone have any preferences? > My big concern is doing a change to another architectures which I can't test... and I will have to make assumptions about the properties of asm() in that architecture. Furthermore, if/when other architectures get support for =@cc or an equivalent, they probably want to change their stuff. >> Perhaps I'm wrong, but I'd really like to avoid the upcasting to "int" >> which isn't needed, because in my testing I find that it definitely >> encourages gcc to generate poor code. > > Yeah, absolutely. I hate 'bool' with a vengence but if 'int' generates worse code > with modern compilers then I'm not going to argue for worse code. Would a 'char' > return type be very weird? Another reason to not hate on "bool" so much: I have personally gotten bitten a few to many times by programmers who thought returning -1 or 2 for what was normally a 0/1 flag in some kind of exceptional case. If the variable is bool you know that that can't happen. One thing, though: we should NOT use bool as input to a system call, because coming from userspace we cannot enforce the required invariant that bits[7:1] == 0.