Use of #pragma pack breaks standard library functionality. Partial fix

This commit is contained in:
Brian Rasmusson
2016-03-30 15:54:28 +02:00
parent d14d07bfd0
commit f360546778

@ -1,3 +1,7 @@
#include <sys/types.h>
#include <ifaddrs.h>
#include "gb-include.h"
#include "Hostdb.h"
@ -1936,20 +1940,8 @@ bool Hostdb::createHostsConf( char *cwd ) {
return true;
}
void swapInts ( void *xx ) {
// do nothing if 32-bit arch
if ( sizeof(void *) == 4 ) return;
// otherwise swap the two 32-bit numbers in this ptr
int32_t *p1 = (int32_t *)xx;
int32_t *p2 = (int32_t *)(((char *)xx)+4);
int32_t tmp = *p1;
*p1 = *p2;
*p2 = tmp;
}
static int32_t s_localIps[20];
#include <sys/types.h>
#include <ifaddrs.h>
int32_t *getLocalIps ( ) {
static bool s_valid = false;
if ( s_valid ) return s_localIps;
@ -1969,8 +1961,6 @@ int32_t *getLocalIps ( ) {
if ( ! p->ifa_addr ) continue;
//break; // mdw hack...
struct sockaddr_in *xx = (sockaddr_in *)p->ifa_addr;
// fix the bug when compiling for 64-bit arch
swapInts ( &xx );
int32_t ip = xx->sin_addr.s_addr;
// skip if loopback we stored above
if ( ip == loopback ) continue;