From owner-cvs-all Fri Aug 9 20: 1:12 2002 Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AF18737B400; Fri, 9 Aug 2002 20:01:07 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6167A43E77; Fri, 9 Aug 2002 20:01:06 -0700 (PDT) (envelope-from peter@FreeBSD.org) Received: from freefall.freebsd.org (peter@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g7A30uJU031589; Fri, 9 Aug 2002 20:00:56 -0700 (PDT) (envelope-from peter@freefall.freebsd.org) Received: (from peter@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g7A30umV031588; Fri, 9 Aug 2002 20:00:56 -0700 (PDT) Message-Id: <200208100300.g7A30umV031588@freefall.freebsd.org> From: Peter Wemm Date: Fri, 9 Aug 2002 20:00:56 -0700 (PDT) To: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: cvs commit: src/sbin/ping ping.c X-FreeBSD-CVS-Branch: HEAD Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG peter 2002/08/09 20:00:56 PDT Modified files: sbin/ping ping.c Log: Fix the broken "avoid unaligned data" fix. The problem is that the builtin gcc memcpy "knows" about types that are supposed to be actually already aligned and triggers alignment errors doing the memcpy itself. "Fix" this by changing it to a bcopy(). In this case, we had: struct timeval *tp; struct timeval tv1; memcpy(&tv1,tp,sizeof(tv1)); .. and since gcc *knows* that a pointer to a timeval is longword aligned and that tv1 is longword aligned, then it can use an inline that assumes alignment. The following works too: cp = (char *)tp; memcpy(&tv1,cp,sizeof(tv1)); Simply casting (char *)tp for the memcpy doesn't work. :-( This affected different 64 bit platforms in different ways and depends a lot on gcc as well. I've seen this on alpha and ia64 at least, although alpha isn't doing it right now. Revision Changes Path 1.69 +2 -2 src/sbin/ping/ping.c To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message