[ruby-oci8-commit] [539] trunk/ruby-oci8: Update RB_GUARD definition and fix tests for rubinius.

nobody at rubyforge.org nobody at rubyforge.org
Sun Nov 11 10:03:11 UTC 2012


Revision: 539
Author:   kubo
Date:     2012-11-11 10:03:11 +0000 (Sun, 11 Nov 2012)
Log Message:
-----------
Update RB_GUARD definition and fix tests for rubinius.

Modified Paths:
--------------
    trunk/ruby-oci8/ChangeLog
    trunk/ruby-oci8/ext/oci8/oci8.h
    trunk/ruby-oci8/test/test_break.rb

Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog	2012-11-10 11:56:48 UTC (rev 538)
+++ trunk/ruby-oci8/ChangeLog	2012-11-11 10:03:11 UTC (rev 539)
@@ -1,3 +1,7 @@
+2012-11-11  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/oci8.h: update RB_GC_GUARD as ruby 1.9.2 defines.
+	* test/test_break.rb: fix tests for rubinius 1.2.4 and 2.0.0.
+
 2012-11-10  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/oci8lib.c: fix compilation errors when ruby version is 1.8.x.
 	* ext/oci8/ocinumber.c: Don't use rb_Rational() when rbx-2.0.testing

Modified: trunk/ruby-oci8/ext/oci8/oci8.h
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8.h	2012-11-10 11:56:48 UTC (rev 538)
+++ trunk/ruby-oci8/ext/oci8/oci8.h	2012-11-11 10:03:11 UTC (rev 539)
@@ -126,8 +126,21 @@
 #define STRINGIZE(name) #name
 #endif
 #ifndef RB_GC_GUARD
-#define RB_GC_GUARD(v) (*(volatile VALUE *)&(v))
+#ifdef __GNUC__
+#define RB_GC_GUARD_PTR(ptr) \
+    __extension__ ({volatile VALUE *rb_gc_guarded_ptr = (ptr); rb_gc_guarded_ptr;})
+#else
+#ifdef _MSC_VER
+#pragma optimize("", off)
 #endif
+static inline volatile VALUE *rb_gc_guarded_ptr(volatile VALUE *ptr) {return ptr;}
+#ifdef _MSC_VER
+#pragma optimize("", on)
+#endif
+#define RB_GC_GUARD_PTR(ptr) rb_gc_guarded_ptr(ptr)
+#endif
+#define RB_GC_GUARD(v) (*RB_GC_GUARD_PTR(&(v)))
+#endif
 
 /* new functions in ruby 1.9.
  * define compatible macros for ruby 1.8 or lower.

Modified: trunk/ruby-oci8/test/test_break.rb
===================================================================
--- trunk/ruby-oci8/test/test_break.rb	2012-11-10 11:56:48 UTC (rev 538)
+++ trunk/ruby-oci8/test/test_break.rb	2012-11-11 10:03:11 UTC (rev 539)
@@ -62,7 +62,15 @@
     expect = []
     expect[PLSQL_DONE] = TIME_IN_PLSQL
     expect[OCIBREAK]   = "Invalid status"
-    expect[SEND_BREAK] = TIME_IN_PLSQL + TIME_TO_BREAK
+    if defined? Rubinius and Rubinius::VERSION >= "2.0"
+      # Rubinius 2.0.0.
+      # DBMS_LOCK.SLEEP blocks ruby threads which try to call C-API.
+      expect[SEND_BREAK] = TIME_TO_BREAK
+    else
+      # MRI and Rubinius 1.2.4.
+      # DBMS_LOCK.SLEEP blocks all ruby threads.
+      expect[SEND_BREAK] = TIME_IN_PLSQL + TIME_TO_BREAK
+    end
     do_test_ocibreak(@conn, expect)
   end
 
@@ -91,7 +99,15 @@
   def test_timeout
     @conn.non_blocking = true
     start_time = Time.now
-    assert_raise(Timeout::Error) do
+
+    if defined? Rubinius and Rubinius::VERSION < "2.0"
+      # Rubinius 1.2.4
+      expected = OCIBreak
+    else
+      # MRI and Rubinius 2.0.0
+      expected = Timeout::Error
+    end
+    assert_raise(expected) do
       Timeout.timeout(1) do
         @conn.exec("BEGIN DBMS_LOCK.SLEEP(5); END;")
       end



More information about the ruby-oci8-commit mailing list