From: KUBO Takehiro Date: 2005-05-11T23:54:07+09:00 Subject: Re: AIX Status? KUBO Takehiro writes: > Jaime Fournier writes: > >> I looked over the listings for status of Socket support on AIX. >> Last entry I see is that it segfaults with >> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/126930 > > How about a patch at > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/128969 > I've forgot whether it had worked fine. It would be right in my memory > but not sure. I'll test it when I have a chance to use a AIX box. OK. It works on AIX 4.3.3. It have been already commited to CVS by Nobu Nakada. I made a context-diff patch for 1.8.2 users. CVS source doesn't need this. gzip -dc ruby-1.8.2.tar.gz | tar xvf - cd ruby-1.8.2 patch -p1 < path_to_/patch1 I made an another patch, which enable to run the configure script without '--without-ipv6'. AIX's getaddrinfo doesn't set (struct addrinfo *)->ai_addr->sa_family and (struct addrinfo *)->ai_addr->sa_len. So set them by (struct addrinfo *)->ai_family and (struct addrinfo *)->ai_addrlen. patch -p1 < path_to_/patch2 ./configure make ======================== patch1 start ======================== diff -cr ruby-1.8.2.orig/configure ruby-1.8.2/configure *** ruby-1.8.2.orig/configure Sat Dec 25 19:58:38 2004 --- ruby-1.8.2/configure Mon May 9 19:21:10 2005 *************** *** 14034,14044 **** rb_cv_dlopen=yes ;; aix*) : ${LDSHARED='/usr/ccs/bin/ld'} XLDFLAGS="$XLDFLAGS -Wl,-bE:ruby.imp" ! DLDFLAGS='-brtl -bI:$(topdir)/ruby.imp -bM:SRE -T512 -H512 '"$DLDFLAGS" ! ARCH_FLAGS='-eInit_$(TARGET)' ! : LDFLAGS="-brtl $LDFLAGS" : ${ARCHFILE="ruby.imp"} ! TRY_LINK='$(CC) $(DLDFLAGS) -oconftest $(INCFLAGS) -I$(hdrdir) $(CPPFLAGS) $(CFLAGS)' TRY_LINK="$TRY_LINK"' $(src) $(LIBPATH) $(LOCAL_LIBS) $(LIBS)' rb_cv_dlopen=yes ;; --- 14034,14043 ---- rb_cv_dlopen=yes ;; aix*) : ${LDSHARED='/usr/ccs/bin/ld'} XLDFLAGS="$XLDFLAGS -Wl,-bE:ruby.imp" ! DLDFLAGS='-brtl -eInit_$(TARGET) -bI:$(topdir)/ruby.imp -bM:SRE -T512 -H512 '"$DLDFLAGS" ! LDFLAGS="-brtl $LDFLAGS" : ${ARCHFILE="ruby.imp"} ! TRY_LINK='$(CC) $(LDFLAGS) -oconftest $(INCFLAGS) -I$(hdrdir) $(CPPFLAGS) $(CFLAGS)' TRY_LINK="$TRY_LINK"' $(src) $(LIBPATH) $(LOCAL_LIBS) $(LIBS)' rb_cv_dlopen=yes ;; diff -cr ruby-1.8.2.orig/configure.in ruby-1.8.2/configure.in *** ruby-1.8.2.orig/configure.in Thu Dec 23 00:16:55 2004 --- ruby-1.8.2/configure.in Mon May 9 19:51:19 2005 *************** *** 894,904 **** rb_cv_dlopen=yes ;; aix*) : ${LDSHARED='/usr/ccs/bin/ld'} XLDFLAGS="$XLDFLAGS -Wl,-bE:ruby.imp" ! DLDFLAGS='-brtl -bI:$(topdir)/ruby.imp -bM:SRE -T512 -H512 '"$DLDFLAGS" ! ARCH_FLAGS='-eInit_$(TARGET)' ! : LDFLAGS="-brtl $LDFLAGS" : ${ARCHFILE="ruby.imp"} ! TRY_LINK='$(CC) $(DLDFLAGS) -oconftest $(INCFLAGS) -I$(hdrdir) $(CPPFLAGS) $(CFLAGS)' TRY_LINK="$TRY_LINK"' $(src) $(LIBPATH) $(LOCAL_LIBS) $(LIBS)' rb_cv_dlopen=yes ;; --- 894,903 ---- rb_cv_dlopen=yes ;; aix*) : ${LDSHARED='/usr/ccs/bin/ld'} XLDFLAGS="$XLDFLAGS -Wl,-bE:ruby.imp" ! DLDFLAGS='-brtl -eInit_$(TARGET) -bI:$(topdir)/ruby.imp -bM:SRE -T512 -H512 '"$DLDFLAGS" ! LDFLAGS="-brtl $LDFLAGS" : ${ARCHFILE="ruby.imp"} ! TRY_LINK='$(CC) $(LDFLAGS) -oconftest $(INCFLAGS) -I$(hdrdir) $(CPPFLAGS) $(CFLAGS)' TRY_LINK="$TRY_LINK"' $(src) $(LIBPATH) $(LOCAL_LIBS) $(LIBS)' rb_cv_dlopen=yes ;; ========================= patch1 end ========================= ======================== patch2 start ======================== diff -cr ruby-1.8.2.orig/ext/socket/extconf.rb ruby-1.8.2/ext/socket/extconf.rb *** ruby-1.8.2.orig/ext/socket/extconf.rb Wed Oct 15 11:25:46 2003 --- ruby-1.8.2/ext/socket/extconf.rb Mon May 9 19:31:11 2005 *************** *** 229,236 **** } for (ai = aitop; ai; ai = ai->ai_next) { if (ai->ai_family == AF_LOCAL) continue; ! if (ai->ai_addr == NULL || ! ai->ai_addrlen == 0 || getnameinfo(ai->ai_addr, ai->ai_addrlen, straddr, sizeof(straddr), strport, sizeof(strport), NI_NUMERICHOST|NI_NUMERICSERV) != 0) { --- 229,241 ---- } for (ai = aitop; ai; ai = ai->ai_next) { if (ai->ai_family == AF_LOCAL) continue; ! if (ai->ai_addr == NULL) ! goto bad; ! #if defined(_AIX) ! ai->ai_addr->sa_len = ai->ai_addrlen; ! ai->ai_addr->sa_family = ai->ai_family; ! #endif ! if (ai->ai_addrlen == 0 || getnameinfo(ai->ai_addr, ai->ai_addrlen, straddr, sizeof(straddr), strport, sizeof(strport), NI_NUMERICHOST|NI_NUMERICSERV) != 0) { diff -cr ruby-1.8.2.orig/ext/socket/socket.c ruby-1.8.2/ext/socket/socket.c *** ruby-1.8.2.orig/ext/socket/socket.c Fri Dec 10 08:39:37 2004 --- ruby-1.8.2/ext/socket/socket.c Mon May 9 19:31:11 2005 *************** *** 166,171 **** --- 166,195 ---- #define getaddrinfo(node,serv,hints,res) ruby_getaddrinfo((node),(serv),(hints),(res)) #endif + #if defined(_AIX) + static int + ruby_getaddrinfo__aix(nodename, servname, hints, res) + char *nodename; + char *servname; + struct addrinfo *hints; + struct addrinfo **res; + { + int error = getaddrinfo(nodename, servname, hints, res); + struct addrinfo *r; + if (error) + return error; + for (r = *res; r != NULL; r = r->ai_next) { + if (r->ai_addr->sa_family == 0) + r->ai_addr->sa_family = r->ai_family; + if (r->ai_addr->sa_len == 0) + r->ai_addr->sa_len = r->ai_addrlen; + } + return 0; + } + #undef getaddrinfo + #define getaddrinfo(node,serv,hints,res) ruby_getaddrinfo__aix((node),(serv),(hints),(res)) + #endif + #ifdef HAVE_CLOSESOCKET #undef close #define close closesocket *************** *** 2289,2295 **** --- 2313,2321 ---- * 4th element holds numeric form, don't resolve. * see ipaddr(). */ + #ifdef AI_NUMERICHOST /* AIX 4.3.3 doesn't have AI_NUMERICHOST. */ hints.ai_flags |= AI_NUMERICHOST; + #endif } } else { ========================= patch2 end =========================