diff --git a/clients/opal/models/send_receive/src/msg.c b/clients/opal/models/send_receive/src/msg.c index a82ac2180..fac5e43d9 100644 --- a/clients/opal/models/send_receive/src/msg.c +++ b/clients/opal/models/send_receive/src/msg.c @@ -4,18 +4,23 @@ * @copyright 2014, Institute for Automation of Complex Power Systems, EONERC */ -#include +#ifdef __linux__ + #include +#elif defined(__powerpc__) + #include +#endif #include "msg.h" void msg_swap(struct msg *m) { - uint32_t *data = (uint32_t *) m->data; - - - /* Swap data */ - for (int i = 0; i < m->length; i++) - data[i] = bswap_32(data[i]); + for (int i = 0; i < m->length; i++) { +#ifdef __linux__ + data[i] = bswap_32(m->data[i].i); +#elif defined(__powerpc__) + data[i] = Xil_EndianSwap32(m->data[i].i); +#endif + } m->endian ^= 1; } diff --git a/server/src/msg.c b/server/src/msg.c index 23bc9513d..22cfa78fa 100644 --- a/server/src/msg.c +++ b/server/src/msg.c @@ -7,8 +7,12 @@ #include #include #include -#include -#include + +#ifdef __linux__ + #include +#elif defined(__powerpc__) + #include +#endif #include "msg.h" #include "node.h" @@ -16,12 +20,13 @@ void msg_swap(struct msg *m) { - uint32_t *data = (uint32_t *) m->data; - - - /* Swap data */ - for (int i = 0; i < m->length; i++) - data[i] = bswap_32(data[i]); + for (int i = 0; i < m->length; i++) { +#ifdef __linux__ + m->data[i].i = bswap_32(m->data[i].i); +#elif defined(__powerpc__) + m->data[i].i = Xil_EndianSwap32(m->data[i].i); +#endif + } m->endian ^= 1; }