From 01cd3467fbd3e9ea212063d0a7405642b8746b94 Mon Sep 17 00:00:00 2001 From: akr Date: Tue, 11 May 2010 14:10:34 +0000 Subject: * ext/socket/extconf.rb: test IPPROTO_IP and IPPROTO_IPV6 constants. * ext/socket/mkconstants.rb: define macros for enum. [ruby-dev:38849] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ ext/socket/extconf.rb | 7 +++++++ ext/socket/mkconstants.rb | 12 ++++++++---- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 527ffbbfcd..e09b1d572f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Tue May 11 23:07:22 2010 Tanaka Akira + + * ext/socket/extconf.rb: test IPPROTO_IP and IPPROTO_IPV6 constants. + + * ext/socket/mkconstants.rb: define macros for enum. + + [ruby-dev:38849] + Tue May 11 21:53:18 2010 Yusuke Endoh * test/rake/test_task_arguments.rb: makes ENV empty during tests diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb index 3ce8316c4f..9125ec1ec3 100644 --- a/ext/socket/extconf.rb +++ b/ext/socket/extconf.rb @@ -110,6 +110,13 @@ end have_header("netinet/tcp.h") if /cygwin/ !~ RUBY_PLATFORM # for cygwin 1.1.5 have_header("netinet/udp.h") +%w[ + IPPROTO_IP + IPPROTO_IPV6 +].each {|name| + have_const(name, headers) +} + 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']) 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 -- cgit v1.2.3