1 /* Time-stamp: <01/08/01 20:58:55 keuchel@w2k> */
8 #ifdef PERL_IMPLICIT_SYS
11 #endif /* PERL_IMPLICIT_SYS */
14 /* Register any extra external extensions */
15 char *staticlinkmodules[] = {
20 EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
25 char *file = __FILE__;
27 newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
30 #ifdef PERL_IMPLICIT_SYS
32 extern "C" void win32_checkTLS(PerlInterpreter *host_perl);
34 win32_checkTLS(PerlInterpreter *host_perl)
37 if (host_perl != my_perl) {
38 printf(" ... bad in win32_checkTLS\n");
39 printf(" %08X ne %08X\n",host_perl,my_perl);
47 int GetLogicalDrives() {
48 return 0; /* no logical drives on CE */
50 int GetLogicalDriveStrings(int size, char addr[]) {
51 return 0; /* no logical drives on CE */
54 DWORD GetFullPathNameA(LPCSTR fn, DWORD blen, LPTSTR buf, LPSTR *pfile) {
58 DWORD GetFullPathNameW(CONST WCHAR *fn, DWORD blen, WCHAR * buf, WCHAR **pfile) {
62 DWORD SetCurrentDirectoryA(LPSTR pPath) {
66 DWORD SetCurrentDirectoryW(CONST WCHAR *pPath) {
69 int xcesetuid(uid_t id){return 0;}
70 int xceseteuid(uid_t id){ return 0;}
71 int xcegetuid() {return 0;}
72 int xcegeteuid(){ return 0;}
78 perl_get_host_info(struct IPerlMemInfo* perlMemInfo,
79 struct IPerlMemInfo* perlMemSharedInfo,
80 struct IPerlMemInfo* perlMemParseInfo,
81 struct IPerlEnvInfo* perlEnvInfo,
82 struct IPerlStdIOInfo* perlStdIOInfo,
83 struct IPerlLIOInfo* perlLIOInfo,
84 struct IPerlDirInfo* perlDirInfo,
85 struct IPerlSockInfo* perlSockInfo,
86 struct IPerlProcInfo* perlProcInfo)
89 Copy(&perlMem, &perlMemInfo->perlMemList, perlMemInfo->nCount, void*);
90 perlMemInfo->nCount = (sizeof(struct IPerlMem)/sizeof(void*));
92 if (perlMemSharedInfo) {
93 Copy(&perlMem, &perlMemSharedInfo->perlMemList, perlMemSharedInfo->nCount, void*);
94 perlMemSharedInfo->nCount = (sizeof(struct IPerlMem)/sizeof(void*));
96 if (perlMemParseInfo) {
97 Copy(&perlMem, &perlMemParseInfo->perlMemList, perlMemParseInfo->nCount, void*);
98 perlMemParseInfo->nCount = (sizeof(struct IPerlMem)/sizeof(void*));
101 Copy(&perlEnv, &perlEnvInfo->perlEnvList, perlEnvInfo->nCount, void*);
102 perlEnvInfo->nCount = (sizeof(struct IPerlEnv)/sizeof(void*));
105 Copy(&perlStdIO, &perlStdIOInfo->perlStdIOList, perlStdIOInfo->nCount, void*);
106 perlStdIOInfo->nCount = (sizeof(struct IPerlStdIO)/sizeof(void*));
109 Copy(&perlLIO, &perlLIOInfo->perlLIOList, perlLIOInfo->nCount, void*);
110 perlLIOInfo->nCount = (sizeof(struct IPerlLIO)/sizeof(void*));
113 Copy(&perlDir, &perlDirInfo->perlDirList, perlDirInfo->nCount, void*);
114 perlDirInfo->nCount = (sizeof(struct IPerlDir)/sizeof(void*));
117 Copy(&perlSock, &perlSockInfo->perlSockList, perlSockInfo->nCount, void*);
118 perlSockInfo->nCount = (sizeof(struct IPerlSock)/sizeof(void*));
121 Copy(&perlProc, &perlProcInfo->perlProcList, perlProcInfo->nCount, void*);
122 perlProcInfo->nCount = (sizeof(struct IPerlProc)/sizeof(void*));
126 EXTERN_C PerlInterpreter*
127 perl_alloc_override(struct IPerlMem** ppMem, struct IPerlMem** ppMemShared,
128 struct IPerlMem** ppMemParse, struct IPerlEnv** ppEnv,
129 struct IPerlStdIO** ppStdIO, struct IPerlLIO** ppLIO,
130 struct IPerlDir** ppDir, struct IPerlSock** ppSock,
131 struct IPerlProc** ppProc)
133 PerlInterpreter *my_perl = NULL;
134 CPerlHost* pHost = new CPerlHost(ppMem, ppMemShared, ppMemParse, ppEnv,
135 ppStdIO, ppLIO, ppDir, ppSock, ppProc);
138 my_perl = perl_alloc_using(pHost->m_pHostperlMem,
139 pHost->m_pHostperlMemShared,
140 pHost->m_pHostperlMemParse,
141 pHost->m_pHostperlEnv,
142 pHost->m_pHostperlStdIO,
143 pHost->m_pHostperlLIO,
144 pHost->m_pHostperlDir,
145 pHost->m_pHostperlSock,
146 pHost->m_pHostperlProc);
148 w32_internal_host = pHost;
154 EXTERN_C PerlInterpreter*
157 PerlInterpreter* my_perl = NULL;
158 CPerlHost* pHost = new CPerlHost();
160 my_perl = perl_alloc_using(pHost->m_pHostperlMem,
161 pHost->m_pHostperlMemShared,
162 pHost->m_pHostperlMemParse,
163 pHost->m_pHostperlEnv,
164 pHost->m_pHostperlStdIO,
165 pHost->m_pHostperlLIO,
166 pHost->m_pHostperlDir,
167 pHost->m_pHostperlSock,
168 pHost->m_pHostperlProc);
170 w32_internal_host = pHost;
173 pHost->host_perl = my_perl; /* FIXME this statement shouldn't be here */
178 win32_delete_internal_host(void *h)
180 CPerlHost *host = (CPerlHost*)h;
184 #endif /* PERL_IMPLICIT_SYS */
186 EXTERN_C HANDLE w32_perldll_handle;
188 EXTERN_C DllExport int
189 RunPerl(int argc, char **argv, char **env)
192 PerlInterpreter *my_perl, *new_perl = NULL;
195 /* XXX this _may_ be a problem on some compilers (e.g. Borland) that
196 * want to free() argv after main() returns. As luck would have it,
197 * Borland's CRT does the right thing to argv[0] already. */
198 char szModuleName[MAX_PATH];
201 XCEGetModuleFileNameA(NULL, szModuleName, sizeof(szModuleName));
202 (void)win32_longpath(szModuleName);
203 argv[0] = szModuleName;
206 #ifdef PERL_GLOBAL_STRUCT
207 #define PERLVAR(var,type) /**/
208 #define PERLVARA(var,type) /**/
209 #define PERLVARI(var,type,init) PL_Vars.var = init;
210 #define PERLVARIC(var,type,init) PL_Vars.var = init;
211 #include "perlvars.h"
218 PERL_SYS_INIT(&argc,&argv);
220 if (!(my_perl = perl_alloc()))
222 perl_construct(my_perl);
223 PL_perl_destruct_level = 0;
225 exitstatus = perl_parse(my_perl, xs_init, argc, argv, env);
227 #if defined(TOP_CLONE) && defined(USE_ITHREADS) /* XXXXXX testing */
228 new_perl = perl_clone(my_perl, 1);
229 exitstatus = perl_run(new_perl);
230 PERL_SET_THX(my_perl);
232 exitstatus = perl_run(my_perl);
236 perl_destruct(my_perl);
240 PERL_SET_THX(new_perl);
241 perl_destruct(new_perl);
252 set_w32_module_name(void);
255 EXTERN_C /* GCC in C++ mode mangles the name, otherwise */
258 DllMain(HANDLE hModule, /* DLL module handle */
259 DWORD fdwReason, /* reason called */
260 LPVOID lpvReserved) /* reserved */
263 /* The DLL is attaching to a process due to process
264 * initialization or a call to LoadLibrary.
266 case DLL_PROCESS_ATTACH:
267 /* #define DEFAULT_BINMODE */
268 #ifdef DEFAULT_BINMODE
269 setmode( fileno( stdin ), O_BINARY );
270 setmode( fileno( stdout ), O_BINARY );
271 setmode( fileno( stderr ), O_BINARY );
276 DisableThreadLibraryCalls((HMODULE)hModule);
279 w32_perldll_handle = hModule;
280 set_w32_module_name();
283 /* The DLL is detaching from a process due to
284 * process termination or call to FreeLibrary.
286 case DLL_PROCESS_DETACH:
289 /* The attached process creates a new thread. */
290 case DLL_THREAD_ATTACH:
293 /* The thread of the attached process terminates. */
294 case DLL_THREAD_DETACH:
304 #if defined(USE_ITHREADS) && defined(PERL_IMPLICIT_SYS)
305 EXTERN_C PerlInterpreter *
306 perl_clone_host(PerlInterpreter* proto_perl, UV flags) {
309 h = new CPerlHost(*(CPerlHost*)PL_sys_intern.internal_host);
310 proto_perl = perl_clone_using(proto_perl, flags,
312 h->m_pHostperlMemShared,
313 h->m_pHostperlMemParse,
321 proto_perl->Isys_intern.internal_host = h;
322 h->host_perl = proto_perl;