summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorAndy Dougherty <doughera@lafcol.lafayette.edu>1995-05-30 22:59:41 +0000
committerAndy Dougherty <doughera@lafcol.lafayette.edu>1995-05-30 22:59:41 +0000
commit16d20bd98cd29be76029ebf04027a7edd34d817b (patch)
tree9ff5dd75c8b63cfd0da63bc9e4d59f464986bc0e /pp_sys.c
parent3b35bae3d5913952e779006fe378c78297e23080 (diff)
downloadperl-16d20bd98cd29be76029ebf04027a7edd34d817b.tar.gz
This is my patch patch.1i for perl5.001.
To apply, change to your perl directory, run the commands above, then apply with patch -p1 -N < thispatch. After you apply this patch, I would recommend: rm config.sh sh Configure [whatever options you use] make depend make make test Here are the highlights: All pod documentation now installed, along with corresponding man pages, if possible (Configure allows you to change this). cppstdin no longer points back to the build directory. This necessitated two changes to the test suite: comp/cpp.t is now a front end that punts if cppstdin is not yet available (the old perl4 trick doesn't work for perl5). The op/misc.t test ./perl -P -e 'use POSIX;' has been dropped since I couldn't think of an elegant way to bypass it for systems that need the cppstdin wrapper. Grand autoload patch included (minus the installperl, lib/, and ext/ changes). The lib/ changes are in patch.1g, and the ext/ changes are in patch.1h. Better detection and use of stdio variants, especially on SVR4. Sarathy's consolidated patches (for ties) included. New filter stuff included. Three patches from Larry (gv.c, toke.c, pp_ctl.c) Patch and enjoy, Andy Dougherty doughera@lafcol.lafayette.edu Dept. of Physics Lafayette College Easton, PA 18042 Here's the file-by-file breakdown of what's included: Changes.Conf Document changes in the Configure & build process. Configure Upgrade to metaconfig PL55. Add /opt hierarchy to paths searched for programs. Tye McQueen's updated std stdio testing. Prompting for installation info for perl module pages. Add possible SITELIB to include site-specific include directories. By default this is disabled, but it seemed a neat idea now that the standard perl library is getting so big. Check that the compiler chosen exists and actually supports the options the user specified. Correctly sort multiple shared library version numbers. Use a compile & link test for gconvert(), dlopen(), and dlerror(). Do not include build directory name in cppstdin wrapper. MANIFEST Updated. Makefile.SH Reorganized a bit to support separate install.perl and install.man targets to use the new installman script and to accomodate those who don't want to install the man pages. Organize cleanup of .SH files a little better. No longer automatically make the pod/*.man files. This is done by installman only if requested. Include additional error messages and info for regenerating the automatically maintained header files. Add 'minitest' target. README Updated. README.vms Fix perl5-porters subscription info. config_H Updated. config_h.SH Updated. configpm Embedded pod. configure GNU configure-like front end to metaconfig's Configure. Only supports a few options. doio.c Updated to use new std stdio testing. embed.h Add new symbols for filtering. global.sym see embed.h. gv.c C<sub method;> patch from lwall. hints/README.hints Updated. hints/aux.sh Updated. hints/cxux.sh Updated. hints/epix.sh New file. hints/freebsd.sh Updated. hints/irix_4.sh Updated. hints/irix_5.sh Updated. hints/irix_6.sh Updated. hints/linux.sh Updated. hints/powerunix.sh Updated. installman New file to install pod/*.pod and lib/*.p(m|od) man pages. installperl Move installation of man pages over to installman script. Install pod/*.pod files in $privlib/pod/. Preserve timestamps on .a files. makedepend.SH Now includes . and .. in PATH to explicitly find cppstdin wrapper. opcode.h opcode.pl shmwrite fix. perl.c Changed unofficial patchlevel message. Included optional SITELIB directory. perl.h #include <memory.h> cryptswitch gone/filters added. EUNICE replaced by UNLINK_ALL_VERSIONS. Only matters for VMS. perldoc.SH New file. pod/perl.pod Describe where modpods are. pp_ctl.c sort bug fix from lwall. pp_hot.c csh glob bug fix from tchrist. Sarathy's consolidated "tie" patch for NETaa13753 N 2 trey pp_sys.c Emulate flock with lockf, if possible. Use new std stdio unit. proto.h Filters stuff. prototype for unlnk() is only needed #if UNLINK_ALL_VERSIONS sv.c Sarathy's consolidated "tie" patch for NETaa13753 N 2 trey Sarathy's consolidated patch for nested ties. Use new std stdio unit. t/comp/cpp.aux New file. This only gets called if cppstdin is avaiable. t/comp/cpp.t Calls cpp.aux test only if cppstdin is available. t/op/misc.t Drop perl -P -e 'use POSIX;' test. it couldn't work on systems without the cppstdin wrapper installed, and is usually misleading when it fails anyway. toke.c filter stuff. fix for NETaa13798 from lwall. unixish.h undef UNLINK_ALL_VERSIONS since it's irrelevant for unix. util.c s/EUNICE/UNLINK_ALL_VERSIONS/ for the unlnk() function. vms/config.vms VMS updates from Charles Bailey. std stdio updates to match changes in perl sources. add UNLINK_ALL_VERSIONS constant, but leave it #undef. vms/ext/MM_VMS.pm vms/ext/VMS/stdio/stdio.xs vms/perlvms.pod vms/vms.c VMS updates from Charles Bailey. x2p/Makefile.SH Updated to match man page Configure questions. Slight clean-up on .SH targets. x2p/str.c Use new std stdio unit.
Diffstat (limited to 'pp_sys.c')
-rw-r--r--pp_sys.c141
1 files changed, 114 insertions, 27 deletions
diff --git a/pp_sys.c b/pp_sys.c
index 87769759dd..8a6c17a59a 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -17,11 +17,15 @@
#include "EXTERN.h"
#include "perl.h"
-/* Omit this -- it causes too much grief on mixed systems.
-#ifdef I_UNISTD
-#include <unistd.h>
-#endif
+/* XXX Omit this -- it causes too much grief on mixed systems.
+ Next time, I should force broken systems to unset i_unistd in
+ hint files.
*/
+#if 0
+# ifdef I_UNISTD
+# include <unistd.h>
+# endif
+#endif
/* Put this after #includes because fork and vfork prototypes may
conflict.
@@ -1242,7 +1246,12 @@ PP(pp_flock)
int argtype;
GV *gv;
FILE *fp;
-#ifdef HAS_FLOCK
+
+#if !defined(HAS_FLOCK) && defined(HAS_LOCKF)
+# define flock lockf_emulate_flock
+#endif
+
+#if defined(HAS_FLOCK) || defined(flock)
argtype = POPi;
if (MAXARG <= 0)
gv = last_in_gv;
@@ -1260,11 +1269,7 @@ PP(pp_flock)
PUSHi(value);
RETURN;
#else
-# ifdef HAS_LOCKF
- DIE(no_func, "flock()"); /* XXX emulate flock() with lockf()? */
-# else
DIE(no_func, "flock()");
-# endif
#endif
}
@@ -2032,18 +2037,12 @@ PP(pp_fttty)
RETPUSHNO;
}
-#if defined(USE_STD_STDIO) || defined(atarist) /* this will work with atariST */
-# define FBASE(f) ((f)->_base)
-# define FSIZE(f) ((f)->_cnt + ((f)->_ptr - (f)->_base))
-# define FPTR(f) ((f)->_ptr)
-# define FCOUNT(f) ((f)->_cnt)
-#else
-# if defined(USE_LINUX_STDIO)
-# define FBASE(f) ((f)->_IO_read_base)
-# define FSIZE(f) ((f)->_IO_read_end - FBASE(f))
-# define FPTR(f) ((f)->_IO_read_ptr)
-# define FCOUNT(f) ((f)->_IO_read_end - FPTR(f))
-# endif
+#if defined(atarist) /* this will work with atariST. Configure will
+ make guesses for other systems. */
+# define FILE_base(f) ((f)->_base)
+# define FILE_ptr(f) ((f)->_ptr)
+# define FILE_cnt(f) ((f)->_cnt)
+# define FILE_bufsiz(f) ((f)->_cnt + ((f)->_ptr - (f)->_base))
#endif
PP(pp_fttext)
@@ -2073,22 +2072,22 @@ PP(pp_fttext)
io = GvIO(statgv);
}
if (io && IoIFP(io)) {
-#ifdef FBASE
+#ifdef FILE_base
Fstat(fileno(IoIFP(io)), &statcache);
if (S_ISDIR(statcache.st_mode)) /* handle NFS glitch */
if (op->op_type == OP_FTTEXT)
RETPUSHNO;
else
RETPUSHYES;
- if (FCOUNT(IoIFP(io)) <= 0) {
+ if (FILE_cnt(IoIFP(io)) <= 0) {
i = getc(IoIFP(io));
if (i != EOF)
(void)ungetc(i, IoIFP(io));
}
- if (FCOUNT(IoIFP(io)) <= 0) /* null file is anything */
+ if (FILE_cnt(IoIFP(io)) <= 0) /* null file is anything */
RETPUSHYES;
- len = FSIZE(IoIFP(io));
- s = FBASE(IoIFP(io));
+ len = FILE_bufsiz(IoIFP(io));
+ s = FILE_base(IoIFP(io));
#else
DIE("-T and -B not implemented on filehandles");
#endif
@@ -2321,7 +2320,7 @@ char *cmd;
char *filename;
{
char mybuf[8192];
- char *s,
+ char *s,
*save_filename = filename;
int anum = 1;
FILE *myfp;
@@ -3871,3 +3870,91 @@ PP(pp_syscall)
#endif
}
+#if !defined(HAS_FLOCK) && defined(HAS_LOCKF)
+
+/* XXX Emulate flock() with lockf(). This is just to increase
+ portability of scripts. The calls are not completely
+ interchangeable. What's really needed is a good file
+ locking module.
+*/
+
+/* We might need <unistd.h> because it sometimes defines the lockf()
+ constants. Unfortunately, <unistd.h> causes troubles on some mixed
+ (BSD/POSIX) systems, such as SunOS 4.1.3. We could just try including
+ <unistd.h> here in this part of the file, but that might
+ conflict with various other #defines and includes above, such as
+ #define vfork fork above.
+
+ Further, the lockf() constants aren't POSIX, so they might not be
+ visible if we're compiling with _POSIX_SOURCE defined. Thus, we'll
+ just stick in the SVID values and be done with it. Sigh.
+*/
+
+# ifndef F_ULOCK
+# define F_ULOCK 0 /* Unlock a previously locked region */
+# endif
+# ifndef F_LOCK
+# define F_LOCK 1 /* Lock a region for exclusive use */
+# endif
+# ifndef F_TLOCK
+# define F_TLOCK 2 /* Test and lock a region for exclusive use */
+# endif
+# ifndef F_TEST
+# define F_TEST 3 /* Test a region for other processes locks */
+# endif
+
+/* These are the flock() constants. Since this sytems doesn't have
+ flock(), the values of the constants are probably not available.
+*/
+# ifndef LOCK_SH
+# define LOCK_SH 1
+# endif
+# ifndef LOCK_EX
+# define LOCK_EX 2
+# endif
+# ifndef LOCK_NB
+# define LOCK_NB 4
+# endif
+# ifndef LOCK_UN
+# define LOCK_UN 8
+# endif
+
+int
+lockf_emulate_flock (fd, operation)
+int fd;
+int operation;
+{
+ int i;
+ switch (operation) {
+
+ /* LOCK_SH - get a shared lock */
+ case LOCK_SH:
+ /* LOCK_EX - get an exclusive lock */
+ case LOCK_EX:
+ i = lockf (fd, F_LOCK, 0);
+ break;
+
+ /* LOCK_SH|LOCK_NB - get a non-blocking shared lock */
+ case LOCK_SH|LOCK_NB:
+ /* LOCK_EX|LOCK_NB - get a non-blocking exclusive lock */
+ case LOCK_EX|LOCK_NB:
+ i = lockf (fd, F_TLOCK, 0);
+ if (i == -1)
+ if ((errno == EAGAIN) || (errno == EACCES))
+ errno = EWOULDBLOCK;
+ break;
+
+ /* LOCK_UN - unlock */
+ case LOCK_UN:
+ i = lockf (fd, F_ULOCK, 0);
+ break;
+
+ /* Default - can't decipher operation */
+ default:
+ i = -1;
+ errno = EINVAL;
+ break;
+ }
+ return (i);
+}
+#endif