summaryrefslogtreecommitdiff
path: root/ext/dl/handle.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-17 04:48:03 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-17 04:48:03 +0000
commit27a39b8ffed0c8317f5d44e21dee52e66ee66e40 (patch)
tree1ad088f250e987d7c3243d19fbb5661fdbe91e50 /ext/dl/handle.c
parente3cb6518d1c4fb3fc74737f66785be419f162ea4 (diff)
* win32/Makefile.sub (config.h): added RUBY_COREDLL.
* ext/dl/handle.c (rb_dlhandle_initialize): returns msvcrt if libc or RUBY_COREDLL is given. [ruby-core:22828] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dl/handle.c')
-rw-r--r--ext/dl/handle.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/ext/dl/handle.c b/ext/dl/handle.c
index 66cb0c912a0..ef02124e6f8 100644
--- a/ext/dl/handle.c
+++ b/ext/dl/handle.c
@@ -7,6 +7,30 @@
VALUE rb_cDLHandle;
+#ifdef HAVE_WINDOWS_H
+# ifndef _WIN32_WCE
+static void *
+w32_coredll(void)
+{
+ MEMORY_BASIC_INFORMATION m;
+ memset(&m, 0, sizeof(m));
+ if( !VirtualQuery(_errno, &m, sizeof(m)) ) return NULL;
+ return m.AllocationBase;
+}
+# endif
+
+static int
+w32_dlclose(void *ptr)
+{
+# ifndef _WIN32_WCE
+ if( ptr == w32_coredll() ) return 0;
+# endif
+ if( FreeLibrary((HMODULE)ptr) ) return 0;
+ return errno = rb_w32_map_errno(GetLastError());
+}
+#define dlclose(ptr) w32_dlclose(ptr)
+#endif
+
void
dlhandle_free(struct dl_handle *dlhandle)
{
@@ -72,6 +96,18 @@ rb_dlhandle_initialize(int argc, VALUE argv[], VALUE self)
HANDLE rb_libruby_handle(void);
ptr = rb_libruby_handle();
}
+ else if( STRCASECMP(clib, "libc") == 0
+# ifdef RUBY_COREDLL
+ || STRCASECMP(clib, RUBY_COREDLL) == 0
+ || STRCASECMP(clib, RUBY_COREDLL".dll") == 0
+# endif
+ ){
+# ifdef _WIN32_WCE
+ ptr = dlopen("coredll.dll", cflag);
+# else
+ ptr = w32_coredll();
+# endif
+ }
else
#endif
ptr = dlopen(clib, cflag);