diff options
| author | comex <comexk@gmail.com> | 2009-02-20 12:55:45 -0500 |
|---|---|---|
| committer | comex <comexk@gmail.com> | 2009-02-20 12:55:45 -0500 |
| commit | 39baa1446e6b5ffbc83b61755297d9687111e807 (patch) | |
| tree | 57ae4059b324211cd619976026cc9bcf2febfd6a | |
| parent | 206419cec9e97b7078d462e882b744485f6051c4 (diff) | |
| parent | f3ce109d4d834691adeb75e55c99e5958478f4a6 (diff) | |
Merge branch 'master' of git@github.com:SquidMan/benzin
Diffstat (limited to '')
| -rw-r--r-- | Makefile | 4 | ||||
| -rwxr-xr-x | endian.c | 39 | ||||
| -rwxr-xr-x | endian.h | 26 |
3 files changed, 45 insertions, 24 deletions
@@ -1,4 +1,6 @@ -OBJECTS = main.o general.o brlyt.o brlan.o memfile.o xml.o +GENERICOBJECTS = main.o general.o memfile.o xml.o endian.o +MAINOBJECTS = brlyt.o brlan.o +OBJECTS = $(GENERICOBJECTS) $(MAINOBJECTS) LIBS = -lmxml OUTPUT = benzin main: $(OBJECTS) diff --git a/endian.c b/endian.c new file mode 100755 index 0000000..ea326a9 --- /dev/null +++ b/endian.c @@ -0,0 +1,39 @@ +#ifndef _ENDIAN_H_ +#define _ENDIAN_H_ + +#include "types.h" +#include "endian.h" + +//#define be16(x) ((x>>8)|(x<<8)) +//#define be32(x) ((x>>24)|((x<<8)&0x00FF0000)|((x>>8)&0x0000FF00)|(x<<24)) +//#define be64(x) ((x>>56)|((x<<40)&(u64)0x00FF000000000000)|((x<<24)&(u64)0x0000FF0000000000)|((x<<8)&(u64)0x000000FF00000000)|((x>>8)&(u64)0x00000000FF000000)|((x>>24)&(u64)0x0000000000FF0000)|((x<<40)&(u64)0x000000000000FF00)|(x<<56)) + +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); +} + +#endif //_ENDIAN_H_ + @@ -7,32 +7,12 @@ //#define be32(x) ((x>>24)|((x<<8)&0x00FF0000)|((x>>8)&0x0000FF00)|(x<<24)) //#define be64(x) ((x>>56)|((x<<40)&(u64)0x00FF000000000000)|((x<<24)&(u64)0x0000FF0000000000)|((x<<8)&(u64)0x000000FF00000000)|((x>>8)&(u64)0x00000000FF000000)|((x>>24)&(u64)0x0000000000FF0000)|((x<<40)&(u64)0x000000000000FF00)|(x<<56)) -u16 be16(u16 x) -{ - return (x>>8) | - (x<<8); -} +u16 be16(u16 x); -u32 be32(u32 x) -{ - return (x>>24) | - ((x<<8) & 0x00FF0000) | - ((x>>8) & 0x0000FF00) | - (x<<24); -} +u32 be32(u32 x); // __int64 for MSVC, "long long" for gcc -u64 be64(u64 x) -{ - return (x>>56) | - ((x<<40) & (u64)0x00FF000000000000) | - ((x<<24) & (u64)0x0000FF0000000000) | - ((x<<8) & (u64)0x000000FF00000000) | - ((x>>8) & (u64)0x00000000FF000000) | - ((x>>24) & (u64)0x0000000000FF0000) | - ((x>>40) & (u64)0x000000000000FF00) | - (x<<56); -} +u64 be64(u64 x); #endif //_ENDIAN_H_ |
