in your extesion will translate to this when PERL_IMPLICIT_CONTEXT is
in effect:
- Perl_sv_setsv(GetPerlInterpreter(), asv, bsv);
+ Perl_sv_setsv(Perl_get_context(), asv, bsv);
or to this otherwise:
Perl_sv_setsv(asv, bsv);
You have to do nothing new in your extension to get this; since
-the Perl library provides GetPerlInterpreter(), it will all just
+the Perl library provides Perl_get_context(), it will all just
work.
The second, more efficient way is to use the following template for
return (exitstatus);
}
+EXTERN_C void
+set_w32_module_name(void);
+
BOOL APIENTRY
DllMain(HANDLE hModule, /* DLL module handle */
DWORD fdwReason, /* reason called */
#endif
DisableThreadLibraryCalls((HMODULE)hModule);
w32_perldll_handle = hModule;
+ set_w32_module_name();
break;
/* The DLL is detaching from a process due to
return (win32_os_id() == VER_PLATFORM_WIN32_NT);
}
+EXTERN_C void
+set_w32_module_name(void)
+{
+ char* ptr;
+ GetModuleFileName((HMODULE)((w32_perldll_handle == INVALID_HANDLE_VALUE)
+ ? GetModuleHandle(NULL)
+ : w32_perldll_handle),
+ w32_module_name, sizeof(w32_module_name));
+
+ /* try to get full path to binary (which may be mangled when perl is
+ * run from a 16-bit app) */
+ /*PerlIO_printf(Perl_debug_log, "Before %s\n", w32_module_name);*/
+ (void)win32_longpath(w32_module_name);
+ /*PerlIO_printf(Perl_debug_log, "After %s\n", w32_module_name);*/
+
+ /* normalize to forward slashes */
+ ptr = w32_module_name;
+ while (*ptr) {
+ if (*ptr == '\\')
+ *ptr = '/';
+ ++ptr;
+ }
+}
+
/* *svp (if non-NULL) is expected to be POK (valid allocated SvPVX(*svp)) */
static char*
get_regstr_from(HKEY hkey, const char *valuename, SV **svp)
baselen = strlen(base);
if (!*w32_module_name) {
- GetModuleFileName((HMODULE)((w32_perldll_handle == INVALID_HANDLE_VALUE)
- ? GetModuleHandle(NULL)
- : w32_perldll_handle),
- w32_module_name, sizeof(w32_module_name));
-
- /* try to get full path to binary (which may be mangled when perl is
- * run from a 16-bit app) */
- /*PerlIO_printf(Perl_debug_log, "Before %s\n", w32_module_name);*/
- (void)win32_longpath(w32_module_name);
- /*PerlIO_printf(Perl_debug_log, "After %s\n", w32_module_name);*/
-
- /* normalize to forward slashes */
- ptr = w32_module_name;
- while (*ptr) {
- if (*ptr == '\\')
- *ptr = '/';
- ++ptr;
- }
+ set_w32_module_name();
}
strcpy(mod_name, w32_module_name);
ptr = strrchr(mod_name, '/');
# define win32_get_sitelib PerlEnv_sitelib_path
#endif
-#if defined(PERL_IMPLICIT_CONTEXT)
-/* compat */
-# define GetPerlInterpreter Perl_get_context
-# define SetPerlInterpreter Perl_set_context
-#endif
-
#ifdef __GNUC__
# ifndef __int64 /* some versions seem to #define it already */
# define __int64 long long