From patchwork Fri Nov 19 22:07:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 342241 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAJM9EBF006170 for ; Fri, 19 Nov 2010 22:09:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758163Ab0KSWIg (ORCPT ); Fri, 19 Nov 2010 17:08:36 -0500 Received: from smtp1.linux-foundation.org ([140.211.169.13]:44810 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758408Ab0KSWIf (ORCPT ); Fri, 19 Nov 2010 17:08:35 -0500 Received: from imap1.linux-foundation.org (imap1.linux-foundation.org [140.211.169.55]) by smtp1.linux-foundation.org (8.14.2/8.14.2/Debian-2build1) with ESMTP id oAJM7M5l021211 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 19 Nov 2010 14:07:22 -0800 Received: from akpm.mtv.corp.google.com (localhost [127.0.0.1]) by imap1.linux-foundation.org (8.13.5.20060308/8.13.5/Debian-3ubuntu1.1) with SMTP id oAJM7Mb1005540; Fri, 19 Nov 2010 14:07:22 -0800 Date: Fri, 19 Nov 2010 14:07:21 -0800 From: Andrew Morton To: Geert Uytterhoeven Cc: michalj@gmail.com, Rolf Eike Beer , linux-kernel@vger.kernel.org, Linux Fbdev development list Subject: Re: abs() vs. abs64() (was: Re: [PATCH] fbdev: fix nearest mode search) Message-Id: <20101119140721.33576c61.akpm@linux-foundation.org> In-Reply-To: References: X-Mailer: Sylpheed 2.4.8 (GTK+ 2.12.9; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-Spam-Status: No, hits=-4.49 required=5 tests=AWL, BAYES_00, PATCH_SUBJECT_OSDL X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.13 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 19 Nov 2010 22:09:15 +0000 (UTC) diff -puN include/linux/kernel.h~include-linux-kernelh-abs-fix-handling-of-32-bit-unsigneds-on-64-bit include/linux/kernel.h --- a/include/linux/kernel.h~include-linux-kernelh-abs-fix-handling-of-32-bit-unsigneds-on-64-bit +++ a/include/linux/kernel.h @@ -143,9 +143,16 @@ extern int _cond_resched(void); #define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0) -#define abs(x) ({ \ - long __x = (x); \ - (__x < 0) ? -__x : __x; \ +#define abs(x) ({ \ + long ret; \ + if (sizeof(x) == sizeof(long)) { \ + long __x = (x); \ + ret = (__x < 0) ? -__x : __x; \ + } else { \ + int __x = (x); \ + ret = (__x < 0) ? -__x : __x; \ + } \ + ret; \ }) #define abs64(x) ({ \