IRIX inet_ntoa() redux...

Marc W. Mengel mengel@fnal.gov
Fri Nov 17 16:47:00 GMT 2000


I know there's been lots of discussion that the n byte structure passing
problem where 8 < n < 16 is hard to fix, and that it "only" breaks
inet_ntoa(), but doesn't that mean we should include a working
inet_ntoa() in the gcc distribution for IRIX?

Couldn't we make:

  char *
  _gcc_workaround_inet_ntoa( struct in_addr a ) {
     static char buf[64];
     unsigned char *pc = (unsigned char *)&a;
     snprintf(buf, 64,  "%d.%d.%d.%d",  pc[0], pc[1], pc[2], pc[3]);
     return buf;
  }

in libgcc.a and add

  #define inet_ntoa _gcc_workaround_inet_ntoa

when fix-header-ing arpa/inet.h? 

If we do it, we should also include the follwing test in the testsuite,
to make sure inet_ntoa() is working:

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

main() {
   struct in_addr foo;
   char *res;

   inet_aton("131.225.8.120", &foo);
   res = inet_ntoa(foo);

   printf("foo is %08lx inet_ntoa yeilds %s\n", *(unsigned long*)&foo,res);
}





More information about the Gcc mailing list