From mboxrd@z Thu Jan 1 00:00:00 1970 From: "David S. Miller" To: ross@ghs.com Cc: mark@codesourcery.com, torvalds@transmeta.com, chip@perlsupport.com, craig@jcb-sc.com, egcs@egcs.cygnus.com, rth@cygnus.com, tim@wagner.Princeton.EDU Subject: Re: Linux and aliasing? Date: Sun, 06 Jun 1999 17:29:00 -0000 Message-id: <199906070033.RAA06574@pizda.davem.net> References: <199906062207.PAA24899@elbe.ghs.com> <199906062207.PAA24899@elbe.ghs.com> X-SW-Source: 1999-06/msg00235.html Date: Sun, 6 Jun 1999 15:07:18 -0700 (PDT) From: Ross Harvey Umm, the ice is getting thin, here. From time to time, I have to change kernel code FROM things like ``a = ntohl((u32 *) p);'' TO things like ``memcpy (&a, p, sizeof a); a = ntohl (a);''. Why? Because it's illegal for a reason, and the alpha platform I support has alignment requirements for which I have a guarantee that the memcpy approach will work and be reasonably efficient. The cast can generate a kernel alignment fault and will either panic or have a hideous run-time fixup cost. This assumes you haven't setup your packet input processing to make the data end up aligned by the time the header parsing gets at it. The cast references work just fine and incur no traps on Alpha in the Linux networking, so I have no idea what you are talking about. Later, David S. Miller davem@redhat.com From mboxrd@z Thu Jan 1 00:00:00 1970 From: "David S. Miller" To: ross@ghs.com Cc: mark@codesourcery.com, torvalds@transmeta.com, chip@perlsupport.com, craig@jcb-sc.com, egcs@egcs.cygnus.com, rth@cygnus.com, tim@wagner.Princeton.EDU Subject: Re: Linux and aliasing? Date: Wed, 30 Jun 1999 15:43:00 -0000 Message-ID: <199906070033.RAA06574@pizda.davem.net> References: <199906062207.PAA24899@elbe.ghs.com> X-SW-Source: 1999-06n/msg00235.html Message-ID: <19990630154300._CbhNmwWiELvfyj5gW-aFszQkTKFaNEd8qRrN9quEpg@z> Date: Sun, 6 Jun 1999 15:07:18 -0700 (PDT) From: Ross Harvey Umm, the ice is getting thin, here. From time to time, I have to change kernel code FROM things like ``a = ntohl((u32 *) p);'' TO things like ``memcpy (&a, p, sizeof a); a = ntohl (a);''. Why? Because it's illegal for a reason, and the alpha platform I support has alignment requirements for which I have a guarantee that the memcpy approach will work and be reasonably efficient. The cast can generate a kernel alignment fault and will either panic or have a hideous run-time fixup cost. This assumes you haven't setup your packet input processing to make the data end up aligned by the time the header parsing gets at it. The cast references work just fine and incur no traps on Alpha in the Linux networking, so I have no idea what you are talking about. Later, David S. Miller davem@redhat.com