summaryrefslogtreecommitdiff
path: root/ext/socket/extconf.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-10 14:43:00 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-10 14:43:00 +0000
commitc799b11273f5c82b750b98612ae0e07bfff1ce7e (patch)
treed5103894f56ac09225a0572878232eaa5f5c2ffc /ext/socket/extconf.rb
parent5b057eeff2c42178ecae22173c8e931cad9622b1 (diff)
* ext/socket/extconf.rb: test structure members just after types test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/extconf.rb')
-rw-r--r--ext/socket/extconf.rb43
1 files changed, 22 insertions, 21 deletions
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index d4e998b..e26ec98 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -76,6 +76,26 @@ 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
+if have_struct_member("struct sockaddr_in", "sin_len", headers)
+ $defs[-1] = "-DHAVE_SIN_LEN" # change from -DHAVE_ST_SIN_LEN.
+end
+
+# doug's fix, NOW add -Dss_family... only if required!
+doug = proc {have_struct_member("struct sockaddr_storage", "ss_family", headers)}
+if (doug[] or
+ with_cppflags($CPPFLAGS + " -Dss_family=__ss_family", &doug))
+ $defs[-1] = "-DHAVE_SOCKADDR_STORAGE" # change from -DHAVE_ST_SS_FAMILY.
+ doug = proc {have_struct_member("struct sockaddr_storage", "ss_len", headers)}
+ doug[] or with_cppflags($CPPFLAGS + " -Dss_len=__ss_len", &doug)
+end
+
+if have_struct_member("struct sockaddr", "sa_len", headers)
+ $defs[-1] = "-DHAVE_SA_LEN " # change from -DHAVE_ST_SA_LEN.
+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)
@@ -135,33 +155,14 @@ ipv6 kit and compile beforehand.
EOS
end
-if have_struct_member("struct sockaddr_in", "sin_len", headers)
- $defs[-1] = "-DHAVE_SIN_LEN" # change from -DHAVE_ST_SIN_LEN.
-end
-
-# doug's fix, NOW add -Dss_family... only if required!
-doug = proc {have_struct_member("struct sockaddr_storage", "ss_family", headers)}
-if (doug[] or
- with_cppflags($CPPFLAGS + " -Dss_family=__ss_family", &doug))
- $defs[-1] = "-DHAVE_SOCKADDR_STORAGE" # change from -DHAVE_ST_SS_FAMILY.
- doug = proc {have_struct_member("struct sockaddr_storage", "ss_len", headers)}
- doug[] or with_cppflags($CPPFLAGS + " -Dss_len=__ss_len", &doug)
-end
-
-if have_struct_member("struct sockaddr", "sa_len", headers)
- $defs[-1] = "-DHAVE_SA_LEN " # change from -DHAVE_ST_SA_LEN.
-end
-
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
-if have_func("sendmsg") | have_func("recvmsg")
- 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'])
-end
+have_func("sendmsg")
+have_func("recvmsg")
if checking_for("recvmsg() with MSG_PEEK allocate file descriptors") {try_run(cpp_include(headers) + <<'EOF')}
#include <stdlib.h>