diff --git a/clients/opal/models/send_receive/include/msg_format.h b/clients/opal/models/send_receive/include/msg_format.h index 4ba4dc41c..40c21453b 100644 --- a/clients/opal/models/send_receive/include/msg_format.h +++ b/clients/opal/models/send_receive/include/msg_format.h @@ -13,8 +13,8 @@ #ifdef __linux__ #define _BSD_SOURCE 1 #include -#elif !defined(BYTE_ORDER) - #error "Please define BYTE_ORDER" +#elif defined(__PPC__) /* Xilinx toolchain */ + #include #endif #include "config.h" @@ -37,6 +37,8 @@ #define MSG_ENDIAN_HOST MSG_ENDIAN_LITTLE #elif BYTE_ORDER == BIG_ENDIAN #define MSG_ENDIAN_HOST MSG_ENDIAN_BIG +#else + #error "Unknown byte order!" #endif /** The total length of a message */ diff --git a/clients/opal/models/send_receive/src/msg.c b/clients/opal/models/send_receive/src/msg.c index f948076d1..19acdca14 100644 --- a/clients/opal/models/send_receive/src/msg.c +++ b/clients/opal/models/send_receive/src/msg.c @@ -6,8 +6,9 @@ #ifdef __linux__ #include -#elif defined(__powerpc__) +#elif defined(__PPC__) /* Xilinx toolchain */ #include + #define bswap_32(x) Xil_EndianSwap32(x) #endif #include "msg.h" @@ -15,13 +16,8 @@ void msg_swap(struct msg *m) { int i; - for (i = 0; i < m->length; i++) { -#ifdef __linux__ + for (i = 0; i < m->length; i++) 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; } diff --git a/server/include/msg_format.h b/server/include/msg_format.h index 4ba4dc41c..40c21453b 100644 --- a/server/include/msg_format.h +++ b/server/include/msg_format.h @@ -13,8 +13,8 @@ #ifdef __linux__ #define _BSD_SOURCE 1 #include -#elif !defined(BYTE_ORDER) - #error "Please define BYTE_ORDER" +#elif defined(__PPC__) /* Xilinx toolchain */ + #include #endif #include "config.h" @@ -37,6 +37,8 @@ #define MSG_ENDIAN_HOST MSG_ENDIAN_LITTLE #elif BYTE_ORDER == BIG_ENDIAN #define MSG_ENDIAN_HOST MSG_ENDIAN_BIG +#else + #error "Unknown byte order!" #endif /** The total length of a message */ diff --git a/server/src/msg.c b/server/src/msg.c index 22cfa78fa..bd369ee47 100644 --- a/server/src/msg.c +++ b/server/src/msg.c @@ -10,8 +10,9 @@ #ifdef __linux__ #include -#elif defined(__powerpc__) +#elif defined(__PPC__) /* Xilinx toolchain */ #include + #define bswap_32(x) Xil_EndianSwap32(x) #endif #include "msg.h" @@ -20,13 +21,9 @@ void msg_swap(struct msg *m) { - for (int i = 0; i < m->length; i++) { -#ifdef __linux__ + int i; + for (i = 0; i < m->length; i++) 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; }