This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
use sysconf(_SC_CLK_TCK) for times()
[perl5.git] / pp_sys.c
index 2639fe9..9f15b0e 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -2053,7 +2053,7 @@ PP(pp_truncate)
     /* XXX Configure probe for the length type of *truncate() needed XXX */
     Off_t len;
 
-#if Size_t_size > IVSIZE
+#if Off_t_size > IVSIZE
     len = (Off_t)POPn;
 #else
     len = (Off_t)POPi;
@@ -2178,7 +2178,9 @@ PP(pp_ioctl)
        DIE(aTHX_ "ioctl is not implemented");
 #endif
     else
-#ifdef HAS_FCNTL
+#ifndef HAS_FCNTL
+      DIE(aTHX_ "fcntl is not implemented");
+#else
 #if defined(OS2) && defined(__EMX__)
        retval = fcntl(PerlIO_fileno(IoIFP(io)), func, (int)s);
 #else
@@ -2201,11 +2203,8 @@ PP(pp_ioctl)
     else {
        PUSHp(zero_but_true, ZBTLEN);
     }
-    RETURN;
-
-#else
-    DIE(aTHX_ "fcntl is not implemented");
 #endif
+    RETURN;
 }
 
 PP(pp_flock)
@@ -3961,6 +3960,9 @@ PP(pp_fork)
            sv_setiv(GvSV(tmpgv), (IV)PerlProc_getpid());
             SvREADONLY_on(GvSV(tmpgv));
         }
+#ifdef THREADS_HAVE_PIDS
+       PL_ppid = (IV)getppid();
+#endif
        hv_clear(PL_pidstatus); /* no kids, so don't wait for 'em */
     }
     PUSHi(childpid);
@@ -4049,24 +4051,14 @@ PP(pp_system)
     I32 did_pipes = 0;
 
     if (PL_tainting) {
-       int some_arg_tainted = 0;
        TAINT_ENV();
        while (++MARK <= SP) {
            (void)SvPV_nolen(*MARK);      /* stringify for taint check */
-           if (PL_tainted) {
-               some_arg_tainted = 1;
+           if (PL_tainted)
                break;
-           }
        }
        MARK = ORIGMARK;
-       /* XXX Remove warning at end of deprecation cycle --RD 2002-02  */
-       if (SP - MARK == 1) {
-           TAINT_PROPER("system");
-       }
-       else if (some_arg_tainted && ckWARN2(WARN_TAINT, WARN_DEPRECATED)) {
-           Perl_warner(aTHX_ packWARN2(WARN_TAINT, WARN_DEPRECATED),
-               "Use of tainted arguments in %s is deprecated", "system");
-       }
+       TAINT_PROPER("system");
     }
     PERL_FLUSHALL_FOR_CHILD;
 #if (defined(HAS_FORK) || defined(AMIGAOS)) && !defined(VMS) && !defined(OS2) || defined(PERL_MICRO)
@@ -4154,10 +4146,19 @@ PP(pp_system)
     result = 0;
     if (PL_op->op_flags & OPf_STACKED) {
        SV *really = *++MARK;
+#  ifdef WIN32
+       value = (I32)do_aspawn(really, MARK, SP);
+#  else
        value = (I32)do_aspawn(really, (void **)MARK, (void **)SP);
+#  endif
     }
-    else if (SP - MARK != 1)
+    else if (SP - MARK != 1) {
+#  ifdef WIN32
+       value = (I32)do_aspawn(Nullsv, MARK, SP);
+#  else
        value = (I32)do_aspawn(Nullsv, (void **)MARK, (void **)SP);
+#  endif
+    }
     else {
        value = (I32)do_spawn(SvPVx(sv_mortalcopy(*SP), n_a));
     }
@@ -4178,24 +4179,14 @@ PP(pp_exec)
     STRLEN n_a;
 
     if (PL_tainting) {
-       int some_arg_tainted = 0;
        TAINT_ENV();
        while (++MARK <= SP) {
            (void)SvPV_nolen(*MARK);      /* stringify for taint check */
-           if (PL_tainted) {
-               some_arg_tainted = 1;
+           if (PL_tainted)
                break;
-           }
        }
        MARK = ORIGMARK;
-       /* XXX Remove warning at end of deprecation cycle --RD 2002-02  */
-       if (SP - MARK == 1) {
-           TAINT_PROPER("exec");
-       }
-       else if (some_arg_tainted && ckWARN2(WARN_TAINT, WARN_DEPRECATED)) {
-           Perl_warner(aTHX_ packWARN2(WARN_TAINT, WARN_DEPRECATED),
-               "Use of tainted arguments in %s is deprecated", "exec");
-       }
+       TAINT_PROPER("exec");
     }
     PERL_FLUSHALL_FOR_CHILD;
     if (PL_op->op_flags & OPf_STACKED) {
@@ -4251,7 +4242,11 @@ PP(pp_getppid)
 {
 #ifdef HAS_GETPPID
     dSP; dTARGET;
+#   ifdef THREADS_HAVE_PIDS
+    XPUSHi( PL_ppid );
+#   else
     XPUSHi( getppid() );
+#   endif
     RETURN;
 #else
     DIE(aTHX_ PL_no_func, "getppid");
@@ -4356,26 +4351,6 @@ PP(pp_time)
     RETURN;
 }
 
-/* XXX The POSIX name is CLK_TCK; it is to be preferred
-   to HZ.  Probably.  For now, assume that if the system
-   defines HZ, it does so correctly.  (Will this break
-   on VMS?)
-   Probably we ought to use _sysconf(_SC_CLK_TCK), if
-   it's supported.    --AD  9/96.
-*/
-
-#ifdef __BEOS__
-#  define HZ 1000000
-#endif
-
-#ifndef HZ
-#  ifdef CLK_TCK
-#    define HZ CLK_TCK
-#  else
-#    define HZ 60
-#  endif
-#endif
-
 PP(pp_tms)
 {
 #ifdef HAS_TIMES
@@ -4389,11 +4364,11 @@ PP(pp_tms)
                                                    /* is returned.                   */
 #endif
 
-    PUSHs(sv_2mortal(newSVnv(((NV)PL_timesbuf.tms_utime)/HZ)));
+    PUSHs(sv_2mortal(newSVnv(((NV)PL_timesbuf.tms_utime)/(NV)PL_clocktick)));
     if (GIMME == G_ARRAY) {
-       PUSHs(sv_2mortal(newSVnv(((NV)PL_timesbuf.tms_stime)/HZ)));
-       PUSHs(sv_2mortal(newSVnv(((NV)PL_timesbuf.tms_cutime)/HZ)));
-       PUSHs(sv_2mortal(newSVnv(((NV)PL_timesbuf.tms_cstime)/HZ)));
+       PUSHs(sv_2mortal(newSVnv(((NV)PL_timesbuf.tms_stime)/(NV)PL_clocktick)));
+       PUSHs(sv_2mortal(newSVnv(((NV)PL_timesbuf.tms_cutime)/(NV)PL_clocktick)));
+       PUSHs(sv_2mortal(newSVnv(((NV)PL_timesbuf.tms_cstime)/(NV)PL_clocktick)));
     }
     RETURN;
 #else