[前][次][番号順一覧][スレッド一覧]

ruby-changes:9655

From: yugui <ko1@a...>
Date: Tue, 30 Dec 2008 19:33:20 +0900 (JST)
Subject: [ruby-changes:9655] Ruby:r21195 (ruby_1_9_1): merges r21177 and r21182 from trunk into ruby_1_9_1.

yugui	2008-12-30 19:32:42 +0900 (Tue, 30 Dec 2008)

  New Revision: 21195

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21195

  Log:
    merges r21177 and r21182 from trunk into ruby_1_9_1.
    * ext/dl/test/test_base.rb: add x86_64-linux's case again. #932
    --
    * 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]

  Modified files:
    branches/ruby_1_9_1/ChangeLog
    branches/ruby_1_9_1/ext/dl/dl.h
    branches/ruby_1_9_1/ext/dl/lib/dl/stack.rb
    branches/ruby_1_9_1/ext/dl/test/test_base.rb
    branches/ruby_1_9_1/ext/dl/test/test_func.rb
    branches/ruby_1_9_1/ext/dl/test/test_import.rb

Index: ruby_1_9_1/ChangeLog
===================================================================
--- ruby_1_9_1/ChangeLog	(revision 21194)
+++ ruby_1_9_1/ChangeLog	(revision 21195)
@@ -1,3 +1,28 @@
+Mon Dec 29 23:41:42 2008  Koichi Sasada  <ko1@a...>
+
+	* 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]
+
 Mon Dec 29 20:57:14 2008  Yuki Sonoda (Yugui)  <yugui@y...>
 
 	* man/ri.1: new manpage.
Index: ruby_1_9_1/ext/dl/test/test_base.rb
===================================================================
--- ruby_1_9_1/ext/dl/test/test_base.rb	(revision 21194)
+++ ruby_1_9_1/ext/dl/test/test_base.rb	(revision 21195)
@@ -5,9 +5,21 @@
 when /cygwin/
   LIBC_SO = "cygwin1.dll"
   LIBM_SO = "cygwin1.dll"
+when /x86_64-linux/
+  LIBC_SO = "/lib64/libc.so.6"
+  LIBM_SO = "/lib64/libm.so.6"
 when /linux/
-  LIBC_SO = "/lib/libc.so.6"
-  LIBM_SO = "/lib/libm.so.6"
+  libdir = '/lib'
+  case [0].pack('L!').size
+  when 4
+    # 32-bit ruby
+    libdir = '/lib32' if File.directory? '/lib32'
+  when 8
+    # 64-bit ruby
+    libdir = '/lib64' if File.directory? '/lib64'
+  end
+  LIBC_SO = File.join(libdir, "libc.so.6")
+  LIBM_SO = File.join(libdir, "libm.so.6")
 when /mingw/, /mswin32/
   LIBC_SO = "msvcrt.dll"
   LIBM_SO = "msvcrt.dll"
Index: ruby_1_9_1/ext/dl/test/test_import.rb
===================================================================
--- ruby_1_9_1/ext/dl/test/test_import.rb	(revision 21194)
+++ ruby_1_9_1/ext/dl/test/test_import.rb	(revision 21195)
@@ -11,10 +11,10 @@
 
     extern "void *strcpy(char*, char*)"
     extern "int isdigit(int)"
-    extern "float atof(string)"
+    extern "double atof(string)"
     extern "unsigned long strtoul(char*, char **, int)"
     extern "int qsort(void*, int, int, void*)"
-    extern "void fprintf(FILE*, char*)"
+    extern "int fprintf(FILE*, char*)"
     extern "int gettimeofday(timeval*, timezone*)" rescue nil
 
     QsortCallback = bind("void *qsort_callback(void*, void*)", :temp)
Index: ruby_1_9_1/ext/dl/test/test_func.rb
===================================================================
--- ruby_1_9_1/ext/dl/test/test_func.rb	(revision 21194)
+++ ruby_1_9_1/ext/dl/test/test_func.rb	(revision 21195)
@@ -24,7 +24,7 @@
     end
 
     def test_atof()
