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

ruby-changes:11150

From: yugui <ko1@a...>
Date: Wed, 4 Mar 2009 18:20:36 +0900 (JST)
Subject: [ruby-changes:11150] Ruby:r22754 (ruby_1_9_1): merges r22690 from trunk into ruby_1_9_1.

yugui	2009-03-04 18:20:22 +0900 (Wed, 04 Mar 2009)

  New Revision: 22754

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

  Log:
    merges r22690 from trunk into ruby_1_9_1.
    --
    * ext/dl/cfunc.c (rb_dlcfunc_call): fix for stdcall and missing
      argument numbers.  [ruby-core:22601]
    * ext/dl/dl.h (DLSTACK_PROTO0_): added.
    
    * ext/dl/mkcallback.rb (gencallback, gen_callback_file),
      (rb_dl_init_callbacks): omit stdcall functions unless supported.
    
    * lib/rubygems/config_file.rb (SHGetFolderPath): stdcall.

  Modified files:
    branches/ruby_1_9_1/ChangeLog
    branches/ruby_1_9_1/ext/dl/cfunc.c
    branches/ruby_1_9_1/ext/dl/dl.h
    branches/ruby_1_9_1/ext/dl/mkcallback.rb
    branches/ruby_1_9_1/lib/rubygems/config_file.rb

Index: ruby_1_9_1/ChangeLog
===================================================================
--- ruby_1_9_1/ChangeLog	(revision 22753)
+++ ruby_1_9_1/ChangeLog	(revision 22754)
@@ -1,3 +1,15 @@
+Sun Mar  1 19:02:03 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/dl/cfunc.c (rb_dlcfunc_call): fix for stdcall and missing
+	  argument numbers.  [ruby-core:22601]
+
+	* ext/dl/dl.h (DLSTACK_PROTO0_): added.
+
+	* ext/dl/mkcallback.rb (gencallback, gen_callback_file),
+	  (rb_dl_init_callbacks): omit stdcall functions unless supported.
+
+	* lib/rubygems/config_file.rb (SHGetFolderPath): stdcall.
+
 Sun Mar  1 17:27:14 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/bigdecimal/bigdecimal.c (gfDebug): uncommented out.
Index: ruby_1_9_1/lib/rubygems/config_file.rb
===================================================================
--- ruby_1_9_1/lib/rubygems/config_file.rb	(revision 22753)
+++ ruby_1_9_1/lib/rubygems/config_file.rb	(revision 22754)
@@ -36,8 +36,8 @@
 
       CSIDL_COMMON_APPDATA = 0x0023
       path = 0.chr * 260
-      SHGetFolderPath = Win32API.new 'shell32', 'SHGetFolderPath', 'LLLLP', 'L'
-      SHGetFolderPath.call 0, CSIDL_COMMON_APPDATA, 0, 1, path
+      SHGetFolderPath = Win32API.new 'shell32', 'SHGetFolderPath', 'PLPLP', 'L', :stdcall
+      SHGetFolderPath.call nil, CSIDL_COMMON_APPDATA, nil, 1, path
 
       path.strip
     rescue LoadError
Index: ruby_1_9_1/ext/dl/cfunc.c
===================================================================
--- ruby_1_9_1/ext/dl/cfunc.c	(revision 22753)
+++ ruby_1_9_1/ext/dl/cfunc.c	(revision 22754)
@@ -224,7 +224,9 @@
 
 
 # define DECL_FUNC_CDECL(f,ret,args)  ret (FUNC_CDECL(*f))(args)
+#ifdef FUNC_STDCALL
 # define DECL_FUNC_STDCALL(f,ret,args)  ret (FUNC_STDCALL(*f))(args)
+#endif
 
 #define CALL_CASE switch( RARRAY_LEN(ary) ){ \
   CASE(0); break; \
@@ -265,7 +267,11 @@
     }
     
     /* calltype == CFUNC_CDECL */
