From b00dfcca177fde79630e182934f509fcdd9f3998 Mon Sep 17 00:00:00 2001 From: usa Date: Thu, 25 Nov 2010 01:31:21 +0000 Subject: [PATCH] * ext/dl/callback/mkcallback.rb (gencallback): shouldn't assume that VALUE is the same size with long. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ext/dl/callback/mkcallback.rb | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 39d71c379c..a6047b5156 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Nov 25 10:29:55 2010 NAKAMURA Usaku + + * ext/dl/callback/mkcallback.rb (gencallback): shouldn't assume that + VALUE is the same size with long. + Thu Nov 25 10:03:14 2010 NAKAMURA Usaku * test/win32ole/test_err_in_callback.rb (teardown): remove tmp file diff --git a/ext/dl/callback/mkcallback.rb b/ext/dl/callback/mkcallback.rb index d2f9e3f2e1..d14072a932 100644 --- a/ext/dl/callback/mkcallback.rb +++ b/ext/dl/callback/mkcallback.rb @@ -128,8 +128,16 @@ FUNC_#{calltype.upcase}(#{func_name(ty,argc,n,calltype)})(#{(0...argc).collect{| { VALUE ret, cb#{argc > 0 ? ", args[#{argc}]" : ""}; #{ + sizeof_voidp = [""].pack('p').size + sizeof_long = [0].pack('l!').size (0...argc).collect{|i| - " args[%d] = LONG2NUM(stack%d);" % [i,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") } cb = rb_ary_entry(rb_ary_entry(#{proc_entry}, #{ty}), #{(n * DLSTACK_SIZE) + argc});