summaryrefslogtreecommitdiff
path: root/ext/dl/handle.c
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-25 00:11:41 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-25 00:11:41 +0000
commit1578edbafc8d641a1829cb1949318aa754fc5485 (patch)
treeb355dd2dea9b73d02eb4de4b0d7f7c11a40bc9df /ext/dl/handle.c
parent159e6439c0d94d0f2c0dffdfe0d76aad631eb876 (diff)
* ext/dl/handle.c (rb_dlhandle_close_enabled_p) testing that handles can
be enabled and disabled for closure on GC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dl/handle.c')
-rw-r--r--ext/dl/handle.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/ext/dl/handle.c b/ext/dl/handle.c
index 6c2ef37b3d..28be36c099 100644
--- a/ext/dl/handle.c
+++ b/ext/dl/handle.c
@@ -181,6 +181,11 @@ rb_dlhandle_initialize(int argc, VALUE argv[], VALUE self)
return Qnil;
}
+/*
+ * call-seq: enable_close
+ *
+ * Enable a call to dlclose() when this DL::Handle is garbage collected.
+ */
VALUE
rb_dlhandle_enable_close(VALUE self)
{
@@ -191,6 +196,11 @@ rb_dlhandle_enable_close(VALUE self)
return Qnil;
}
+/*
+ * call-seq: disable_close
+ *
+ * Disable a call to dlclose() when this DL::Handle is garbage collected.
+ */
VALUE
rb_dlhandle_disable_close(VALUE self)
{
@@ -202,6 +212,23 @@ rb_dlhandle_disable_close(VALUE self)
}
/*
+ * call-seq: close_enabled?
+ *
+ * Returns +true+ if dlclose() will be called when this DL::Handle is
+ * garbage collected.
+ */
+static VALUE
+rb_dlhandle_close_enabled_p(VALUE self)
+{
+ struct dl_handle *dlhandle;
+
+ TypedData_Get_Struct(self, struct dl_handle, &dlhandle_data_type, dlhandle);
+
+ if(dlhandle->enable_close) return Qtrue;
+ return Qfalse;
+}
+
+/*
* call-seq: to_i
*
* Returns the memory address for this handle.
@@ -338,6 +365,7 @@ Init_dlhandle(void)
rb_define_method(rb_cDLHandle, "[]", rb_dlhandle_sym, 1);
rb_define_method(rb_cDLHandle, "disable_close", rb_dlhandle_disable_close, 0);
rb_define_method(rb_cDLHandle, "enable_close", rb_dlhandle_enable_close, 0);
+ rb_define_method(rb_cDLHandle, "close_enabled?", rb_dlhandle_close_enabled_p, 0);
}
/* mode: c; tab-with=8; sw=8; ts=8; noexpandtab: */