Boost logo

Boost-Commit :

From: kbelco_at_[hidden]
Date: 2007-11-12 17:52:13


Author: noel_belcourt
Date: 2007-11-12 17:52:12 EST (Mon, 12 Nov 2007)
New Revision: 41048
URL: http://svn.boost.org/trac/boost/changeset/41048

Log:
Get the unix timing working correctly.

Text files modified:
   trunk/tools/jam/src/execunix.c | 14 +++++++++++---
   1 files changed, 11 insertions(+), 3 deletions(-)

Modified: trunk/tools/jam/src/execunix.c
==============================================================================
--- trunk/tools/jam/src/execunix.c (original)
+++ trunk/tools/jam/src/execunix.c 2007-11-12 17:52:12 EST (Mon, 12 Nov 2007)
@@ -65,6 +65,7 @@
 static int select_timeout = 0;
 static int intr = 0;
 static int cmdsrunning = 0;
+static struct tms old_time;
 
 #define OUT 0
 #define ERR 1
@@ -110,6 +111,7 @@
         char *action,
         char *target )
 {
+ static int initialized = 0;
         int out[2], err[2];
         int slot, len;
         char *argv[ MAXARGC + 1 ]; /* +1 for NULL */
@@ -170,6 +172,12 @@
         cmdtab[ slot ].command = BJAM_MALLOC_ATOMIC(strlen(string)+1);
         strcpy(cmdtab[slot].command, string);
 
+ /* initialize only once */
+ if ( ! initialized ) {
+ times(&old_time);
+ initialized = 1;
+ }
+
         /* create pipe from child to parent */
 
         if (pipe(out) < 0)
@@ -412,7 +420,7 @@
     int rstat;
     timing_info time;
     fd_set fds;
- struct tms old_time, new_time;
+ struct tms new_time;
 
     /* Handle naive make1() which doesn't know if cmds are running. */
 
@@ -476,8 +484,6 @@
                                 cmdtab[i].exit_reason = EXIT_FAIL;
                         }
 
- times(&old_time);
-
                         /* print out the rule and target name */
                         out_action(cmdtab[i].action, cmdtab[i].target,
                             cmdtab[i].command, cmdtab[i].buffer[OUT], cmdtab[i].buffer[ERR],
@@ -488,6 +494,8 @@
                         time.system = (double)(new_time.tms_cstime - old_time.tms_cstime) / CLOCKS_PER_SEC;
                         time.user = (double)(new_time.tms_cutime - old_time.tms_cutime) / CLOCKS_PER_SEC;
     
+ old_time = new_time;
+
                         /* Drive the completion */
 
                         --cmdsrunning;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk