From 5db16f6aca34f97afbc0dca7253849c56c0c381d Mon Sep 17 00:00:00 2001 From: "Fifer, Eric" Date: Thu, 24 Feb 2000 17:15:28 +0000 Subject: [PATCH] cygwin port To: "'perl5-porters@perl.org'" Message-ID: <779F20BCCE5AD31186A50008C75D99791716E1@SILLDN_MAIL1> p4raw-id: //depot/cfgperl@5241 --- MANIFEST | 1 + Makefile.SH | 3 -- README.cygwin | 105 +++++++++++++++++++++++++++++++--------------------- cygwin/Makefile.SHs | 3 ++ cygwin/cygwin.c | 37 ++++++++++++++++++ hints/cygwin.sh | 6 ++- perl.c | 2 +- t/op/stat.t | 4 +- 8 files changed, 111 insertions(+), 50 deletions(-) create mode 100644 cygwin/cygwin.c diff --git a/MANIFEST b/MANIFEST index 38bf884..746a170 100644 --- a/MANIFEST +++ b/MANIFEST @@ -68,6 +68,7 @@ configure.com Configure-equivalent for VMS configure.gnu Crude emulation of GNU configure cop.h Control operator header cv.h Code value header +cygwin/cygwin.c Additional code for Cygwin port cygwin/Makefile.SHs Shared library generation for Cygwin port cygwin/ld2.in ld wrapper template for Cygwin port cygwin/perlld.in dll generator template for Cygwin port diff --git a/Makefile.SH b/Makefile.SH index e44f653..c4098eb 100644 --- a/Makefile.SH +++ b/Makefile.SH @@ -320,9 +320,6 @@ ext.libs: $(static_ext) # How to build libperl. This is still rather convoluted. # Load up custom Makefile.SH fragment for shared loading and executables: case "$osname" in -cygwin*) - Makefile_s="cygwin/Makefile.SHs" - ;; *) Makefile_s="$osname/Makefile.SHs" ;; diff --git a/README.cygwin b/README.cygwin index ab60a58..5a0be88 100644 --- a/README.cygwin +++ b/README.cygwin @@ -134,7 +134,7 @@ binaries to be stripped, you can either add a B<-s> option when Configure prompts you, Any additional ld flags (NOT including libraries)? [none] -s - Any special flags to pass to gcc to use dynamic loading? [none] -s + Any special flags to pass to gcc to use dynamic linking? [none] -s Any special flags to pass to ld2 to create a dynamically loaded library? [none] -s @@ -155,7 +155,7 @@ C. The crypt libraries in GNU libc have been ported to Cygwin. -The DES based Ultra Fast Crypt port was done by Alexey Truhan +The DES based Ultra Fast Crypt port was done by Alexey Truhan: http://dome.weeg.uiowa.edu/pub/domestic/sos/cw32crypt-dist-0.tgz @@ -183,12 +183,9 @@ F. =item * C<-lcygipc> (C) -A port of SysV IPC is available for Cygwin: - - http://www.multione.capgemini.fr/tools/pack_ipc/ - -The 1.3 release does not include ftok(), but code for ftok() can be -borrowed from glibc. +A port of SysV IPC is available for Cygwin. It has not been extensively +tested. In particular, C does not configure properly +because the configure test fails and on Win9x the shm*() functions hang. =back @@ -222,17 +219,17 @@ more than one interpreter instance. This works with the Cygwin port. The PerlIO abstraction works with the Cygwin port. -=item * C<-Duse64bits -Duselonglong> +=item * C<-Duse64bits> I supports 64-bit integers. However, several additional long long -functions are necessary to use them within Perl (I<{atol,strtoul}l>). +functions are necessary to use them within Perl (I<{strtol,strtoul}l>). These are B yet available with Cygwin. =item * C<-Duselongdouble> I supports long doubles (12 bytes). However, several additional long double math functions are necessary to use them within Perl -(I<{sqrt,pow,atan2,exp,fmod,log,cos,frexp,sin,floor,modf,atof}l>). +(I<{atan2,cos,exp,floor,fmod,frexp,log,modf,pow,sin,sqrt}l,strtold>). These are B yet available with Cygwin. =item * C<-Dusethreads> @@ -242,7 +239,7 @@ POSIX threads are B yet implemented in Cygwin. =item * C<-Duselargefiles> Although Win32 supports large files, Cygwin currently uses 32-bit ints -for internal size and positional calculations. +for internal size and position calculations. =back @@ -265,6 +262,21 @@ hint file. You should keep the recommended value. +=item * Win9x and d_eofnblk + +Win9x does not correctly report C with a non-blocking read on a +closed pipe. You will see the following messages: + + But it also returns -1 to signal EOF, so be careful! + WARNING: you can't distinguish between EOF and no data! + + *** WHOA THERE!!! *** + The recommended value for $d_eofnblk on this machine was "define"! + Keep the recommended value? [y] + +At least for consistency with WinNT, you should keep the recommended +value. + =item * Checking how std your stdio is... Configure reports: @@ -273,6 +285,8 @@ Configure reports: This is correct. +=back + =head1 MAKE Simply run make and wait: @@ -313,8 +327,8 @@ The same tests are run both times, but more information is provided when running as `C<./perl harness>'. Test results vary depending on your host system and your Cygwin -configuration. It is possible that Cygwin will pass all the tests, but it -is more likely that some tests will fail for one of the the reasons below. +configuration. It is possible that Cygwin will pass all the tests, +but it is more likely that some tests will fail for one of these reasons. =head2 File Permissions @@ -337,7 +351,6 @@ options, these tests will fail: lib/db-hash.t 16 lib/db-recno.t 18 lib/gdbm.t 2 - lib/glob-basic.t 9 (directory always readable) lib/ndbm.t 2 lib/odbm.t 2 lib/sdbm.t 2 @@ -391,7 +404,7 @@ directories (although, this is B recommended). =head2 /etc/group -Cygwin does not need F, in which case the F +Cygwin does not require F, in which case the F test will be skipped. The check performed by F expects to see entries that use the members field, otherwise this test will fail: @@ -401,18 +414,17 @@ see entries that use the members field, otherwise this test will fail: =head2 Unexplained Failures -Any additional tests that fail are likely due to bugs in Cygwin. It is -expected that by the time of the next net release most of these will -be solved so they are not described here. None of the current bugs are -serious enough that workarounds are needed. +Any additional tests that fail are likely due to bugs in Cygwin or the +optional libraries. It is expected that by the time of the next net +release most of these will be solved so they are not described here. =head2 Script Portability -Cygwin does an outstanding job of providing UNIX-like semantics on top -of Win32 systems. However, in addition to the items noted above, there -are some differences that you should know about. This is only a very -brief guide to portability, more information about Cygwin can be found -in the Cygwin documentation. +Cygwin does an outstanding job of providing UNIX-like semantics on +top of Win32 systems. However, in addition to the items noted above, +there are some differences that you should know about. This is only a +very brief guide to portability, more information can be found in the +Cygwin documentation. =over 4 @@ -439,15 +451,17 @@ F provided by Sergey Okhapkin at: =item * Text/Binary When a file is opened it is in either text or binary mode. In text mode -it is subject to CR/LF/Ctrl-Z translations. Perl provides a binmode() -function to force binary mode on files that otherwise would be treated -as text. With Cygwin, the default mode for an open() is determined by the -mode of the mount that underlies a file. For binmode() to be effective, -the underlying mount must be text. There is no way to force text mode -on a file underneath a binary mount. The text/binary issue is covered -at length in the Cygwin documentation. +a file is subject to CR/LF/Ctrl-Z translations. With Cygwin, the default +mode for an open() is determined by the mode of the mount that underlies +the file. Perl provides a binmode() function to set binary mode on files +that otherwise would be treated as text. sysopen() with the C +flag sets text mode on files that otherwise would be treated as binary: + + sysopen(FOO, "bar", O_WRONLY|O_CREAT|O_TEXT) -lseek() only works with files opened in binary mode. +lseek(), tell() and sysseek() only work with files opened in binary mode. + +The text/binary issue is covered at length in the Cygwin documentation. =item * F<.exe> @@ -458,8 +472,8 @@ automatically when building a program. However, when accessing an executable as a normal file (e.g., I or I in a makefile) the F<.exe> is not transparent. -NOTE: There is a version of I that understands F<.exe>, it can -be found at: +NOTE: There is a version of I that understands the F<.exe> +semantics, it can be found at: ftp://ftp.franken.de/pub/win32/develop/gnuwin32/cygwin/porters/Humblet_Pierre_A/ @@ -474,8 +488,6 @@ although this is appropriate on Win9x since there is no security model. File locking using the C command to fcntl() is a stub that returns C. -Win32 can not unlink() an open file (but this is emulated by Cygwin). - Win9x can not rename() an open file (although WinNT can). =back @@ -484,7 +496,10 @@ Win9x can not rename() an open file (although WinNT can). This will install Perl, including man pages. - make install 2>&1 | tee log.make-install + make install | tee log.make-install + +NOTE: If C is redirected `C' will B prompt +you to install I into F. You may need to be I to run `C'. If you are not, you must have write access to the directories in question. @@ -520,21 +535,25 @@ be kept as clean as possible. ext/ODBM_File/hints/cygwin.pl hints/cygwin.sh Porting/patchls - cygwin in port list - Makefile.SH - linklibperl, cygwin/Makefile.SHs + Makefile.SH - linklibperl makedepend.SH - uwinfix Configure - help finding hints from uname, shared libperl required for dynamic loading installman - man pages with :: translated to . - installperl - install dll, install to pods + installperl - install dll/ld2/perlld, install to pods =item Tests t/io/tell.t - binmode - t/op/magic.t - $^X WORKAROUND, s/.exe// - t/op/stat.t - no /dev, no -u (setuid) + t/lib/glob-basic.t - Win32 directory list access differs from read mode + t/op/magic.t - $^X/symlink WORKAROUND, s/.exe// + t/op/stat.t - no /dev, skip Win32 ftCreationTime quirk + (cache manager sometimes preserves ctime of file + previously created and deleted), no -u (setuid) =item Compiled Perl Source + cygwin/cygwin.c - os_extras (getcwd) doio.c - win9x can not rename a file when it is open EXTERN.h - __declspec(dllimport) XSUB.h - __declspec(dllexport) @@ -587,4 +606,4 @@ Teun Burgers Eburgers@ecn.nlE. =head1 HISTORY -Last updated: 28 January 2000 +Last updated: 24 February 2000 diff --git a/cygwin/Makefile.SHs b/cygwin/Makefile.SHs index 8d77778..d67f55f 100644 --- a/cygwin/Makefile.SHs +++ b/cygwin/Makefile.SHs @@ -25,6 +25,9 @@ esac addtopath=`pwd` $spitshell >>Makefile < + + +/* see also Cwd.pm */ +static +XS(Cygwin_cwd) +{ + dXSARGS; + char *cwd; + + if(items != 0) + Perl_croak(aTHX_ "Usage: Cwd::cwd()"); + if(cwd = getcwd(NULL, 0)) { + ST(0) = sv_2mortal(newSVpv(cwd, 0)); + safesysfree(cwd); + XSRETURN(1); + } + XSRETURN_UNDEF; +} + +void +init_os_extras(void) +{ + char *file = __FILE__; + dTHX; + + newXS("Cwd::cwd", Cygwin_cwd, file); +} diff --git a/hints/cygwin.sh b/hints/cygwin.sh index 4843200..42114c2 100644 --- a/hints/cygwin.sh +++ b/hints/cygwin.sh @@ -8,6 +8,7 @@ firstmakefile='GNUmakefile' case "$ldlibpthname" in '') ldlibpthname=PATH ;; esac +archobjs='cygwin.o' # mandatory (overrides incorrect defaults) test -z "$cc" && cc='gcc' @@ -25,9 +26,9 @@ libswanted="$libswanted cygipc cygwin kernel32" archname='cygwin' # dynamic loading -ld='ld2' # - otherwise -fpic cccdlflags=' ' +ld='ld2' # optional(ish) # - perl malloc needs to be unpolluted @@ -38,6 +39,9 @@ d_chroot='undef' d_seteuid='undef' d_setegid='undef' +# Win9x problem with non-blocking read from a closed pipe +d_eofnblk='define' + # strip exe's and dll's #ldflags="$ldflags -s" #ccdlflags="$ccdlflags -s" diff --git a/perl.c b/perl.c index 3b47644..46ffde5 100644 --- a/perl.c +++ b/perl.c @@ -1174,7 +1174,7 @@ print \" \\@INC:\\n @INC\\n\";"); if (xsinit) (*xsinit)(aTHXo); /* in case linked C routines want magical variables */ -#if defined(VMS) || defined(WIN32) || defined(DJGPP) +#if defined(VMS) || defined(WIN32) || defined(DJGPP) || defined(__CYGWIN__) init_os_extras(); #endif diff --git a/t/op/stat.t b/t/op/stat.t index 40f8f1f..9c76e8b 100755 --- a/t/op/stat.t +++ b/t/op/stat.t @@ -32,17 +32,17 @@ if (open(FOO, ">Op.stat.tmp")) { else { print "# res=$res, nlink=$nlink.\nnot ok 1\n"; } - if ($Is_MSWin32 || ($mtime && $mtime == $ctime)) { + if ($Is_MSWin32 or $Is_Cygwin || ($mtime && $mtime == $ctime)) { print "ok 2\n"; } else { print "# |$mtime| vs |$ctime|\nnot ok 2\n"; } + sleep 3; print FOO "Now is the time for all good men to come to.\n"; close(FOO); - sleep 2; } else { print "# open failed: $!\nnot ok 1\nnot ok 2\n"; } -- 2.7.4