summaryrefslogtreecommitdiff
path: root/ext/socket
diff options
context:
space:
mode:
Diffstat (limited to 'ext/socket')
-rw-r--r--ext/socket/mkconstants.rb19
-rw-r--r--ext/socket/socket.c4
2 files changed, 16 insertions, 7 deletions
diff --git a/ext/socket/mkconstants.rb b/ext/socket/mkconstants.rb
index d74310cb34a..02d7e17b774 100644
--- a/ext/socket/mkconstants.rb
+++ b/ext/socket/mkconstants.rb
@@ -43,19 +43,30 @@ def each_data
else
define = "sock_define_const"
end
- yield define, name, default_value
+ guard = nil
+ if /\A(AF_INET6|PF_INET6)\z/ =~ name
+ # IPv6 is not supported although AF_INET6 is defined on bcc32/mingw
+ guard = "defined(INET6)"
+ end
+ yield guard, define, name, default_value
}
end
result << ERB.new(<<'EOS', nil, '%').result(binding)
-% each_data {|define, name, default_value|
-#ifdef <%=name%>
+% each_data {|guard, define, name, default_value|
+% if guard
+#if <%=guard%>
+% end
+#if defined(<%=name%>)
<%=define%>(<%=c_str name%>, <%=name%>);
% if default_value
#else
<%=define%>(<%=c_str name%>, <%=default_value%>);
% end
#endif
+% if guard
+#endif
+% end
% }
EOS
@@ -79,6 +90,8 @@ SOCK_PACKET
AF_INET
PF_INET
+AF_INET6
+PF_INET6
AF_UNIX
PF_UNIX
AF_AX25
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 11976b01a43..b91e1396cde 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -3733,8 +3733,4 @@ Init_socket()
/* constants */
mConst = rb_define_module_under(rb_cSocket, "Constants");
#include "constants.h"
-#ifdef INET6 /* IPv6 is not supported although AF_INET6 is defined on bcc32/mingw */
- sock_define_const("AF_INET6", AF_INET6);
- sock_define_const("PF_INET6", PF_INET6);
-#endif
}