* ext/socket/mkconstants.rb: Convert integer constants bigger than int
correctly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9d099423e7
commit
a7acc99193
@ -1,3 +1,8 @@
|
|||||||
|
Sat May 18 00:38:47 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* ext/socket/mkconstants.rb: Convert integer constants bigger than int
|
||||||
|
correctly.
|
||||||
|
|
||||||
Fri May 17 22:02:15 2013 Tanaka Akira <akr@fsij.org>
|
Fri May 17 22:02:15 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* ext/socket/ifaddr.c: Use unsigned LONG_LONG to represent flags
|
* ext/socket/ifaddr.c: Use unsigned LONG_LONG to represent flags
|
||||||
|
@ -56,17 +56,12 @@ DEFS = h.to_a
|
|||||||
|
|
||||||
def each_const
|
def each_const
|
||||||
DEFS.each {|name, default_value|
|
DEFS.each {|name, default_value|
|
||||||
if name =~ /\AINADDR_/
|
|
||||||
make_value = "UINT2NUM"
|
|
||||||
else
|
|
||||||
make_value = "INT2NUM"
|
|
||||||
end
|
|
||||||
guard = nil
|
guard = nil
|
||||||
if /\A(AF_INET6|PF_INET6|IPV6_.*)\z/ =~ name
|
if /\A(AF_INET6|PF_INET6|IPV6_.*)\z/ =~ name
|
||||||
# IPv6 is not supported although AF_INET6 is defined on mingw
|
# IPv6 is not supported although AF_INET6 is defined on mingw
|
||||||
guard = "defined(INET6)"
|
guard = "defined(INET6)"
|
||||||
end
|
end
|
||||||
yield guard, make_value, name, default_value
|
yield guard, name, default_value
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -78,7 +73,7 @@ def each_name(pat)
|
|||||||
end
|
end
|
||||||
|
|
||||||
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
|
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
|
||||||
% each_const {|guard, make_value, name, default_value|
|
% each_const {|guard, name, default_value|
|
||||||
#if !defined(<%=name%>)
|
#if !defined(<%=name%>)
|
||||||
# if defined(HAVE_CONST_<%=name.upcase%>)
|
# if defined(HAVE_CONST_<%=name.upcase%>)
|
||||||
# define <%=name%> <%=name%>
|
# define <%=name%> <%=name%>
|
||||||
@ -91,23 +86,23 @@ ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
|
|||||||
% }
|
% }
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_defs_in_guard(make_value, name, default_value)")
|
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_defs_in_guard(name, default_value)")
|
||||||
#if defined(<%=name%>)
|
#if defined(<%=name%>)
|
||||||
/* <%= COMMENTS[name] %> */
|
/* <%= COMMENTS[name] %> */
|
||||||
rb_define_const(rb_cSocket, <%=c_str name%>, <%=make_value%>(<%=name%>));
|
rb_define_const(rb_cSocket, <%=c_str name%>, INTEGER2VALUE(<%=name%>));
|
||||||
/* <%= COMMENTS[name] %> */
|
/* <%= COMMENTS[name] %> */
|
||||||
rb_define_const(rb_mSockConst, <%=c_str name%>, <%=make_value%>(<%=name%>));
|
rb_define_const(rb_mSockConst, <%=c_str name%>, INTEGER2VALUE(<%=name%>));
|
||||||
#endif
|
#endif
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_defs")
|
ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_defs")
|
||||||
% each_const {|guard, make_value, name, default_value|
|
% each_const {|guard, name, default_value|
|
||||||
% if guard
|
% if guard
|
||||||
#if <%=guard%>
|
#if <%=guard%>
|
||||||
<%= gen_const_defs_in_guard(make_value, name, default_value).chomp %>
|
<%= gen_const_defs_in_guard(name, default_value).chomp %>
|
||||||
#endif
|
#endif
|
||||||
% else
|
% else
|
||||||
<%= gen_const_defs_in_guard(make_value, name, default_value).chomp %>
|
<%= gen_const_defs_in_guard(name, default_value).chomp %>
|
||||||
% end
|
% end
|
||||||
% }
|
% }
|
||||||
EOS
|
EOS
|
||||||
@ -284,6 +279,12 @@ result = ERB.new(<<'EOS', nil, '%').result(binding)
|
|||||||
|
|
||||||
<%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| vardef }.join("\n") %>
|
<%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| vardef }.join("\n") %>
|
||||||
|
|
||||||
|
#ifdef HAVE_LONG_LONG
|
||||||
|
#define INTEGER2VALUE(n) ((n) <= 0 ? LL2NUM(n) : ULL2NUM(n))
|
||||||
|
#else
|
||||||
|
#define INTEGER2VALUE(n) ((n) <= 0 ? LONG2NUM(n) : ULONG2NUM(n))
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
init_constants(void)
|
init_constants(void)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user