#ifndef OSC_HOSTENDIANNESS_H
#define OSC_HOSTENDIANNESS_H
-//#define OSC_HOST_BIG_ENDIAN 1
-
-//*
-// Make sure either OSC_HOST_LITTLE_ENDIAN or OSC_HOST_BIG_ENDIAN is defined
-//
-// If you know a way to enhance the detection below for Linux and/or MacOSX
-// please let me know! I've tried a few things which don't work.
-//*/
-//
-//#if defined(OSC_HOST_LITTLE_ENDIAN) || defined(OSC_HOST_BIG_ENDIAN)
-//
+#define OSC_HOST_LITTLE_ENDIAN 1
+
+/*
+ Make sure either OSC_HOST_LITTLE_ENDIAN or OSC_HOST_BIG_ENDIAN is defined
+
+ If you know a way to enhance the detection below for Linux and/or MacOSX
+ please let me know! I've tried a few things which don't work.
+*/
+
+#if defined(OSC_HOST_LITTLE_ENDIAN) || defined(OSC_HOST_BIG_ENDIAN)
+
// you can define one of the above symbols from the command line
// then you don't have to edit this file.
-//
-//#elif defined(__WIN32__) || defined(WIN32) || defined(WINCE)
-//
-// assume that __WIN32__ is only defined on little endian systems
-//
-//#define OSC_HOST_LITTLE_ENDIAN 1
-//#undef OSC_HOST_BIG_ENDIAN
-//
-//#elif defined(__APPLE__)
-//
-//#if defined(__LITTLE_ENDIAN__)
-//
-//#define OSC_HOST_LITTLE_ENDIAN 1
-//#undef OSC_HOST_BIG_ENDIAN
-//
-//#elif defined(__BIG_ENDIAN__)
-//
-//#define OSC_HOST_BIG_ENDIAN 1
-//#undef OSC_HOST_LITTLE_ENDIAN
-//
-//#endif
-//
-//#endif
-//
-//#if !defined(OSC_HOST_LITTLE_ENDIAN) && !defined(OSC_HOST_BIG_ENDIAN)
-//
-//#error please edit OSCHostEndianness.h to configure endianness
-//
-//#endif
+
+#elif defined(__WIN32__) || defined(WIN32) || defined(WINCE)
+
+ assume that __WIN32__ is only defined on little endian systems
+
+#define OSC_HOST_LITTLE_ENDIAN 1
+#undef OSC_HOST_BIG_ENDIAN
+
+#elif defined(__APPLE__)
+
+#if defined(__LITTLE_ENDIAN__)
+
+#define OSC_HOST_LITTLE_ENDIAN 1
+#undef OSC_HOST_BIG_ENDIAN
+
+#elif defined(__BIG_ENDIAN__)
+
+#define OSC_HOST_BIG_ENDIAN 1
+#undef OSC_HOST_LITTLE_ENDIAN
+
+#endif
+
+#endif
+
+#if !defined(OSC_HOST_LITTLE_ENDIAN) && !defined(OSC_HOST_BIG_ENDIAN)
+
+#error please edit OSCHostEndianness.h to configure endianness
+
+#endif
#endif /* OSC_HOSTENDIANNESS_H */
#include <stdlib.h>
#include <assert.h>
+#include <common/endian.h>
+
#if defined(__WIN32__) || defined(WIN32)
#include <malloc.h> // for alloca
#endif
static void FromInt32( char *p, int32 x )
{
#ifdef OSC_HOST_LITTLE_ENDIAN
- union{
+ /*union{
osc::int32 i;
char c[4];
} u;
p[3] = u.c[0];
p[2] = u.c[1];
p[1] = u.c[2];
- p[0] = u.c[3];
+ p[0] = u.c[3];*/
+ *reinterpret_cast<int32*>(p) = caspar::swap_byte_order(x);
#else
*reinterpret_cast<int32*>(p) = x;
#endif
static void FromUInt32( char *p, uint32 x )
{
#ifdef OSC_HOST_LITTLE_ENDIAN
- union{
+ /*union{
osc::uint32 i;
char c[4];
} u;
p[3] = u.c[0];
p[2] = u.c[1];
p[1] = u.c[2];
- p[0] = u.c[3];
+ p[0] = u.c[3];*/
+ *reinterpret_cast<uint32*>(p) = caspar::swap_byte_order(x);
#else
*reinterpret_cast<uint32*>(p) = x;
#endif
static void FromInt64( char *p, int64 x )
{
#ifdef OSC_HOST_LITTLE_ENDIAN
- union{
+ /*union{
osc::int64 i;
char c[8];
} u;
p[3] = u.c[4];
p[2] = u.c[5];
p[1] = u.c[6];
- p[0] = u.c[7];
+ p[0] = u.c[7];*/
+ *reinterpret_cast<int64*>(p) = caspar::swap_byte_order(x);
#else
*reinterpret_cast<int64*>(p) = x;
#endif
static void FromUInt64( char *p, uint64 x )
{
#ifdef OSC_HOST_LITTLE_ENDIAN
- union{
+ /*union{
osc::uint64 i;
char c[8];
} u;
p[3] = u.c[4];
p[2] = u.c[5];
p[1] = u.c[6];
- p[0] = u.c[7];
+ p[0] = u.c[7];*/
+ *reinterpret_cast<uint64*>(p) = caspar::swap_byte_order(x);
#else
*reinterpret_cast<uint64*>(p) = x;
#endif