2 * "The Road goes ever on and on, down from the door where it began."
15 #ifdef PERL_IMPLICIT_SYS
18 #endif /* PERL_IMPLICIT_SYS */
21 /* Register any extra external extensions */
22 char *staticlinkmodules[] = {
27 EXTERN_C void boot_DynaLoader (pTHXo_ CV* cv);
32 char *file = __FILE__;
34 newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
37 #ifdef PERL_IMPLICIT_SYS
42 perl_get_host_info(struct IPerlMemInfo* perlMemInfo,
43 struct IPerlMemInfo* perlMemSharedInfo,
44 struct IPerlMemInfo* perlMemParseInfo,
45 struct IPerlEnvInfo* perlEnvInfo,
46 struct IPerlStdIOInfo* perlStdIOInfo,
47 struct IPerlLIOInfo* perlLIOInfo,
48 struct IPerlDirInfo* perlDirInfo,
49 struct IPerlSockInfo* perlSockInfo,
50 struct IPerlProcInfo* perlProcInfo)
53 Copy(&perlMem, &perlMemInfo->perlMemList, perlMemInfo->nCount, void*);
54 perlMemInfo->nCount = (sizeof(struct IPerlMem)/sizeof(void*));
56 if (perlMemSharedInfo) {
57 Copy(&perlMem, &perlMemSharedInfo->perlMemList, perlMemSharedInfo->nCount, void*);
58 perlMemSharedInfo->nCount = (sizeof(struct IPerlMem)/sizeof(void*));
60 if (perlMemParseInfo) {
61 Copy(&perlMem, &perlMemParseInfo->perlMemList, perlMemParseInfo->nCount, void*);
62 perlMemParseInfo->nCount = (sizeof(struct IPerlMem)/sizeof(void*));
65 Copy(&perlEnv, &perlEnvInfo->perlEnvList, perlEnvInfo->nCount, void*);
66 perlEnvInfo->nCount = (sizeof(struct IPerlEnv)/sizeof(void*));
69 Copy(&perlStdIO, &perlStdIOInfo->perlStdIOList, perlStdIOInfo->nCount, void*);
70 perlStdIOInfo->nCount = (sizeof(struct IPerlStdIO)/sizeof(void*));
73 Copy(&perlLIO, &perlLIOInfo->perlLIOList, perlLIOInfo->nCount, void*);
74 perlLIOInfo->nCount = (sizeof(struct IPerlLIO)/sizeof(void*));
77 Copy(&perlDir, &perlDirInfo->perlDirList, perlDirInfo->nCount, void*);
78 perlDirInfo->nCount = (sizeof(struct IPerlDir)/sizeof(void*));
81 Copy(&perlSock, &perlSockInfo->perlSockList, perlSockInfo->nCount, void*);
82 perlSockInfo->nCount = (sizeof(struct IPerlSock)/sizeof(void*));
85 Copy(&perlProc, &perlProcInfo->perlProcList, perlProcInfo->nCount, void*);
86 perlProcInfo->nCount = (sizeof(struct IPerlProc)/sizeof(void*));
90 EXTERN_C PerlInterpreter*
91 perl_alloc_override(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
92 struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv,
93 struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO,
94 struct IPerlDir** ppDir, struct IPerlSock** ppSock,
95 struct IPerlProc** ppProc)
97 PerlInterpreter *my_perl = NULL;
98 CPerlHost* pHost = new CPerlHost(ppMem, ppMemShared, ppMemParse, ppEnv,
99 ppStdIO, ppLIO, ppDir, ppSock, ppProc);
102 my_perl = perl_alloc_using(pHost->m_pHostperlMem,
103 pHost->m_pHostperlMemShared,
104 pHost->m_pHostperlMemParse,
105 pHost->m_pHostperlEnv,
106 pHost->m_pHostperlStdIO,
107 pHost->m_pHostperlLIO,
108 pHost->m_pHostperlDir,
109 pHost->m_pHostperlSock,
110 pHost->m_pHostperlProc);
113 CPerlObj* pPerl = (CPerlObj*)my_perl;
115 w32_internal_host = pHost;
121 EXTERN_C PerlInterpreter*
124 PerlInterpreter* my_perl = NULL;
125 CPerlHost* pHost = new CPerlHost();
127 my_perl = perl_alloc_using(pHost->m_pHostperlMem,
128 pHost->m_pHostperlMemShared,
129 pHost->m_pHostperlMemParse,
130 pHost->m_pHostperlEnv,
131 pHost->m_pHostperlStdIO,
132 pHost->m_pHostperlLIO,
133 pHost->m_pHostperlDir,
134 pHost->m_pHostperlSock,
135 pHost->m_pHostperlProc);
138 CPerlObj* pPerl = (CPerlObj*)my_perl;
140 w32_internal_host = pHost;
147 win32_delete_internal_host(void *h)
149 CPerlHost *host = (CPerlHost*)h;
156 perl_construct(PerlInterpreter* my_perl)
158 CPerlObj* pPerl = (CPerlObj*)my_perl;
165 win32_fprintf(stderr, "%s\n",
166 "Error: Unable to construct data structures");
172 perl_destruct(PerlInterpreter* my_perl)
174 CPerlObj* pPerl = (CPerlObj*)my_perl;
189 perl_free(PerlInterpreter* my_perl)
191 CPerlObj* pPerl = (CPerlObj*)my_perl;
192 void *host = w32_internal_host;
204 win32_delete_internal_host(host);
209 perl_run(PerlInterpreter* my_perl)
211 CPerlObj* pPerl = (CPerlObj*)my_perl;
222 win32_fprintf(stderr, "Error: Runtime exception\n");
230 perl_parse(PerlInterpreter* my_perl, void (*xsinit)(CPerlObj*), int argc, char** argv, char** env)
233 CPerlObj* pPerl = (CPerlObj*)my_perl;
235 retVal = Perl_parse(xsinit, argc, argv, env);
239 retVal = Perl_parse(xsinit, argc, argv, env);
243 win32_fprintf(stderr, "Error: Parse exception\n");
251 #undef PL_perl_destruct_level
252 #define PL_perl_destruct_level int dummy
254 #endif /* PERL_OBJECT */
255 #endif /* PERL_IMPLICIT_SYS */
257 EXTERN_C HANDLE w32_perldll_handle;
259 EXTERN_C DllExport int
260 RunPerl(int argc, char **argv, char **env)
263 PerlInterpreter *my_perl, *new_perl = NULL;
266 /* XXX this _may_ be a problem on some compilers (e.g. Borland) that
267 * want to free() argv after main() returns. As luck would have it,
268 * Borland's CRT does the right thing to argv[0] already. */
269 char szModuleName[MAX_PATH];
272 GetModuleFileName(NULL, szModuleName, sizeof(szModuleName));
273 (void)win32_longpath(szModuleName);
274 argv[0] = szModuleName;
277 #ifdef PERL_GLOBAL_STRUCT
278 #define PERLVAR(var,type) /**/
279 #define PERLVARA(var,type) /**/
280 #define PERLVARI(var,type,init) PL_Vars.var = init;
281 #define PERLVARIC(var,type,init) PL_Vars.var = init;
282 #include "perlvars.h"
289 PERL_SYS_INIT(&argc,&argv);
291 if (!(my_perl = perl_alloc()))
293 perl_construct(my_perl);
294 PL_perl_destruct_level = 0;
296 exitstatus = perl_parse(my_perl, xs_init, argc, argv, env);
298 #if defined(TOP_CLONE) && defined(USE_ITHREADS) /* XXXXXX testing */
300 CPerlHost *h = new CPerlHost();
301 new_perl = perl_clone_using(my_perl, 1,
303 h->m_pHostperlMemShared,
304 h->m_pHostperlMemParse,
312 CPerlObj *pPerl = (CPerlObj*)new_perl;
314 new_perl = perl_clone(my_perl, 1);
316 exitstatus = perl_run(new_perl);
317 PERL_SET_THX(my_perl);
319 exitstatus = perl_run(my_perl);
323 perl_destruct(my_perl);
327 PERL_SET_THX(new_perl);
328 perl_destruct(new_perl);
339 set_w32_module_name(void);
342 EXTERN_C /* GCC in C++ mode mangles the name, otherwise */
345 DllMain(HANDLE hModule, /* DLL module handle */
346 DWORD fdwReason, /* reason called */
347 LPVOID lpvReserved) /* reserved */
350 /* The DLL is attaching to a process due to process
351 * initialization or a call to LoadLibrary.
353 case DLL_PROCESS_ATTACH:
354 /* #define DEFAULT_BINMODE */
355 #ifdef DEFAULT_BINMODE
356 setmode( fileno( stdin ), O_BINARY );
357 setmode( fileno( stdout ), O_BINARY );
358 setmode( fileno( stderr ), O_BINARY );
361 DisableThreadLibraryCalls((HMODULE)hModule);
362 w32_perldll_handle = hModule;
363 set_w32_module_name();
366 /* The DLL is detaching from a process due to
367 * process termination or call to FreeLibrary.
369 case DLL_PROCESS_DETACH:
372 /* The attached process creates a new thread. */
373 case DLL_THREAD_ATTACH:
376 /* The thread of the attached process terminates. */
377 case DLL_THREAD_DETACH: