diff options
author | Benjamin Stuhl <sho_pi@hotmail.com> | 2000-11-13 07:08:08 -0800 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2000-11-14 01:21:09 +0000 |
commit | e4f5f122ab7cc3be1192952bdb2a1d5866d09862 (patch) | |
tree | 5cf09c48cc83a16ea460db17f84afc45830116d0 /win32 | |
parent | 3665706c6eea33eebf9fc30d19a4d0ef49721b3c (diff) | |
download | perl-e4f5f122ab7cc3be1192952bdb2a1d5866d09862.tar.gz |
Get PerlIO building on Win32
Message-ID: <20001113230808.18659.qmail@web6305.mail.yahoo.com>
p4raw-id: //depot/perl@7679
Diffstat (limited to 'win32')
-rw-r--r-- | win32/Makefile | 90 | ||||
-rw-r--r-- | win32/bin/mdelete.bat | 30 | ||||
-rw-r--r-- | win32/config.gc | 2 | ||||
-rw-r--r-- | win32/config.vc | 2 | ||||
-rw-r--r-- | win32/win32.c | 51 | ||||
-rw-r--r-- | win32/win32.h | 1 | ||||
-rw-r--r-- | win32/win32sck.c | 39 |
7 files changed, 172 insertions, 43 deletions
diff --git a/win32/Makefile b/win32/Makefile index af119909e8..121f8c8622 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -63,6 +63,12 @@ INST_ARCH = \$(ARCHNAME) #USE_IMP_SYS = define # +# uncomment to enable the experimental PerlIO I/O subsystem.
+# This is currently incompatible with USE_MULTI, USE_ITHREADS,
+# and USE_IMP_SYS
+#USE_PERLIO = define
+
+#
# WARNING! This option is deprecated and will eventually go away (enable # USE_ITHREADS instead). # @@ -273,10 +279,18 @@ ARCHNAME = MSWin32-$(PROCESSOR_ARCHITECTURE)-thread !IF "$(USE_MULTI)" == "define" ARCHNAME = MSWin32-$(PROCESSOR_ARCHITECTURE)-multi !ELSE +!IF "$(USE_PERLIO)" == "define"
+ARCHNAME = MSWin32-$(PROCESSOR_ARCHITECTURE)-perlio
+!ELSE
ARCHNAME = MSWin32-$(PROCESSOR_ARCHITECTURE) !ENDIF !ENDIF !ENDIF +!ENDIF
+
+!IF "$(USE_PERLIO)" == "define"
+BUILDOPT = $(BUILDOPT) -DUSE_PERLIO
+!ENDIF
!IF "$(USE_ITHREADS)" == "define" ARCHNAME = $(ARCHNAME)-thread @@ -465,6 +479,8 @@ RCOPY = xcopy /f /r /i /e /d NOOP = @echo NULL = +DEL = bin\mdelete.bat
+
# # filenames given to xsubpp must have forward slashes (since it puts # full pathnames in #line strings) @@ -691,8 +707,8 @@ CFG_VARS = \ "INST_ARCH=$(INST_ARCH)" \ "archname=$(ARCHNAME)" \ "cc=$(CC)" \ - "ccflags=$(OPTIMIZE:"=\") $(DEFINES) $(BUILDOPT)" \ - "cf_email=$(EMAIL)" \ + "ccflags=-nologo -Gf -W3 $(OPTIMIZE:"=\") $(DEFINES) $(BUILDOPT)" \
+ "cf_email=$(EMAIL)" \
"d_crypt=$(D_CRYPT)" \ "d_mymalloc=$(PERL_MALLOC)" \ "libs=$(LIBFILES)" \ @@ -753,14 +769,16 @@ regen_config_h: rename config.h $(CFGH_TMPL) $(CONFIGPM) : $(MINIPERL) ..\config.sh config_h.PL ..\minimod.pl - cd .. && miniperl configpm + cd ..
+ miniperl configpm
+ cd win32
if exist lib\* $(RCOPY) lib\*.* ..\lib\$(NULL) $(XCOPY) ..\*.h $(COREDIR)\*.* $(XCOPY) *.h $(COREDIR)\*.* $(XCOPY) ..\ext\re\re.pm $(LIBDIR)\*.* $(RCOPY) include $(COREDIR)\*.* - $(MINIPERL) -I..\lib config_h.PL "INST_VER=$(INST_VER)" \ - || $(MAKE) /$(MAKEFLAGS) $(CONFIGPM) + -$(MINIPERL) -I..\lib config_h.PL "INST_VER=$(INST_VER)"
+ if errorlevel 1 $(MAKE) /$(MAKEFLAGS) $(CONFIGPM)
$(MINIPERL) : $(MINIDIR) $(MINI_OBJ) $(LINK32) -subsystem:console -out:$@ @<< @@ -803,7 +821,9 @@ $(PERLDLL): perldll.def $(PERLDLL_OBJ) $(PERLDLL_RES) $(XCOPY) $(PERLIMPLIB) $(COREDIR) $(MINIMOD) : $(MINIPERL) ..\minimod.pl - cd .. && miniperl minimod.pl > lib\ExtUtils\Miniperl.pm + cd ..
+ miniperl minimod.pl > lib\ExtUtils\Miniperl.pm
+ cd win32
..\x2p\a2p$(o) : ..\x2p\a2p.c $(CC) -I..\x2p $(CFLAGS) $(OBJOUT_FLAG)$@ -c ..\x2p\a2p.c @@ -1004,10 +1024,14 @@ distclean: clean -del /f $(LIBDIR)\Devel\Peek.pm $(LIBDIR)\Devel\DProf.pm -del /f $(LIBDIR)\File\Glob.pm -del /f $(LIBDIR)\Storable.pm - -if exist $(LIBDIR)\IO rmdir /s /q $(LIBDIR)\IO || rmdir /s $(LIBDIR)\IO - -if exist $(LIBDIR)\Thread rmdir /s /q $(LIBDIR)\Thread || rmdir /s $(LIBDIR)\Thread - -if exist $(LIBDIR)\B rmdir /s /q $(LIBDIR)\B || rmdir /s $(LIBDIR)\B - -if exist $(LIBDIR)\Data rmdir /s /q $(LIBDIR)\Data || rmdir /s $(LIBDIR)\Data + -if exist $(LIBDIR)\IO rmdir /s /q $(LIBDIR)\IO
+ -rmdir /s $(LIBDIR)\IO
+ -if exist $(LIBDIR)\Thread rmdir /s /q $(LIBDIR)\Thread
+ -rmdir /s $(LIBDIR)\Thread
+ -if exist $(LIBDIR)\B rmdir /s /q $(LIBDIR)\B
+ -rmdir /s $(LIBDIR)\B
+ -if exist $(LIBDIR)\Data rmdir /s /q $(LIBDIR)\Data
+ -rmdir /s $(LIBDIR)\Data
-del /f $(PODDIR)\*.html -del /f $(PODDIR)\*.bat cd ..\utils @@ -1024,8 +1048,10 @@ distclean: clean cd $(EXTDIR) -del /s *.lib *.def *.map *.pdb *.bs Makefile *$(o) pm_to_blib cd ..\win32 - -if exist $(AUTODIR) rmdir /s /q $(AUTODIR) || rmdir /s $(AUTODIR) - -if exist $(COREDIR) rmdir /s /q $(COREDIR) || rmdir /s $(COREDIR) + -if exist $(AUTODIR) rmdir /s /q $(AUTODIR)
+ -rmdir /s $(AUTODIR)
+ -if exist $(COREDIR) rmdir /s /q $(COREDIR)
+ -rmdir /s $(COREDIR)
install : all installbare installhtml @@ -1082,26 +1108,26 @@ test-wide-notty : test-prep cd ..\win32 clean : - -@erase miniperlmain$(o) - -@erase $(MINIPERL) - -@erase perlglob$(o) - -@erase perlmain$(o) - -@erase config.w32 - -@erase /f config.h - -@erase $(GLOBEXE) - -@erase $(PERLEXE) - -@erase $(WPERLEXE) - -@erase $(PERLDLL) - -@erase $(CORE_OBJ) - -if exist $(MINIDIR) rmdir /s /q $(MINIDIR) || rmdir /s $(MINIDIR) - -@erase $(WIN32_OBJ) - -@erase $(DLL_OBJ) - -@erase $(X2P_OBJ) - -@erase ..\*$(o) ..\*.lib ..\*.exp *$(o) *.lib *.exp *.res - -@erase ..\t\*.exe ..\t\*.dll ..\t\*.bat - -@erase ..\x2p\*.exe ..\x2p\*.bat - -@erase *.ilk - -@erase *.pdb + -@$(DEL) miniperlmain$(o)
+ -@$(DEL) $(MINIPERL)
+ -@$(DEL) perlglob$(o)
+ -@$(DEL) perlmain$(o)
+ -@$(DEL) config.w32
+ -@$(DEL) /f config.h
+ -@$(DEL) $(GLOBEXE)
+ -@$(DEL) $(PERLEXE)
+ -@$(DEL) $(WPERLEXE)
+ -@$(DEL) $(PERLDLL)
+ -@$(DEL) $(CORE_OBJ)
+ -if exist $(MINIDIR) deltree /y $(MINIDIR)
+ -@$(DEL) $(WIN32_OBJ)
+ -@$(DEL) $(DLL_OBJ)
+ -@$(DEL) $(X2P_OBJ)
+ -@$(DEL) ..\*$(o) ..\*.lib ..\*.exp *$(o) *.lib *.exp *.res
+ -@$(DEL) ..\t\*.exe ..\t\*.dll ..\t\*.bat
+ -@$(DEL) ..\x2p\*.exe ..\x2p\*.bat
+ -@$(DEL) *.ilk
+ -@$(DEL) *.pdb
# Handy way to run perlbug -ok without having to install and run the # installed perlbug. We don't re-run the tests here - we trust the user. diff --git a/win32/bin/mdelete.bat b/win32/bin/mdelete.bat new file mode 100644 index 0000000000..99b1c3dbf0 --- /dev/null +++ b/win32/bin/mdelete.bat @@ -0,0 +1,30 @@ +@echo off
+rem ! This is a batch file to delete all the files on its
+rem ! command line, to work around command.com's del command's
+rem ! braindeadness
+rem !
+rem ! -- BKS, 11-11-2000
+
+:nextfile
+set file=%1
+shift
+if "%file%"=="" goto end
+del %file%
+goto nextfile
+:end
+
+@echo off
+rem ! This is a batch file to delete all the files on its
+rem ! command line, to work around command.com's del command's
+rem ! braindeadness
+rem !
+rem ! -- BKS, 11-11-2000
+
+:nextfile
+set file=%1
+shift
+if "%file%"=="" goto end
+del %file%
+goto nextfile
+:end
+
diff --git a/win32/config.gc b/win32/config.gc index ffb3a7f981..171f153844 100644 --- a/win32/config.gc +++ b/win32/config.gc @@ -323,7 +323,7 @@ d_statvfs='undef' d_stdio_cnt_lval='define' d_stdio_ptr_lval='define' d_stdio_ptr_lval_sets_cnt='undef' -d_stdio_ptr_lval_nochange_cnt='undef' +d_stdio_ptr_lval_nochange_cnt='define'
d_stdio_stream_array='undef' d_stdiobase='define' d_stdstdio='define' diff --git a/win32/config.vc b/win32/config.vc index 042bcc0526..6ec27fdab4 100644 --- a/win32/config.vc +++ b/win32/config.vc @@ -323,7 +323,7 @@ d_statvfs='undef' d_stdio_cnt_lval='define' d_stdio_ptr_lval='define' d_stdio_ptr_lval_sets_cnt='undef' -d_stdio_ptr_lval_nochange_cnt='undef' +d_stdio_ptr_lval_nochange_cnt='define'
d_stdio_stream_array='undef' d_stdiobase='define' d_stdstdio='define' diff --git a/win32/win32.c b/win32/win32.c index 2b31878a52..e4e553c36e 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -977,6 +977,31 @@ chown(const char *path, uid_t owner, gid_t group) return 0; } +/*
+ * XXX this needs strengthening (for PerlIO)
+ * -- BKS, 11-11-200
+*/
+int mkstemp(const char *path)
+{
+ dTHX;
+ char buf[MAX_PATH+1];
+ int i = 0, fd = -1;
+
+retry:
+ if (i++ > 10) { /* give up */
+ errno = ENOENT;
+ return -1;
+ }
+ if (!GetTempFileNameA((LPCSTR)path, "plr", 1, buf)) {
+ errno = ENOENT;
+ return -1;
+ }
+ fd = PerlLIO_open3(buf, O_CREAT|O_RDWR|O_EXCL, 0600);
+ if (fd == -1)
+ goto retry;
+ return fd;
+}
+
static long find_pid(int pid) { @@ -2106,7 +2131,6 @@ win32_str_os_error(void *sv, DWORD dwErr) } } - DllExport int win32_fprintf(FILE *fp, const char *format, ...) { @@ -2341,9 +2365,11 @@ win32_pipe(int *pfd, unsigned int size, int mode) /* * a popen() clone that respects PERL5SHELL + *
+ * changed to return PerlIO* rather than FILE * by BKS, 11-11-2000
*/ -DllExport FILE* +DllExport PerlIO*
win32_popen(const char *command, const char *mode) { #ifdef USE_RTL_POPEN @@ -2417,7 +2443,11 @@ win32_popen(const char *command, const char *mode) } /* we have an fd, return a file stream */ - return (win32_fdopen(p[parent], (char *)mode)); +#ifdef USE_PERLIO
+ return (PerlIO_fdopen(p[parent], (char *)mode));
+#else
+ return (fdopen(p[parent], (char *)mode));
+#endif
cleanup: /* we don't need to check for errors here */ @@ -2437,7 +2467,7 @@ cleanup: */ DllExport int -win32_pclose(FILE *pf) +win32_pclose(PerlIO *pf)
{ #ifdef USE_RTL_POPEN return _pclose(pf); @@ -2447,7 +2477,7 @@ win32_pclose(FILE *pf) SV *sv; LOCK_FDPID_MUTEX; - sv = *av_fetch(w32_fdpid, win32_fileno(pf), TRUE); + sv = *av_fetch(w32_fdpid, PerlIO_fileno(pf), TRUE);
if (SvIOK(sv)) childpid = SvIVX(sv); @@ -2459,7 +2489,11 @@ win32_pclose(FILE *pf) return -1; } - win32_fclose(pf); +#ifdef USE_PERLIO
+ PerlIO_close(pf);
+#else
+ fclose(pf);
+#endif
SvIVX(sv) = 0; UNLOCK_FDPID_MUTEX; @@ -2721,10 +2755,13 @@ win32_open(const char *path, int flag, ...) return open(PerlDir_mapA(path), flag, pmode); } +/* close() that understands socket */
+extern int my_close(int); /* in win32sck.c */
+
DllExport int win32_close(int fd) { - return close(fd); + return my_close(fd);
} DllExport int diff --git a/win32/win32.h b/win32/win32.h index d9ffbfe1a1..808191a30c 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -302,6 +302,7 @@ extern int kill(int pid, int sig); extern void *sbrk(int need); extern char * getlogin(void); extern int chown(const char *p, uid_t o, gid_t g); +extern int mkstemp(const char *path);
#undef Stat #define Stat win32_stat diff --git a/win32/win32sck.c b/win32/win32sck.c index 3b81d8bcae..4a4131c1b1 100644 --- a/win32/win32sck.c +++ b/win32/win32sck.c @@ -418,6 +418,41 @@ win32_socket(int af, int type, int protocol) return s; } +/*
+ * close RTL fd while respecting sockets
+ * added as temporary measure until PerlIO has real
+ * Win32 native layer
+ * -- BKS, 11-11-2000
+*/
+
+int my_close(int fd)
+{
+ int osf;
+ if (!wsock_started) /* No WinSock? */
+ return(close(fd)); /* Then not a socket. */
+ osf = TO_SOCKET(fd);/* Get it now before it's gone! */
+ if (osf != -1) {
+ int err;
+ err = closesocket(osf);
+ if (err == 0) {
+#if defined(USE_FIXED_OSFHANDLE) || defined(PERL_MSVCRT_READFIX)
+ _set_osfhnd(fd, INVALID_HANDLE_VALUE);
+#endif
+ (void)close(fd); /* handle already closed, ignore error */
+ return 0;
+ }
+ else if (err == SOCKET_ERROR) {
+ err = WSAGetLastError();
+ if (err != WSAENOTSOCK) {
+ (void)close(fd);
+ errno = err;
+ return EOF;
+ }
+ }
+ }
+ return close(fd);
+}
+
#undef fclose int my_fclose (FILE *pf) @@ -425,14 +460,14 @@ my_fclose (FILE *pf) int osf; if (!wsock_started) /* No WinSock? */ return(fclose(pf)); /* Then not a socket. */ - osf = TO_SOCKET(fileno(pf));/* Get it now before it's gone! */ + osf = TO_SOCKET(win32_fileno(pf));/* Get it now before it's gone! */
if (osf != -1) { int err; win32_fflush(pf); err = closesocket(osf); if (err == 0) { #if defined(USE_FIXED_OSFHANDLE) || defined(PERL_MSVCRT_READFIX) - _set_osfhnd(fileno(pf), INVALID_HANDLE_VALUE); + _set_osfhnd(win32_fileno(pf), INVALID_HANDLE_VALUE);
#endif (void)fclose(pf); /* handle already closed, ignore error */ return 0; |