From 27a39b8ffed0c8317f5d44e21dee52e66ee66e40 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 17 Mar 2009 04:48:03 +0000 Subject: * 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 --- ext/dl/handle.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'ext/dl/handle.c') diff --git a/ext/dl/handle.c b/ext/dl/handle.c index 66cb0c912a..ef02124e6f 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); -- cgit v1.2.3