Autoconf apparently gives us a nice define for processor endianess.

This commit is contained in:
irungentoo 2014-04-19 11:38:14 -04:00
parent 39ac20fc2d
commit 98bea094b3
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98

View File

@ -67,22 +67,17 @@ uint32_t id_copy(uint8_t *dest, uint8_t *src)
void host_to_net(uint8_t *num, uint16_t numbytes) void host_to_net(uint8_t *num, uint16_t numbytes)
{ {
union { #ifndef WORDS_BIGENDIAN
uint32_t i; uint32_t i;
uint8_t c[4]; uint8_t buff[numbytes];
} a;
a.i = 1;
if (a.c[0] == 1) { for (i = 0; i < numbytes; ++i) {
uint32_t i; buff[i] = num[numbytes - i - 1];
uint8_t buff[numbytes];
for (i = 0; i < numbytes; ++i) {
buff[i] = num[numbytes - i - 1];
}
memcpy(num, buff, numbytes);
} }
memcpy(num, buff, numbytes);
#endif
return;
} }
/* state load/save */ /* state load/save */