1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/dl/callback/mkcallback.rb (gencallback): use PTR2NUM.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2011-07-28 03:32:56 +00:00
parent eda13c7ee2
commit d3d44cd928
2 changed files with 6 additions and 12 deletions

View file

@ -1,4 +1,6 @@
Thu Jul 28 12:32:49 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
Thu Jul 28 12:32:53 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/dl/callback/mkcallback.rb (gencallback): use PTR2NUM.
* ext/dl/cptr.c (rb_dlptr_aref, rb_dlptr_aset): check NULL pointer
dereference.

View file

@ -124,21 +124,13 @@ def gencallback(ty, calltype, proc_entry, argc, n)
<<-EOS
#{calltype == STDCALL ? "\n#ifdef FUNC_STDCALL" : ""}
static #{DLTYPE[ty][:type]}
FUNC_#{calltype.upcase}(#{func_name(ty,argc,n,calltype)})(#{(0...argc).collect{|i| "DLSTACK_TYPE stack" + i.to_s}.join(", ")})
FUNC_#{calltype.upcase}(#{func_name(ty,argc,n,calltype)})(#{(0...argc).collect{|i| "DLSTACK_TYPE stack#{i}"}.join(", ")})
{
VALUE ret, cb#{argc > 0 ? ", args[#{argc}]" : ""};
#{
sizeof_voidp = [""].pack('p').size
sizeof_long = [0].pack('l!').size
(0...argc).collect{|i|
if sizeof_voidp == sizeof_long
" args[%d] = LONG2NUM(stack%d);" % [i,i]
elsif sizeof_voidp == 8 # should get sizeof_long_long...
" args[%d] = LL2NUM(stack%d);" % [i,i]
else
raise "unknown size of void*"
end
}.join("\n")
"\n args[#{i}] = PTR2NUM(stack#{i});"
}.join("")
}
cb = rb_ary_entry(rb_ary_entry(#{proc_entry}, #{ty}), #{(n * DLSTACK_SIZE) + argc});
ret = rb_funcall2(cb, rb_dl_cb_call, #{argc}, #{argc > 0 ? 'args' : 'NULL'});