From patchwork Tue Jan 25 22:30:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Williams X-Patchwork-Id: 80417 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id DC970B70EC for ; Wed, 26 Jan 2011 09:31:06 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DC803280BC; Tue, 25 Jan 2011 23:31:04 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sJZ+dsnn-KKd; Tue, 25 Jan 2011 23:31:04 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 053CB2808F; Tue, 25 Jan 2011 23:31:03 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 252642808F for ; Tue, 25 Jan 2011 23:31:01 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LLoh8+ieXogK for ; Tue, 25 Jan 2011 23:30:59 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail3.caviumnetworks.com (mail3.caviumnetworks.com [12.108.191.235]) by theia.denx.de (Postfix) with ESMTP id 06EA82808A for ; Tue, 25 Jan 2011 23:30:57 +0100 (CET) Received: from caexch01.caveonetworks.com (Not Verified[192.168.16.9]) by mail3.caviumnetworks.com with MailMarshal (v6, 7, 2, 8378) id ; Tue, 25 Jan 2011 14:31:45 -0800 Received: from caexch01.caveonetworks.com ([192.168.16.9]) by caexch01.caveonetworks.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 25 Jan 2011 14:30:56 -0800 Received: from awilliams-suse.localnet ([12.108.191.236]) by caexch01.caveonetworks.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 25 Jan 2011 14:30:56 -0800 From: Aaron Williams To: u-boot@lists.denx.de Date: Tue, 25 Jan 2011 14:30:55 -0800 User-Agent: KMail/1.13.5 (Linux/2.6.34.7-0.7-desktop; KDE/4.5.5; x86_64; ; ) MIME-Version: 1.0 Message-Id: <201101251430.55755.Aaron.Williams@caviumnetworks.com> X-OriginalArrivalTime: 25 Jan 2011 22:30:56.0160 (UTC) FILETIME=[885B3A00:01CBBCDF] Subject: [U-Boot] [PATCH 1/1] fix min/max macros in common.h X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de In some of my work with the Cavium Octeon 64-bit processor I ran into a problem with the min and max macros provided in common.h. The problem occurs if x is 32-bit and y is 64-bit. In this case, y will always be truncated to 32-bits. This patch fixes this problem. -Aaron diff --git a/include/common.h b/include/common.h index d8c912d..cf5c076 100644 --- a/include/common.h +++ b/include/common.h @@ -180,11 +180,13 @@ typedef void (interrupt_handler_t)(void *); * General Purpose Utilities */ #define min(X, Y) \ - ({ typeof (X) __x = (X), __y = (Y); \ + ({ typeof (X) __x = (X); \ + typeof (Y) __y = (Y); \ (__x < __y) ? __x : __y; }) #define max(X, Y) \ - ({ typeof (X) __x = (X), __y = (Y); \ + ({ typeof (X) __x = (X); \ + typeof (Y) __y = (Y); \ (__x > __y) ? __x : __y; }) #define MIN(x, y) min(x, y)