From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30087 invoked by alias); 24 Sep 2007 16:57:08 -0000 Received: (qmail 30079 invoked by uid 22791); 24 Sep 2007 16:57:07 -0000 X-Spam-Status: No, hits=-0.7 required=5.0 tests=AWL,BAYES_50,DK_POLICY_SIGNSOME,FORGED_RCVD_HELO,SPF_PASS X-Spam-Check-By: sourceware.org Received: from cenn.mc.mpls.visi.com (HELO cenn-smtp.mc.mpls.visi.com) (208.42.156.9) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 24 Sep 2007 16:57:04 +0000 Received: from rivatek.dnsalias.net (c-76-17-159-202.hsd1.mn.comcast.net [76.17.159.202]) by cenn-smtp.mc.mpls.visi.com (Postfix) with ESMTP id 92D938154 for ; Mon, 24 Sep 2007 11:57:02 -0500 (CDT) Received: by rivatek.dnsalias.net (Postfix, from userid 1001) id D6BA254225; Mon, 24 Sep 2007 11:57:01 -0500 (CDT) Date: Mon, 24 Sep 2007 16:57:00 -0000 From: Grant Edwards To: ecos-patches@ecos.sourceware.org Subject: Fix for hal_endian.h SWAP16() macro Message-ID: <20070924165701.GA453@grante.dsl.visi.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="AhhlLboLdkugWU4S" Content-Disposition: inline X-PGP-Key: http://www.visi.com/~grante/pubkey.asc User-Agent: Mutt/1.5.9i X-Virus-Checked: Checked by ClamAV on sourceware.org Mailing-List: contact ecos-patches-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: ecos-patches-owner@ecos.sourceware.org X-SW-Source: 2007-09/txt/msg00017.txt.bz2 --AhhlLboLdkugWU4S Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 310 The SWAP16() macro is broken. unsigned u = SWAP16(0x1234); u will be 0x123412 instead of 0x3412. Here's a fix. I believe that the SWAP32() macro will also break in a similar way on systems where "int" is larger than 32 bits, but I have no way to test that conjecture. -- Grant Edwards grante@visi.com --AhhlLboLdkugWU4S Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="hal_endian.h--SWAP16.patch" Content-length: 1156 ? hal_endian.h--SWAP16.patch Index: hal_endian.h =================================================================== RCS file: /cvs/ecos/ecos/packages/hal/common/current/include/hal_endian.h,v retrieving revision 1.3 diff -U10 -r1.3 hal_endian.h --- hal_endian.h 23 May 2002 23:02:47 -0000 1.3 +++ hal_endian.h 24 Sep 2007 16:48:40 -0000 @@ -56,21 +56,21 @@ #include // CYGBLD_HAL_ENDIAN_H #include // endian setting // Allow HALs to override the generic implementation of swap macros #ifdef CYGBLD_HAL_ENDIAN_H # include CYGBLD_HAL_ENDIAN_H #endif #ifndef CYG_SWAP16 # define CYG_SWAP16(_x_) \ - ({ cyg_uint16 _x = (_x_); ((_x << 8) | (_x >> 8)); }) + ({ cyg_uint16 _x = (_x_); (cyg_uint16)((_x << 8) | (_x >> 8)); }) #endif #ifndef CYG_SWAP32 # define CYG_SWAP32(_x_) \ ({ cyg_uint32 _x = (_x_); \ ((_x << 24) | \ ((0x0000FF00UL & _x) << 8) | \ ((0x00FF0000UL & _x) >> 8) | \ (_x >> 24)); }) #endif --AhhlLboLdkugWU4S--