From owner-freebsd-current@FreeBSD.ORG Mon Jul 5 16:44:31 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1DFB316A4CE for ; Mon, 5 Jul 2004 16:44:31 +0000 (GMT) Received: from smtp.des.no (flood.des.no [217.116.83.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7F9AE43D2F for ; Mon, 5 Jul 2004 16:44:30 +0000 (GMT) (envelope-from des@des.no) Received: by smtp.des.no (Pony Express, from userid 666) id 2C881531A; Mon, 5 Jul 2004 18:44:29 +0200 (CEST) Received: from dwp.des.no (des.no [80.203.228.37]) by smtp.des.no (Pony Express) with ESMTP id 4BD1D5309; Mon, 5 Jul 2004 18:44:21 +0200 (CEST) Received: by dwp.des.no (Postfix, from userid 2602) id 1628DB860; Mon, 5 Jul 2004 18:44:21 +0200 (CEST) To: David Malone References: <20040705133820.GA9159@stud.fit.vutbr.cz> <20040705161059.GA52584@walton.maths.tcd.ie> From: des@des.no (=?iso-8859-1?q?Dag-Erling_Sm=F8rgrav?=) Date: Mon, 05 Jul 2004 18:44:21 +0200 In-Reply-To: (Dag-Erling =?iso-8859-1?q?Sm=F8rgrav's?= message of "Mon, 05 Jul 2004 18:30:35 +0200") Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on flood.des.no X-Spam-Level: X-Spam-Status: No, hits=0.0 required=5.0 tests=AWL autolearn=no version=2.63 cc: Divacky Roman cc: current@freebsd.org Subject: Re: recent libalias changes X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jul 2004 16:44:31 -0000 --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable des@des.no (Dag-Erling Sm=F8rgrav) writes: > David Malone writes: > > With Divacky's help we localised his problem to alias.c. The twowords > > function breaks the strick aliasing rule, try replacing it with: > > [...] > oh no you don't - this is not endian-clean. Please try the attached patch. DES --=20 Dag-Erling Sm=F8rgrav - des@des.no --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=twowords.diff Index: alias.c =================================================================== RCS file: /home/ncvs/src/lib/libalias/alias.c,v retrieving revision 1.46 diff -u -r1.46 alias.c --- alias.c 5 Jul 2004 11:10:57 -0000 1.46 +++ alias.c 5 Jul 2004 16:42:00 -0000 @@ -139,9 +139,16 @@ static __inline int twowords(void *p) { - u_short *s = p; + uint8_t *c = p; - return (s[0] + s[1]); +#if BYTE_ORDER == LITTLE_ENDIAN + uint16_t s1 = ((uint16_t)c[1] << 8) + (uint16_t)c[0]; + uint16_t s2 = ((uint16_t)c[3] << 8) + (uint16_t)c[2]; +#else + uint16_t s1 = ((uint16_t)c[0] << 8) + (uint16_t)c[1]; + uint16_t s2 = ((uint16_t)c[2] << 8) + (uint16_t)c[3]; +#endif + return (s1 + s2); } /* TCP Handling Routines --=-=-=--