From d0ed5a93786881e2ddda99d0c83e4d1a216a3ca8 Mon Sep 17 00:00:00 2001 From: ko1 Date: Mon, 29 Dec 2008 14:54:24 +0000 Subject: * ext/dl/test/test_base.rb: add libc search logic. this patch is written by Takehiro Kubo. [ruby-core:20963] [Bug #932] * ext/dl/dl.h: Add ",..." as the last argument. this patch is written by Takehiro Kubo. Bug #633 [ruby-core:19289] * ext/dl/lib/dl/stack.rb: add add_padding() to calculate alignment. this patch is written by Takehiro Kubo. Bug #633 [ruby-core:19289] * ext/dl/test/test_func.rb: atof()'s return value is double. this patch is written by Takehiro Kubo. Bug #633 [ruby-core:19289] * ext/dl/test/test_import.rb: - atof()'s return value is double. - The types of qsort's second and third argument are size_t. - fprintf()'s return value is int. this patch is written by Takehiro Kubo. Bug #633 [ruby-core:19289] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21182 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/dl/lib/dl/stack.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'ext/dl/lib') diff --git a/ext/dl/lib/dl/stack.rb b/ext/dl/lib/dl/stack.rb index 9daf089775..99a24bc1ba 100644 --- a/ext/dl/lib/dl/stack.rb +++ b/ext/dl/lib/dl/stack.rb @@ -121,20 +121,26 @@ end @template = "" addr = 0 types.each{|t| - orig_addr = addr - addr = align(orig_addr, ALIGN_MAP[t]) - d = addr - orig_addr - if( d > 0 ) - @template << "x#{d}" - end + addr = add_padding(addr, ALIGN_MAP[t]) @template << PACK_MAP[t] addr += SIZE_MAP[t] } + addr = add_padding(addr, ALIGN_MAP[SIZEOF_VOIDP]) if( addr % SIZEOF_VOIDP == 0 ) @size = addr / SIZEOF_VOIDP else @size = (addr / SIZEOF_VOIDP) + 1 end end + + def add_padding(addr, align) + orig_addr = addr + addr = align(orig_addr, align) + d = addr - orig_addr + if( d > 0 ) + @template << "x#{d}" + end + addr + end end end -- cgit v1.2.3