|
Revision 3527, 1.1 kB
(checked in by robert, 9 years ago)
|
|
From Fred Mammond, fixes for x86_64 build
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | #include "flt.h" |
|---|
| 4 | |
|---|
| 5 | using namespace flt; |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | int flt::isLittleEndianMachine() |
|---|
| 10 | { |
|---|
| 11 | int a = 1; |
|---|
| 12 | return (int)(*(char*)&a); |
|---|
| 13 | } |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | void flt::endian2(void* pSrc, int nSrc, void* pDst, int ) |
|---|
| 18 | { |
|---|
| 19 | if (nSrc == 2) |
|---|
| 20 | { |
|---|
| 21 | short tmp1; |
|---|
| 22 | tmp1 = *(short *)pSrc; |
|---|
| 23 | tmp1 = (tmp1 << 8) | ((tmp1 >> 8) & 0xff); |
|---|
| 24 | *(short *)pDst = tmp1; |
|---|
| 25 | } |
|---|
| 26 | else if (nSrc == 4) |
|---|
| 27 | { |
|---|
| 28 | uint32 tmp1; |
|---|
| 29 | tmp1 = *(uint32 *)pSrc; |
|---|
| 30 | tmp1 = (tmp1 << 24) | ((tmp1 << 8) & 0xff0000) | ((tmp1 >> 8) & 0xff00) | ((tmp1 >> 24) & 0xff); |
|---|
| 31 | *(uint32 *)pDst = tmp1; |
|---|
| 32 | } |
|---|
| 33 | else if (nSrc == 8) |
|---|
| 34 | { |
|---|
| 35 | uint32 tmp1, tmp2; |
|---|
| 36 | tmp1 = *(uint32 *)pSrc; |
|---|
| 37 | tmp2 = *(1 + (uint32 *)pSrc); |
|---|
| 38 | tmp1 = (tmp1 << 24) | ((tmp1 << 8) & 0xff0000) | ((tmp1 >> 8) & 0xff00) | ((tmp1 >> 24) & 0xff); |
|---|
| 39 | tmp2 = (tmp2 << 24) | ((tmp2 << 8) & 0xff0000) | ((tmp2 >> 8) & 0xff00) | ((tmp2 >> 24) & 0xff); |
|---|
| 40 | *(uint32 *)pDst = tmp2; |
|---|
| 41 | *(1 + (uint32 *)pDst) = tmp1; |
|---|
| 42 | } |
|---|
| 43 | } |
|---|