[ruby-oci8-commit] [428] trunk/ruby-oci8: * ext/oci8/oci8lib.c: add __declspec(dllexport) to Init_oci8lib().

nobody at rubyforge.org nobody at rubyforge.org
Sun Jun 12 06:21:24 EDT 2011


Revision: 428
Author:   kubo
Date:     2011-06-12 06:21:23 -0400 (Sun, 12 Jun 2011)

Log Message:
-----------
* ext/oci8/oci8lib.c: add __declspec(dllexport) to Init_oci8lib(). The mingw32
    gcc compiler doesn't export functions without it if more than one function
    is declared with it.
* ext/oci8/oraconf.rb: work around for rubinius 1.2.3, which doesn't support
    Array#pack('P').
* lib/oci8/oci8.rb: fix a bug introduced by the previous commit.
* ext/oci8/env.c, ext/oci8/extconf.rb, ext/oci8/oci8.c, ext/oci8/oci8.h,
  ext/oci8/oci8lib.c: Use HAVE_RB_THREAD_BLOCKING_REGION instead of
    HAVE_TYPE_RB_BLOCKING_FUNCTION_T. have_type("rb_blocking_function_t", "ruby.h")
    unexpectedly doesn't work on Visual Studio 2010.

Modified Paths:
--------------
    branches/ruby-oci8-2.0/ChangeLog
    branches/ruby-oci8-2.0/ext/oci8/env.c
    branches/ruby-oci8-2.0/ext/oci8/extconf.rb
    branches/ruby-oci8-2.0/ext/oci8/oci8.c
    branches/ruby-oci8-2.0/ext/oci8/oci8.h
    branches/ruby-oci8-2.0/ext/oci8/oci8lib.c
    branches/ruby-oci8-2.0/ext/oci8/oraconf.rb
    branches/ruby-oci8-2.0/lib/oci8/oci8.rb
    trunk/ruby-oci8/ChangeLog
    trunk/ruby-oci8/ext/oci8/env.c
    trunk/ruby-oci8/ext/oci8/extconf.rb
    trunk/ruby-oci8/ext/oci8/oci8.c
    trunk/ruby-oci8/ext/oci8/oci8.h
    trunk/ruby-oci8/ext/oci8/oci8lib.c
    trunk/ruby-oci8/ext/oci8/oraconf.rb
    trunk/ruby-oci8/lib/oci8/oci8.rb

Modified: branches/ruby-oci8-2.0/ChangeLog
===================================================================
--- branches/ruby-oci8-2.0/ChangeLog	2011-06-10 13:32:09 UTC (rev 427)
+++ branches/ruby-oci8-2.0/ChangeLog	2011-06-12 10:21:23 UTC (rev 428)
@@ -1,3 +1,15 @@
+2011-06-12  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/oci8lib.c: add __declspec(dllexport) to Init_oci8lib(). The mingw32
+	    gcc compiler doesn't export functions without it if more than one function
+	    is declared with it.
+	* ext/oci8/oraconf.rb: work around for rubinius 1.2.3, which doesn't support
+	    Array#pack('P').
+	* lib/oci8/oci8.rb: fix a bug introduced by the previous commit.
+	* ext/oci8/env.c, ext/oci8/extconf.rb, ext/oci8/oci8.c, ext/oci8/oci8.h,
+	  ext/oci8/oci8lib.c: Use HAVE_RB_THREAD_BLOCKING_REGION instead of
+	    HAVE_TYPE_RB_BLOCKING_FUNCTION_T. have_type("rb_blocking_function_t", "ruby.h")
+	    unexpectedly doesn't work on Visual Studio 2010.
+
 2011-06-10  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/apiwrap.yml, lib/oci8/oci8.rb: fix for Psych YAML library.
 	* ext/oci8/extconf.rb, ext/oci8/oci8.h, ext/oci8/ocihandle.c: fix to

Modified: branches/ruby-oci8-2.0/ext/oci8/env.c
===================================================================
--- branches/ruby-oci8-2.0/ext/oci8/env.c	2011-06-10 13:32:09 UTC (rev 427)
+++ branches/ruby-oci8-2.0/ext/oci8/env.c	2011-06-12 10:21:23 UTC (rev 428)
@@ -12,7 +12,7 @@
 #include <util.h>
 #endif
 
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
 ub4 oci8_env_mode = OCI_OBJECT | OCI_THREADED;
 #else
 ub4 oci8_env_mode = OCI_OBJECT;
@@ -31,7 +31,7 @@
     return oci8_global_envhp;
 }
 
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
 /*
  * oci8_errhp is a thread local object in ruby 1.9.
  */
