From 72f25c648fb329577865b1d34a6801c14abe94c8 Mon Sep 17 00:00:00 2001 From: yugui Date: Thu, 15 Jan 2009 15:38:42 +0000 Subject: merges r21505 from trunk into ruby_1_9_1. * ext/socket/extconf.rb (gai_strerror): checks if available and if returns const pointer. * ext/socket/getaddrinfo.c (gai_strerror): defines only if non available. [ruby-core:21328] git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@21558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ ext/socket/extconf.rb | 13 +++++++++++++ ext/socket/getaddrinfo.c | 7 +++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index bfe29fbf2..ea08f95f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Wed Jan 14 13:09:00 2009 Nobuyoshi Nakada + + * ext/socket/extconf.rb (gai_strerror): checks if available and if + returns const pointer. + + * ext/socket/getaddrinfo.c (gai_strerror): defines only if non + available. [ruby-core:21328] + Wed Jan 14 12:39:16 2009 Nobuyoshi Nakada * io.c (rb_io_wait_readable, rb_io_wait_writable): need rb_fd_ptr. diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb index 06011d61a..99deaf879 100644 --- a/ext/socket/extconf.rb +++ b/ext/socket/extconf.rb @@ -254,6 +254,19 @@ unless getaddr_info_ok and have_func("getnameinfo", headers) and have_func("geta have_func("inet_ntop") or have_func("inet_ntoa") have_func("inet_pton") or have_func("inet_aton") have_func("getservbyport") + if have_func("gai_strerror") + unless checking_for("gai_strerror() returns const pointer") {!try_compile(< +void +conftest_gai_strerror_is_const() +{ + *gai_strerror(0) = 0; +} +EOF + $defs << "-DGAI_STRERROR_CONST" + end + end have_header("arpa/nameser.h") have_header("resolv.h") end diff --git a/ext/socket/getaddrinfo.c b/ext/socket/getaddrinfo.c index de16b9fb1..5ce935f58 100644 --- a/ext/socket/getaddrinfo.c +++ b/ext/socket/getaddrinfo.c @@ -39,6 +39,9 @@ */ #include "ruby/config.h" +#ifdef RUBY_EXTCONF_H +#include RUBY_EXTCONF_H +#endif #include #ifndef _WIN32 #include @@ -195,8 +198,8 @@ if (pai->ai_flags & AI_CANONNAME) {\ #define ERR(err) { error = (err); goto bad; } -#ifndef __HAIKU__ -#if defined __UCLIBC__ +#ifndef HAVE_GAI_STRERROR +#ifdef GAI_STRERROR_CONST const #endif char * -- cgit