From: Vadim Konovalov Date: Fri, 25 Jul 2003 22:17:11 +0000 (+0400) Subject: WinCE port addition X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8f33b42a5befbbd0d1d798a463bfe4ac2ba9bf10;p=p5sagit%2Fp5-mst-13.2.git WinCE port addition From: "Konovalov, Vadim" Message-ID: <845FCFF2D4C0FC468B485E8777C7A00C200D42@cio-test001.spb.lucent.com> p4raw-id: //depot/perl@20219 --- diff --git a/MANIFEST b/MANIFEST index e68ad81..7a2799a 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2984,7 +2984,6 @@ wince/perl.rc WinCE port wince/perlhost.h Perl "host" implementation wince/perllib.c WinCE port wince/perlmain.c WinCE port -wince/README.compile WinCE port wince/README.perlce WinCE port wince/registry.bat WinCE port wince/runperl.c WinCE port diff --git a/README.ce b/README.ce index 23378a9..e8d4c49 100644 --- a/README.ce +++ b/README.ce @@ -16,12 +16,16 @@ software is distributed. This section describes the steps to be performed to build PerlCE. You may find additional and newer information about building perl -for WincE using following URL: +for WinCE using following URL: http://perlce.sourceforge.net There should also be pre-built binaries there. +Don't be confused by large size of downloaded distribution or constructed +binaries: entire distribution could be large for WinCE ideology, but +you may strip it at your wish and use only required parts. + =head2 Tools & SDK For compiling, you need following: @@ -57,11 +61,7 @@ nmake -f makefile.ce with appropriate parameters and it accepts extra parameters and forwards them to "nmake" command as additional arguments. You should pass target this way. -Currently default target build all required perls, also there exists -target 'dist' that prepares distribution file set. Other targets -are currently in development stage. - -So, to prepare distribution you need to do following: +To prepare distribution you need to do following: =over 4 @@ -77,8 +77,54 @@ So, to prepare distribution you need to do following: =back -Before you start, you need to build celib.dll and w32console. -See instructions in these packages for building. +makefile.ce has CROSS_NAME macro, and it is used further to refer to +your cross-compilation scheme. You could assign a name to it, but this +is not necessary, because by default it is assigned after your machine +configuration name, such as "wince-sh3-hpc-wce211", and this is enough +to distinguish different builds at the same time. This option could be +handy for several different builds on same platform to perform, say, +threaded build. In a following example we assume that all required +environment variables are set properly for C cross-compiler (a special +*.bat file could fit perfectly to this purpose) and your compile.bat +has proper "MACHINE" parameter set, to, say, "wince-mips-pocket-wce300". + + compile.bat + compile.bat dist + compile.bat CROSS_NAME=mips-wce300-thr "USE_ITHREADS=define" "USE_IMP_SYS=define" "USE_MULTI=define" + compile.bat CROSS_NAME=mips-wce300-thr "USE_ITHREADS=define" "USE_IMP_SYS=define" "USE_MULTI=define" dist + +If all goes okay and no errors during a build, you'll get two independent +distributions: "wince-mips-pocket-wce300" and "mips-wce300-thr". + +Target 'dist' prepares distribution file set. Target 'zipdist' performs +same as 'dist' but additionally compresses distribution files into zip +archive. + +NOTE: during a build there could be created a number (or one) of Config.pm +for cross-compilation ("foreign" Config.pm) and those are hidden inside +../xlib/$(CROSS_NAME) with other auxilary files, but, and this is important to +note, there should be *no* Config.pm for host miniperl. +If you'll get an error that perl could not find Config.pm somewhere in building +process this means something went wrong. Most probably you forgot to +specify a cross-compilation when invoking miniperl.exe to Makefile.PL +When building an extension for cross-compilation your command line should +look like + + ..\miniperl.exe -I..\lib -MCross=mips-wce300-thr Makefile.PL + +or just + + ..\miniperl.exe -I..\lib -MCross Makefile.PL + +to refer a cross-compilation that was created last time. + + +If you decided to build with fcrypt.c file, please refer to README.win32 +file, as long as all legal considerations and steps to do are exactly same +in this case. + +All questions related to building for WinCE devices could be asked in +perlce-users@lists.sourceforge.net mailing list. =head1 Acknowledgements diff --git a/wince/Makefile.ce b/wince/Makefile.ce index 5d45220..4115316 100644 --- a/wince/Makefile.ce +++ b/wince/Makefile.ce @@ -762,7 +762,7 @@ $(EXTDIR)\DynaLoader\dl_win32.xs: dl_win32.xs #---------------------------------------------------------------------------------- Extensions: ..\win32\buildext.pl $(PERLDEP) $(CONFIGPM) $(HPERL) -I..\lib -I..\win32 -MCross=$(CROSS_NAME) ..\win32\buildext.pl $(MAKE) $(PERLDEP) $(EXTDIR) \ - !POSIX !Time/HiRes !XS/Typemap + !POSIX Extensions_clean: -if exist $(MINIPERL) $(MINIPERL) -I..\lib buildext.pl $(MAKE) $(PERLDEP) $(EXTDIR) clean @@ -829,9 +829,6 @@ XDLLOBJS = $(XDLLOBJS) $(DLLDIR)\malloc.obj !IF "$(CRYPT_SRC)" != "" XDLLOBJS = $(XDLLOBJS) $(DLLDIR)\fcrypt.obj !ENDIF -!IF "$(CRYPT_SRC)" != "" -XDLLOBJS = $(XDLLOBJS) $(DLLDIR)\fcrypt.obj -!ENDIF {$(SRCDIR)}.c{$(DLLDIR)}.obj: $(CC) -c $(CFLAGS_O) -DPERL_EXTERNAL_GLOB -Fo$(DLLDIR)\ $< @@ -847,7 +844,7 @@ $(DLLDIR)\toke.obj: # -DPERL_IMPLICIT_SYS needs C++ for perllib.c # This is the only file that depends on perlhost.h, vmem.h, and vdir.h !IF "$(USE_IMP_SYS)" == "define" -$(DLLDIR)\perllib$(o) : perllib.c ..\win32\perlhost.h .\vdir.h .\vmem.h +$(DLLDIR)\perllib$(o) : perllib.c .\perlhost.h .\vdir.h .\vmem.h $(CC) -c -I. $(CFLAGS_O) $(CXX_FLAG) $(OBJOUT_FLAG)$@ perllib.c rem (frustrated) mv perllib.obj $(DLLDIR) !ENDIF diff --git a/wince/README.compile b/wince/README.compile deleted file mode 100644 index 3325402..0000000 --- a/wince/README.compile +++ /dev/null @@ -1,44 +0,0 @@ -Change config.ce. The makefile will automatically generate new -config.h. - -To generate a new Config.pm, delete config.h or -touch config.ce. - -The socket stuff has been rewritten so fds from ceio are used. This -makes it easy to use them as perl file handles. - -Socket and IO dlls compiled. Seem to work. - -The sequence for building a new target is: - -make -f Makefile.ce clean # clean up -make -f Makefile.ce all # build for target - -CROSS_NAME macro is provided to name your current cross compilation. -It is "wince" by default, but may be any other identifier to -differentiate and co-exist miscellaneous configurations. -So your command often will be - -make -f Makefile.ce all CROSS_NAME=[my-cross-name] - -It is implemented an easy way to build most of module extensions. -First, you need to do - - nmake host-install CROSS_NAME=[my-cross-name] - -This command will install a set of files into your perl directory. -That will allow you to do cross-compiling for your CE device. -Those files are C libraries, h-files, Cross.pm, Config.pm. Note -that it will use first found perl in your path. You should think about -your PATH variable and change it at your will before copying such files. - -After that to do cross-compiling you need to invoke - - perl -MCross Makefile.PL - -or - - perl -MCross=[my-cross-name] Makefile.PL - -to prepare Makefile, and then nmake, nmake install, as usually you do. -'test' tartget is still not ready. diff --git a/wince/README.perlce b/wince/README.perlce index dfe962f..34a3e37 100644 --- a/wince/README.perlce +++ b/wince/README.perlce @@ -58,8 +58,6 @@ PERLFILES files from a perl for win32 installation and put the distributed files into the right directories. - Do not copy any Win32/X86 dlls from your PC to the device... - The following files are a reasonable minimum if you want to do some socket stuff: diff --git a/wince/compile.bat b/wince/compile.bat index 72c7042..79ed2fb 100644 --- a/wince/compile.bat +++ b/wince/compile.bat @@ -6,7 +6,7 @@ rem set ARG-1=PV= set ARG-2=INST_VER= -set ARG-3=INSTALL_ROOT=\Storage Card\perl-tests\perl@19053 +set ARG-3=INSTALL_ROOT=\Storage Card\perl58m set ARG-4=WCEROOT=%SDKROOT% set ARG-5=CEPATH=%WCEROOT% set ARG-6=CELIBDLLDIR=d:\personal\pocketPC\celib-palm-3.0 diff --git a/wince/wince.c b/wince/wince.c index 675d9344..cb3c388 100644 --- a/wince/wince.c +++ b/wince/wince.c @@ -364,12 +364,6 @@ win32_signal(int sig, Sighandler_t subcode) return FALSE; } -DllExport void -win32_clearenv() -{ - return; -} - DllExport char *** win32_environ(void) @@ -610,13 +604,14 @@ win32_uname(struct utsname *name) void sig_terminate(pTHX_ int sig) { - Perl_warn(aTHX_ "Terminating on signal SIG%s(%d)\n",PL_sig_name[sig], sig); + Perl_warn(aTHX_ "Terminating on signal SIG%s(%d)\n",PL_sig_name[sig], sig); /* exit() seems to be safe, my_exit() or die() is a problem in ^C thread */ exit(sig); } +void DllExport int win32_async_check(pTHX) { @@ -638,7 +633,6 @@ win32_async_check(pTHX) goto Raise; break; #endif - /* We use WM_USER to fake kill() with other signals */ case WM_USER: { sig = msg.wParam; @@ -753,6 +747,41 @@ do_raise(pTHX_ int sig) return 1; } +/* Timing related stuff */ + +int +do_raise(pTHX_ int sig) +{ + if (sig < SIG_SIZE) { + Sighandler_t handler = w32_sighandler[sig]; + if (handler == SIG_IGN) { + return 0; + } + else if (handler != SIG_DFL) { + (*handler)(sig); + return 0; + } + else { + /* Choose correct default behaviour */ + switch (sig) { +#ifdef SIGCLD + case SIGCLD: +#endif +#ifdef SIGCHLD + case SIGCHLD: +#endif + case 0: + return 0; + case SIGTERM: + default: + break; + } + } + } + /* Tell caller to exit thread/process as approriate */ + return 1; +} + static UINT timerid = 0; static VOID CALLBACK TimerProc(HWND win, UINT msg, UINT id, DWORD time) @@ -1690,6 +1719,70 @@ qualified_path(const char *cmd) return Nullch; } +/* The following are just place holders. + * Some hosts may provide and environment that the OS is + * not tracking, therefore, these host must provide that + * environment and the current directory to CreateProcess + */ + +DllExport void* +win32_get_childenv(void) +{ + return NULL; +} + +DllExport void +win32_free_childenv(void* d) +{ +} + +DllExport void +win32_clearenv(void) +{ + char *envv = GetEnvironmentStrings(); + char *cur = envv; + STRLEN len; + while (*cur) { + char *end = strchr(cur,'='); + if (end && end != cur) { + *end = '\0'; + xcesetenv(cur, "", 0); + *end = '='; + cur = end + strlen(end+1)+2; + } + else if ((len = strlen(cur))) + cur += len+1; + } + FreeEnvironmentStrings(envv); +} + +DllExport char* +win32_get_childdir(void) +{ + dTHX; + char* ptr; + char szfilename[(MAX_PATH+1)*2]; + if (USING_WIDE()) { + WCHAR wfilename[MAX_PATH+1]; + GetCurrentDirectoryW(MAX_PATH+1, wfilename); + W2AHELPER(wfilename, szfilename, sizeof(szfilename)); + } + else { + GetCurrentDirectoryA(MAX_PATH+1, szfilename); + } + + New(0, ptr, strlen(szfilename)+1, char); + strcpy(ptr, szfilename); + return ptr; +} + +DllExport void +win32_free_childdir(char* d) +{ + dTHX; + Safefree(d); +} + /* XXX this needs to be made more compatible with the spawnvp() * provided by the various RTLs. In particular, searching for * *.{com,bat,cmd} files (as done by the RTLs) is unimplemented. @@ -2165,13 +2258,6 @@ Perl_win32_init(int *argcp, char ***argvp) MALLOC_INIT; } -void -Perl_win32_term(void) -{ - OP_REFCNT_TERM; - MALLOC_TERM; -} - DllExport void Perl_win32_term(void) { @@ -2211,12 +2297,6 @@ win32_wait(int *status) } int -do_spawn(char *cmd) -{ - return xcesystem(cmd); -} - -int Perl_do_spawn(pTHX_ char *cmd) { return do_spawn(aTHX_ cmd); diff --git a/wince/wince.h b/wince/wince.h index c82c7a6..f4264dd 100644 --- a/wince/wince.h +++ b/wince/wince.h @@ -64,6 +64,7 @@ XCE_EXPORT void XCEShowMessageA(const char *fmt, ...); #define ftime xceftime #define ctime xcectime #define gettimeofday xcegettimeofday +#define GetSystemTimeAsFileTime XCEGetSystemTimeAsFileTime XCE_EXPORT int xcesetuid(uid_t id); XCE_EXPORT int xceseteuid(uid_t id);