This commit is contained in:
jrowlandls
2011-09-16 09:06:37 +01:00
3 changed files with 28 additions and 6 deletions

View File

@@ -131,17 +131,25 @@ inline int64 swap(int64 val)
template<>
inline float swap(float val)
{
int32* pval = (int32*)&val;
*pval = swap32(*pval);
return val;
union {
int32 i;
float f;
} conv;
conv.f = val;
conv.i = swap32(conv.i);
return conv.f;
}
template<>
inline double swap(double val)
{
int64* pval = (int64*)&val;
*pval = swap64(*pval);
return val;
union {
int64 i;
double d;
} conv;
conv.d = val;
conv.i = swap64(conv.i);
return conv.d;
}
#define is_aligned(POINTER, BYTE_COUNT) \

View File

@@ -30,6 +30,10 @@ PROD_HOST += testBitSet
testBitSet_SRCS += testBitSet.cpp
testBitSet_LIBS += pvData Com
PROD_HOST += testByteOrder
testByteOrder_SRCS += testByteOrder.cpp
testByteOrder_LIBS += Com
PROD_HOST += testByteBuffer
testByteBuffer_SRCS += testByteBuffer.cpp
testByteBuffer_LIBS += pvData Com

View File

@@ -0,0 +1,10 @@
#include <epicsEndian.h>
#include <stdio.h>
int main()
{
printf("EPICS_BYTE_ORDER: %s\n", (EPICS_BYTE_ORDER == EPICS_ENDIAN_LITTLE) ? "little" : "big");
printf("EPICS_FLOAT_WORD_ORDER: %s\n", (EPICS_FLOAT_WORD_ORDER == EPICS_ENDIAN_LITTLE) ? "little" : "big");
return 0;
}