-      f = Function.new(CFunc.new(@libc['atof'], TYPE_FLOAT, 'atof'),
+      f = Function.new(CFunc.new(@libc['atof'], TYPE_DOUBLE, 'atof'),
                        [TYPE_VOIDP])
       r = f.call("12.34")
       assert_match(12.00..13.00, r)
Index: ruby_1_9_1/ext/dl/dl.h
===================================================================
--- ruby_1_9_1/ext/dl/dl.h	(revision 21194)
+++ ruby_1_9_1/ext/dl/dl.h	(revision 21195)
@@ -50,29 +50,65 @@
     stack[15],stack[16],stack[17],stack[18],stack[19]
 
 #define DLSTACK_PROTO0 
-#define DLSTACK_PROTO1 DLSTACK_TYPE
-#define DLSTACK_PROTO2 DLSTACK_PROTO1, DLSTACK_TYPE
-#define DLSTACK_PROTO3 DLSTACK_PROTO2, DLSTACK_TYPE
-#define DLSTACK_PROTO4 DLSTACK_PROTO3, DLSTACK_TYPE
-#define DLSTACK_PROTO4 DLSTACK_PROTO3, DLSTACK_TYPE
-#define DLSTACK_PROTO5 DLSTACK_PROTO4, DLSTACK_TYPE
-#define DLSTACK_PROTO6 DLSTACK_PROTO5, DLSTACK_TYPE
-#define DLSTACK_PROTO7 DLSTACK_PROTO6, DLSTACK_TYPE
-#define DLSTACK_PROTO8 DLSTACK_PROTO7, DLSTACK_TYPE
-#define DLSTACK_PROTO9 DLSTACK_PROTO8, DLSTACK_TYPE
-#define DLSTACK_PROTO10 DLSTACK_PROTO9, DLSTACK_TYPE
-#define DLSTACK_PROTO11 DLSTACK_PROTO10, DLSTACK_TYPE
-#define DLSTACK_PROTO12 DLSTACK_PROTO11, DLSTACK_TYPE
-#define DLSTACK_PROTO13 DLSTACK_PROTO12, DLSTACK_TYPE
-#define DLSTACK_PROTO14 DLSTACK_PROTO13, DLSTACK_TYPE
-#define DLSTACK_PROTO14 DLSTACK_PROTO13, DLSTACK_TYPE
-#define DLSTACK_PROTO15 DLSTACK_PROTO14, DLSTACK_TYPE
-#define DLSTACK_PROTO16 DLSTACK_PROTO15, DLSTACK_TYPE
-#define DLSTACK_PROTO17 DLSTACK_PROTO16, DLSTACK_TYPE
-#define DLSTACK_PROTO18 DLSTACK_PROTO17, DLSTACK_TYPE
-#define DLSTACK_PROTO19 DLSTACK_PROTO18, DLSTACK_TYPE
-#define DLSTACK_PROTO20 DLSTACK_PROTO19, DLSTACK_TYPE
+#define DLSTACK_PROTO1_ DLSTACK_TYPE
+#define DLSTACK_PROTO2_ DLSTACK_PROTO1_, DLSTACK_TYPE
+#define DLSTACK_PROTO3_ DLSTACK_PROTO2_, DLSTACK_TYPE
+#define DLSTACK_PROTO4_ DLSTACK_PROTO3_, DLSTACK_TYPE
+#define DLSTACK_PROTO4_ DLSTACK_PROTO3_, DLSTACK_TYPE
+#define DLSTACK_PROTO5_ DLSTACK_PROTO4_, DLSTACK_TYPE
+#define DLSTACK_PROTO6_ DLSTACK_PROTO5_, DLSTACK_TYPE
+#define DLSTACK_PROTO7_ DLSTACK_PROTO6_, DLSTACK_TYPE
+#define DLSTACK_PROTO8_ DLSTACK_PROTO7_, DLSTACK_TYPE
+#define DLSTACK_PROTO9_ DLSTACK_PROTO8_, DLSTACK_TYPE
+#define DLSTACK_PROTO10_ DLSTACK_PROTO9_, DLSTACK_TYPE
+#define DLSTACK_PROTO11_ DLSTACK_PROTO10_, DLSTACK_TYPE
+#define DLSTACK_PROTO12_ DLSTACK_PROTO11_, DLSTACK_TYPE
+#define DLSTACK_PROTO13_ DLSTACK_PROTO12_, DLSTACK_TYPE
+#define DLSTACK_PROTO14_ DLSTACK_PROTO13_, DLSTACK_TYPE
+#define DLSTACK_PROTO14_ DLSTACK_PROTO13_, DLSTACK_TYPE
+#define DLSTACK_PROTO15_ DLSTACK_PROTO14_, DLSTACK_TYPE
+#define DLSTACK_PROTO16_ DLSTACK_PROTO15_, DLSTACK_TYPE
+#define DLSTACK_PROTO17_ DLSTACK_PROTO16_, DLSTACK_TYPE
+#define DLSTACK_PROTO18_ DLSTACK_PROTO17_, DLSTACK_TYPE
+#define DLSTACK_PROTO19_ DLSTACK_PROTO18_, DLSTACK_TYPE
+#define DLSTACK_PROTO20_ DLSTACK_PROTO19_, DLSTACK_TYPE
 
+/*
+ * Add ",..." as the last argument.
+ * This is required for variable argument functions such
+ * as fprintf() on x86_64-linux.
+ *
+ * http://refspecs.linuxfoundation.org/elf/x86_64-abi-0.95.pdf
+ * page 19:
+ *
+ *   For calls that may call functions that use varargs or stdargs
+ *   (prototype-less calls or calls to functions containing ellipsis
+ *   (...) in the declaration) %al is used as hidden argument to
+ *   specify the number of SSE registers used.
+ */
+#define DLSTACK_PROTO1 DLSTACK_PROTO1_, ...
+#define DLSTACK_PROTO2 DLSTACK_PROTO2_, ...
+#define DLSTACK_PROTO3 DLSTACK_PROTO3_, ...
+#define DLSTACK_PROTO4 DLSTACK_PROTO4_, ...
+#define DLSTACK_PROTO4 DLSTACK_PROTO4_, ...
+#define DLSTACK_PROTO5 DLSTACK_PROTO5_, ...
+#define DLSTACK_PROTO6 DLSTACK_PROTO6_, ...
+#define DLSTACK_PROTO7 DLSTACK_PROTO7_, ...
+#define DLSTACK_PROTO8 DLSTACK_PROTO8_, ...
+#define DLSTACK_PROTO9 DLSTACK_PROTO9_, ...
+#define DLSTACK_PROTO10 DLSTACK_PROTO10_, ...
+#define DLSTACK_PROTO11 DLSTACK_PROTO11_, ...
+#define DLSTACK_PROTO12 DLSTACK_PROTO12_, ...
+#define DLSTACK_PROTO13 DLSTACK_PROTO13_, ...
+#define DLSTACK_PROTO14 DLSTACK_PROTO14_, ...
+#define DLSTACK_PROTO14 DLSTACK_PROTO14_, ...
+#define DLSTACK_PROTO15 DLSTACK_PROTO15_, ...
+#define DLSTACK_PROTO16 DLSTACK_PROTO16_, ...
+#define DLSTACK_PROTO17 DLSTACK_PROTO17_, ...
+#define DLSTACK_PROTO18 DLSTACK_PROTO18_, ...
+#define DLSTACK_PROTO19 DLSTACK_PROTO19_, ...
+#define DLSTACK_PROTO20 DLSTACK_PROTO20_, ...
+
 #define DLSTACK_ARGS0(stack)
 #define DLSTACK_ARGS1(stack) stack[0]
 #define DLSTACK_ARGS2(stack) DLSTACK_ARGS1(stack), stack[1]
Index: ruby_1_9_1/ext/dl/lib/dl/stack.rb
===================================================================
--- ruby_1_9_1/ext/dl/lib/dl/stack.rb	(revision 21194)
+++ ruby_1_9_1/ext/dl/lib/dl/stack.rb	(revision 21195)
@@ -121,20 +121,26 @@
       @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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]