This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Support truncate() in VOS port
authorPaul Green <Paul.Green@stratus.com>
Mon, 21 Jan 2002 23:27:00 +0000 (18:27 -0500)
committerJarkko Hietaniemi <jhi@iki.fi>
Tue, 22 Jan 2002 16:46:48 +0000 (16:46 +0000)
Message-Id: <200201220428.XAA15304@mailhub1.stratus.com>

p4raw-id: //depot/perl@14376

MANIFEST
hints/vos.sh
vos/vos.c [new file with mode: 0644]
vos/vosish.h

index ba44a28..3e9aa80 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -2437,6 +2437,7 @@ vos/install_perl.cm               VOS command macro to install perl after building
 vos/Makefile                   A helper for maintaining the config.*.* in UNIX
 vos/perl.bind                  VOS bind control file
 vos/test_vos_dummies.c         Test program for "vos_dummies.c"
+vos/vos.c                      VOS emulations for missing POSIX functions
 vos/vosish.h                   VOS-specific header file
 vos/vos_dummies.c              Wrappers to soak up undefined functions
 warnings.h                     The warning numbers
index f4e9700..c06adba 100644 (file)
@@ -14,7 +14,8 @@ ccflags="-D_SVID_SOURCE -D_POSIX_C_SOURCE=199509L"
 
 # Make command.
 make="/system/gnu_library/bin/gmake"
-_make="/system/gnu_library/bin/gmake"
+# indented to not put it into config.sh
+  _make="/system/gnu_library/bin/gmake"
 
 # Architecture name
 archname="hppa1.1"
@@ -74,3 +75,10 @@ fflushNULL=define
 
 # VOS has a link() function but it is a dummy.
 d_link="undef"
+
+# VOS does not have truncate() but we supply one in vos.c
+d_truncate="define"
+archobjs="vos.o"
+
+# Help gmake find vos.c
+test -h vos.c || ln -s vos/vos.c vos.c
diff --git a/vos/vos.c b/vos/vos.c
new file mode 100644 (file)
index 0000000..c3566d4
--- /dev/null
+++ b/vos/vos.c
@@ -0,0 +1,22 @@
+/* Beginning of modification history */
+/* Written 02-01-02 by Nick Ing-Simmons (nick@ing-simmons.net) */
+/* End of modification history */
+
+/* VOS doesn't supply a truncate function, so we build one up
+   from the available POSIX functions.  */
+
+#include <fcntl.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+int
+truncate(const char *path, off_t len)
+{
+ int fd = open(path,O_WRONLY);
+ int code = -1;
+ if (fd >= 0) {
+   code = ftruncate(fd,len);
+   close(fd); 
+ }
+ return code;
+}
index cc5e464..5befc65 100644 (file)
@@ -6,3 +6,6 @@
 
 /* The following declaration is an avoidance for posix-950. */
 extern int ioctl (int fd, int request, ...);
+
+/* Specify a prototype for truncate() since we are supplying one. */
+extern int truncate (const char *path, off_t len);