Re: Endianness conversion functions

Christian Biere <[email protected]>
Newsgroups gmane.os.netbsd.devel.general
Message-ID <20070118235041.GD3234@cyclonus>
Christian Biere wrote:
> 	uint32_t x;
> 	memcpy(&x, buf, 4);
> 	return le32toh(x);
 
> Even with -O0 there's no call to memcpy() only to this function. With -O1 the
> code is always inlined even if inline isn't specified.

Actually if both __inline (or inline) and __attribute__((__always_inline__))
are used, then function is inlined at -O0 too. The call to bswap however isn't.
So if -O0 is a concern, there should be bswap_inline variants which should be
used here.

-- 
Christian
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.