[ruby-oci8-commit] [534] trunk/ruby-oci8: Fix for ruby-2.0.0-dev.
nobody at rubyforge.org
nobody at rubyforge.org
Tue Oct 2 06:11:04 UTC 2012
Revision: 534
Author: kubo
Date: 2012-10-02 06:11:04 +0000 (Tue, 02 Oct 2012)
Log Message:
-----------
Fix for ruby-2.0.0-dev.
Modified Paths:
--------------
trunk/ruby-oci8/ChangeLog
trunk/ruby-oci8/ext/oci8/apiwrap.c.tmpl
trunk/ruby-oci8/ext/oci8/connection_pool.c
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/thread_util.c
trunk/ruby-oci8/ext/oci8/thread_util.h
trunk/ruby-oci8/lib/oci8.rb.in
trunk/ruby-oci8/setup.rb
Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog 2012-08-12 12:04:38 UTC (rev 533)
+++ trunk/ruby-oci8/ChangeLog 2012-10-02 06:11:04 UTC (rev 534)
@@ -1,3 +1,13 @@
+2012-10-02 KUBO Takehiro <kubo at jiubao.org>
+ * ext/oci8/apiwrap.c.tmpl, ext/oci8/connection_pool.c, ext/oci8/env.c,
+ ext/oci8/extconf.rb, ext/oci8/oci8.c, ext/oci8/oci8.h, ext/oci8/oci8lib.c,
+ ext/oci8/thread_util.c, ext/oci8/thread_util.h:
+ replace rb_thread_blocking_region(), which is deprecated in ruby 2.0.0,
+ with rb_thread_call_without_gvl() and rename oci8_blocking_region()
+ to oci8_call_without_gvl().
+ * lib/oci8.rb.in: Ruby 2.0.0-dev's API version is changed to 2.0.0.
+ * setup.rb: use RbConfig instead of Config for ruby 2.0.0-dev.
+
2012-08-12 KUBO Takehiro <kubo at jiubao.org>
* ext/oci8/stmt.c, lib/oci8/cursor.rb: revise yard comment.
Modified: trunk/ruby-oci8/ext/oci8/apiwrap.c.tmpl
===================================================================
--- trunk/ruby-oci8/ext/oci8/apiwrap.c.tmpl 2012-08-12 12:04:38 UTC (rev 533)
+++ trunk/ruby-oci8/ext/oci8/apiwrap.c.tmpl 2012-10-02 06:11:04 UTC (rev 534)
@@ -4,7 +4,7 @@
%>
#define API_WRAP_C 1
#include "apiwrap.h"
-#ifdef HAVE_RB_THREAD_BLOCKING_REGION
+#ifdef NATIVE_THREAD_WITH_GVL
#define BLOCKING_FUNCTION_EPILOGUE(svcctx) do { (svcctx)->executing_thread = Qnil; } while (0)
#else
#define BLOCKING_FUNCTION_EPILOGUE(svcctx) do { } while (0)
@@ -54,7 +54,7 @@
#endif
#if defined RUNTIME_API_CHECK || ORACLE_CLIENT_VERSION >= <%=f.version_num%>
-static VALUE oci8_<%=f.name%>_cb(void *user_data)
+static void *oci8_<%=f.name%>_cb(void *user_data)
{
oci8_<%=f.name%>_data_t *data = (oci8_<%=f.name%>_data_t *)user_data;
<% if f.ret == 'void'
@@ -64,10 +64,10 @@
<% end %>
<% if f.ret == 'sword'
%> BLOCKING_FUNCTION_EPILOGUE(data->svcctx);
- return (VALUE)data->rv;
+ return (void*)(VALUE)data->rv;
<% else
%> BLOCKING_FUNCTION_EPILOGUE(data->svcctx);
- return (VALUE)0;
+ return NULL;
<% end %>
}
#else
@@ -82,7 +82,7 @@
<% f.args.each do |a|
%> data.<%=a.name%> = <%=a.name%>;
<% end
-%> oci8_blocking_region(svcctx, oci8_<%=f.name%>_cb, &data);
+%> oci8_call_without_gvl(svcctx, oci8_<%=f.name%>_cb, &data);
<% if f.ret != 'void'
%> return data.rv;
<% end
Modified: trunk/ruby-oci8/ext/oci8/connection_pool.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/connection_pool.c 2012-08-12 12:04:38 UTC (rev 533)
+++ trunk/ruby-oci8/ext/oci8/connection_pool.c 2012-10-02 06:11:04 UTC (rev 534)
@@ -21,11 +21,11 @@
rb_gc_mark(cpool->pool_name);
}
-static VALUE cpool_free_thread(void *arg)
+static void *cpool_free_thread(void *arg)
{
OCIConnectionPoolDestroy((OCICPool *)arg, oci8_errhp, OCI_DEFAULT);
OCIHandleFree(arg, OCI_HTYPE_CPOOL);
- return 0;
+ return NULL;
}
static void oci8_cpool_free(oci8_base_t *base)
Modified: trunk/ruby-oci8/ext/oci8/env.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/env.c 2012-08-12 12:04:38 UTC (rev 533)
+++ trunk/ruby-oci8/ext/oci8/env.c 2012-10-02 06:11:04 UTC (rev 534)
@@ -110,7 +110,7 @@
int error;
#endif
-#if !defined(HAVE_RB_THREAD_BLOCKING_REGION) && !defined(_WIN32)
+#if !defined(NATIVE_THREAD_WITH_GVL) && !defined(_WIN32)
/* workaround code.
*
* Some instant clients set the environment variables
Modified: trunk/ruby-oci8/ext/oci8/extconf.rb
===================================================================
--- trunk/ruby-oci8/ext/oci8/extconf.rb 2012-08-12 12:04:38 UTC (rev 533)
+++ trunk/ruby-oci8/ext/oci8/extconf.rb 2012-10-02 06:11:04 UTC (rev 534)
@@ -107,18 +107,20 @@
# ruby 1.8 headers
have_header("intern.h")
have_header("util.h")
-# ruby 1.9 headers
+# ruby 1.9.1 headers
have_header("ruby/util.h")
have_type('rb_encoding', ['ruby/ruby.h', 'ruby/encoding.h'])
+# ruby 2.0.0 headers
+have_header("ruby/thread.h")
# $! in C API
have_var("ruby_errinfo", "ruby.h") # ruby 1.8
have_func("rb_errinfo", "ruby.h") # ruby 1.9
-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")
+have_func("rb_thread_call_without_gvl", "ruby.h")
# replace files
replace = {
@@ -135,7 +137,8 @@
if ruby_engine == 'ruby'
# Config::CONFIG["ruby_version"] indicates the ruby API version.
# 1.8 - ruby 1.8.x
- # 1.9.1 - ruby 1.9.1, 1.9.2 and 2.0.0-dev at the present time.
+ # 1.9.1 - ruby 1.9.1, 1.9.2
+ # 2.0.0 - ruby 2.0.0
so_basename += RbConfig::CONFIG["ruby_version"].gsub(/\W/, '')
else
so_basename += ruby_engine
Modified: trunk/ruby-oci8/ext/oci8/oci8.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8.c 2012-08-12 12:04:38 UTC (rev 533)
+++ trunk/ruby-oci8/ext/oci8/oci8.c 2012-10-02 06:11:04 UTC (rev 534)
@@ -137,7 +137,7 @@
svcctx->pid = getpid();
svcctx->is_autocommit = 0;
-#ifdef HAVE_RB_THREAD_BLOCKING_REGION
+#ifdef NATIVE_THREAD_WITH_GVL
svcctx->non_blocking = 1;
#endif
svcctx->long_read_len = INT2FIX(65535);
@@ -272,7 +272,7 @@
return sla;
}
-static VALUE simple_logoff_execute(void *arg)
+static void *simple_logoff_execute(void *arg)
{
simple_logoff_arg_t *sla = (simple_logoff_arg_t *)arg;
OCIError *errhp = oci8_errhp;
@@ -281,7 +281,7 @@
OCITransRollback(sla->svchp, errhp, OCI_DEFAULT);
rv = OCILogoff(sla->svchp, errhp);
xfree(sla);
- return (VALUE)rv;
+ return (void*)(VALUE)rv;
}
static const oci8_logoff_strategy_t simple_logoff = {
@@ -313,7 +313,7 @@
return cla;
}
-static VALUE complex_logoff_execute(void *arg)
+static void *complex_logoff_execute(void *arg)
{
complex_logoff_arg_t *cla = (complex_logoff_arg_t *)arg;
OCIError *errhp = oci8_errhp;
@@ -339,7 +339,7 @@
OCIHandleFree(cla->svchp, OCI_HTYPE_SVCCTX);
}
xfree(cla);
- return (VALUE)rv;
+ return (void*)(VALUE)rv;
}
static const oci8_logoff_strategy_t complex_logoff = {
@@ -536,7 +536,7 @@
void *data = strategy->prepare(svcctx);
svcctx->base.type = 0;
svcctx->logoff_strategy = NULL;
- chker2(oci8_blocking_region(svcctx, strategy->execute, data), &svcctx->base);
+ chker2(oci8_call_without_gvl(svcctx, strategy->execute, data), &svcctx->base);
}
return Qtrue;
}
@@ -579,7 +579,7 @@
static VALUE oci8_non_blocking_p(VALUE self)
{
oci8_svcctx_t *svcctx = DATA_PTR(self);
-#ifdef HAVE_RB_THREAD_BLOCKING_REGION
+#ifdef NATIVE_THREAD_WITH_GVL
return svcctx->non_blocking ? Qtrue : Qfalse;
#else
sb1 non_blocking;
@@ -629,7 +629,7 @@
static VALUE oci8_set_non_blocking(VALUE self, VALUE val)
{
oci8_svcctx_t *svcctx = DATA_PTR(self);
-#ifdef HAVE_RB_THREAD_BLOCKING_REGION
+#ifdef NATIVE_THREAD_WITH_GVL
svcctx->non_blocking = RTEST(val);
#else
sb1 non_blocking;
@@ -723,7 +723,7 @@
if (NIL_P(svcctx->executing_thread)) {
return Qfalse;
}
-#ifndef HAVE_RB_THREAD_BLOCKING_REGION
+#ifndef NATIVE_THREAD_WITH_GVL
chker2(OCIBreak(svcctx->base.hp.ptr, oci8_errhp), &svcctx->base);
#endif
rb_thread_wakeup(svcctx->executing_thread);
Modified: trunk/ruby-oci8/ext/oci8/oci8.h
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8.h 2012-08-12 12:04:38 UTC (rev 533)
+++ trunk/ruby-oci8/ext/oci8/oci8.h 2012-10-02 06:11:04 UTC (rev 534)
@@ -135,9 +135,6 @@
#if !defined(HAVE_RB_ERRINFO) && defined(HAVE_RUBY_ERRINFO)
#define rb_errinfo() ruby_errinfo
#endif
-#if !defined HAVE_TYPE_RB_BLOCKING_FUNCTION_T_ && !defined HAVE_TYPE_RB_BLOCKING_FUNCTION_TP
-typedef VALUE rb_blocking_function_t(void *);
-#endif
#ifndef HAVE_TYPE_RB_ENCODING
#define rb_enc_associate(str, enc) do {} while(0)
@@ -160,7 +157,11 @@
#endif
#endif
-#if defined(HAVE_NATIVETHREAD) || defined(HAVE_RB_THREAD_BLOCKING_REGION)
+#if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL) || defined(HAVE_RB_THREAD_BLOCKING_REGION)
+#define NATIVE_THREAD_WITH_GVL 1
+#endif
+
+#if defined(HAVE_NATIVETHREAD) || NATIVE_THREAD_WITH_GVL
/*
* oci8_errhp is a thread local object in ruby 1.9, rubinius
* and ruby 1.8 configured with --enable-pthread.
@@ -213,7 +214,7 @@
#define oci8_tls_get(key) pthread_getspecific(key)
#define oci8_tls_set(key, val) pthread_setspecific((key), (val))
#endif
-#endif /* HAVE_RB_THREAD_BLOCKING_REGION */
+#endif /* USE_THREAD_LOCAL_ERRHP */
/* utility macros
*/
@@ -350,7 +351,7 @@
struct oci8_logoff_strategy {
void *(*prepare)(oci8_svcctx_t *svcctx);
- rb_blocking_function_t *execute;
+ void *(*execute)(void *);
};
typedef struct {
@@ -448,7 +449,7 @@
VALUE oci8_define_bind_class(const char *name, const oci8_bind_vtable_t *vptr);
void oci8_link_to_parent(oci8_base_t *base, oci8_base_t *parent);
void oci8_unlink_from_parent(oci8_base_t *base);
-sword oci8_blocking_region(oci8_svcctx_t *svcctx, rb_blocking_function_t func, void *data);
+sword oci8_call_without_gvl(oci8_svcctx_t *svcctx, void *(*func)(void *), void *data);
sword oci8_exec_sql(oci8_svcctx_t *svcctx, const char *sql_text, ub4 num_define_vars, oci8_exec_sql_var_t *define_vars, ub4 num_bind_vars, oci8_exec_sql_var_t *bind_vars, int raise_on_error);
#if defined RUNTIME_API_CHECK
void *oci8_find_symbol(const char *symbol_name);
Modified: trunk/ruby-oci8/ext/oci8/oci8lib.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8lib.c 2012-08-12 12:04:38 UTC (rev 533)
+++ trunk/ruby-oci8/ext/oci8/oci8lib.c 2012-10-02 06:11:04 UTC (rev 534)
@@ -4,6 +4,9 @@
*/
#include "oci8.h"
+#ifdef HAVE_RUBY_THREAD_H
+#include <ruby/thread.h>
+#endif
ID oci8_id_at_last_error;
ID oci8_id_new;
@@ -199,41 +202,16 @@
base->parent = NULL;
}
-#ifdef HAVE_RB_THREAD_BLOCKING_REGION
+#ifdef NATIVE_THREAD_WITH_GVL
-#if 0
-typedef struct {
- dvoid *hndlp;
- OCIError *errhp;
-} ocibreak_arg_t;
-
-static VALUE call_OCIBreak(void *user_data)
-{
- ocibreak_arg_t *arg = (ocibreak_arg_t *)user_data;
- OCIBreak(arg->hndlp, arg->errhp);
- return Qnil;
-}
-
static void oci8_unblock_func(void *user_data)
{
oci8_svcctx_t *svcctx = (oci8_svcctx_t *)user_data;
- if (svcctx->base.hp.ptr != NULL) {
- ocibreak_arg_t arg;
- arg.hndlp = svcctx->base.hp.ptr;
- arg.errhp = oci8_errhp;
- rb_thread_blocking_region(call_OCIBreak, &arg, NULL, NULL);
- }
-}
-#else
-static void oci8_unblock_func(void *user_data)
-{
- oci8_svcctx_t *svcctx = (oci8_svcctx_t *)user_data;
OCIBreak(svcctx->base.hp.ptr, oci8_errhp);
}
-#endif
/* ruby 1.9 */
-sword oci8_blocking_region(oci8_svcctx_t *svcctx, rb_blocking_function_t func, void *data)
+sword oci8_call_without_gvl(oci8_svcctx_t *svcctx, void *(*func)(void *), void *data)
{
if (svcctx->non_blocking) {
sword rv;
@@ -243,7 +221,11 @@
}
svcctx->executing_thread = rb_thread_current();
/* Note: executing_thread is cleard at the end of the blocking function. */
- rv = (sword)rb_thread_blocking_region(func, data, oci8_unblock_func, svcctx);
+#ifdef HAVE_RB_THREAD_CALL_WITHOUT_GVL
+ rv = (sword)(VALUE)rb_thread_call_without_gvl(func, data, oci8_unblock_func, svcctx);
+#else
+ rv = (sword)rb_thread_blocking_region(func, (rb_blocking_function_t)data, oci8_unblock_func, svcctx);
+#endif
if (rv == OCI_ERROR) {
if (oci8_get_error_code(oci8_errhp) == 1013) {
rb_raise(eOCIBreak, "Canceled by user request.");
@@ -251,10 +233,10 @@
}
return rv;
} else {
- return (sword)func(data);
+ return (sword)(VALUE)func(data);
}
}
-#else /* HAVE_RB_THREAD_BLOCKING_REGION */
+#else /* NATIVE_THREAD_WITH_GVL */
/* ruby 1.8 */
typedef struct {
@@ -301,7 +283,7 @@
return Qnil;
}
-sword oci8_blocking_region(oci8_svcctx_t *svcctx, rb_blocking_function_t func, void *data)
+sword oci8_call_without_gvl(oci8_svcctx_t *svcctx, void *(*func)(void *), void *data)
{
blocking_region_arg_t arg;
@@ -313,7 +295,7 @@
}
return (sword)rb_ensure(blocking_function_execute, (VALUE)&arg, blocking_function_ensure, (VALUE)svcctx);
}
-#endif /* HAVE_RB_THREAD_BLOCKING_REGION */
+#endif /* NATIVE_THREAD_WITH_GVL */
typedef struct {
oci8_svcctx_t *svcctx;
Modified: trunk/ruby-oci8/ext/oci8/thread_util.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/thread_util.c 2012-08-12 12:04:38 UTC (rev 533)
+++ trunk/ruby-oci8/ext/oci8/thread_util.c 2012-10-02 06:11:04 UTC (rev 534)
@@ -15,7 +15,7 @@
#endif
typedef struct {
- rb_blocking_function_t *func;
+ void *(*func)(void *);
void *arg;
} adapter_arg_t;
@@ -36,7 +36,7 @@
free(aa);
}
-int oci8_run_native_thread(rb_blocking_function_t func, void *arg)
+int oci8_run_native_thread(void *(*func)(void*), void *arg)
{
adapter_arg_t *aa = malloc(sizeof(adapter_arg_t));
if (aa == NULL) {
@@ -63,7 +63,7 @@
return NULL;
}
-int oci8_run_native_thread(rb_blocking_function_t func, void *arg)
+int oci8_run_native_thread(void *(*func)(void *), void *arg)
{
pthread_t thread;
adapter_arg_t *aa = malloc(sizeof(adapter_arg_t));
Modified: trunk/ruby-oci8/ext/oci8/thread_util.h
===================================================================
--- trunk/ruby-oci8/ext/oci8/thread_util.h 2012-08-12 12:04:38 UTC (rev 533)
+++ trunk/ruby-oci8/ext/oci8/thread_util.h 2012-10-02 06:11:04 UTC (rev 534)
@@ -16,7 +16,7 @@
* Don't call any ruby functions in the func.
* The return value is errno.
*/
-int oci8_run_native_thread(rb_blocking_function_t func, void *arg);
+int oci8_run_native_thread(void *(*func)(void *), void *arg);
#else
Modified: trunk/ruby-oci8/lib/oci8.rb.in
===================================================================
--- trunk/ruby-oci8/lib/oci8.rb.in 2012-08-12 12:04:38 UTC (rev 533)
+++ trunk/ruby-oci8/lib/oci8.rb.in 2012-10-02 06:11:04 UTC (rev 534)
@@ -28,10 +28,13 @@
so_basename = 'oci8lib_'
if ruby_engine == 'ruby'
# The suffix number indicates the ruby API version.
- # 18 - ruby 1.8.x
- # 191 - ruby 1.9.1, 1.9.2 and 2.0.0-dev at the present time.
+ # 1.8 - ruby 1.8.x
+ # 1.9.1 - ruby 1.9.1, 1.9.2
+ # 2.0.0 - ruby 2.0.0-dev at the present time.
case RUBY_VERSION
- when /^1\.9/, /^2\.0/
+ when /^2\.0/
+ so_basename += '200'
+ when /^1\.9/
so_basename += '191'
when /^1\.8/
so_basename += '18'
Modified: trunk/ruby-oci8/setup.rb
===================================================================
--- trunk/ruby-oci8/setup.rb 2012-08-12 12:04:38 UTC (rev 533)
+++ trunk/ruby-oci8/setup.rb 2012-10-02 06:11:04 UTC (rev 534)
@@ -72,6 +72,8 @@
end
end
+RbConfig = Config unless defined? RbConfig
+
#
# Application independent utilities
#
@@ -106,7 +108,7 @@
class ConfigTable
- c = ::Config::CONFIG
+ c = ::RbConfig::CONFIG
rubypath = c['bindir'] + '/' + c['ruby_install_name']
@@ -1217,7 +1219,7 @@
raise InstallError, "no ruby extention exists: 'ruby #{$0} setup' first"
end
- DLEXT = /\.#{ ::Config::CONFIG['DLEXT'] }\z/
+ DLEXT = /\.#{ ::RbConfig::CONFIG['DLEXT'] }\z/
def _ruby_extentions(dir)
Dir.open(dir) {|d|
More information about the ruby-oci8-commit
mailing list