diff options
| author | megazig <megazig@megazig-desktop.(none)> | 2009-04-12 23:00:48 -0500 |
|---|---|---|
| committer | megazig <megazig@megazig-desktop.(none)> | 2009-04-12 23:00:48 -0500 |
| commit | 25c8362e3cb0348f89d2f25d0613a7f5cb810c03 (patch) | |
| tree | 349c814da134260564e98c2a1185e6114cf51a2b /endian.c | |
| parent | 994c6e516c73f74a99042d53cb6155da11491692 (diff) | |
Brlyt is hella fixed
Diffstat (limited to '')
| -rwxr-xr-x | endian.c | 27 |
1 files changed, 25 insertions, 2 deletions
@@ -10,8 +10,8 @@ u16 be16(u16 x) { - return (x>>8) | - (x<<8); + return (u16)(((x>>8)) | + ((x&0xff)<<8)); } u32 be32(u32 x) @@ -22,6 +22,29 @@ u32 be32(u32 x) (x<<24); } +u32 int_swap_bytes(u32 int1) +{ + unsigned char *int1c; int1c = (unsigned char*)&int1; + + unsigned char charTemp = 0x00; + charTemp = int1c[0]; int1c[0] = int1c[3]; int1c[3] = charTemp; + charTemp = 0x00; + charTemp = int1c[1]; int1c[1] = int1c[2]; int1c[2] = charTemp; + + u32 *newInt; newInt = (int*)int1c; + return *newInt; +} + +u16 short_swap_bytes(u16 short1) +{ + unsigned char* short1c; short1c = (unsigned char*)&short1; + unsigned char charTemp = 0x00; + charTemp = short1c[0]; short1c[0] = short1c[1]; short1c[1] = charTemp; + + unsigned short *newShort; newShort = (unsigned short*)short1c; + return *newShort; +} + // __int64 for MSVC, "long long" for gcc u64 be64(u64 x) { |
