summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/socket/extconf.rb7
-rw-r--r--ext/socket/mkconstants.rb12
2 files changed, 15 insertions, 4 deletions
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