@@ -110,11 +110,11 @@
 
 void Init_oci8_env(void)
 {
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
     int error;
 #endif
 
-#if !defined(HAVE_TYPE_RB_BLOCKING_FUNCTION_T) && !defined(_WIN32)
+#if !defined(HAVE_RB_THREAD_BLOCKING_REGION) && !defined(_WIN32)
     /* workaround code.
      *
      * Some instant clients set the environment variables
@@ -160,7 +160,7 @@
         }
     }
 
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
 /* ruby 1.9 */
 #if defined(_WIN32)
     if (!dllmain_is_called) {

Modified: branches/ruby-oci8-2.0/ext/oci8/extconf.rb
===================================================================
--- branches/ruby-oci8-2.0/ext/oci8/extconf.rb	2011-06-10 13:32:09 UTC (rev 427)
+++ branches/ruby-oci8-2.0/ext/oci8/extconf.rb	2011-06-12 10:21:23 UTC (rev 428)
@@ -115,6 +115,7 @@
 have_type("rb_blocking_function_t", "ruby.h")
 have_func("rb_set_end_proc", "ruby.h")
 have_func("rb_class_superclass", "ruby.h")
+have_func("rb_thread_blocking_region", "ruby.h")
 
 # replace files
 replace = {

Modified: branches/ruby-oci8-2.0/ext/oci8/oci8.c
===================================================================
--- branches/ruby-oci8-2.0/ext/oci8/oci8.c	2011-06-10 13:32:09 UTC (rev 427)
+++ branches/ruby-oci8-2.0/ext/oci8/oci8.c	2011-06-12 10:21:23 UTC (rev 428)
@@ -313,7 +313,7 @@
     }
     svcctx->pid = getpid();
     svcctx->is_autocommit = 0;
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
     svcctx->non_blocking = 1;
 #endif
     svcctx->long_read_len = INT2FIX(65535);
@@ -417,7 +417,7 @@
 static VALUE oci8_non_blocking_p(VALUE self)
 {
     oci8_svcctx_t *svcctx = DATA_PTR(self);
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
     return svcctx->non_blocking ? Qtrue : Qfalse;
 #else
     sb1 non_blocking;
@@ -470,7 +470,7 @@
 static VALUE oci8_set_non_blocking(VALUE self, VALUE val)
 {
     oci8_svcctx_t *svcctx = DATA_PTR(self);
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
     svcctx->non_blocking = RTEST(val);
 #else
     sb1 non_blocking;
@@ -560,14 +560,14 @@
 static VALUE oci8_break(VALUE self)
 {
     oci8_svcctx_t *svcctx = DATA_PTR(self);
-#ifndef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifndef HAVE_RB_THREAD_BLOCKING_REGION
     sword rv;
 #endif
 
     if (NIL_P(svcctx->executing_thread)) {
         return Qfalse;
     }
-#ifndef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifndef HAVE_RB_THREAD_BLOCKING_REGION
     rv = OCIBreak(svcctx->base.hp.ptr, oci8_errhp);
     if (rv != OCI_SUCCESS)
         oci8_raise(oci8_errhp, rv, NULL);

Modified: branches/ruby-oci8-2.0/ext/oci8/oci8.h
===================================================================
--- branches/ruby-oci8-2.0/ext/oci8/oci8.h	2011-06-10 13:32:09 UTC (rev 427)
+++ branches/ruby-oci8-2.0/ext/oci8/oci8.h	2011-06-12 10:21:23 UTC (rev 428)
@@ -189,7 +189,7 @@
  *    set a value to the key.
  *
  */
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
 /* ruby 1.9 */
 #if defined(_WIN32)
 #include <windows.h>
@@ -202,7 +202,7 @@
 #define oci8_tls_get(key)        pthread_getspecific(key)
 #define oci8_tls_set(key, val)   pthread_setspecific((key), (val))
 #endif
-#endif /* HAVE_TYPE_RB_BLOCKING_FUNCTION_T */
+#endif /* HAVE_RB_THREAD_BLOCKING_REGION */
 
 /* utility macros
  */
@@ -308,7 +308,7 @@
     OCIServer *srvhp;
     rb_pid_t pid;
     char is_autocommit;
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
     char non_blocking;
 #endif
     VALUE long_read_len;
@@ -362,7 +362,7 @@
  *   extern OCIError *oci8_errhp;
  */
 #define oci8_envhp (LIKELY(oci8_global_envhp != NULL) ? oci8_global_envhp : oci8_make_envhp())
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
 #define oci8_errhp oci8_get_errhp()
 #else
 #define oci8_errhp (LIKELY(oci8_global_errhp != NULL) ? oci8_global_errhp : oci8_make_errhp())
@@ -372,7 +372,7 @@
 extern ub4 oci8_env_mode;
 extern OCIEnv *oci8_global_envhp;
 OCIEnv *oci8_make_envhp(void);
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
 extern oci8_tls_key_t oci8_tls_key; /* native thread key */
 OCIError *oci8_make_errhp(void);
 

Modified: branches/ruby-oci8-2.0/ext/oci8/oci8lib.c
===================================================================
--- branches/ruby-oci8-2.0/ext/oci8/oci8lib.c	2011-06-10 13:32:09 UTC (rev 427)
+++ branches/ruby-oci8-2.0/ext/oci8/oci8lib.c	2011-06-12 10:21:23 UTC (rev 428)
@@ -51,6 +51,9 @@
 }
 #endif
 
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
 void
 Init_oci8lib()
 {
@@ -212,7 +215,7 @@
     base->parent = NULL;
 }
 
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
 
 #if 0
 typedef struct {
@@ -267,7 +270,7 @@
         return (sword)func(data);
     }
 }
-#else /* HAVE_TYPE_RB_BLOCKING_FUNCTION_T */
+#else /* HAVE_RB_THREAD_BLOCKING_REGION */
 
 /* ruby 1.8 */
 sword oci8_blocking_region(oci8_svcctx_t *svcctx, rb_blocking_function_t func, void *data)
@@ -297,7 +300,7 @@
     svcctx->executing_thread = Qnil;
     return rv;
 }
-#endif /* HAVE_TYPE_RB_BLOCKING_FUNCTION_T */
+#endif /* HAVE_RB_THREAD_BLOCKING_REGION */
 
 typedef struct {
     oci8_svcctx_t *svcctx;

Modified: branches/ruby-oci8-2.0/ext/oci8/oraconf.rb
===================================================================
--- branches/ruby-oci8-2.0/ext/oci8/oraconf.rb	2011-06-10 13:32:09 UTC (rev 427)
+++ branches/ruby-oci8-2.0/ext/oci8/oraconf.rb	2011-06-12 10:21:23 UTC (rev 428)
@@ -402,7 +402,15 @@
     so_ext = 'so'
     nls_data_ext = nil
     check_proc = nil
-    is_32bit = [nil].pack('p').size == 4
+    size_of_pointer = begin
+                        # the size of a pointer.
+                        [nil].pack('P').size
+                      rescue ArgumentError
+                        # Rubinius 1.2.3 doesn't support Array#pack('P').
+                        # Use Fixnum#size, which returns the size of long.
+                        1.size
+                      end
+    is_32bit = size_of_pointer == 4
     is_big_endian = "\x01\x02".unpack('s')[0] == 0x0102
     case RUBY_PLATFORM
     when /mswin32|cygwin|mingw32|bccwin32/

Modified: branches/ruby-oci8-2.0/lib/oci8/oci8.rb
===================================================================
--- branches/ruby-oci8-2.0/lib/oci8/oci8.rb	2011-06-10 13:32:09 UTC (rev 427)
+++ branches/ruby-oci8-2.0/lib/oci8/oci8.rb	2011-06-12 10:21:23 UTC (rev 428)
@@ -545,7 +545,7 @@
 
 class OraNumber
 
-  if YAML == Psych
+  if defined? Psych and YAML == Psych
 
     yaml_tag '!ruby/object:OraNumber'
     def encode_with coder # :nodoc:

Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog	2011-06-10 13:32:09 UTC (rev 427)
+++ trunk/ruby-oci8/ChangeLog	2011-06-12 10:21:23 UTC (rev 428)
@@ -1,3 +1,15 @@
+2011-06-12  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/oci8lib.c: add __declspec(dllexport) to Init_oci8lib(). The mingw32
+	    gcc compiler doesn't export functions without it if more than one function
+	    is declared with it.
+	* ext/oci8/oraconf.rb: work around for rubinius 1.2.3, which doesn't support
+	    Array#pack('P').
+	* lib/oci8/oci8.rb: fix a bug introduced by the previous commit.
+	* ext/oci8/env.c, ext/oci8/extconf.rb, ext/oci8/oci8.c, ext/oci8/oci8.h,
+	  ext/oci8/oci8lib.c: Use HAVE_RB_THREAD_BLOCKING_REGION instead of
+	    HAVE_TYPE_RB_BLOCKING_FUNCTION_T. have_type("rb_blocking_function_t", "ruby.h")
+	    unexpectedly doesn't work on Visual Studio 2010.
+
 2011-06-10  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/apiwrap.yml, lib/oci8/oci8.rb: fix for Psych YAML library.
 	* ext/oci8/extconf.rb, ext/oci8/oci8.h, ext/oci8/ocihandle.c: fix to

Modified: trunk/ruby-oci8/ext/oci8/env.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/env.c	2011-06-10 13:32:09 UTC (rev 427)
+++ trunk/ruby-oci8/ext/oci8/env.c	2011-06-12 10:21:23 UTC (rev 428)
@@ -12,7 +12,7 @@
 #include <util.h>
 #endif
 
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
 ub4 oci8_env_mode = OCI_OBJECT | OCI_THREADED;
 #else
 ub4 oci8_env_mode = OCI_OBJECT;
@@ -31,7 +31,7 @@
     return oci8_global_envhp;
 }
 
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
 /*
  * oci8_errhp is a thread local object in ruby 1.9.
  */
@@ -110,11 +110,11 @@
 
 void Init_oci8_env(void)
 {
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
     int error;
 #endif
 
-#if !defined(HAVE_TYPE_RB_BLOCKING_FUNCTION_T) && !defined(_WIN32)
+#if !defined(HAVE_RB_THREAD_BLOCKING_REGION) && !defined(_WIN32)
     /* workaround code.
      *
      * Some instant clients set the environment variables
@@ -160,7 +160,7 @@
         }
     }
 
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
 /* ruby 1.9 */
 #if defined(_WIN32)
     if (!dllmain_is_called) {

Modified: trunk/ruby-oci8/ext/oci8/extconf.rb
===================================================================
--- trunk/ruby-oci8/ext/oci8/extconf.rb	2011-06-10 13:32:09 UTC (rev 427)
+++ trunk/ruby-oci8/ext/oci8/extconf.rb	2011-06-12 10:21:23 UTC (rev 428)
@@ -117,6 +117,7 @@
 have_type("rb_blocking_function_t", "ruby.h")
 have_func("rb_set_end_proc", "ruby.h")
 have_func("rb_class_superclass", "ruby.h")
+have_func("rb_thread_blocking_region", "ruby.h")
 
 # replace files
 replace = {

Modified: trunk/ruby-oci8/ext/oci8/oci8.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8.c	2011-06-10 13:32:09 UTC (rev 427)
+++ trunk/ruby-oci8/ext/oci8/oci8.c	2011-06-12 10:21:23 UTC (rev 428)
@@ -100,7 +100,7 @@
     ((oci8_svcctx_associate_t *)svcctx->server)->svcctx = svcctx;
     svcctx->pid = getpid();
     svcctx->is_autocommit = 0;
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
     svcctx->non_blocking = 1;
 #endif
     svcctx->long_read_len = INT2FIX(65535);
@@ -478,7 +478,7 @@
 static VALUE oci8_non_blocking_p(VALUE self)
 {
     oci8_svcctx_t *svcctx = DATA_PTR(self);
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
     return svcctx->non_blocking ? Qtrue : Qfalse;
 #else
     sb1 non_blocking;
@@ -531,7 +531,7 @@
 static VALUE oci8_set_non_blocking(VALUE self, VALUE val)
 {
     oci8_svcctx_t *svcctx = DATA_PTR(self);
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
     svcctx->non_blocking = RTEST(val);
 #else
     sb1 non_blocking;
@@ -621,14 +621,14 @@
 static VALUE oci8_break(VALUE self)
 {
     oci8_svcctx_t *svcctx = DATA_PTR(self);
-#ifndef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifndef HAVE_RB_THREAD_BLOCKING_REGION
     sword rv;
 #endif
 
     if (NIL_P(svcctx->executing_thread)) {
         return Qfalse;
     }
-#ifndef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifndef HAVE_RB_THREAD_BLOCKING_REGION
     rv = OCIBreak(svcctx->base.hp.ptr, oci8_errhp);
     if (rv != OCI_SUCCESS)
         oci8_raise(oci8_errhp, rv, NULL);

Modified: trunk/ruby-oci8/ext/oci8/oci8.h
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8.h	2011-06-10 13:32:09 UTC (rev 427)
+++ trunk/ruby-oci8/ext/oci8/oci8.h	2011-06-12 10:21:23 UTC (rev 428)
@@ -192,7 +192,7 @@
  *    set a value to the key.
  *
  */
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
 /* ruby 1.9 */
 #if defined(_WIN32)
 #include <windows.h>
@@ -205,7 +205,7 @@
 #define oci8_tls_get(key)        pthread_getspecific(key)
 #define oci8_tls_set(key, val)   pthread_setspecific((key), (val))
 #endif
-#endif /* HAVE_TYPE_RB_BLOCKING_FUNCTION_T */
+#endif /* HAVE_RB_THREAD_BLOCKING_REGION */
 
 /* utility macros
  */
@@ -315,7 +315,7 @@
     rb_pid_t pid;
     unsigned char state;
     char is_autocommit;
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
     char non_blocking;
 #endif
     VALUE long_read_len;
@@ -369,7 +369,7 @@
  *   extern OCIError *oci8_errhp;
  */
 #define oci8_envhp (LIKELY(oci8_global_envhp != NULL) ? oci8_global_envhp : oci8_make_envhp())
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
 #define oci8_errhp oci8_get_errhp()
 #else
 #define oci8_errhp (LIKELY(oci8_global_errhp != NULL) ? oci8_global_errhp : oci8_make_errhp())
@@ -379,7 +379,7 @@
 extern ub4 oci8_env_mode;
 extern OCIEnv *oci8_global_envhp;
 OCIEnv *oci8_make_envhp(void);
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
 extern oci8_tls_key_t oci8_tls_key; /* native thread key */
 OCIError *oci8_make_errhp(void);
 

Modified: trunk/ruby-oci8/ext/oci8/oci8lib.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8lib.c	2011-06-10 13:32:09 UTC (rev 427)
+++ trunk/ruby-oci8/ext/oci8/oci8lib.c	2011-06-12 10:21:23 UTC (rev 428)
@@ -51,6 +51,9 @@
 }
 #endif
 
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
 void
 Init_oci8lib()
 {
@@ -216,7 +219,7 @@
     base->parent = NULL;
 }
 
-#ifdef HAVE_TYPE_RB_BLOCKING_FUNCTION_T
+#ifdef HAVE_RB_THREAD_BLOCKING_REGION
 
 #if 0
 typedef struct {
@@ -271,7 +274,7 @@
         return (sword)func(data);
     }
 }
-#else /* HAVE_TYPE_RB_BLOCKING_FUNCTION_T */
+#else /* HAVE_RB_THREAD_BLOCKING_REGION */
 
 /* ruby 1.8 */
 sword oci8_blocking_region(oci8_svcctx_t *svcctx, rb_blocking_function_t func, void *data)
@@ -301,7 +304,7 @@
     svcctx->executing_thread = Qnil;
     return rv;
 }
-#endif /* HAVE_TYPE_RB_BLOCKING_FUNCTION_T */
+#endif /* HAVE_RB_THREAD_BLOCKING_REGION */
 
 typedef struct {
     oci8_svcctx_t *svcctx;

Modified: trunk/ruby-oci8/ext/oci8/oraconf.rb
===================================================================
--- trunk/ruby-oci8/ext/oci8/oraconf.rb	2011-06-10 13:32:09 UTC (rev 427)
+++ trunk/ruby-oci8/ext/oci8/oraconf.rb	2011-06-12 10:21:23 UTC (rev 428)
@@ -402,7 +402,15 @@
     so_ext = 'so'
     nls_data_ext = nil
     check_proc = nil
-    is_32bit = [nil].pack('p').size == 4
+    size_of_pointer = begin
+                        # the size of a pointer.
+                        [nil].pack('P').size
+                      rescue ArgumentError
+                        # Rubinius 1.2.3 doesn't support Array#pack('P').
+                        # Use Fixnum#size, which returns the size of long.
+                        1.size
+                      end
+    is_32bit = size_of_pointer == 4
     is_big_endian = "\x01\x02".unpack('s')[0] == 0x0102
     case RUBY_PLATFORM
     when /mswin32|cygwin|mingw32|bccwin32/

Modified: trunk/ruby-oci8/lib/oci8/oci8.rb
===================================================================
--- trunk/ruby-oci8/lib/oci8/oci8.rb	2011-06-10 13:32:09 UTC (rev 427)
+++ trunk/ruby-oci8/lib/oci8/oci8.rb	2011-06-12 10:21:23 UTC (rev 428)
@@ -657,7 +657,7 @@
 
 class OraNumber
 
-  if YAML == Psych
+  if defined? Psych and YAML == Psych
 
     yaml_tag '!ruby/object:OraNumber'
     def encode_with coder # :nodoc:




More information about the ruby-oci8-commit mailing list