Subject: Re: Endianness conversion functions
To: None <tech-misc@NetBSD.org>
From: Christian Biere <christianbiere@gmx.de>
List: tech-misc
Date: 01/20/2007 22:40:01
Krister Walfridsson wrote:
> On Thu, 18 Jan 2007, Christian Biere wrote:
> >are there any objections against the patch below? These could then
> >completely replace the almost identical code in sys/fs/cd9660/iso.h
> >as well as sys/fs/msdosfs/bpb.h and -DUNALIGNED_ACCESS could be removed
> >from the relevant Makefiles.
> 
> This breaks the C aliasing rules [*], so I would prefer to instead
> change sys/fs/cd9660/iso.h and sys/fs/msdosfs/bpb.h to use a correct
> implementation (using e.g. memcpy, which for sufficiently new gcc
> should generate as efficient code but without the potential lossage
> arising from aliasing issues.)

What about the prototype? Is a blatant use of __builtin_memcpy() ok? It
seems GCC is not smart enough to replace a byte-copy loop with the
equivalent __builtin_memcpy() on its own.

-- 
Christian