From: Paul Green Date: Mon, 21 Jan 2002 23:27:00 +0000 (-0500) Subject: Support truncate() in VOS port X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7b2b351e8fdcd287739431e25ffed099b66cdee2;p=p5sagit%2Fp5-mst-13.2.git Support truncate() in VOS port Message-Id: <200201220428.XAA15304@mailhub1.stratus.com> p4raw-id: //depot/perl@14376 --- diff --git a/MANIFEST b/MANIFEST index ba44a28..3e9aa80 100644 --- 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 diff --git a/hints/vos.sh b/hints/vos.sh index f4e9700..c06adba 100644 --- a/hints/vos.sh +++ b/hints/vos.sh @@ -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 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 +#include +#include + +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; +} diff --git a/vos/vosish.h b/vos/vosish.h index cc5e464..5befc65 100644 --- a/vos/vosish.h +++ b/vos/vosish.h @@ -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);