1 /* WINCE.C - stuff for Windows CE
3 * Time-stamp: <26/10/01 15:25:20 keuchel@keuchelnt>
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
9 #define WIN32_LEAN_AND_MEAN
10 #define WIN32IO_IS_STDIO
14 #define PERLIO_NOT_STDIO 0
16 #if !defined(PERLIO_IS_STDIO) && !defined(USE_SFIO)
27 #define PERL_NO_GET_CONTEXT
37 #include "celib_defs.h"
40 #include "cewin32_defs.h"
41 #include "cecrt_defs.h"
44 #include "stdio-palmsize.h"
49 #define EXECF_SPAWN_NOWAIT 3
51 #if defined(PERL_IMPLICIT_SYS)
52 # undef win32_get_privlib
53 # define win32_get_privlib g_win32_get_privlib
54 # undef win32_get_sitelib
55 # define win32_get_sitelib g_win32_get_sitelib
56 # undef win32_get_vendorlib
57 # define win32_get_vendorlib g_win32_get_vendorlib
59 # define do_spawn g_do_spawn
61 # define getlogin g_getlogin
64 static long filetime_to_clock(PFILETIME ft);
65 static BOOL filetime_from_time(PFILETIME ft, time_t t);
66 static char * get_emd_part(SV **leading, char *trailing, ...);
67 static char * win32_get_xlib(const char *pl, const char *xlib,
71 HANDLE w32_perldll_handle = INVALID_HANDLE_VALUE;
72 char w32_module_name[MAX_PATH+1];
75 static DWORD w32_platform = (DWORD)-1;
80 return (win32_os_id() == VER_PLATFORM_WIN32_WINDOWS);
86 return (win32_os_id() == VER_PLATFORM_WIN32_NT);
92 return (win32_os_id() == VER_PLATFORM_WIN32_CE);
96 set_w32_module_name(void)
99 XCEGetModuleFileNameA((HMODULE)((w32_perldll_handle == INVALID_HANDLE_VALUE)
100 ? XCEGetModuleHandleA(NULL)
101 : w32_perldll_handle),
102 w32_module_name, sizeof(w32_module_name));
104 /* normalize to forward slashes */
105 ptr = w32_module_name;
113 /* *svp (if non-NULL) is expected to be POK (valid allocated SvPVX(*svp)) */
115 get_regstr_from(HKEY hkey, const char *valuename, SV **svp)
117 /* Retrieve a REG_SZ or REG_EXPAND_SZ from the registry */
120 const char *subkey = "Software\\Perl";
124 retval = XCERegOpenKeyExA(hkey, subkey, 0, KEY_READ, &handle);
125 if (retval == ERROR_SUCCESS) {
127 retval = XCERegQueryValueExA(handle, valuename, 0, &type, NULL, &datalen);
128 if (retval == ERROR_SUCCESS && type == REG_SZ) {
131 *svp = sv_2mortal(newSVpvn("",0));
132 SvGROW(*svp, datalen);
133 retval = XCERegQueryValueExA(handle, valuename, 0, NULL,
134 (PBYTE)SvPVX(*svp), &datalen);
135 if (retval == ERROR_SUCCESS) {
137 SvCUR_set(*svp,datalen-1);
145 /* *svp (if non-NULL) is expected to be POK (valid allocated SvPVX(*svp)) */
147 get_regstr(const char *valuename, SV **svp)
149 char *str = get_regstr_from(HKEY_CURRENT_USER, valuename, svp);
151 str = get_regstr_from(HKEY_LOCAL_MACHINE, valuename, svp);
155 /* *prev_pathp (if non-NULL) is expected to be POK (valid allocated SvPVX(sv)) */
157 get_emd_part(SV **prev_pathp, char *trailing_path, ...)
161 char mod_name[MAX_PATH+1];
165 int oldsize, newsize;
168 va_start(ap, trailing_path);
169 strip = va_arg(ap, char *);
171 sprintf(base, "%d.%d", (int)PERL_REVISION, (int)PERL_VERSION);
172 baselen = strlen(base);
174 if (!*w32_module_name) {
175 set_w32_module_name();
177 strcpy(mod_name, w32_module_name);
178 ptr = strrchr(mod_name, '/');
179 while (ptr && strip) {
180 /* look for directories to skip back */
183 ptr = strrchr(mod_name, '/');
184 /* avoid stripping component if there is no slash,
185 * or it doesn't match ... */
186 if (!ptr || stricmp(ptr+1, strip) != 0) {
187 /* ... but not if component matches m|5\.$patchlevel.*| */
188 if (!ptr || !(*strip == '5' && *(ptr+1) == '5'
189 && strncmp(strip, base, baselen) == 0
190 && strncmp(ptr+1, base, baselen) == 0))
196 strip = va_arg(ap, char *);
204 strcpy(++ptr, trailing_path);
206 /* only add directory if it exists */
207 if (XCEGetFileAttributesA(mod_name) != (DWORD) -1) {
208 /* directory exists */
211 *prev_pathp = sv_2mortal(newSVpvn("",0));
212 sv_catpvn(*prev_pathp, ";", 1);
213 sv_catpv(*prev_pathp, mod_name);
214 return SvPVX(*prev_pathp);
221 win32_get_privlib(const char *pl)
224 char *stdlib = "lib";
225 char buffer[MAX_PATH+1];
228 /* $stdlib = $HKCU{"lib-$]"} || $HKLM{"lib-$]"} || $HKCU{"lib"} || $HKLM{"lib"} || ""; */
229 sprintf(buffer, "%s-%s", stdlib, pl);
230 if (!get_regstr(buffer, &sv))
231 (void)get_regstr(stdlib, &sv);
233 /* $stdlib .= ";$EMD/../../lib" */
234 return get_emd_part(&sv, stdlib, ARCHNAME, "bin", Nullch);
238 win32_get_xlib(const char *pl, const char *xlib, const char *libname)
242 char pathstr[MAX_PATH+1];
248 /* $HKCU{"$xlib-$]"} || $HKLM{"$xlib-$]"} . ---; */
249 sprintf(regstr, "%s-%s", xlib, pl);
250 (void)get_regstr(regstr, &sv1);
253 * ";$EMD/" . ((-d $EMD/../../../$]) ? "../../.." : "../.."). "/$libname/$]/lib"; */
254 sprintf(pathstr, "%s/%s/lib", libname, pl);
255 (void)get_emd_part(&sv1, pathstr, ARCHNAME, "bin", pl, Nullch);
257 /* $HKCU{$xlib} || $HKLM{$xlib} . ---; */
258 (void)get_regstr(xlib, &sv2);
261 * ";$EMD/" . ((-d $EMD/../../../$]) ? "../../.." : "../.."). "/$libname/lib"; */
262 sprintf(pathstr, "%s/lib", libname);
263 (void)get_emd_part(&sv2, pathstr, ARCHNAME, "bin", pl, Nullch);
272 sv_catpvn(sv1, ";", 1);
279 win32_get_sitelib(const char *pl)
281 return win32_get_xlib(pl, "sitelib", "site");
284 #ifndef PERL_VENDORLIB_NAME
285 # define PERL_VENDORLIB_NAME "vendor"
289 win32_get_vendorlib(const char *pl)
291 return win32_get_xlib(pl, "vendorlib", PERL_VENDORLIB_NAME);
294 #if !defined(PERL_IMPLICIT_SYS)
295 /* since the current process environment is being updated in util.c
296 * the library functions will get the correct environment
299 Perl_my_popen(pTHX_ char *cmd, char *mode)
301 printf("popen(%s)\n", cmd);
303 Perl_croak(aTHX_ PL_no_func, "popen");
308 Perl_my_pclose(pTHX_ PerlIO *fp)
310 Perl_croak(aTHX_ PL_no_func, "pclose");
315 DllExport unsigned long
318 static OSVERSIONINFOA osver;
320 if (osver.dwPlatformId != w32_platform) {
321 memset(&osver, 0, sizeof(OSVERSIONINFOA));
322 osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
323 XCEGetVersionExA(&osver);
324 w32_platform = osver.dwPlatformId;
326 return (unsigned long)w32_platform;
336 Perl_do_exec(pTHX_ char *cmd)
338 Perl_croak_nocontext("exec() unimplemented on this platform");
343 win32_pipe(int *pfd, unsigned int size, int mode)
346 Perl_croak(aTHX_ PL_no_func, "pipe");
351 win32_times(struct tms *timebuf)
354 Perl_croak(aTHX_ PL_no_func, "times");
360 win32_signal(int sig, Sighandler_t subcode)
363 Perl_croak_nocontext("signal() TBD on this platform");
375 win32_opendir(char *filename)
377 return opendir(filename);
380 DllExport struct direct *
381 win32_readdir(DIR *dirp)
383 return readdir(dirp);
387 win32_telldir(DIR *dirp)
390 Perl_croak(aTHX_ PL_no_func, "telldir");
395 win32_seekdir(DIR *dirp, long loc)
398 Perl_croak(aTHX_ PL_no_func, "seekdir");
402 win32_rewinddir(DIR *dirp)
405 Perl_croak(aTHX_ PL_no_func, "rewinddir");
409 win32_closedir(DIR *dirp)
416 win32_kill(int pid, int sig)
419 Perl_croak(aTHX_ PL_no_func, "kill");
423 DllExport unsigned int
424 win32_sleep(unsigned int t)
430 win32_stat(const char *path, struct stat *sbuf)
432 return xcestat(path, sbuf);
436 win32_longpath(char *path)
441 #ifndef USE_WIN32_RTL_ENV
444 win32_getenv(const char *name)
446 return xcegetenv(name);
450 win32_putenv(const char *name)
452 return xceputenv(name);
458 filetime_to_clock(PFILETIME ft)
460 __int64 qw = ft->dwHighDateTime;
462 qw |= ft->dwLowDateTime;
463 qw /= 10000; /* File time ticks at 0.1uS, clock at 1mS */
467 /* fix utime() so it works on directories in NT */
469 filetime_from_time(PFILETIME pFileTime, time_t Time)
471 struct tm *pTM = localtime(&Time);
472 SYSTEMTIME SystemTime;
478 SystemTime.wYear = pTM->tm_year + 1900;
479 SystemTime.wMonth = pTM->tm_mon + 1;
480 SystemTime.wDay = pTM->tm_mday;
481 SystemTime.wHour = pTM->tm_hour;
482 SystemTime.wMinute = pTM->tm_min;
483 SystemTime.wSecond = pTM->tm_sec;
484 SystemTime.wMilliseconds = 0;
486 return SystemTimeToFileTime(&SystemTime, &LocalTime) &&
487 LocalFileTimeToFileTime(&LocalTime, pFileTime);
491 win32_unlink(const char *filename)
493 return xceunlink(filename);
497 win32_utime(const char *filename, struct utimbuf *times)
499 return xceutime(filename, (struct _utimbuf *) times);
503 win32_gettimeofday(struct timeval *tp, void *not_used)
505 return xcegettimeofday(tp,not_used);
509 win32_uname(struct utsname *name)
512 STRLEN nodemax = sizeof(name->nodename)-1;
513 OSVERSIONINFOA osver;
515 memset(&osver, 0, sizeof(OSVERSIONINFOA));
516 osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
517 if (XCEGetVersionExA(&osver)) {
519 switch (osver.dwPlatformId) {
520 case VER_PLATFORM_WIN32_CE:
521 strcpy(name->sysname, "Windows CE");
523 case VER_PLATFORM_WIN32_WINDOWS:
524 strcpy(name->sysname, "Windows");
526 case VER_PLATFORM_WIN32_NT:
527 strcpy(name->sysname, "Windows NT");
529 case VER_PLATFORM_WIN32s:
530 strcpy(name->sysname, "Win32s");
533 strcpy(name->sysname, "Win32 Unknown");
538 sprintf(name->release, "%d.%d",
539 osver.dwMajorVersion, osver.dwMinorVersion);
542 sprintf(name->version, "Build %d",
543 osver.dwPlatformId == VER_PLATFORM_WIN32_NT
544 ? osver.dwBuildNumber : (osver.dwBuildNumber & 0xffff));
545 if (osver.szCSDVersion[0]) {
546 char *buf = name->version + strlen(name->version);
547 sprintf(buf, " (%s)", osver.szCSDVersion);
551 *name->sysname = '\0';
552 *name->version = '\0';
553 *name->release = '\0';
557 hep = win32_gethostbyname("localhost");
559 STRLEN len = strlen(hep->h_name);
560 if (len <= nodemax) {
561 strcpy(name->nodename, hep->h_name);
564 strncpy(name->nodename, hep->h_name, nodemax);
565 name->nodename[nodemax] = '\0';
570 if (!XCEGetComputerNameA(name->nodename, &sz))
571 *name->nodename = '\0';
574 /* machine (architecture) */
578 GetSystemInfo(&info);
580 switch (info.wProcessorArchitecture) {
581 case PROCESSOR_ARCHITECTURE_INTEL:
583 case PROCESSOR_ARCHITECTURE_MIPS:
584 arch = "mips"; break;
585 case PROCESSOR_ARCHITECTURE_ALPHA:
586 arch = "alpha"; break;
587 case PROCESSOR_ARCHITECTURE_PPC:
589 case PROCESSOR_ARCHITECTURE_ARM:
591 case PROCESSOR_HITACHI_SH3:
593 case PROCESSOR_SHx_SH3:
597 arch = "unknown"; break;
599 strcpy(name->machine, arch);
605 sig_terminate(pTHX_ int sig)
607 Perl_warn(aTHX_ "Terminating on signal SIG%s(%d)\n",PL_sig_name[sig], sig);
608 /* exit() seems to be safe, my_exit() or die() is a problem in ^C
615 win32_async_check(pTHX)
619 /* Passing PeekMessage -1 as HWND (2nd arg) only get PostThreadMessage() messages
620 * and ignores window messages - should co-exist better with windows apps e.g. Tk
622 while (PeekMessage(&msg, (HWND)-1, 0, 0, PM_REMOVE|PM_NOYIELD)) {
624 switch(msg.message) {
627 /* Perhaps some other messages could map to signals ? ... */
630 /* Treat WM_QUIT like SIGHUP? */
636 /* We use WM_USER to fake kill() with other signals */
640 if (do_raise(aTHX_ sig)) {
641 sig_terminate(aTHX_ sig);
647 /* alarm() is a one-shot but SetTimer() repeats so kill it */
649 KillTimer(NULL,w32_timerid);
652 /* Now fake a call to signal handler */
653 if (do_raise(aTHX_ 14)) {
654 sig_terminate(aTHX_ 14);
659 /* Otherwise do normal Win32 thing - in case it is useful */
661 TranslateMessage(&msg);
662 DispatchMessage(&msg);
669 /* Above or other stuff may have set a signal flag */
670 if (PL_sig_pending) {
676 /* This function will not return until the timeout has elapsed, or until
677 * one of the handles is ready. */
679 win32_msgwait(pTHX_ DWORD count, LPHANDLE handles, DWORD timeout, LPDWORD resultp)
681 /* We may need several goes at this - so compute when we stop */
683 if (timeout != INFINITE) {
684 ticks = GetTickCount();
688 DWORD result = MsgWaitForMultipleObjects(count,handles,FALSE,timeout-ticks, QS_ALLEVENTS);
691 if (result == WAIT_TIMEOUT) {
692 /* Ran out of time - explicit return of zero to avoid -ve if we
693 have scheduling issues
697 if (timeout != INFINITE) {
698 ticks = GetTickCount();
700 if (result == WAIT_OBJECT_0 + count) {
701 /* Message has arrived - check it */
702 (void)win32_async_check(aTHX);
705 /* Not timeout or message - one of handles is ready */
709 /* compute time left to wait */
710 ticks = timeout - ticks;
711 /* If we are past the end say zero */
712 return (ticks > 0) ? ticks : 0;
715 /* Timing related stuff */
718 do_raise(pTHX_ int sig)
720 if (sig < SIG_SIZE) {
721 Sighandler_t handler = w32_sighandler[sig];
722 if (handler == SIG_IGN) {
725 else if (handler != SIG_DFL) {
730 /* Choose correct default behaviour */
746 /* Tell caller to exit thread/process as approriate */
750 static UINT timerid = 0;
752 static VOID CALLBACK TimerProc(HWND win, UINT msg, UINT id, DWORD time)
755 KillTimer(NULL,timerid);
760 DllExport unsigned int
761 win32_alarm(unsigned int sec)
764 * the 'obvious' implentation is SetTimer() with a callback
765 * which does whatever receiving SIGALRM would do
766 * we cannot use SIGALRM even via raise() as it is not
767 * one of the supported codes in <signal.h>
769 * Snag is unless something is looking at the message queue
770 * nothing happens :-(
775 timerid = SetTimer(NULL,timerid,sec*1000,(TIMERPROC)TimerProc);
777 Perl_croak_nocontext("Cannot set timer");
783 KillTimer(NULL,timerid);
790 #ifdef HAVE_DES_FCRYPT
791 extern char * des_fcrypt(const char *txt, const char *salt, char *cbuf);
795 win32_crypt(const char *txt, const char *salt)
798 #ifdef HAVE_DES_FCRYPT
800 return des_fcrypt(txt, salt, w32_crypt_buffer);
802 Perl_croak(aTHX_ "The crypt() function is unimplemented due to excessive paranoia.");
807 /* C doesn't like repeat struct definitions */
809 #if defined(USE_FIXED_OSFHANDLE) || defined(PERL_MSVCRT_READFIX)
812 #define _CRTIMP __declspec(dllimport)
816 * Control structure for lowio file handles
819 long osfhnd; /* underlying OS file HANDLE */
820 char osfile; /* attributes of file (e.g., open in text mode?) */
821 char pipech; /* one char buffer for handles opened on pipes */
823 CRITICAL_SECTION lock;
828 * Array of arrays of control structures for lowio files.
830 EXTERN_C _CRTIMP ioinfo* __pioinfo[];
833 * Definition of IOINFO_L2E, the log base 2 of the number of elements in each
834 * array of ioinfo structs.
839 * Definition of IOINFO_ARRAY_ELTS, the number of elements in ioinfo array
841 #define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
844 * Access macros for getting at an ioinfo struct and its fields from a
847 #define _pioinfo(i) (__pioinfo[(i) >> IOINFO_L2E] + ((i) & (IOINFO_ARRAY_ELTS - 1)))
848 #define _osfhnd(i) (_pioinfo(i)->osfhnd)
849 #define _osfile(i) (_pioinfo(i)->osfile)
850 #define _pipech(i) (_pioinfo(i)->pipech)
855 * redirected io subsystem for all XS modules
865 /* the rest are the remapped stdio routines */
873 return "no-getlogin";
889 win32_ferror(FILE *fp)
902 * Since the errors returned by the socket error function
903 * WSAGetLastError() are not known by the library routine strerror
904 * we have to roll our own.
908 win32_strerror(int e)
910 return xcestrerror(e);
914 win32_str_os_error(void *sv, DWORD dwErr)
918 sv_setpvn((SV*)sv, "Error", 5);
923 win32_fprintf(FILE *fp, const char *format, ...)
926 va_start(marker, format); /* Initialize variable arguments. */
928 return (vfprintf(fp, format, marker));
932 win32_printf(const char *format, ...)
935 va_start(marker, format); /* Initialize variable arguments. */
937 return (vprintf(format, marker));
941 win32_vfprintf(FILE *fp, const char *format, va_list args)
943 return (vfprintf(fp, format, args));
947 win32_vprintf(const char *format, va_list args)
949 return (vprintf(format, args));
953 win32_fread(void *buf, size_t size, size_t count, FILE *fp)
955 return fread(buf, size, count, fp);
959 win32_fwrite(const void *buf, size_t size, size_t count, FILE *fp)
961 return fwrite(buf, size, count, fp);
965 win32_fopen(const char *filename, const char *mode)
967 return xcefopen(filename, mode);
971 win32_fdopen(int handle, const char *mode)
973 return palm_fdopen(handle, mode);
977 win32_freopen(const char *path, const char *mode, FILE *stream)
979 return xcefreopen(path, mode, stream);
983 win32_fclose(FILE *pf)
985 return xcefclose(pf);
989 win32_fputs(const char *s,FILE *pf)
995 win32_fputc(int c,FILE *pf)
1001 win32_ungetc(int c,FILE *pf)
1003 return ungetc(c,pf);
1007 win32_getc(FILE *pf)
1013 win32_fileno(FILE *pf)
1015 return palm_fileno(pf);
1019 win32_clearerr(FILE *pf)
1026 win32_fflush(FILE *pf)
1032 win32_ftell(FILE *pf)
1038 win32_fseek(FILE *pf,long offset,int origin)
1040 return fseek(pf, offset, origin);
1043 /* fpos_t seems to be int64 on hpc pro! Really stupid. */
1044 /* But maybe someday there will be such large disks in a hpc... */
1046 win32_fgetpos(FILE *pf, fpos_t *p)
1048 return fgetpos(pf, p);
1052 win32_fsetpos(FILE *pf, const fpos_t *p)
1054 return fsetpos(pf, p);
1058 win32_rewind(FILE *pf)
1060 fseek(pf, 0, SEEK_SET);
1068 char prefix[MAX_PATH+1];
1069 char filename[MAX_PATH+1];
1070 DWORD len = GetTempPath(MAX_PATH, prefix);
1071 if (len && len < MAX_PATH) {
1072 if (GetTempFileName(prefix, "plx", 0, filename)) {
1073 HANDLE fh = CreateFile(filename,
1074 DELETE | GENERIC_READ | GENERIC_WRITE,
1078 FILE_ATTRIBUTE_NORMAL
1079 | FILE_FLAG_DELETE_ON_CLOSE,
1081 if (fh != INVALID_HANDLE_VALUE) {
1082 int fd = win32_open_osfhandle((intptr_t)fh, 0);
1084 #if defined(__BORLANDC__)
1085 setmode(fd,O_BINARY);
1087 DEBUG_p(PerlIO_printf(Perl_debug_log,
1088 "Created tmpfile=%s\n",filename));
1100 int fd = win32_tmpfd();
1102 return win32_fdopen(fd, "w+b");
1115 win32_fstat(int fd, struct stat *sbufptr)
1117 return xcefstat(fd, sbufptr);
1121 win32_link(const char *oldname, const char *newname)
1124 Perl_croak(aTHX_ PL_no_func, "link");
1130 win32_rename(const char *oname, const char *newname)
1132 return xcerename(oname, newname);
1136 win32_setmode(int fd, int mode)
1138 /* currently 'celib' seem to have this function in src, but not
1139 * exported. When it will be, we'll uncomment following line.
1141 /* return xcesetmode(fd, mode); */
1146 win32_chsize(int fd, Off_t size)
1148 return chsize(fd, size);
1152 win32_lseek(int fd, long offset, int origin)
1154 return xcelseek(fd, offset, origin);
1160 return xcelseek(fd, 0, SEEK_CUR);
1164 win32_open(const char *path, int flag, ...)
1170 pmode = va_arg(ap, int);
1173 return xceopen(path, flag, pmode);
1179 return xceclose(fd);
1186 Perl_croak(aTHX_ PL_no_func, "eof");
1193 return xcedup(fd); /* from celib/ceio.c; requires some more work on it */
1197 win32_dup2(int fd1,int fd2)
1199 return xcedup2(fd1,fd2);
1203 win32_read(int fd, void *buf, unsigned int cnt)
1205 return xceread(fd, buf, cnt);
1209 win32_write(int fd, const void *buf, unsigned int cnt)
1211 return xcewrite(fd, (void *) buf, cnt);
1215 win32_mkdir(const char *dir, int mode)
1217 return xcemkdir(dir);
1221 win32_rmdir(const char *dir)
1223 return xcermdir(dir);
1227 win32_chdir(const char *dir)
1229 return xcechdir(dir);
1233 win32_access(const char *path, int mode)
1235 return xceaccess(path, mode);
1239 win32_chmod(const char *path, int mode)
1241 return xcechmod(path, mode);
1245 win32_perror(const char *str)
1251 win32_setbuf(FILE *pf, char *buf)
1254 Perl_croak(aTHX_ PL_no_func, "setbuf");
1258 win32_setvbuf(FILE *pf, char *buf, int type, size_t size)
1260 return setvbuf(pf, buf, type, size);
1264 win32_flushall(void)
1270 win32_fcloseall(void)
1276 win32_fgets(char *s, int n, FILE *pf)
1278 return fgets(s, n, pf);
1288 win32_fgetc(FILE *pf)
1294 win32_putc(int c, FILE *pf)
1300 win32_puts(const char *s)
1312 win32_putchar(int c)
1319 #ifndef USE_PERL_SBRK
1321 static char *committed = NULL;
1322 static char *base = NULL;
1323 static char *reserved = NULL;
1324 static char *brk = NULL;
1325 static DWORD pagesize = 0;
1326 static DWORD allocsize = 0;
1334 GetSystemInfo(&info);
1335 /* Pretend page size is larger so we don't perpetually
1336 * call the OS to commit just one page ...
1338 pagesize = info.dwPageSize << 3;
1339 allocsize = info.dwAllocationGranularity;
1341 /* This scheme fails eventually if request for contiguous
1342 * block is denied so reserve big blocks - this is only
1343 * address space not memory ...
1345 if (brk+need >= reserved)
1347 DWORD size = 64*1024*1024;
1349 if (committed && reserved && committed < reserved)
1351 /* Commit last of previous chunk cannot span allocations */
1352 addr = (char *) VirtualAlloc(committed,reserved-committed,MEM_COMMIT,PAGE_READWRITE);
1354 committed = reserved;
1356 /* Reserve some (more) space
1357 * Note this is a little sneaky, 1st call passes NULL as reserved
1358 * so lets system choose where we start, subsequent calls pass
1359 * the old end address so ask for a contiguous block
1361 addr = (char *) VirtualAlloc(reserved,size,MEM_RESERVE,PAGE_NOACCESS);
1364 reserved = addr+size;
1379 if (brk > committed)
1381 DWORD size = ((brk-committed + pagesize -1)/pagesize) * pagesize;
1382 char *addr = (char *) VirtualAlloc(committed,size,MEM_COMMIT,PAGE_READWRITE);
1397 win32_malloc(size_t size)
1399 return malloc(size);
1403 win32_calloc(size_t numitems, size_t size)
1405 return calloc(numitems,size);
1409 win32_realloc(void *block, size_t size)
1411 return realloc(block,size);
1415 win32_free(void *block)
1420 /* returns pointer to the next unquoted space or the end of the string */
1422 find_next_space(const char *s)
1424 bool in_quotes = FALSE;
1426 /* ignore doubled backslashes, or backslash+quote */
1427 if (*s == '\\' && (s[1] == '\\' || s[1] == '"')) {
1430 /* keep track of when we're within quotes */
1431 else if (*s == '"') {
1433 in_quotes = !in_quotes;
1435 /* break it up only at spaces that aren't in quotes */
1436 else if (!in_quotes && isSPACE(*s))
1445 create_command_line(char *cname, STRLEN clen, const char * const *args)
1452 bool bat_file = FALSE;
1453 bool cmd_shell = FALSE;
1454 bool dumb_shell = FALSE;
1455 bool extra_quotes = FALSE;
1456 bool quote_next = FALSE;
1459 cname = (char*)args[0];
1461 /* The NT cmd.exe shell has the following peculiarity that needs to be
1462 * worked around. It strips a leading and trailing dquote when any
1463 * of the following is true:
1464 * 1. the /S switch was used
1465 * 2. there are more than two dquotes
1466 * 3. there is a special character from this set: &<>()@^|
1467 * 4. no whitespace characters within the two dquotes
1468 * 5. string between two dquotes isn't an executable file
1469 * To work around this, we always add a leading and trailing dquote
1470 * to the string, if the first argument is either "cmd.exe" or "cmd",
1471 * and there were at least two or more arguments passed to cmd.exe
1472 * (not including switches).
1473 * XXX the above rules (from "cmd /?") don't seem to be applied
1474 * always, making for the convolutions below :-(
1478 clen = strlen(cname);
1481 && (stricmp(&cname[clen-4], ".bat") == 0
1482 || (IsWinNT() && stricmp(&cname[clen-4], ".cmd") == 0)))
1488 char *exe = strrchr(cname, '/');
1489 char *exe2 = strrchr(cname, '\\');
1496 if (stricmp(exe, "cmd.exe") == 0 || stricmp(exe, "cmd") == 0) {
1500 else if (stricmp(exe, "command.com") == 0
1501 || stricmp(exe, "command") == 0)
1508 DEBUG_p(PerlIO_printf(Perl_debug_log, "Args "));
1509 for (index = 0; (arg = (char*)args[index]) != NULL; ++index) {
1510 STRLEN curlen = strlen(arg);
1511 if (!(arg[0] == '"' && arg[curlen-1] == '"'))
1512 len += 2; /* assume quoting needed (worst case) */
1514 DEBUG_p(PerlIO_printf(Perl_debug_log, "[%s]",arg));
1516 DEBUG_p(PerlIO_printf(Perl_debug_log, "\n"));
1519 New(1310, cmd, len, char);
1524 extra_quotes = TRUE;
1527 for (index = 0; (arg = (char*)args[index]) != NULL; ++index) {
1529 STRLEN curlen = strlen(arg);
1531 /* we want to protect empty arguments and ones with spaces with
1532 * dquotes, but only if they aren't already there */
1537 else if (quote_next) {
1538 /* see if it really is multiple arguments pretending to
1539 * be one and force a set of quotes around it */
1540 if (*find_next_space(arg))
1543 else if (!(arg[0] == '"' && curlen > 1 && arg[curlen-1] == '"')) {
1545 while (i < curlen) {
1546 if (isSPACE(arg[i])) {
1549 else if (arg[i] == '"') {
1573 && *arg == '/' /* see if arg is "/c", "/x/c", "/x/d/c" etc. */
1574 && stricmp(arg+curlen-2, "/c") == 0)
1576 /* is there a next argument? */
1577 if (args[index+1]) {
1578 /* are there two or more next arguments? */
1579 if (args[index+2]) {
1581 extra_quotes = TRUE;
1584 /* single argument, force quoting if it has spaces */
1600 qualified_path(const char *cmd)
1604 char *fullcmd, *curfullcmd;
1610 fullcmd = (char*)cmd;
1612 if (*fullcmd == '/' || *fullcmd == '\\')
1619 pathstr = PerlEnv_getenv("PATH");
1620 New(0, fullcmd, MAX_PATH+1, char);
1621 curfullcmd = fullcmd;
1626 /* start by appending the name to the current prefix */
1627 strcpy(curfullcmd, cmd);
1628 curfullcmd += cmdlen;
1630 /* if it doesn't end with '.', or has no extension, try adding
1631 * a trailing .exe first */
1632 if (cmd[cmdlen-1] != '.'
1633 && (cmdlen < 4 || cmd[cmdlen-4] != '.'))
1635 strcpy(curfullcmd, ".exe");
1636 res = GetFileAttributes(fullcmd);
1637 if (res != 0xFFFFFFFF && !(res & FILE_ATTRIBUTE_DIRECTORY))
1642 /* that failed, try the bare name */
1643 res = GetFileAttributes(fullcmd);
1644 if (res != 0xFFFFFFFF && !(res & FILE_ATTRIBUTE_DIRECTORY))
1647 /* quit if no other path exists, or if cmd already has path */
1648 if (!pathstr || !*pathstr || has_slash)
1651 /* skip leading semis */
1652 while (*pathstr == ';')
1655 /* build a new prefix from scratch */
1656 curfullcmd = fullcmd;
1657 while (*pathstr && *pathstr != ';') {
1658 if (*pathstr == '"') { /* foo;"baz;etc";bar */
1659 pathstr++; /* skip initial '"' */
1660 while (*pathstr && *pathstr != '"') {
1661 if ((STRLEN)(curfullcmd-fullcmd) < MAX_PATH-cmdlen-5)
1662 *curfullcmd++ = *pathstr;
1666 pathstr++; /* skip trailing '"' */
1669 if ((STRLEN)(curfullcmd-fullcmd) < MAX_PATH-cmdlen-5)
1670 *curfullcmd++ = *pathstr;
1675 pathstr++; /* skip trailing semi */
1676 if (curfullcmd > fullcmd /* append a dir separator */
1677 && curfullcmd[-1] != '/' && curfullcmd[-1] != '\\')
1679 *curfullcmd++ = '\\';
1687 /* The following are just place holders.
1688 * Some hosts may provide and environment that the OS is
1689 * not tracking, therefore, these host must provide that
1690 * environment and the current directory to CreateProcess
1694 win32_get_childenv(void)
1700 win32_free_childenv(void* d)
1705 win32_clearenv(void)
1707 char *envv = GetEnvironmentStrings();
1711 char *end = strchr(cur,'=');
1712 if (end && end != cur) {
1714 xcesetenv(cur, "", 0);
1716 cur = end + strlen(end+1)+2;
1718 else if ((len = strlen(cur)))
1721 FreeEnvironmentStrings(envv);
1725 win32_get_childdir(void)
1729 char szfilename[(MAX_PATH+1)*2];
1731 WCHAR wfilename[MAX_PATH+1];
1732 GetCurrentDirectoryW(MAX_PATH+1, wfilename);
1733 W2AHELPER(wfilename, szfilename, sizeof(szfilename));
1736 GetCurrentDirectoryA(MAX_PATH+1, szfilename);
1739 New(0, ptr, strlen(szfilename)+1, char);
1740 strcpy(ptr, szfilename);
1745 win32_free_childdir(char* d)
1751 /* XXX this needs to be made more compatible with the spawnvp()
1752 * provided by the various RTLs. In particular, searching for
1753 * *.{com,bat,cmd} files (as done by the RTLs) is unimplemented.
1754 * This doesn't significantly affect perl itself, because we
1755 * always invoke things using PERL5SHELL if a direct attempt to
1756 * spawn the executable fails.
1758 * XXX splitting and rejoining the commandline between do_aspawn()
1759 * and win32_spawnvp() could also be avoided.
1765 win32_spawnvp(int mode, const char *cmdname, const char *const *argv)
1767 #ifdef USE_RTL_SPAWNVP
1768 return spawnvp(mode, cmdname, (char * const *)argv);
1775 STARTUPINFO StartupInfo;
1776 PROCESS_INFORMATION ProcessInformation;
1779 char *fullcmd = Nullch;
1780 char *cname = (char *)cmdname;
1784 clen = strlen(cname);
1785 /* if command name contains dquotes, must remove them */
1786 if (strchr(cname, '"')) {
1788 New(0,cname,clen+1,char);
1801 cmd = create_command_line(cname, clen, argv);
1803 env = PerlEnv_get_childenv();
1804 dir = PerlEnv_get_childdir();
1807 case P_NOWAIT: /* asynch + remember result */
1808 if (w32_num_children >= MAXIMUM_WAIT_OBJECTS) {
1813 /* Create a new process group so we can use GenerateConsoleCtrlEvent()
1816 /* not supported on CE create |= CREATE_NEW_PROCESS_GROUP; */
1819 case P_WAIT: /* synchronous execution */
1821 default: /* invalid mode */
1826 memset(&StartupInfo,0,sizeof(StartupInfo));
1827 StartupInfo.cb = sizeof(StartupInfo);
1828 memset(&tbl,0,sizeof(tbl));
1829 PerlEnv_get_child_IO(&tbl);
1830 StartupInfo.dwFlags = tbl.dwFlags;
1831 StartupInfo.dwX = tbl.dwX;
1832 StartupInfo.dwY = tbl.dwY;
1833 StartupInfo.dwXSize = tbl.dwXSize;
1834 StartupInfo.dwYSize = tbl.dwYSize;
1835 StartupInfo.dwXCountChars = tbl.dwXCountChars;
1836 StartupInfo.dwYCountChars = tbl.dwYCountChars;
1837 StartupInfo.dwFillAttribute = tbl.dwFillAttribute;
1838 StartupInfo.wShowWindow = tbl.wShowWindow;
1839 StartupInfo.hStdInput = tbl.childStdIn;
1840 StartupInfo.hStdOutput = tbl.childStdOut;
1841 StartupInfo.hStdError = tbl.childStdErr;
1842 if (StartupInfo.hStdInput == INVALID_HANDLE_VALUE &&
1843 StartupInfo.hStdOutput == INVALID_HANDLE_VALUE &&
1844 StartupInfo.hStdError == INVALID_HANDLE_VALUE)
1846 create |= CREATE_NEW_CONSOLE;
1849 StartupInfo.dwFlags |= STARTF_USESTDHANDLES;
1851 if (w32_use_showwindow) {
1852 StartupInfo.dwFlags |= STARTF_USESHOWWINDOW;
1853 StartupInfo.wShowWindow = w32_showwindow;
1856 DEBUG_p(PerlIO_printf(Perl_debug_log, "Spawning [%s] with [%s]\n",
1859 if (!CreateProcess(cname, /* search PATH to find executable */
1860 cmd, /* executable, and its arguments */
1861 NULL, /* process attributes */
1862 NULL, /* thread attributes */
1863 TRUE, /* inherit handles */
1864 create, /* creation flags */
1865 (LPVOID)env, /* inherit environment */
1866 dir, /* inherit cwd */
1868 &ProcessInformation))
1870 /* initial NULL argument to CreateProcess() does a PATH
1871 * search, but it always first looks in the directory
1872 * where the current process was started, which behavior
1873 * is undesirable for backward compatibility. So we
1874 * jump through our own hoops by picking out the path
1875 * we really want it to use. */
1877 fullcmd = qualified_path(cname);
1879 if (cname != cmdname)
1882 DEBUG_p(PerlIO_printf(Perl_debug_log,
1883 "Retrying [%s] with same args\n",
1893 if (mode == P_NOWAIT) {
1894 /* asynchronous spawn -- store handle, return PID */
1895 ret = (int)ProcessInformation.dwProcessId;
1896 if (IsWin95() && ret < 0)
1899 w32_child_handles[w32_num_children] = ProcessInformation.hProcess;
1900 w32_child_pids[w32_num_children] = (DWORD)ret;
1905 win32_msgwait(aTHX_ 1, &ProcessInformation.hProcess, INFINITE, NULL);
1906 /* FIXME: if msgwait returned due to message perhaps forward the
1907 "signal" to the process
1909 GetExitCodeProcess(ProcessInformation.hProcess, &status);
1911 CloseHandle(ProcessInformation.hProcess);
1914 CloseHandle(ProcessInformation.hThread);
1917 PerlEnv_free_childenv(env);
1918 PerlEnv_free_childdir(dir);
1920 if (cname != cmdname)
1927 win32_execv(const char *cmdname, const char *const *argv)
1930 Perl_croak(aTHX_ PL_no_func, "execv");
1935 win32_execvp(const char *cmdname, const char *const *argv)
1938 Perl_croak(aTHX_ PL_no_func, "execvp");
1943 win32_dynaload(const char* filename)
1948 hModule = XCELoadLibraryA(filename);
1953 /* this is needed by Cwd.pm... */
1960 SV *sv = sv_newmortal();
1962 xcegetcwd(buf, sizeof(buf));
1964 sv_setpv(sv, xcestrdup(buf));
1968 #ifndef INCOMPLETE_TAINTS
1969 SvTAINTED_on(ST(0));
1980 Perl_croak(aTHX_ "usage: Win32::SetCwd($cwd)");
1982 if (!xcechdir(SvPV_nolen(ST(0))))
1989 XS(w32_GetTickCount)
1992 DWORD msec = GetTickCount();
2000 XS(w32_GetOSVersion)
2003 OSVERSIONINFOA osver;
2005 osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
2006 if (!XCEGetVersionExA(&osver)) {
2009 XPUSHs(newSVpvn(osver.szCSDVersion, strlen(osver.szCSDVersion)));
2010 XPUSHs(newSViv(osver.dwMajorVersion));
2011 XPUSHs(newSViv(osver.dwMinorVersion));
2012 XPUSHs(newSViv(osver.dwBuildNumber));
2014 XPUSHs(newSViv(osver.dwPlatformId));
2023 XSRETURN_IV(IsWinNT());
2031 XSRETURN_IV(IsWin95());
2039 XSRETURN_IV(IsWinCE());
2049 if(SystemParametersInfoW(SPI_GETOEMINFO, sizeof(wbuf), wbuf, FALSE))
2050 WideCharToMultiByte(CP_ACP, 0, wbuf, -1, buf, sizeof(buf), 0, 0);
2052 sprintf(buf, "SystemParametersInfo failed: %d", GetLastError());
2063 Perl_croak(aTHX_ "usage: Win32::Sleep($milliseconds)");
2074 Perl_croak(aTHX_ "usage: Win32::CopyFile($from, $to, $overwrite)");
2077 char szSourceFile[MAX_PATH+1];
2078 strcpy(szSourceFile, PerlDir_mapA(SvPV_nolen(ST(0))));
2079 bResult = XCECopyFileA(szSourceFile, SvPV_nolen(ST(1)),
2096 unsigned int flags = MB_OK;
2098 txt = SvPV_nolen(ST(0));
2100 if (items < 1 || items > 2)
2101 Perl_croak(aTHX_ "usage: Win32::MessageBox($txt, [$flags])");
2104 flags = SvIV(ST(1));
2106 res = XCEMessageBoxA(NULL, txt, "Perl", flags);
2112 XS(w32_GetPowerStatus)
2116 SYSTEM_POWER_STATUS_EX sps;
2118 if(GetSystemPowerStatusEx(&sps, TRUE) == FALSE)
2123 XPUSHs(newSViv(sps.ACLineStatus));
2124 XPUSHs(newSViv(sps.BatteryFlag));
2125 XPUSHs(newSViv(sps.BatteryLifePercent));
2126 XPUSHs(newSViv(sps.BatteryLifeTime));
2127 XPUSHs(newSViv(sps.BatteryFullLifeTime));
2128 XPUSHs(newSViv(sps.BackupBatteryFlag));
2129 XPUSHs(newSViv(sps.BackupBatteryLifePercent));
2130 XPUSHs(newSViv(sps.BackupBatteryLifeTime));
2131 XPUSHs(newSViv(sps.BackupBatteryFullLifeTime));
2143 SHELLEXECUTEINFO si;
2145 wchar_t wfile[MAX_PATH];
2149 Perl_croak(aTHX_ "usage: Win32::ShellEx($file, $verb)");
2151 file = SvPV_nolen(ST(0));
2152 verb = SvPV_nolen(ST(1));
2154 memset(&si, 0, sizeof(si));
2155 si.cbSize = sizeof(si);
2156 si.fMask = SEE_MASK_FLAG_NO_UI;
2158 MultiByteToWideChar(CP_ACP, 0, verb, -1,
2159 wverb, sizeof(wverb)/2);
2160 si.lpVerb = (TCHAR *)wverb;
2162 MultiByteToWideChar(CP_ACP, 0, file, -1,
2163 wfile, sizeof(wfile)/2);
2164 si.lpFile = (TCHAR *)wfile;
2166 if(ShellExecuteEx(&si) == FALSE)
2175 Perl_init_os_extras(void)
2178 char *file = __FILE__;
2181 w32_perlshell_tokens = Nullch;
2182 w32_perlshell_items = -1;
2183 w32_fdpid = newAV(); /* XX needs to be in Perl_win32_init()? */
2184 New(1313, w32_children, 1, child_tab);
2185 w32_num_children = 0;
2187 newXS("Win32::GetCwd", w32_GetCwd, file);
2188 newXS("Win32::SetCwd", w32_SetCwd, file);
2189 newXS("Win32::GetTickCount", w32_GetTickCount, file);
2190 newXS("Win32::GetOSVersion", w32_GetOSVersion, file);
2192 newXS("Win32::ShellEx", w32_ShellEx, file);
2194 newXS("Win32::IsWinNT", w32_IsWinNT, file);
2195 newXS("Win32::IsWin95", w32_IsWin95, file);
2196 newXS("Win32::IsWinCE", w32_IsWinCE, file);
2197 newXS("Win32::CopyFile", w32_CopyFile, file);
2198 newXS("Win32::Sleep", w32_Sleep, file);
2199 newXS("Win32::MessageBox", w32_MessageBox, file);
2200 newXS("Win32::GetPowerStatus", w32_GetPowerStatus, file);
2201 newXS("Win32::GetOemInfo", w32_GetOemInfo, file);
2210 fgets(buf, sizeof(buf), stdin);
2214 Perl_win32_init(int *argcp, char ***argvp)
2219 if((p = xcegetenv("PERLDEBUG")) && (p[0] == 'y' || p[0] == 'Y'))
2227 Perl_win32_term(void)
2234 win32_get_child_IO(child_IO_table* ptbl)
2236 ptbl->childStdIn = GetStdHandle(STD_INPUT_HANDLE);
2237 ptbl->childStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
2238 ptbl->childStdErr = GetStdHandle(STD_ERROR_HANDLE);
2241 win32_flock(int fd, int oper)
2244 Perl_croak(aTHX_ PL_no_func, "flock");
2249 win32_waitpid(int pid, int *status, int flags)
2252 Perl_croak(aTHX_ PL_no_func, "waitpid");
2257 win32_wait(int *status)
2260 Perl_croak(aTHX_ PL_no_func, "wait");
2265 Perl_do_spawn(pTHX_ char *cmd)
2267 return do_spawn(aTHX_ cmd);
2271 Perl_do_aspawn(pTHX_ SV *really, SV **mark, SV **sp)
2273 Perl_croak(aTHX_ PL_no_func, "aspawn");
2278 wce_reopen_stdout(char *fname)
2280 if(xcefreopen(fname, "w", stdout) == NULL)
2291 printf("Hit RETURN");
2293 fgets(buf, sizeof(buf), stdin);
2297 /* //////////////////////////////////////////////////////////////////// */
2302 getcwd(char *buf, size_t size)
2304 return xcegetcwd(buf, size);
2314 win32_open_osfhandle(intptr_t osfhandle, int flags)
2317 char fileflags=0; /* _osfile flags */
2319 Perl_croak_nocontext("win32_open_osfhandle() TBD on this platform");
2324 win32_get_osfhandle(int fd)
2327 char fileflags=0; /* _osfile flags */
2329 Perl_croak_nocontext("win32_get_osfhandle() TBD on this platform");
2334 * a popen() clone that respects PERL5SHELL
2336 * changed to return PerlIO* rather than FILE * by BKS, 11-11-2000
2340 win32_popen(const char *command, const char *mode)
2342 Perl_croak_nocontext("win32_popen() TBD on this platform");
2346 win32_popenlist(const char *mode, IV narg, SV **args)
2349 Perl_croak(aTHX_ "List form of pipe open not implemented");
2358 win32_pclose(PerlIO *pf)
2360 #ifdef USE_RTL_POPEN
2364 int childpid, status;
2368 sv = *av_fetch(w32_fdpid, PerlIO_fileno(pf), TRUE);
2371 childpid = SvIVX(sv);
2388 if (win32_waitpid(childpid, &status, 0) == -1)
2393 #endif /* USE_RTL_POPEN */
2397 win32_fdupopen(FILE *pf)
2402 int fileno = win32_dup(win32_fileno(pf));
2404 XCEMessageBoxA(NULL, "NEED TO IMPLEMENT a place in .../wince/wince.c(win32_fdupopen)", "Perl(developer)", 0);
2405 Perl_croak_nocontext("win32_fdupopen() TBD on this platform");
2408 /* open the file in the same mode */
2409 if((pf)->_flag & _IOREAD) {
2413 else if((pf)->_flag & _IOWRT) {
2417 else if((pf)->_flag & _IORW) {
2423 /* it appears that the binmode is attached to the
2424 * file descriptor so binmode files will be handled
2427 pfdup = win32_fdopen(fileno, mode);
2429 /* move the file pointer to the same position */
2430 if (!fgetpos(pf, &pos)) {
2431 fsetpos(pfdup, &pos);
2437 #ifdef HAVE_INTERP_INTERN
2441 win32_csighandler(int sig)
2444 dTHXa(PERL_GET_SIG_CONTEXT);
2445 Perl_warn(aTHX_ "Got signal %d",sig);
2451 Perl_sys_intern_init(pTHX)
2454 w32_perlshell_tokens = Nullch;
2455 w32_perlshell_vec = (char**)NULL;
2456 w32_perlshell_items = 0;
2457 w32_fdpid = newAV();
2458 New(1313, w32_children, 1, child_tab);
2459 w32_num_children = 0;
2460 # ifdef USE_ITHREADS
2462 New(1313, w32_pseudo_children, 1, child_tab);
2463 w32_num_pseudo_children = 0;
2465 w32_init_socktype = 0;
2471 Perl_sys_intern_clear(pTHX)
2473 Safefree(w32_perlshell_tokens);
2474 Safefree(w32_perlshell_vec);
2475 /* NOTE: w32_fdpid is freed by sv_clean_all() */
2476 Safefree(w32_children);
2478 KillTimer(NULL,w32_timerid);
2481 # ifdef USE_ITHREADS
2482 Safefree(w32_pseudo_children);
2486 # ifdef USE_ITHREADS
2489 Perl_sys_intern_dup(pTHX_ struct interp_intern *src, struct interp_intern *dst)
2491 dst->perlshell_tokens = Nullch;
2492 dst->perlshell_vec = (char**)NULL;
2493 dst->perlshell_items = 0;
2494 dst->fdpid = newAV();
2495 Newz(1313, dst->children, 1, child_tab);
2497 Newz(1313, dst->pseudo_children, 1, child_tab);
2498 dst->thr_intern.Winit_socktype = 0;
2500 dst->poll_count = 0;
2501 Copy(src->sigtable,dst->sigtable,SIG_SIZE,Sighandler_t);
2503 # endif /* USE_ITHREADS */
2504 #endif /* HAVE_INTERP_INTERN */
2507 win32_free_argvw(pTHX_ void *ptr)
2509 char** argv = (char**)ptr;
2517 win32_argv2utf8(int argc, char** argv)
2519 /* do nothing, since we're not aware of command line arguments
2526 Perl_sys_intern_clear(pTHX)
2528 Safefree(w32_perlshell_tokens);
2529 Safefree(w32_perlshell_vec);
2530 /* NOTE: w32_fdpid is freed by sv_clean_all() */
2531 Safefree(w32_children);
2532 # ifdef USE_ITHREADS
2533 Safefree(w32_pseudo_children);
2538 // added to remove undefied symbol error in CodeWarrior compilation
2540 Perl_Ireentrant_buffer_ptr(aTHX)