aboutsummaryrefslogtreecommitdiff
path: root/contrib/perl5/ext/POSIX/POSIX.xs
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/perl5/ext/POSIX/POSIX.xs')
-rw-r--r--contrib/perl5/ext/POSIX/POSIX.xs147
1 files changed, 76 insertions, 71 deletions
diff --git a/contrib/perl5/ext/POSIX/POSIX.xs b/contrib/perl5/ext/POSIX/POSIX.xs
index 7ffd49411a5b..1dd4ae36687c 100644
--- a/contrib/perl5/ext/POSIX/POSIX.xs
+++ b/contrib/perl5/ext/POSIX/POSIX.xs
@@ -1,3 +1,4 @@
+/* $FreeBSD$ */
#ifdef WIN32
#define _POSIX_
#endif
@@ -55,9 +56,6 @@
#ifdef I_UNISTD
#include <unistd.h>
#endif
-#ifdef MACOS_TRADITIONAL
-#undef fdopen
-#endif
#include <fcntl.h>
#if defined(__VMS) && !defined(__POSIX_SOURCE)
@@ -83,7 +81,7 @@
/* The non-POSIX CRTL times() has void return type, so we just get the
current time directly */
- clock_t vms_times(struct tms *bufptr) {
+ clock_t vms_times(struct tms *PL_bufptr) {
dTHX;
clock_t retval;
/* Get wall time and convert to 10 ms intervals to
@@ -104,7 +102,7 @@
_ckvmssts(lib$ediv(&divisor,vmstime,(long int *)&retval,&remainder));
# endif
/* Fill in the struct tms using the CRTL routine . . .*/
- times((tbuffer_t *)bufptr);
+ times((tbuffer_t *)PL_bufptr);
return (clock_t) retval;
}
# define times(t) vms_times(t)
@@ -142,12 +140,10 @@
# define sigdelset(a,b) not_here("sigdelset")
# define sigfillset(a) not_here("sigfillset")
# define sigismember(a,b) not_here("sigismember")
-# define setuid(a) not_here("setuid")
-# define setgid(a) not_here("setgid")
#else
# ifndef HAS_MKFIFO
-# if defined(OS2) || defined(MACOS_TRADITIONAL)
+# ifdef OS2
# define mkfifo(a,b) not_here("mkfifo")
# else /* !( defined OS2 ) */
# ifndef mkfifo
@@ -156,17 +152,12 @@
# endif
# endif /* !HAS_MKFIFO */
-# ifdef MACOS_TRADITIONAL
-# define ttyname(a) (char*)not_here("ttyname")
-# define tzset() not_here("tzset")
-# else
-# include <grp.h>
-# include <sys/times.h>
-# ifdef HAS_UNAME
-# include <sys/utsname.h>
-# endif
-# include <sys/wait.h>
+# include <grp.h>
+# include <sys/times.h>
+# ifdef HAS_UNAME
+# include <sys/utsname.h>
# endif
+# include <sys/wait.h>
# ifdef I_UTIME
# include <utime.h>
# endif
@@ -539,12 +530,12 @@ mini_mktime(struct tm *ptm)
}
#ifdef HAS_LONG_DOUBLE
-# if LONG_DOUBLESIZE > NVSIZE
+# if LONG_DOUBLESIZE > DOUBLESIZE
# undef HAS_LONG_DOUBLE /* XXX until we figure out how to use them */
# endif
#endif
-#ifndef HAS_LONG_DOUBLE
+#ifndef HAS_LONG_DOUBLE
#ifdef LDBL_MAX
#undef LDBL_MAX
#endif
@@ -564,7 +555,11 @@ not_here(char *s)
}
static
-NV
+#if defined(HAS_LONG_DOUBLE) && (LONG_DOUBLESIZE > DOUBLESIZE)
+long double
+#else
+double
+#endif
constant(char *name, int arg)
{
errno = 0;
@@ -1523,11 +1518,6 @@ constant(char *name, int arg)
break;
case 'H':
if (strEQ(name, "HUGE_VAL"))
-#if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
- /* HUGE_VALL is admittedly non-POSIX but if we are using long doubles
- * we might as well use long doubles. --jhi */
- return HUGE_VALL;
-#endif
#ifdef HUGE_VAL
return HUGE_VAL;
#else
@@ -2302,9 +2292,9 @@ constant(char *name, int arg)
#else
goto not_there;
#endif
- if (strEQ(name, "STDERR_FILENO"))
-#ifdef STDERR_FILENO
- return STDERR_FILENO;
+ if (strEQ(name, "STRERR_FILENO"))
+#ifdef STRERR_FILENO
+ return STRERR_FILENO;
#else
goto not_there;
#endif
@@ -3016,7 +3006,7 @@ setcc(termios_ref, ccix, cc)
MODULE = POSIX PACKAGE = POSIX
-NV
+double
constant(name,arg)
char * name
int arg
@@ -3172,7 +3162,7 @@ localeconv()
#ifdef HAS_LOCALECONV
struct lconv *lcbuf;
RETVAL = newHV();
- if ((lcbuf = localeconv())) {
+ if (lcbuf = localeconv()) {
/* the strings */
if (lcbuf->decimal_point && *lcbuf->decimal_point)
hv_store(RETVAL, "decimal_point", 13,
@@ -3305,73 +3295,73 @@ setlocale(category, locale = 0)
RETVAL
-NV
+double
acos(x)
- NV x
+ double x
-NV
+double
asin(x)
- NV x
+ double x
-NV
+double
atan(x)
- NV x
+ double x
-NV
+double
ceil(x)
- NV x
+ double x
-NV
+double
cosh(x)
- NV x
+ double x
-NV
+double
floor(x)
- NV x
+ double x
-NV
+double
fmod(x,y)
- NV x
- NV y
+ double x
+ double y
void
frexp(x)
- NV x
+ double x
PPCODE:
int expvar;
/* (We already know stack is long enough.) */
PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar))));
PUSHs(sv_2mortal(newSViv(expvar)));
-NV
+double
ldexp(x,exp)
- NV x
+ double x
int exp
-NV
+double
log10(x)
- NV x
+ double x
void
modf(x)
- NV x
+ double x
PPCODE:
- NV intvar;
+ double intvar;
/* (We already know stack is long enough.) */
- PUSHs(sv_2mortal(newSVnv(Perl_modf(x,&intvar))));
+ PUSHs(sv_2mortal(newSVnv(modf(x,&intvar))));
PUSHs(sv_2mortal(newSVnv(intvar)));
-NV
+double
sinh(x)
- NV x
+ double x
-NV
+double
tan(x)
- NV x
+ double x
-NV
+double
tanh(x)
- NV x
+ double x
SysRet
sigaction(sig, action, oldaction = 0)
@@ -3417,8 +3407,9 @@ sigaction(sig, action, oldaction = 0)
/* Set up any desired mask. */
svp = hv_fetch(action, "MASK", 4, FALSE);
if (svp && sv_isa(*svp, "POSIX::SigSet")) {
- IV tmp = SvIV((SV*)SvRV(*svp));
- sigset = INT2PTR(sigset_t*, tmp);
+ unsigned long tmp;
+ tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
+ sigset = (sigset_t*) tmp;
act.sa_mask = *sigset;
}
else
@@ -3443,8 +3434,9 @@ sigaction(sig, action, oldaction = 0)
/* Get back the mask. */
svp = hv_fetch(oldaction, "MASK", 4, TRUE);
if (sv_isa(*svp, "POSIX::SigSet")) {
- IV tmp = SvIV((SV*)SvRV(*svp));
- sigset = INT2PTR(sigset_t*, tmp);
+ unsigned long tmp;
+ tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
+ sigset = (sigset_t*) tmp;
}
else {
New(0, sigset, 1, sigset_t);
@@ -3515,7 +3507,7 @@ SysRet
nice(incr)
int incr
-void
+int
pipe()
PPCODE:
int fds[2];
@@ -3558,7 +3550,7 @@ tcsetpgrp(fd, pgrp_id)
int fd
pid_t pgrp_id
-void
+int
uname()
PPCODE:
#ifdef HAS_UNAME
@@ -3692,7 +3684,7 @@ strtoul(str, base = 0)
PUSHs(&PL_sv_undef);
}
-void
+SV *
strxfrm(src)
SV * src
CODE:
@@ -3827,10 +3819,7 @@ mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
OUTPUT:
RETVAL
-#XXX: if $xsubpp::WantOptimize is always the default
-# sv_setpv(TARG, ...) could be used rather than
-# ST(0) = sv_2mortal(newSVpv(...))
-void
+char *
strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
char * fmt
int sec
@@ -3847,6 +3836,11 @@ strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
char tmpbuf[128];
struct tm mytm;
int len;
+#ifdef __FreeBSD__
+ long sgmtoff;
+ int sisdst;
+ char *szone;
+#endif
init_tm(&mytm); /* XXX workaround - see init_tm() above */
mytm.tm_sec = sec;
mytm.tm_min = min;
@@ -3857,7 +3851,18 @@ strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
mytm.tm_wday = wday;
mytm.tm_yday = yday;
mytm.tm_isdst = isdst;
+#ifdef __FreeBSD__
+ sgmtoff = mytm.tm_gmtoff;
+ sisdst = mytm.tm_isdst;
+ szone = mytm.tm_zone;
+ /* to prevent mess with shifted hours/days/etc. */
+ (void) timegm(&mytm);
+ mytm.tm_gmtoff = sgmtoff;
+ mytm.tm_isdst = sisdst;
+ mytm.tm_zone = szone;
+#else
mini_mktime(&mytm);
+#endif
len = strftime(tmpbuf, sizeof tmpbuf, fmt, &mytm);
/*
** The following is needed to handle to the situation where