-    if( cfunc->calltype == CFUNC_CDECL ){
+    if( cfunc->calltype == CFUNC_CDECL
+#ifndef FUNC_STDCALL
+	|| cfunc->calltype == CFUNC_STDCALL
+#endif
+	){
 	switch( cfunc->type ){
 	case DLTYPE_VOID:
 #define CASE(n) case n: { \
@@ -329,9 +335,9 @@
 #if HAVE_LONG_LONG  /* used in ruby.h */
 	case DLTYPE_LONG_LONG:
 #define CASE(n) case n: { \
-	    DECL_FUNC_CDECL(f,LONG_LONG,DLSTACK_PROTO) = cfunc->ptr; \
+	    DECL_FUNC_CDECL(f,LONG_LONG,DLSTACK_PROTO##n) = cfunc->ptr; \
 	    LONG_LONG ret; \
-	    ret = f(DLSTACK_ARGS(stack)); \
+	    ret = f(DLSTACK_ARGS##n(stack)); \
 	    result = LL2NUM(ret); \
 }
 	    CALL_CASE;
@@ -340,9 +346,9 @@
 #endif
 	case DLTYPE_FLOAT:
 #define CASE(n) case n: { \
-	    DECL_FUNC_CDECL(f,float,DLSTACK_PROTO) = cfunc->ptr; \
+	    DECL_FUNC_CDECL(f,float,DLSTACK_PROTO##n) = cfunc->ptr; \
 	    float ret; \
-	    ret = f(DLSTACK_ARGS(stack)); \
+	    ret = f(DLSTACK_ARGS##n(stack)); \
 	    result = rb_float_new(ret); \
 }
 	    CALL_CASE;
@@ -350,9 +356,9 @@
 	    break;
 	case DLTYPE_DOUBLE:
 #define CASE(n) case n: { \
-	    DECL_FUNC_CDECL(f,double,DLSTACK_PROTO) = cfunc->ptr; \
+	    DECL_FUNC_CDECL(f,double,DLSTACK_PROTO##n) = cfunc->ptr; \
 	    double ret; \
-	    ret = f(DLSTACK_ARGS(stack)); \
+	    ret = f(DLSTACK_ARGS##n(stack)); \
 	    result = rb_float_new(ret); \
 }
 	    CALL_CASE;
@@ -362,12 +368,13 @@
 	    rb_raise(rb_eDLTypeError, "unknown type %d", cfunc->type);
 	}
     }
+#ifdef FUNC_STDCALL
     else if( cfunc->calltype == CFUNC_STDCALL ){
 	/* calltype == CFUNC_STDCALL */
 	switch( cfunc->type ){
 	case DLTYPE_VOID:
 #define CASE(n) case n: { \
-            DECL_FUNC_STDCALL(f,void,DLSTACK_PROTO##n) = cfunc->ptr; \
+            DECL_FUNC_STDCALL(f,void,DLSTACK_PROTO##n##_) = cfunc->ptr; \
 	    f(DLSTACK_ARGS##n(stack)); \
 	    result = Qnil; \
 }
@@ -376,7 +383,7 @@
 	    break;
 	case DLTYPE_VOIDP:
 #define CASE(n) case n: { \
-	    DECL_FUNC_STDCALL(f,void*,DLSTACK_PROTO##n) = cfunc->ptr; \
+	    DECL_FUNC_STDCALL(f,void*,DLSTACK_PROTO##n##_) = cfunc->ptr; \
 	    void * ret; \
 	    ret = f(DLSTACK_ARGS##n(stack)); \
 	    result = PTR2NUM(ret); \
@@ -386,7 +393,7 @@
 	    break;
 	case DLTYPE_CHAR:
 #define CASE(n) case n: { \
-	    DECL_FUNC_STDCALL(f,char,DLSTACK_PROTO##n) = cfunc->ptr; \
+	    DECL_FUNC_STDCALL(f,char,DLSTACK_PROTO##n##_) = cfunc->ptr; \
 	    char ret; \
 	    ret = f(DLSTACK_ARGS##n(stack)); \
 	    result = CHR2FIX(ret); \
@@ -396,7 +403,7 @@
 	    break;
 	case DLTYPE_SHORT:
 #define CASE(n) case n: { \
-	    DECL_FUNC_STDCALL(f,short,DLSTACK_PROTO##n) = cfunc->ptr; \
+	    DECL_FUNC_STDCALL(f,short,DLSTACK_PROTO##n##_) = cfunc->ptr; \
 	    short ret; \
 	    ret = f(DLSTACK_ARGS##n(stack)); \
 	    result = INT2NUM((int)ret); \
@@ -406,7 +413,7 @@
 	    break;
 	case DLTYPE_INT:
 #define CASE(n) case n: { \
-	    DECL_FUNC_STDCALL(f,int,DLSTACK_PROTO##n) = cfunc->ptr; \
+	    DECL_FUNC_STDCALL(f,int,DLSTACK_PROTO##n##_) = cfunc->ptr; \
 	    int ret; \
 	    ret = f(DLSTACK_ARGS##n(stack)); \
 	    result = INT2NUM(ret); \
@@ -416,7 +423,7 @@
 	    break;
 	case DLTYPE_LONG:
 #define CASE(n) case n: { \
-	    DECL_FUNC_STDCALL(f,long,DLSTACK_PROTO##n) = cfunc->ptr; \
+	    DECL_FUNC_STDCALL(f,long,DLSTACK_PROTO##n##_) = cfunc->ptr; \
 	    long ret; \
 	    ret = f(DLSTACK_ARGS##n(stack)); \
 	    result = LONG2NUM(ret); \
@@ -427,9 +434,9 @@
 #if HAVE_LONG_LONG  /* used in ruby.h */
 	case DLTYPE_LONG_LONG:
 #define CASE(n) case n: { \
-	    DECL_FUNC_STDCALL(f,LONG_LONG,DLSTACK_PROTO) = cfunc->ptr; \
+	    DECL_FUNC_STDCALL(f,LONG_LONG,DLSTACK_PROTO##n##_) = cfunc->ptr; \
 	    LONG_LONG ret; \
-	    ret = f(DLSTACK_ARGS(stack)); \
+	    ret = f(DLSTACK_ARGS##n(stack)); \
 	    result = LL2NUM(ret); \
 }
 	    CALL_CASE;
@@ -438,9 +445,9 @@
 #endif
 	case DLTYPE_FLOAT:
 #define CASE(n) case n: { \
-	    DECL_FUNC_STDCALL(f,float,DLSTACK_PROTO) = cfunc->ptr; \
+	    DECL_FUNC_STDCALL(f,float,DLSTACK_PROTO##n##_) = cfunc->ptr; \
 	    float ret; \
-	    ret = f(DLSTACK_ARGS(stack)); \
+	    ret = f(DLSTACK_ARGS##n(stack)); \
 	    result = rb_float_new(ret); \
 }
 	    CALL_CASE;
@@ -448,9 +455,9 @@
 	    break;
 	case DLTYPE_DOUBLE:
 #define CASE(n) case n: { \
-	    DECL_FUNC_STDCALL(f,double,DLSTACK_PROTO) = cfunc->ptr; \
+	    DECL_FUNC_STDCALL(f,double,DLSTACK_PROTO##n##_) = cfunc->ptr; \
 	    double ret; \
-	    ret = f(DLSTACK_ARGS(stack)); \
+	    ret = f(DLSTACK_ARGS##n(stack)); \
 	    result = rb_float_new(ret); \
 }
 	    CALL_CASE;
@@ -460,6 +467,7 @@
 	    rb_raise(rb_eDLTypeError, "unknown type %d", cfunc->type);
 	}
     }
+#endif
     else{
 	rb_raise(rb_eDLError,
 #ifndef LONG_LONG_VALUE
Index: ruby_1_9_1/ext/dl/dl.h
===================================================================
--- ruby_1_9_1/ext/dl/dl.h	(revision 22753)
+++ ruby_1_9_1/ext/dl/dl.h	(revision 22754)
@@ -6,9 +6,6 @@
 #if !defined(FUNC_CDECL)
 #  define FUNC_CDECL(x) x
 #endif
-#if !defined(FUNC_STDCALL)
-#  define FUNC_STDCALL(x) x
-#endif
 
 #if defined(HAVE_DLFCN_H)
 # include <dlfcn.h>
@@ -49,7 +46,7 @@
     stack[10],stack[11],stack[12],stack[13],stack[14],\
     stack[15],stack[16],stack[17],stack[18],stack[19]
 
-#define DLSTACK_PROTO0 
+#define DLSTACK_PROTO0_ void
 #define DLSTACK_PROTO1_ DLSTACK_TYPE
 #define DLSTACK_PROTO2_ DLSTACK_PROTO1_, DLSTACK_TYPE
 #define DLSTACK_PROTO3_ DLSTACK_PROTO2_, DLSTACK_TYPE
@@ -86,6 +83,7 @@
  *   (...) in the declaration) %al is used as hidden argument to
  *   specify the number of SSE registers used.
  */
+#define DLSTACK_PROTO0 void
 #define DLSTACK_PROTO1 DLSTACK_PROTO1_, ...
 #define DLSTACK_PROTO2 DLSTACK_PROTO2_, ...
 #define DLSTACK_PROTO3 DLSTACK_PROTO3_, ...
Index: ruby_1_9_1/ext/dl/mkcallback.rb
===================================================================
--- ruby_1_9_1/ext/dl/mkcallback.rb	(revision 22753)
+++ ruby_1_9_1/ext/dl/mkcallback.rb	(revision 22754)
@@ -114,7 +114,7 @@
 
 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(", ")})
 {
@@ -128,7 +128,7 @@
     ret = rb_funcall2(cb, rb_dl_cb_call, #{argc}, #{argc > 0 ? 'args' : 'NULL'});
     return #{DLTYPE[ty][:conv] ? DLTYPE[ty][:conv] % "ret" : ""};
 }
-
+#{calltype == STDCALL ? "#endif\n" : ""}
   EOS
 end
 
@@ -157,7 +157,9 @@
     f.puts <<-EOS
 #include "dl.h"
 extern VALUE rb_DLCdeclCallbackAddrs, rb_DLCdeclCallbackProcs;
+#ifdef FUNC_STDCALL
 extern VALUE rb_DLStdcallCallbackAddrs, rb_DLStdcallCallbackProcs;
+#endif
 extern ID   rb_dl_cb_call;
     EOS
     yield f
@@ -167,8 +169,10 @@
 {
 #{gen_push_proc_ary(ty, "rb_DLCdeclCallbackProcs")}
 #{gen_push_addr_ary(ty, "rb_DLCdeclCallbackAddrs", CDECL)}
+#ifdef FUNC_STDCALL
 #{gen_push_proc_ary(ty, "rb_DLStdcallCallbackProcs")}
 #{gen_push_addr_ary(ty, "rb_DLStdcallCallbackAddrs", STDCALL)}
+#endif
 }
     EOS
   }
@@ -201,11 +205,13 @@
     tmp = rb_DLCdeclCallbackAddrs = rb_ary_new();
     rb_define_const(rb_mDL, "CdeclCallbackAddrs", tmp);
 
+#ifdef FUNC_STDCALL
     tmp = rb_DLStdcallCallbackProcs = rb_ary_new();
     rb_define_const(rb_mDL, "StdcallCallbackProcs", tmp);
 
     tmp = rb_DLStdcallCallbackAddrs = rb_ary_new();
     rb_define_const(rb_mDL, "StdcallCallbackAddrs", tmp);
+#endif
 
 #{
     (0...MAX_DLTYPE).collect{|ty|

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

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