This message generated a parse failure. Raw output follows here. Please use 'back' to navigate. From devnull@lkml.org Fri Apr 19 23:23:25 2024 Delivery-date: Wed, 25 Apr 2007 20:31:16 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S2993102AbXDYUai (ORCPT ); Wed, 25 Apr 2007 16:30:38 -0400 Received: from spirit.analogic.com ([204.178.40.4]:2267 "EHLO spirit.analogic.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2993050AbXDYUah convert rfc822-to-8bit (ORCPT ); Wed, 25 Apr 2007 16:30:37 -0400 Received: from chaos.analogic.com ([10.112.50.11]) by phoenix.analogic.com with Microsoft SMTPSVC(6.0.3790.211); Wed, 25 Apr 2007 16:30:30 -0400 Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT X-MimeOLE: Produced By Microsoft Exchange V6.5 Received: from chaos.analogic.com (localhost [127.0.0.1]) by chaos.analogic.com (8.12.11/8.12.11) with ESMTP id l3PKUUCj027373; Wed, 25 Apr 2007 16:30:30 -0400 Received: (from linux-os@localhost) by chaos.analogic.com (8.12.11/8.12.11/Submit) id l3PKUT8l027372; Wed, 25 Apr 2007 16:30:29 -0400 X-OriginalArrivalTime: 25 Apr 2007 20:30:31.0034 (UTC) FILETIME=[91813DA0:01C78778] content-class: urn:content-classes:message Subject: Re: [RFC][PATCH] fix abs() macro to work with types wider than int Date: Wed, 25 Apr 2007 16:30:29 -0400 Message-Id: In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [RFC][PATCH] fix abs() macro to work with types wider than int Thread-Index: AceHeJGKsBwGgn29RE+Ts/VuobbyeQ== References: <20070419092339.GA13569@dwarf.suse.cz><20070419084339.418dbe69.randy.dunlap@oracle.com><4628B5B6.90303@student.ltu.se><20070425082028.8ece3094.randy.dunlap@oracle.com> To: "Andreas Schwab" Cc: "John Anthony Kazos Jr." , "Randy Dunlap" , "Richard Knutsson" , "Jiri Bohac" , , "Linux kernel" Reply-To: "linux-os \(Dick Johnson\)" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 25 Apr 2007, Andreas Schwab wrote: > "linux-os (Dick Johnson)" writes: > >> I think this works, regardless of the length of the integers: >> >> #define abs(x) (((x)<0)?-(x):(x)) > > But it evaluates its argument more than once. > > Andreas. > Sure. Macros do that. If that's not okay, then you need either a temporary variable or a function. The original query was for a macro. Any macro that tests something then returns a value based upon the test is going to have that problem. Any attempt to just AND off a sign bit is going to have width problems. You can't have your cake and eat it too. Even whacking off the sign- bit may fail because there may be two variable accesses which could mean two function calls, destroying the logic. Cheers, Dick Johnson Penguin : Linux version 2.6.16.24 on an i686 machine (5592.62 BogoMips). New book: http://www.AbominableFirebug.com/ _  **************************************************************** The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to DeliveryErrors@analogic.com - and destroy all copies of this information, including any attachments, without reading or disclosing them. Thank you. - 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/