diff --git a/opal/util/if.c b/opal/util/if.c index 396b454ec9..3df812ead5 100644 --- a/opal/util/if.c +++ b/opal/util/if.c @@ -41,15 +41,22 @@ #include #endif #ifdef HAVE_NET_IF_H -#if defined(__APPLE__) && defined(__POWERPC__) && defined(_LP64) -/* Apple engineering suggested this as a workaround for a bug in OS X - * 10.4 (Tiger) that prevented ioctl(..., SIOCGIFCONF, ...) from - * working properly in 64 bit mode */ -#pragma options align=power +#if defined(__APPLE__) && defined(_LP64) +/* Apple engineering suggested using options align=power as a + workaround for a bug in OS X 10.4 (Tiger) that prevented ioctl(..., + SIOCGIFCONF, ...) from working properly in 64 bit mode on Power PC. + It turns out that the underlying issue is the size of struct + ifconf, which the kernel expects to be 12 and natural 64 bit + alignment would make 16. The same bug appears in 64 bit mode on + Intel macs, but align=power is a no-op there, so instead, use the + pack pragma to instruct the compiler to pack on 4 byte words, which + has the same effect as align=power for our needs and works on both + Intel and Power PC Macs. */ +#pragma pack(push,4) #endif #include -#if defined(__APPLE__) && defined(__POWERPC__) && defined(_LP64) -#pragma options align=reset +#if defined(__APPLE__) && defined(_LP64) +#pragma pack(pop) #endif #endif #ifdef HAVE_NETDB_H