1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/socket/extconf.rb: test functions just after struct members.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2013-02-12 20:51:19 +00:00
parent caa0e40f4d
commit d7923c8279
2 changed files with 142 additions and 133 deletions

View file

@ -1,3 +1,7 @@
Wed Feb 13 05:49:21 2013 Tanaka Akira <akr@fsij.org>
* ext/socket/extconf.rb: test functions just after struct members.
Tue Feb 12 12:02:35 2013 NARUSE, Yui <naruse@ruby-lang.org>
* ext/json: merge JSON 1.7.7.

View file

@ -96,9 +96,56 @@ end
have_struct_member('struct msghdr', 'msg_control', ['sys/types.h', 'sys/socket.h'])
have_struct_member('struct msghdr', 'msg_accrights', ['sys/types.h', 'sys/socket.h'])
ipv6 = false
default_ipv6 = /cygwin|beos|haiku/ !~ RUBY_PLATFORM
if enable_config("ipv6", default_ipv6)
if have_func(test_func)
have_func("sendmsg")
have_func("recvmsg")
have_func("freehostent")
have_func("freeaddrinfo")
if /haiku/ !~ RUBY_PLATFORM and have_func("gai_strerror")
if checking_for("gai_strerror() returns const pointer") {!try_compile(<<EOF)}
#{cpp_include(headers)}
#include <stdlib.h>
void
conftest_gai_strerror_is_const()
{
*gai_strerror(0) = 0;
}
EOF
$defs << "-DGAI_STRERROR_CONST"
end
end
have_func("accept4")
have_func('inet_ntop(0, (const void *)0, (char *)0, 0)') or
have_func("inet_ntoa(*(struct in_addr *)NULL)")
have_func('inet_pton(0, "", (void *)0)') or have_func('inet_aton("", (struct in_addr *)0)')
have_func('getservbyport(0, "")')
have_func("getifaddrs")
have_func("getpeereid")
have_func("getpeerucred")
have_func("if_indextoname")
have_func("hsterror")
have_func("getipnodebyname")
have_func("gethostbyname2")
if !have_func("socketpair(0, 0, 0, 0)") and have_func("rb_w32_socketpair(0, 0, 0, 0)")
$defs << "-Dsocketpair(a,b,c,d)=rb_w32_socketpair((a),(b),(c),(d))"
$defs << "-DHAVE_SOCKETPAIR"
end
unless have_func("gethostname((char *)0, 0)")
have_func("uname")
end
ipv6 = false
default_ipv6 = /cygwin|beos|haiku/ !~ RUBY_PLATFORM
if enable_config("ipv6", default_ipv6)
if checking_for("ipv6") {try_link(<<EOF)}
#include <sys/types.h>
#ifndef _WIN32
@ -114,9 +161,9 @@ EOF
$defs << "-DENABLE_IPV6" << "-DINET6"
ipv6 = true
end
end
end
if ipv6
if ipv6
if $mingw
$CPPFLAGS << " -D_WIN32_WINNT=0x501" unless $CPPFLAGS.include?("_WIN32_WINNT")
end
@ -153,18 +200,15 @@ Fatal: no #{ipv6lib} library found. cannot continue.
You need to fetch lib#{ipv6lib}.a from appropriate
ipv6 kit and compile beforehand.
EOS
end
end
if !have_macro("IPPROTO_IPV6", headers) && have_const("IPPROTO_IPV6", headers)
if !have_macro("IPPROTO_IPV6", headers) && have_const("IPPROTO_IPV6", headers)
IO.read(File.join(File.dirname(__FILE__), "mkconstants.rb")).sub(/\A.*^__END__$/m, '').split(/\r?\n/).grep(/\AIPPROTO_\w*/){$&}.each {|name|
have_const(name, headers) unless $defs.include?("-DHAVE_CONST_#{name.upcase}")
}
end
end
have_func("sendmsg")
have_func("recvmsg")
if checking_for("recvmsg() with MSG_PEEK allocate file descriptors") {try_run(cpp_include(headers) + <<'EOF')}
if checking_for("recvmsg() with MSG_PEEK allocate file descriptors") {try_run(cpp_include(headers) + <<'EOF')}
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@ -285,9 +329,9 @@ int main(int argc, char *argv[])
}
EOF
$defs << "-DFD_PASSING_WORK_WITH_RECVMSG_MSG_PEEK"
end
end
getaddr_info_ok = (enable_config("wide-getaddrinfo") && :wide) ||
getaddr_info_ok = (enable_config("wide-getaddrinfo") && :wide) ||
(checking_for("wide getaddrinfo") {try_run(<<EOF)} && :os)
#{cpp_include(headers)}
#include <stdlib.h>
@ -396,7 +440,7 @@ main(void)
return EXIT_FAILURE;
}
EOF
if ipv6 and not getaddr_info_ok
if ipv6 and not getaddr_info_ok
abort <<EOS
Fatal: --enable-ipv6 is specified, and your OS seems to support IPv6 feature.
@ -404,41 +448,23 @@ But your getaddrinfo() and getnameinfo() are appeared to be broken. Sorry,
you cannot compile IPv6 socket classes with broken these functions.
You can try --enable-wide-getaddrinfo.
EOS
end
end
case with_config("lookup-order-hack", "UNSPEC")
when "INET"
case with_config("lookup-order-hack", "UNSPEC")
when "INET"
$defs << "-DLOOKUP_ORDER_HACK_INET"
when "INET6"
when "INET6"
$defs << "-DLOOKUP_ORDER_HACK_INET6"
when "UNSPEC"
when "UNSPEC"
# nothing special
else
else
abort <<EOS
Fatal: invalid value for --with-lookup-order-hack (expected INET, INET6 or UNSPEC)
EOS
end
have_func("freehostent")
have_func("freeaddrinfo")
if /haiku/ !~ RUBY_PLATFORM and have_func("gai_strerror")
if checking_for("gai_strerror() returns const pointer") {!try_compile(<<EOF)}
#{cpp_include(headers)}
#include <stdlib.h>
void
conftest_gai_strerror_is_const()
{
*gai_strerror(0) = 0;
}
EOF
$defs << "-DGAI_STRERROR_CONST"
end
end
have_func("accept4")
$objs = [
$objs = [
"init.#{$OBJEXT}",
"constants.#{$OBJEXT}",
"basicsocket.#{$OBJEXT}",
@ -453,9 +479,9 @@ $objs = [
"option.#{$OBJEXT}",
"ancdata.#{$OBJEXT}",
"raddrinfo.#{$OBJEXT}"
]
]
if getaddr_info_ok == :wide or
if getaddr_info_ok == :wide or
!have_func("getnameinfo", headers) or !have_func("getaddrinfo", headers)
if have_struct_member("struct in6_addr", "s6_addr8", headers)
$defs[-1] = "s6_addr=s6_addr8"
@ -467,35 +493,13 @@ if getaddr_info_ok == :wide or
$objs += ["getaddrinfo.#{$OBJEXT}"]
$objs += ["getnameinfo.#{$OBJEXT}"]
$defs << "-DGETADDRINFO_EMU"
end
have_func('inet_ntop(0, (const void *)0, (char *)0, 0)') or
have_func("inet_ntoa(*(struct in_addr *)NULL)")
have_func('inet_pton(0, "", (void *)0)') or have_func('inet_aton("", (struct in_addr *)0)')
have_func('getservbyport(0, "")')
have_func("getifaddrs")
have_func("getpeereid")
have_func("getpeerucred")
have_func("if_indextoname")
# workaround for recent Windows SDK
$defs << "-DIPPROTO_IPV6=IPPROTO_IPV6" if $defs.include?("-DHAVE_CONST_IPPROTO_IPV6") && !have_macro("IPPROTO_IPV6")
$distcleanfiles << "constants.h" << "constdefs.*"
if have_func(test_func)
have_func("hsterror")
have_func("getipnodebyname") or have_func("gethostbyname2")
if !have_func("socketpair(0, 0, 0, 0)") and have_func("rb_w32_socketpair(0, 0, 0, 0)")
$defs << "-Dsocketpair(a,b,c,d)=rb_w32_socketpair((a),(b),(c),(d))"
$defs << "-DHAVE_SOCKETPAIR"
end
unless have_func("gethostname((char *)0, 0)")
have_func("uname")
end
# workaround for recent Windows SDK
$defs << "-DIPPROTO_IPV6=IPPROTO_IPV6" if $defs.include?("-DHAVE_CONST_IPPROTO_IPV6") && !have_macro("IPPROTO_IPV6")
$distcleanfiles << "constants.h" << "constdefs.*"
if enable_config("socks", ENV["SOCKS_SERVER"])
if have_library("socks5", "SOCKSinit")
$defs << "-DSOCKS5" << "-DSOCKS"
@ -503,6 +507,7 @@ if have_func(test_func)
$defs << "-DSOCKS"
end
end
hdr = "netinet6/in6.h"
if /darwin/ =~ RUBY_PLATFORM and !try_compile(<<"SRC", nil, :werror=>true)
#include <netinet/in.h>