summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-26 03:43:19 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-26 03:43:19 +0000
commita36cd96c2a01b5cc4e569fba5c7d7c0da0c30664 (patch)
tree5783d10a1d24001c4cfb021887d8e07e208a1a02
parent93ed9f08ad9e9aa1aa44d83e6dc850721e1fd112 (diff)
* ext/curses/extconf.rb: Test linkability of curses_version at first.
* ext/socket/extconf.rb: Test the behavior of fd passing with MSG_PEEK only if recvmsg(), msg_control member, AF_UNIX and SCM_RIGHTS are available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--ext/curses/extconf.rb62
-rw-r--r--ext/socket/extconf.rb74
3 files changed, 78 insertions, 66 deletions
diff --git a/ChangeLog b/ChangeLog
index 60a6558996..f43fa78a94 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Fri Apr 26 12:41:22 2013 Tanaka Akira <akr@fsij.org>
+
+ * ext/curses/extconf.rb: Test linkability of curses_version at first.
+
+ * ext/socket/extconf.rb: Test the behavior of fd passing with MSG_PEEK
+ only if recvmsg(), msg_control member, AF_UNIX and SCM_RIGHTS are
+ available.
+
Fri Apr 26 00:07:52 2013 Hiroshi Shirosaki <h.shirosaki@gmail.com>
* lib/rinda/ring.rb (Rinda::RingServer#initialize): accept array
diff --git a/ext/curses/extconf.rb b/ext/curses/extconf.rb
index 467494e190..830369c301 100644
--- a/ext/curses/extconf.rb
+++ b/ext/curses/extconf.rb
@@ -89,40 +89,40 @@ if header_library
when "variable"
$defs << '-DHAVE_VAR_CURSES_VERSION'
when nil
- function_p = nil
- variable_p = nil
- if [header, library].any? {|v| /ncurses|pdcurses|xcurses/i =~ v }
- function_p = true
- end
- if !CROSS_COMPILING
- prolog = cpp_include(curses)
- function_p = checking_for(checking_message('function curses_version', curses)) {
- try_run(<<-"End")
- #{prolog}
- int main(int argc, char *argv[])
- {
- curses_version();
- return EXIT_SUCCESS;
- }
- End
+ func_test_program = cpp_include(curses) + <<-"End"
+ int main(int argc, char *argv[])
+ {
+ curses_version();
+ return EXIT_SUCCESS;
}
- variable_p = checking_for(checking_message('variable curses_version', curses)) {
- try_run(<<-"End")
- #{prolog}
- extern char *curses_version;
- int main(int argc, char *argv[])
- {
- int i = 0;
- for (i = 0; i < 100; i++) {
- if (curses_version[i] == 0)
- return 0 < i ? EXIT_SUCCESS : EXIT_FAILURE;
- if (curses_version[i] & 0x80)
- return EXIT_FAILURE;
- }
- return EXIT_FAILURE;
+ End
+ var_test_program = cpp_include(curses) + <<-"End"
+ extern char *curses_version;
+ int main(int argc, char *argv[])
+ {
+ int i = 0;
+ for (i = 0; i < 100; i++) {
+ if (curses_version[i] == 0)
+ return 0 < i ? EXIT_SUCCESS : EXIT_FAILURE;
+ if (curses_version[i] & 0x80)
+ return EXIT_FAILURE;
}
- End
+ return EXIT_FAILURE;
}
+ End
+ function_p = checking_for(checking_message('link function curses_version', curses)) { try_link(func_test_program) } ? nil : false
+ variable_p = checking_for(checking_message('link variable curses_version', curses)) { try_link(var_test_program) } ? nil : false
+ if [header, library].any? {|v| /ncurses|pdcurses|xcurses/i =~ v }
+ function_p = true if function_p == nil
+ variable_p = false if variable_p == nil
+ end
+ if !CROSS_COMPILING
+ if function_p != false
+ function_p = checking_for(checking_message('run function curses_version', curses)) { try_run(func_test_program) }
+ end
+ if variable_p != false
+ variable_p = checking_for(checking_message('run variable curses_version', curses)) { try_run(var_test_program) }
+ end
end
$defs << '-DHAVE_FUNC_CURSES_VERSION' if function_p
$defs << '-DHAVE_VAR_CURSES_VERSION' if variable_p
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index d7bae22727..50283ec3b3 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -305,7 +305,8 @@ have_type("struct ip_mreq", headers) # 4.4BSD
have_type("struct ip_mreqn", headers) # Linux 2.4
have_type("struct ipv6_mreq", headers) # RFC 3493
-have_struct_member('struct msghdr', 'msg_control', headers) unless $mswin or $mingw
+have_msg_control = nil
+have_msg_control = have_struct_member('struct msghdr', 'msg_control', headers) unless $mswin or $mingw
have_struct_member('struct msghdr', 'msg_accrights', headers)
case RUBY_PLATFORM
@@ -332,7 +333,7 @@ end
if have_func(test_func, headers)
have_func("sendmsg(0, (struct msghdr *)NULL, 0)", headers) # POSIX
- have_func("recvmsg(0, (struct msghdr *)NULL, 0)", headers) # POSIX
+ have_recvmsg = have_func("recvmsg(0, (struct msghdr *)NULL, 0)", headers) # POSIX
have_func("freehostent((struct hostent *)NULL)", headers) # RFC 2553
have_func("freeaddrinfo((struct addrinfo *)NULL)", headers) # RFC 2553
@@ -432,38 +433,40 @@ EOS
when false
# nothing to do.
else
- case RUBY_PLATFORM
- when /linux/
- # Linux 2.6.38 allocate fds by recvmsg with MSG_PEEK.
- close_fds = true
- when /bsd|darwin/
- # FreeBSD 8.2.0, NetBSD 5 and MacOS X Snow Leopard doesn't
- # allocate fds by recvmsg with MSG_PEEK.
- # [ruby-dev:44189]
- # http://bugs.ruby-lang.org/issues/5075
- close_fds = false
- else
- close_fds = nil
- end
- if !CROSS_COMPILING
- if checking_for("recvmsg() with MSG_PEEK allocate file descriptors") {try_run(cpp_include(headers) + RECVMSG_WITH_MSG_PEEK_ALLOCATE_FD_TEST)}
- if close_fds == false
- warn "unexpected recvmsg() with MSG_PEEK behavor on #{RUBY_PLATFORM}: fd allocation unexpected."
- elsif close_fds == nil
- puts "info: #{RUBY_PLATFORM} recvmsg() with MSG_PEEK allocates fds."
- end
+ if have_msg_control && have_recvmsg &&
+ have_const('AF_UNIX', headers) && have_const('SCM_RIGHTS', headers)
+ case RUBY_PLATFORM
+ when /linux/
+ # Linux 2.6.38 allocate fds by recvmsg with MSG_PEEK.
close_fds = true
+ when /bsd|darwin/
+ # FreeBSD 8.2.0, NetBSD 5 and MacOS X Snow Leopard doesn't
+ # allocate fds by recvmsg with MSG_PEEK.
+ # [ruby-dev:44189]
+ # http://bugs.ruby-lang.org/issues/5075
+ close_fds = false
else
- if close_fds == true
- warn "unexpected recvmsg() with MSG_PEEK behavor on #{RUBY_PLATFORM}: fd allocation expected."
- elsif close_fds == nil
- puts "info: #{RUBY_PLATFORM}: recvmsg() with MSG_PEEK doesn't allocates fds."
+ close_fds = nil
+ end
+ if !CROSS_COMPILING
+ if checking_for("recvmsg() with MSG_PEEK allocate file descriptors") {try_run(cpp_include(headers) + RECVMSG_WITH_MSG_PEEK_ALLOCATE_FD_TEST)}
+ if close_fds == false
+ warn "unexpected recvmsg() with MSG_PEEK behavor on #{RUBY_PLATFORM}: fd allocation unexpected."
+ elsif close_fds == nil
+ puts "info: #{RUBY_PLATFORM} recvmsg() with MSG_PEEK allocates fds."
+ end
+ close_fds = true
+ else
+ if close_fds == true
+ warn "unexpected recvmsg() with MSG_PEEK behavor on #{RUBY_PLATFORM}: fd allocation expected."
+ elsif close_fds == nil
+ puts "info: #{RUBY_PLATFORM}: recvmsg() with MSG_PEEK doesn't allocates fds."
+ end
+ close_fds = false
end
- close_fds = false
end
- end
- if close_fds == nil
- abort <<EOS
+ if close_fds == nil
+ abort <<EOS
Fatal: cannot test recvmsg() with MSG_PEEK allocate file descriptors or not
because cross-compilation.
Specify a configure option.
@@ -472,9 +475,10 @@ If recvmsg() with MSG_PEEK allocates fds on fd passing:
If recvmsg() with MSG_PEEK doesn't allocate fds on fd passing:
--disable-close-fds-by-recvmsg-with-peek
EOS
- end
- if close_fds
- $defs << "-DFD_PASSING_WORK_WITH_RECVMSG_MSG_PEEK"
+ end
+ if close_fds
+ $defs << "-DFD_PASSING_WORK_WITH_RECVMSG_MSG_PEEK"
+ end
end
end
@@ -484,7 +488,7 @@ EOS
when nil
if have_func("getnameinfo", headers) and have_func("getaddrinfo", headers)
getaddr_info_ok = :os
- if !CROSS_COMPILING && !checking_for("wide getaddrinfo") {try_run(cpp_include(headers) + GETADDRINFO_GETNAMEINFO_TEST)}
+ if !CROSS_COMPILING && !checking_for("system getaddrinfo working") {try_run(cpp_include(headers) + GETADDRINFO_GETNAMEINFO_TEST)}
getaddr_info_ok = :wide
end
else
@@ -493,7 +497,7 @@ EOS
when false
if have_func("getnameinfo", headers) and have_func("getaddrinfo", headers)
getaddr_info_ok = :os
- if !CROSS_COMPILING && !checking_for("wide getaddrinfo") {try_run(cpp_include(headers) + GETADDRINFO_GETNAMEINFO_TEST)}
+ if !CROSS_COMPILING && !checking_for("system getaddrinfo working") {try_run(cpp_include(headers) + GETADDRINFO_GETNAMEINFO_TEST)}
getaddr_info_ok = nil
end
else