cvs commit: src/sys/sys endian.h src/share/man/man9 byteorder.9

Ruslan Ermilov ru at FreeBSD.org
Fri Apr 4 21:16:37 PST 2003


On Fri, Apr 04, 2003 at 04:08:23PM -0700, M. Warner Losh wrote:
> In message: <20030404085200.GA1765 at sunbay.com>
>             Ruslan Ermilov <ru at FreeBSD.org> writes:
> : +#define	BSWAP64(x)	(uint64_t) \
> : +	(((x) >> 56) | (((x) >> 40) & 0xff00) | (((x) >> 24) & 0xff0000) | \
> : +	(((x) >> 8) & 0xff000000) | (((x) << 8) & ((uint64_t)0xff << 32)) | \
> : +	(((x) << 24) & ((uint64_t)0xff << 40)) | \
> : +	(((x) << 40) & ((uint64_t)0xff << 48)) | (((x) << 56)))
> 
> 0xffull or 0xffULL might be better than the casts here.  This does
> assume that 0ull == (uint64_t)0, which does hold for all our
> architectures...
> 
Why make assumptions where uint64_t gives us precisely what
we need?  Note that these are evaluated at compile time, so
it cannot affect the run-time performance.


Cheers,
-- 
Ruslan Ermilov		Sysadmin and DBA,
ru at sunbay.com		Sunbay Software AG,
ru at FreeBSD.org		FreeBSD committer,
+380.652.512.251	Simferopol, Ukraine

http://www.FreeBSD.org	The Power To Serve
http://www.oracle.com	Enabling The Information Age
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/cvs-src/attachments/20030405/9662828d/attachment.bin


More information about the cvs-src mailing list