diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-05-16 12:15:27 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-05-16 12:15:27 +0000 |
commit | 5b86607ebd3180dfaf5a11b261b03fa40e7ebf4e (patch) | |
tree | 7fb30e877a399e8ab34722a268d975c95c3e04ef /ext | |
parent | 1aabe245c12357b86b8a089dd8b28c11369bfbe7 (diff) |
merges r27742 and r27746 from trunk into ruby_1_9_2.
--
* ext/socket/extconf.rb: test IPPROTO_IP and IPPROTO_IPV6 constants.
* ext/socket/mkconstants.rb: define macros for enum.
[ruby-dev:38849]
--
* ext/socket/extconf.rb: test all IPPROTO_* constants for recent Win32
SDK.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@27834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/socket/extconf.rb | 8 | ||||
-rw-r--r-- | ext/socket/mkconstants.rb | 12 |
2 files changed, 15 insertions, 5 deletions
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb index 3ce8316c4f..71deaa218d 100644 --- a/ext/socket/extconf.rb +++ b/ext/socket/extconf.rb @@ -110,6 +110,12 @@ end have_header("netinet/tcp.h") if /cygwin/ !~ RUBY_PLATFORM # for cygwin 1.1.5 have_header("netinet/udp.h") +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")) && /64-darwin/ !~ RUBY_PLATFORM # CMSG_ macros are broken on 64bit darwin, because of use of __DARWIN_ALIGN. have_struct_member('struct msghdr', 'msg_control', ['sys/types.h', 'sys/socket.h']) @@ -335,7 +341,7 @@ have_header("ucred.h", headers) have_func("getpeerucred") # workaround for recent Windows SDK -$defs << "-DIPPROTO_IPV6=IPPROTO_IPV6" if have_const("IPPROTO_IPV6") && !have_macro("IPPROTO_IPV6") +$defs << "-DIPPROTO_IPV6=IPPROTO_IPV6" if $defs.include?("-DHAVE_CONST_IPPROTO_IPV6") && !have_macro("IPPROTO_IPV6") $distcleanfiles << "constants.h" << "constdefs.*" diff --git a/ext/socket/mkconstants.rb b/ext/socket/mkconstants.rb index c796cb4870..fe00f30e3d 100644 --- a/ext/socket/mkconstants.rb +++ b/ext/socket/mkconstants.rb @@ -73,11 +73,15 @@ end ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_decls") % each_const {|guard, make_value, name, default_value| -% if default_value -#ifndef <%=name%> -# define <%=name%> <%=default_value%> +#if !defined(<%=name%>) +# if defined(HAVE_CONST_<%=name.upcase%>) +# define <%=name%> <%=name%> +%if default_value +# else +# define <%=name%> <%=default_value%> +%end +# endif #endif -% end % } EOS |