This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
POSIX: revert exported functions to 5.20.2 state
[perl5.git] / vos / vos.c
CommitLineData
7b2b351e
PG
1/* Beginning of modification history */
2/* Written 02-01-02 by Nick Ing-Simmons (nick@ing-simmons.net) */
a5f25d7a
PG
3/* Modified 02-03-27 by Paul Green (Paul.Green@stratus.com) to
4 add socketpair() dummy. */
0ee4199b
PG
5/* Modified 02-04-24 by Paul Green (Paul.Green@stratus.com) to
6 have pow(0,0) return 1, avoiding c-1471. */
dab8accc
PG
7/* Modified 06-09-25 by Paul Green (Paul.Green@stratus.com) to
8 add syslog entries. */
3722f0dc
PG
9/* Modified 08-02-04 by Paul Green (Paul.Green@stratus.com) to
10 open the syslog file in the working dir. */
05954a8b
PG
11/* Modified 11-10-17 by Paul Green to remove the dummy copies
12 of socketpair() and the syslog functions. */
7b2b351e
PG
13/* End of modification history */
14
a5f25d7a 15#include <errno.h>
7b2b351e 16#include <fcntl.h>
dab8accc
PG
17#include <stdio.h>
18#include <stdlib.h>
19#include <string.h>
7b2b351e
PG
20#include <sys/types.h>
21#include <unistd.h>
22
a5f25d7a
PG
23/* VOS doesn't supply a truncate function, so we build one up
24 from the available POSIX functions. */
25
7b2b351e
PG
26int
27truncate(const char *path, off_t len)
28{
29 int fd = open(path,O_WRONLY);
30 int code = -1;
31 if (fd >= 0) {
32 code = ftruncate(fd,len);
33 close(fd);
34 }
35 return code;
36}
a5f25d7a 37
0ee4199b
PG
38/* Supply a private version of the power function that returns 1
39 for x**0. This avoids c-1471. Abigail's Japh tests depend
40 on this fix. We leave all the other cases to the VOS C
41 runtime. */
42
43double s_crt_pow(double *x, double *y);
44
45double pow(x,y)
46double x, y;
47{
48 if (y == 0e0) /* c-1471 */
49 {
50 errno = EDOM;
51 return (1e0);
52 }
53
54 return(s_crt_pow(&x,&y));
55}