From 82afee74aba00c54ab59356ab715cbe4206fb14c Mon Sep 17 00:00:00 2001 From: Alex Marshall Date: Wed, 18 Mar 2009 12:32:15 -0700 Subject: Added Zetsubou, a (currently only) TPL extractor, which will eventually be able to write TPLs. Successor to gentpl. --- zetsubou/endian.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 zetsubou/endian.c (limited to 'zetsubou/endian.c') diff --git a/zetsubou/endian.c b/zetsubou/endian.c new file mode 100644 index 0000000..027b3dc --- /dev/null +++ b/zetsubou/endian.c @@ -0,0 +1,38 @@ +/* + * endian.c + * Zetsubou + * + * Created by Alex Marshall on 09/03/16. + * Copyright 2009 __MyCompanyName__. All rights reserved. + * + */ + +#include "types.h" +#include "endian.h" + +u16 be16(u16 x) +{ + return (x>>8) | + (x<<8); +} + +u32 be32(u32 x) +{ + return (x>>24) | + ((x<<8) & 0x00FF0000) | + ((x>>8) & 0x0000FF00) | + (x<<24); +} + +// __int64 for MSVC, "long long" for gcc +u64 be64(u64 x) +{ + return (x>>56) | + ((x<<40) & (u64)0x00FF000000000000LL) | + ((x<<24) & (u64)0x0000FF0000000000LL) | + ((x<<8) & (u64)0x000000FF00000000LL) | + ((x>>8) & (u64)0x00000000FF000000LL) | + ((x>>24) & (u64)0x0000000000FF0000LL) | + ((x>>40) & (u64)0x000000000000FF00LL) | + (x<<56); +} -- cgit v1.3.1