Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r79501 - in trunk/tools/build/v2/engine: . modules
From: jurko.gospodnetic_at_[hidden]
Date: 2012-07-14 12:11:18


Author: jurko
Date: 2012-07-14 12:11:16 EDT (Sat, 14 Jul 2012)
New Revision: 79501
URL: http://svn.boost.org/trac/boost/changeset/79501

Log:
Boost Jam code cleanup - wrapped up timestamp values inside a timstamp structure instead of using a raw time_t value as another preparation step towards implementing support for timestamps with resolution finer than 1 second. All timestamp manipulation now done using the new timestamp_XXX() API.

Other related minor stylistic changes:
  - timestamp_from_target() renamed to timestamp_from_path()
  - timestamp_from_target() parameter order switched
  - comment updates
  - added some const function parameter modifiers
  - some header #include directives reordered alphabetically
Text files modified:
   trunk/tools/build/v2/engine/builtins.c | 12 ++--
   trunk/tools/build/v2/engine/execcmd.h | 6 +-
   trunk/tools/build/v2/engine/execnt.c | 11 ++--
   trunk/tools/build/v2/engine/execunix.c | 22 ++++----
   trunk/tools/build/v2/engine/filent.c | 19 ++++---
   trunk/tools/build/v2/engine/filent.h | 6 +-
   trunk/tools/build/v2/engine/filesys.c | 25 +++++----
   trunk/tools/build/v2/engine/filesys.h | 16 +++--
   trunk/tools/build/v2/engine/fileunix.c | 35 ++++++++-----
   trunk/tools/build/v2/engine/hcache.c | 19 ++++---
   trunk/tools/build/v2/engine/jam.c | 7 ++
   trunk/tools/build/v2/engine/make.c | 68 ++++++++++++++++-----------
   trunk/tools/build/v2/engine/make1.c | 17 +++---
   trunk/tools/build/v2/engine/modules/path.c | 6 +-
   trunk/tools/build/v2/engine/output.c | 27 ++++++----
   trunk/tools/build/v2/engine/output.h | 22 ++++----
   trunk/tools/build/v2/engine/rules.h | 28 +++++-----
   trunk/tools/build/v2/engine/search.c | 12 ++--
   trunk/tools/build/v2/engine/search.h | 6 +-
   trunk/tools/build/v2/engine/timestamp.c | 98 +++++++++++++++++++++++++++++++--------
   trunk/tools/build/v2/engine/timestamp.h | 16 ++++++
   21 files changed, 294 insertions(+), 184 deletions(-)

Modified: trunk/tools/build/v2/engine/builtins.c
==============================================================================
--- trunk/tools/build/v2/engine/builtins.c (original)
+++ trunk/tools/build/v2/engine/builtins.c 2012-07-14 12:11:16 EDT (Sat, 14 Jul 2012)
@@ -636,7 +636,7 @@
 
 
 static void builtin_glob_back( void * closure, OBJECT * file, int status,
- time_t const time )
+ timestamp const * const time )
 {
     PROFILE_ENTER( BUILTIN_GLOB_BACK );
 
@@ -754,11 +754,11 @@
 
 static LIST * append_if_exists( LIST * list, OBJECT * file )
 {
- time_t time;
- timestamp_from_target( file, &time );
- return time > 0
- ? list_push_back( list, object_copy( file ) )
- : list;
+ timestamp time;
+ timestamp_from_path( &time, file );
+ return timestamp_empty( &time )
+ ? list
+ : list_push_back( list, object_copy( file ) );
 }
 
 

Modified: trunk/tools/build/v2/engine/execcmd.h
==============================================================================
--- trunk/tools/build/v2/engine/execcmd.h (original)
+++ trunk/tools/build/v2/engine/execcmd.h 2012-07-14 12:11:16 EDT (Sat, 14 Jul 2012)
@@ -17,15 +17,15 @@
 
 #include "lists.h"
 #include "strings.h"
+#include "timestamp.h"
 
-#include <time.h>
 
 typedef struct timing_info
 {
     double system;
     double user;
- time_t start;
- time_t end;
+ timestamp start;
+ timestamp end;
 } timing_info;
 
 typedef void (* ExecCmdCallback)

Modified: trunk/tools/build/v2/engine/execnt.c
==============================================================================
--- trunk/tools/build/v2/engine/execnt.c (original)
+++ trunk/tools/build/v2/engine/execnt.c 2012-07-14 12:11:16 EDT (Sat, 14 Jul 2012)
@@ -27,10 +27,9 @@
  * Do not just set JAMSHELL to cmd.exe - it will not work!
  *
  * External routines:
- * exec_check() - preprocess and validate the command
- * exec_cmd() - launch an async command execution
- * exec_wait() - wait for any of the async command processes to
- * terminate
+ * exec_check() - preprocess and validate the command
+ * exec_cmd() - launch an async command execution
+ * exec_wait() - wait for any of the async command processes to terminate
  */
 
 #include "jam.h"
@@ -674,8 +673,8 @@
     {
         time->system = filetime_to_seconds( kernel );
         time->user = filetime_to_seconds( user );
- time->start = filetime_to_timestamp( creation );
- time->end = filetime_to_timestamp( exit );
+ filetime_to_timestamp( creation, &time->start );
+ filetime_to_timestamp( exit, &time->end );
     }
 }
 

Modified: trunk/tools/build/v2/engine/execunix.c
==============================================================================
--- trunk/tools/build/v2/engine/execunix.c (original)
+++ trunk/tools/build/v2/engine/execunix.c 2012-07-14 12:11:16 EDT (Sat, 14 Jul 2012)
@@ -75,14 +75,14 @@
 
 static struct
 {
- int pid; /* on win32, a real process handle */
- int fd[ 2 ]; /* file descriptors for stdout and stderr */
- FILE * stream[ 2 ]; /* child's stdout (0) and stderr (1) file stream */
- clock_t start_time; /* start time of child process */
- int exit_reason; /* termination status */
- char * buffer[ 2 ]; /* buffers to hold stdout and stderr, if any */
- int buf_size[ 2 ]; /* buffer sizes in bytes */
- time_t start_dt; /* start of command timestamp */
+ int pid; /* on win32, a real process handle */
+ int fd[ 2 ]; /* file descriptors for stdout and stderr */
+ FILE * stream[ 2 ]; /* child's stdout and stderr file streams */
+ clock_t start_time; /* start time of child process */
+ int exit_reason; /* termination status */
+ char * buffer[ 2 ]; /* buffers to hold stdout and stderr, if any */
+ int buf_size[ 2 ]; /* buffer sizes in bytes */
+ timestamp start_dt; /* start of command timestamp */
 
     /* Function called when the command completes. */
     ExecCmdCallback func;
@@ -184,7 +184,7 @@
 
     /* Start the command */
 
- cmdtab[ slot ].start_dt = time( 0 );
+ timestamp_init( &cmdtab[ slot ].start_dt, time( 0 ) );
 
     if ( 0 < globs.timeout )
     {
@@ -505,8 +505,8 @@
                         old_time.tms_cstime ) / CLOCKS_PER_SEC;
                     time_info.user = (double)( new_time.tms_cutime -
                         old_time.tms_cutime ) / CLOCKS_PER_SEC;
- time_info.start = cmdtab[ i ].start_dt;
- time_info.end = time( 0 );
+ timestamp_copy( &time_info.start, &cmdtab[ i ].start_dt );
+ timestamp_init( &time_info.end, time( 0 ) );
                     old_time = new_time;
                 }
 

Modified: trunk/tools/build/v2/engine/filent.c
==============================================================================
--- trunk/tools/build/v2/engine/filent.c (original)
+++ trunk/tools/build/v2/engine/filent.c 2012-07-14 12:11:16 EDT (Sat, 14 Jul 2012)
@@ -110,7 +110,8 @@
             ff->is_file = finfo->ff_attrib & FA_DIREC ? 0 : 1;
             ff->is_dir = !ff->is_file;
             ff->size = finfo->ff_fsize;
- ff->time = ( finfo->ff_ftime << 16 ) | finfo->ff_ftime;
+ timestamp_init( &ff->time, ( finfo->ff_ftime << 16 ) |
+ finfo->ff_ftime );
         }
     }
     while ( !findnext( finfo ) );
@@ -141,7 +142,7 @@
                 ff->is_file = finfo->attrib & _A_SUBDIR ? 0 : 1;
                 ff->is_dir = !ff->is_file;
                 ff->size = finfo->size;
- ff->time = finfo->time_write;
+ timestamp_init( &ff->time, finfo->time_write );
             }
         }
         while ( !_findnext( handle, finfo ) );
@@ -172,7 +173,7 @@
         char const * const name = object_str( d->name );
         if ( name[ 0 ] == '\\' && !name[ 1 ] )
         {
- (*func)( closure, d->name, 1 /* stat()'ed */, d->time );
+ (*func)( closure, d->name, 1 /* stat()'ed */, &d->time );
         }
         else if ( name[ 0 ] && name[ 1 ] == ':' && name[ 2 ] && !name[ 3 ] )
         {
@@ -189,8 +190,8 @@
              * $(p2). But, that seems rather fragile.
              */
             OBJECT * const dir_no_slash = object_new_range( name, 2 );
- (*func)( closure, d->name, 1 /* stat()'ed */, d->time );
- (*func)( closure, dir_no_slash, 1 /* stat()'ed */, d->time );
+ (*func)( closure, d->name, 1 /* stat()'ed */, &d->time );
+ (*func)( closure, dir_no_slash, 1 /* stat()'ed */, &d->time );
             object_free( dir_no_slash );
         }
     }
@@ -337,7 +338,9 @@
         sprintf( buf, "%s(%.*s)", archive, endname - name, name );
         {
             OBJECT * const member = object_new( buf );
- (*func)( closure, member, 1 /* time valid */, (time_t)lar_date );
+ timestamp time;
+ timestamp_init( &time, (time_t)lar_date );
+ (*func)( closure, member, 1 /* time valid */, &time );
             object_free( member );
         }
 
@@ -366,7 +369,7 @@
  * Lifted shamelessly from the CPython implementation.
  */
 
-time_t filetime_to_timestamp( FILETIME const ft )
+void filetime_to_timestamp( FILETIME const ft, timestamp * const time )
 {
     /* Seconds between 1.1.1601 and 1.1.1970 */
     static __int64 const secs_between_epochs = 11644473600;
@@ -385,7 +388,7 @@
     /* For resolutions finer than 1 second use the following:
      * nsec = (int)( in % 10000000 ) * 100;
      */
- return (time_t)( ( in / 10000000 ) - secs_between_epochs );
+ timestamp_init( time, (time_t)( ( in / 10000000 ) - secs_between_epochs ) );
 }
 
 #endif /* OS_NT */

Modified: trunk/tools/build/v2/engine/filent.h
==============================================================================
--- trunk/tools/build/v2/engine/filent.h (original)
+++ trunk/tools/build/v2/engine/filent.h 2012-07-14 12:11:16 EDT (Sat, 14 Jul 2012)
@@ -11,12 +11,12 @@
 #ifndef FILENT_JG20120714_H
 #define FILENT_JG20120714_H
 
+#include "timestamp.h"
+
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
-#include <time.h>
-
 double filetime_to_seconds( FILETIME const ft );
-time_t filetime_to_timestamp( FILETIME const ft );
+void filetime_to_timestamp( FILETIME const ft, timestamp * const time );
 
 #endif

Modified: trunk/tools/build/v2/engine/filesys.c
==============================================================================
--- trunk/tools/build/v2/engine/filesys.c (original)
+++ trunk/tools/build/v2/engine/filesys.c 2012-07-14 12:11:16 EDT (Sat, 14 Jul 2012)
@@ -59,7 +59,7 @@
  * file_build1() - construct a path string based on PATHNAME information
  */
 
-void file_build1( PATHNAME * f, string * file )
+void file_build1( PATHNAME * const f, string * file )
 {
     if ( DEBUG_SEARCH )
     {
@@ -123,7 +123,7 @@
  * referenced.
  */
 
-file_info_t * file_info( OBJECT * path )
+file_info_t * file_info( OBJECT * const path )
 {
     OBJECT * const path_key = path_as_key( path );
     file_info_t * finfo;
@@ -139,7 +139,7 @@
         finfo->is_file = 0;
         finfo->is_dir = 0;
         finfo->size = 0;
- finfo->time = 0;
+ timestamp_clear( &finfo->time );
         finfo->files = L0;
     }
     else
@@ -153,7 +153,7 @@
  * file_is_file() - return whether a path identifies an existing file
  */
 
-int file_is_file( OBJECT * path )
+int file_is_file( OBJECT * const path )
 {
     file_info_t const * const ff = file_query( path );
     return ff ? ff->is_file : -1;
@@ -164,11 +164,11 @@
  * file_time() - get a file timestamp
  */
 
-int file_time( OBJECT * path, time_t * time )
+int file_time( OBJECT * const path, timestamp * const time )
 {
     file_info_t const * const ff = file_query( path );
     if ( !ff ) return -1;
- *time = ff->time;
+ timestamp_copy( time, &ff->time );
     return 0;
 }
 
@@ -180,7 +180,7 @@
  * the path does not reference an existing file system object.
  */
 
-file_info_t * file_query( OBJECT * path )
+file_info_t * file_query( OBJECT * const path )
 {
     /* FIXME: Add tracking for disappearing files (i.e. those that can not be
      * detected by stat() even though they had been detected successfully
@@ -196,7 +196,7 @@
      * failed.
      */
     file_info_t * const ff = file_info( path );
- if ( !ff->time )
+ if ( timestamp_empty( &ff->time ) )
     {
         if ( file_query_( ff ) < 0 )
             return 0;
@@ -204,7 +204,8 @@
         /* Set the path's timestamp to 1 in case it is 0 or undetected to avoid
          * confusion with non-existing paths.
          */
- if ( !ff->time ) ff->time = 1;
+ if ( timestamp_empty( &ff->time ) )
+ timestamp_init( &ff->time, 1 );
     }
     return ff;
 }
@@ -222,7 +223,7 @@
     char const * const pathstr = object_str( info->name );
     char const * const pathspec = *pathstr ? pathstr : ".";
 
- assert( !info->time );
+ assert( timestamp_empty( &info->time ) );
 
     if ( stat( pathspec, &statbuf ) < 0 )
         return -1;
@@ -230,7 +231,7 @@
     info->is_file = statbuf.st_mode & S_IFREG ? 1 : 0;
     info->is_dir = statbuf.st_mode & S_IFDIR ? 1 : 0;
     info->size = statbuf.st_size;
- info->time = statbuf.st_mtime;
+ timestamp_init( &info->time, statbuf.st_mtime );
     return 0;
 }
 
@@ -296,7 +297,7 @@
              * short path variant thus allowing for many different path
              * strings identifying the same file.
              */
- (*func)( closure, ff->name, 1 /* stat()'ed */, ff->time );
+ (*func)( closure, ff->name, 1 /* stat()'ed */, &ff->time );
         }
     }
 }

Modified: trunk/tools/build/v2/engine/filesys.h
==============================================================================
--- trunk/tools/build/v2/engine/filesys.h (original)
+++ trunk/tools/build/v2/engine/filesys.h 2012-07-14 12:11:16 EDT (Sat, 14 Jul 2012)
@@ -21,6 +21,7 @@
 #include "lists.h"
 #include "object.h"
 #include "pathsys.h"
+#include "timestamp.h"
 
 
 typedef struct file_info_t
@@ -29,22 +30,23 @@
     short is_file;
     short is_dir;
     unsigned long size;
- time_t time;
+ timestamp time;
     LIST * files;
 } file_info_t;
 
-typedef void (*scanback)( void * closure, OBJECT * path, int found, time_t t );
+typedef void (*scanback)( void * closure, OBJECT * path, int found,
+ timestamp const * const t );
 
 
 void file_archscan( char const * arch, scanback func, void * closure );
-void file_build1( PATHNAME * f, string * file ) ;
+void file_build1( PATHNAME * const f, string * file ) ;
 void file_dirscan( OBJECT * dir, scanback func, void * closure );
-file_info_t * file_info( OBJECT * path );
-int file_is_file( OBJECT * path );
+file_info_t * file_info( OBJECT * const path );
+int file_is_file( OBJECT * const path );
 int file_mkdir( char const * const path );
-file_info_t * file_query( OBJECT * path );
+file_info_t * file_query( OBJECT * const path );
 void file_remove_atexit( OBJECT * const path );
-int file_time( OBJECT * path, time_t * time );
+int file_time( OBJECT * const path, timestamp * const time );
 
 /* Internal utility worker functions. */
 int file_query_posix_( file_info_t * const info );

Modified: trunk/tools/build/v2/engine/fileunix.c
==============================================================================
--- trunk/tools/build/v2/engine/fileunix.c (original)
+++ trunk/tools/build/v2/engine/fileunix.c 2012-07-14 12:11:16 EDT (Sat, 14 Jul 2012)
@@ -157,7 +157,7 @@
 
     /* Special case / : enter it */
     if ( !strcmp( object_str( d->name ), "/" ) )
- (*func)( closure, d->name, 1 /* stat()'ed */, d->time );
+ (*func)( closure, d->name, 1 /* stat()'ed */, &d->time );
 }
 
 
@@ -230,7 +230,6 @@
         char * c;
         char * src;
         char * dest;
- OBJECT * member;
 
         strncpy( lar_name, ar_hdr.ar_name, sizeof( ar_hdr.ar_name ) );
 
@@ -274,9 +273,13 @@
 
         sprintf( buf, "%s(%s)", archive, lar_name );
 
- member = object_new( buf );
- (*func)( closure, member, 1 /* time valid */, (time_t)lar_date );
- object_free( member );
+ {
+ OBJECT * const member = object_new( buf );
+ timestamp time;
+ timestamp_init( &time, (time_t)lar_date );
+ (*func)( closure, member, 1 /* time valid */, &time );
+ object_free( member );
+ }
 
         offset += SARHDR + ( ( lar_size + 1 ) & ~1 );
         lseek( fd, offset, 0 );
@@ -317,7 +320,6 @@
     {
         long lar_date;
         int lar_namlen;
- OBJECT * member;
 
         sscanf( ar_hdr.hdr.ar_namlen, "%d" , &lar_namlen );
         sscanf( ar_hdr.hdr.ar_date , "%ld", &lar_date );
@@ -330,9 +332,13 @@
 
         sprintf( buf, "%s(%s)", archive, ar_hdr.hdr._ar_name.ar_name );
 
- member = object_new( buf );
- (*func)( closure, member, 1 /* time valid */, (time_t)lar_date );
- object_free( member );
+ {
+ OBJECT * const member = object_new( buf );
+ timestamp time;
+ timestamp_init( &time, (time_t)lar_date );
+ (*func)( closure, member, 1 /* time valid */, &time );
+ object_free( member );
+ }
     }
 }
 
@@ -365,7 +371,6 @@
     {
         long lar_date;
         int lar_namlen;
- OBJECT * member;
 
         sscanf( ar_hdr.hdr.ar_namlen, "%d" , &lar_namlen );
         sscanf( ar_hdr.hdr.ar_date , "%ld" , &lar_date );
@@ -378,9 +383,13 @@
 
         sprintf( buf, "%s(%s)", archive, ar_hdr.hdr._ar_name.ar_name );
 
- member = object_new( buf );
- (*func)( closure, member, 1 /* time valid */, (time_t)lar_date );
- object_free( member );
+ {
+ OBJECT * const member = object_new( buf );
+ timestamp time;
+ timestamp_init( &time, (time_t)lar_date );
+ (*func)( closure, member, 1 /* time valid */, &time );
+ object_free( member );
+ }
     }
 }
 

Modified: trunk/tools/build/v2/engine/hcache.c
==============================================================================
--- trunk/tools/build/v2/engine/hcache.c (original)
+++ trunk/tools/build/v2/engine/hcache.c 2012-07-14 12:11:16 EDT (Sat, 14 Jul 2012)
@@ -39,6 +39,7 @@
 #include "regexp.h"
 #include "rules.h"
 #include "search.h"
+#include "timestamp.h"
 #include "variable.h"
 
 typedef struct hcachedata HCACHEDATA ;
@@ -46,7 +47,7 @@
 struct hcachedata
 {
     OBJECT * boundname;
- time_t time;
+ timestamp time;
     LIST * includes;
     LIST * hdrscan; /* the HDRSCAN value for this target */
     int age; /* if too old, we will remove it from cache */
@@ -243,7 +244,7 @@
             goto cleanup;
         }
 
- cachedata.time = atoi( object_str( time_str ) );
+ timestamp_init( &cachedata.time, atoi( object_str( time_str ) ) );
         cachedata.age = atoi( object_str( age_str ) ) + 1;
 
         count = atoi( object_str( includes_count_str ) );
@@ -286,10 +287,10 @@
         if ( !found )
         {
             c->boundname = cachedata.boundname;
- c->time = cachedata.time;
             c->includes = cachedata.includes;
             c->hdrscan = cachedata.hdrscan;
             c->age = cachedata.age;
+ timestamp_copy( &c->time, &cachedata.time );
         }
         else
         {
@@ -372,9 +373,11 @@
         else if ( c->age > maxage )
             continue;
 
- sprintf( includes_count_str, "%lu", (long unsigned) list_length( c->includes ) );
- sprintf( hdrscan_count_str, "%lu", (long unsigned) list_length( c->hdrscan ) );
- sprintf( time_str, "%lu", (long unsigned)c->time );
+ sprintf( includes_count_str, "%lu", (long unsigned)list_length(
+ c->includes ) );
+ sprintf( hdrscan_count_str, "%lu", (long unsigned)list_length(
+ c->hdrscan ) );
+ sprintf( time_str, "%lu", (long unsigned)c->time.secs );
         sprintf( age_str, "%lu", (long unsigned)c->age );
 
         write_netstring( f, CACHE_RECORD_HEADER );
@@ -423,7 +426,7 @@
 
     if ( ( c = (HCACHEDATA *)hash_find( hcachehash, t->boundname ) ) )
     {
- if ( c->time == t->time )
+ if ( !timestamp_cmp( &c->time, &t->time ) )
         {
             LIST * const l1 = hdrscan;
             LIST * const l2 = c->hdrscan;
@@ -496,7 +499,7 @@
     {
         LIST * const l = headers1( L0, t->boundname, rec, re );
 
- c->time = t->time;
+ timestamp_copy( &c->time, &t->time );
         c->age = 0;
         c->includes = list_copy( l );
         c->hdrscan = list_copy( hdrscan );

Modified: trunk/tools/build/v2/engine/jam.c
==============================================================================
--- trunk/tools/build/v2/engine/jam.c (original)
+++ trunk/tools/build/v2/engine/jam.c 2012-07-14 12:11:16 EDT (Sat, 14 Jul 2012)
@@ -386,7 +386,12 @@
 #endif
 
         /* Set JAMDATE. */
- var_set( root_module(), constant_JAMDATE, list_new( outf_time(time(0)) ), VAR_SET );
+ {
+ timestamp current;
+ timestamp_init( &current, time( 0 ) );
+ var_set( root_module(), constant_JAMDATE, list_new( outf_time(
+ &current ) ), VAR_SET );
+ }
 
         /* Set JAM_VERSION. */
         var_set( root_module(), constant_JAM_VERSION,

Modified: trunk/tools/build/v2/engine/make.c
==============================================================================
--- trunk/tools/build/v2/engine/make.c (original)
+++ trunk/tools/build/v2/engine/make.c 2012-07-14 12:11:16 EDT (Sat, 14 Jul 2012)
@@ -30,6 +30,7 @@
  */
 
 #include "jam.h"
+#include "make.h"
 
 #include "command.h"
 #ifdef OPT_HEADER_CACHE_EXT
@@ -37,11 +38,11 @@
 #endif
 #include "headers.h"
 #include "lists.h"
-#include "make.h"
 #include "object.h"
 #include "parse.h"
 #include "rules.h"
 #include "search.h"
+#include "timestamp.h"
 #include "variable.h"
 
 #include <assert.h>
@@ -283,9 +284,9 @@
     TARGETS * c;
     TARGET * ptime = t;
     TARGET * located_target = 0;
- time_t last;
- time_t leaf;
- time_t hlast;
+ timestamp last;
+ timestamp leaf;
+ timestamp hlast;
     int fate;
     char const * flag = "";
     SETTINGS * s;
@@ -331,7 +332,9 @@
         if ( another_target )
             located_target = bindtarget( another_target );
 
- t->binding = t->time ? T_BIND_EXISTS : T_BIND_MISSING;
+ t->binding = timestamp_empty( &t->time )
+ ? T_BIND_MISSING
+ : T_BIND_EXISTS;
     }
 
     /* INTERNAL, NOTFILE header nodes have the time of their parents. */
@@ -387,8 +390,8 @@
             break;
 
         case T_BIND_EXISTS:
- printf( "time\t--\t%s%s: %s", spaces( depth ),
- object_str( t->name ), ctime( &t->time ) );
+ printf( "time\t--\t%s%s: %s\n", spaces( depth ),
+ object_str( t->name ), timestamp_str( &t->time ) );
             break;
         }
     }
@@ -466,8 +469,8 @@
      */
 
     /* Step 4a: Pick up dependencies' time and fate. */
- last = 0;
- leaf = 0;
+ timestamp_clear( &last );
+ timestamp_clear( &leaf );
     fate = T_FATE_STABLE;
     for ( c = t->depends; c; c = c->next )
     {
@@ -479,8 +482,10 @@
             TARGET * const scc_root = target_scc( c->target );
             if ( scc_root != t->scc_root )
             {
- c->target->leaf = max( c->target->leaf, scc_root->leaf );
- c->target->time = max( c->target->time, scc_root->time );
+ timestamp_max( &c->target->leaf, &c->target->leaf,
+ &scc_root->leaf );
+ timestamp_max( &c->target->time, &c->target->time,
+ &scc_root->time );
                 c->target->fate = max( c->target->fate, scc_root->fate );
             }
         }
@@ -488,13 +493,13 @@
         /* If LEAVES has been applied, we only heed the timestamps of the leaf
          * source nodes.
          */
- leaf = max( leaf, c->target->leaf );
+ timestamp_max( &leaf, &leaf, &c->target->leaf );
         if ( t->flags & T_FLAG_LEAVES )
         {
- last = leaf;
+ timestamp_copy( &last, &leaf );
             continue;
         }
- last = max( last, c->target->time );
+ timestamp_max( &last, &last, &c->target->time );
         fate = max( fate, c->target->fate );
 
 #ifdef OPT_GRAPH_DEBUG_EXT
@@ -513,7 +518,10 @@
      * If a header is newer than a temp source that includes it, the temp source
      * will need building.
      */
- hlast = t->includes ? t->includes->time : 0;
+ if ( t->includes )
+ timestamp_copy( &hlast, &t->includes->time );
+ else
+ timestamp_clear( &hlast );
 
     /* Step 4c: handle NOUPDATE oddity.
      *
@@ -530,8 +538,8 @@
                     object_str( t->name ) );
 #endif
 
- last = 0;
- t->time = 0;
+ timestamp_clear( &last );
+ timestamp_clear( &t->time );
 
         /* Do not inherit our fate from our dependencies. Decide fate based only
          * upon other flags and our binding (done later).
@@ -575,21 +583,24 @@
     {
         fate = T_FATE_MISSING;
     }
- else if ( ( t->binding == T_BIND_EXISTS ) && ( last > t->time ) )
+ else if ( t->binding == T_BIND_EXISTS && timestamp_cmp( &last, &t->time ) >
+ 0 )
     {
 #ifdef OPT_GRAPH_DEBUG_EXT
         oldTimeStamp = 1;
 #endif
         fate = T_FATE_OUTDATED;
     }
- else if ( ( t->binding == T_BIND_PARENTS ) && ( last > p->time ) )
+ else if ( t->binding == T_BIND_PARENTS && timestamp_cmp( &last, &p->time ) >
+ 0 )
     {
 #ifdef OPT_GRAPH_DEBUG_EXT
         oldTimeStamp = 1;
 #endif
         fate = T_FATE_NEEDTMP;
     }
- else if ( ( t->binding == T_BIND_PARENTS ) && ( hlast > p->time ) )
+ else if ( t->binding == T_BIND_PARENTS && timestamp_cmp( &hlast, &p->time )
+ > 0 )
     {
         fate = T_FATE_NEEDTMP;
     }
@@ -601,12 +612,12 @@
     {
         fate = T_FATE_TOUCHED;
     }
- else if ( ( t->binding == T_BIND_EXISTS ) && ( t->flags & T_FLAG_TEMP ) )
+ else if ( t->binding == T_BIND_EXISTS && ( t->flags & T_FLAG_TEMP ) )
     {
         fate = T_FATE_ISTMP;
     }
- else if ( ( t->binding == T_BIND_EXISTS ) && p &&
- ( p->binding != T_BIND_UNBOUND ) && ( t->time > p->time ) )
+ else if ( t->binding == T_BIND_EXISTS && p && p->binding != T_BIND_UNBOUND
+ && timestamp_cmp( &t->time, &p->time ) > 0 )
     {
 #ifdef OPT_GRAPH_DEBUG_EXT
         oldTimeStamp = 1;
@@ -658,8 +669,8 @@
     /* Step 4f: Propagate dependencies' time & fate. */
     /* Set leaf time to be our time only if this is a leaf. */
 
- t->time = max( t->time, last );
- t->leaf = leaf ? leaf : t->time ;
+ timestamp_max( &t->time, &t->time, &last );
+ timestamp_copy( &t->leaf, timestamp_empty( &leaf ) ? &t->time : &leaf );
     /* This target's fate may have been updated by virtue of following some
      * target's rebuilds list, so only allow it to be increased to the fate we
      * have calculated. Otherwise, grab its new fate.
@@ -715,7 +726,8 @@
 
     if ( !( t->flags & T_FLAG_NOTFILE ) && ( fate >= T_FATE_SPOIL ) )
         flag = "+";
- else if ( ( t->binding == T_BIND_EXISTS ) && p && ( t->time > p->time ) )
+ else if ( t->binding == T_BIND_EXISTS && p && timestamp_cmp( &t->time,
+ &p->time ) > 0 )
         flag = "*";
 
     if ( DEBUG_MAKEPROG )
@@ -824,7 +836,7 @@
     {
         printf( " %s : Depends on %s (%s)", spaces( depth ),
            target_name( c->target ), target_fate[ (int)c->target->fate ] );
- if ( c->target->time == t->time )
+ if ( !timestamp_cmp( &c->target->time, &t->time ) )
             printf( " (max time)");
         printf( "\n" );
     }
@@ -860,7 +872,7 @@
         chain = chain->next;
 
         /* Find point s in result for c. */
- while ( s && ( s->target->time > c->target->time ) )
+ while ( s && timestamp_cmp( &s->target->time, &c->target->time ) > 0 )
             s = s->next;
 
         /* Insert c in front of s (might be 0). */

Modified: trunk/tools/build/v2/engine/make1.c
==============================================================================
--- trunk/tools/build/v2/engine/make1.c (original)
+++ trunk/tools/build/v2/engine/make1.c 2012-07-14 12:11:16 EDT (Sat, 14 Jul 2012)
@@ -513,7 +513,8 @@
         if ( globs.noexec || cmd->noop )
         {
             timing_info time_info = { 0 };
- time_info.start = time_info.end = time( 0 );
+ timestamp_init( &time_info.start, time( 0 ) );
+ timestamp_copy( &time_info.end, &time_info.start );
             make1c_closure( t, EXEC_CMD_OK, &time_info, "", "", EXIT_OK );
         }
         else
@@ -687,7 +688,7 @@
  * timing_info.
  */
 
-static void call_timing_rule( TARGET * target, timing_info const * time )
+static void call_timing_rule( TARGET * target, timing_info const * const time )
 {
     LIST * timing_rule;
 
@@ -712,9 +713,9 @@
 
         /* start end user system :: info about the action command */
         lol_add( frame->args, list_push_back( list_push_back( list_push_back( list_new(
- outf_time ( time->start ) ),
- outf_time ( time->end ) ),
- outf_double( time->user ) ),
+ outf_time( &time->start ) ),
+ outf_time( &time->end ) ),
+ outf_double( time->user ) ),
             outf_double( time->system ) ) );
 
         /* Call the rule. */
@@ -772,8 +773,8 @@
             list_push_back( list_push_back( list_push_back( list_push_back( list_push_back( list_new(
                 object_new( executed_command ) ),
                 outf_int( status ) ),
- outf_time( time->start ) ),
- outf_time( time->end ) ),
+ outf_time( &time->start ) ),
+ outf_time( &time->end ) ),
                 outf_double( time->user ) ),
                 outf_double( time->system ) ) );
 
@@ -1233,6 +1234,6 @@
     pushsettings( root_module(), t->settings );
     object_free( t->boundname );
     t->boundname = search( t->name, &t->time, 0, t->flags & T_FLAG_ISFILE );
- t->binding = t->time ? T_BIND_EXISTS : T_BIND_MISSING;
+ t->binding = timestamp_empty( &t->time ) ? T_BIND_MISSING : T_BIND_EXISTS;
     popsettings( root_module(), t->settings );
 }

Modified: trunk/tools/build/v2/engine/modules/path.c
==============================================================================
--- trunk/tools/build/v2/engine/modules/path.c (original)
+++ trunk/tools/build/v2/engine/modules/path.c 2012-07-14 12:11:16 EDT (Sat, 14 Jul 2012)
@@ -9,9 +9,9 @@
 
 LIST * path_exists( FRAME * frame, int flags )
 {
- time_t time;
- timestamp_from_target( list_front( lol_get( frame->args, 0 ) ), &time );
- return time ? list_new( object_new( "true" ) ) : L0;
+ timestamp time;
+ timestamp_from_path( &time, list_front( lol_get( frame->args, 0 ) ) );
+ return timestamp_empty( &time ) ? L0 : list_new( object_new( "true" ) );
 }
 
 

Modified: trunk/tools/build/v2/engine/output.c
==============================================================================
--- trunk/tools/build/v2/engine/output.c (original)
+++ trunk/tools/build/v2/engine/output.c 2012-07-14 12:11:16 EDT (Sat, 14 Jul 2012)
@@ -6,13 +6,16 @@
 
 #include "jam.h"
 #include "output.h"
-#include "object.h"
+
+#include "timestamp.h"
+
 #include <stdio.h>
 
+
 #define bjam_out (stdout)
 #define bjam_err (stderr)
 
-static void out_( char const * data, FILE * io )
+static void out_( char const * data, FILE * const io )
 {
     while ( *data )
     {
@@ -25,12 +28,12 @@
 
 void out_action
 (
- char const * action,
- char const * target,
- char const * command,
- char const * out_data,
- char const * err_data,
- int exit_reason
+ char const * const action,
+ char const * const target,
+ char const * const command,
+ char const * const out_data,
+ char const * const err_data,
+ int const exit_reason
 )
 {
     /* Print out the action + target line, if the action is quiet the action
@@ -75,7 +78,7 @@
 }
 
 
-OBJECT * outf_int( int value )
+OBJECT * outf_int( int const value )
 {
     char buffer[ 50 ];
     sprintf( buffer, "%i", value );
@@ -83,7 +86,7 @@
 }
 
 
-OBJECT * outf_double( double value )
+OBJECT * outf_double( double const value )
 {
     char buffer[ 50 ];
     sprintf( buffer, "%f", value );
@@ -91,9 +94,9 @@
 }
 
 
-OBJECT * outf_time( time_t value )
+OBJECT * outf_time( timestamp const * const time )
 {
     char buffer[ 50 ];
- strftime( buffer, 49, "%Y-%m-%d %H:%M:%SZ", gmtime( &value ) );
+ strftime( buffer, 49, "%Y-%m-%d %H:%M:%SZ", gmtime( &time->secs ) );
     return object_new( buffer );
 }

Modified: trunk/tools/build/v2/engine/output.h
==============================================================================
--- trunk/tools/build/v2/engine/output.h (original)
+++ trunk/tools/build/v2/engine/output.h 2012-07-14 12:11:16 EDT (Sat, 14 Jul 2012)
@@ -8,23 +8,23 @@
 #define BJAM_OUTPUT_H
 
 #include "object.h"
-#include <time.h>
+#include "timestamp.h"
 
 #define EXIT_OK 0
 #define EXIT_FAIL 1
 #define EXIT_TIMEOUT 2
 
 void out_action(
- const char * action,
- const char * target,
- const char * command,
- const char * out_data,
- const char * err_data,
- int exit_reason
- );
+ char const * const action,
+ char const * const target,
+ char const * const command,
+ char const * const out_data,
+ char const * const err_data,
+ int const exit_reason
+);
 
-OBJECT * outf_int( int value );
-OBJECT * outf_double( double value );
-OBJECT * outf_time( time_t value );
+OBJECT * outf_int( int const value );
+OBJECT * outf_double( double const value );
+OBJECT * outf_time( timestamp const * const value );
 
 #endif

Modified: trunk/tools/build/v2/engine/rules.h
==============================================================================
--- trunk/tools/build/v2/engine/rules.h (original)
+++ trunk/tools/build/v2/engine/rules.h 2012-07-14 12:11:16 EDT (Sat, 14 Jul 2012)
@@ -10,21 +10,11 @@
  * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
  */
 
-#ifndef RULES_DWA_20011020_H
-#define RULES_DWA_20011020_H
-
-#include "jam.h"
-
-#include "function.h"
-#include "modules.h"
-
-
 /*
  * rules.h - targets, rules, and related information
  *
- * This file describes the structures holding the targets, rules, and
- * related information accumulated by interpreting the statements
- * of the jam files.
+ * This file describes the structures holding the targets, rules, and related
+ * information accumulated by interpreting the statements of the jam files.
  *
  * The following are defined:
  *
@@ -36,6 +26,16 @@
  * TARGET - an entity (e.g. a file) that can be built.
  */
 
+#ifndef RULES_DWA_20011020_H
+#define RULES_DWA_20011020_H
+
+#include "jam.h"
+
+#include "function.h"
+#include "modules.h"
+#include "timestamp.h"
+
+
 typedef struct _rule RULE;
 typedef struct _target TARGET;
 typedef struct _targets TARGETS;
@@ -170,8 +170,8 @@
     TARGET * original_target; /* original_target->includes = this */
     char rescanned;
 
- time_t time; /* update time */
- time_t leaf; /* update time of leaf sources */
+ timestamp time; /* update time */
+ timestamp leaf; /* update time of leaf sources */
 
     char fate; /* make0()'s diagnosis */
 

Modified: trunk/tools/build/v2/engine/search.c
==============================================================================
--- trunk/tools/build/v2/engine/search.c (original)
+++ trunk/tools/build/v2/engine/search.c 2012-07-14 12:11:16 EDT (Sat, 14 Jul 2012)
@@ -85,8 +85,8 @@
  * 'another_target'.
  */
 
-OBJECT * search( OBJECT * target, time_t * time, OBJECT * * another_target,
- int file )
+OBJECT * search( OBJECT * target, timestamp * const time,
+ OBJECT * * another_target, int const file )
 {
     PATHNAME f[ 1 ];
     LIST * varlist;
@@ -127,7 +127,7 @@
         explicitly_located = 1;
 
         key = object_new( buf->value );
- timestamp_from_target( key, time );
+ timestamp_from_path( time, key );
         object_free( key );
         found = 1;
     }
@@ -156,7 +156,7 @@
             key = path_as_key( test_path );
             object_free( test_path );
             ff = file_query( key );
- timestamp_from_target( key, time );
+ timestamp_from_path( time, key );
 
             if ( ( ba = (BINDING *)hash_find( explicit_bindings, key ) ) )
             {
@@ -169,7 +169,7 @@
                 object_free( key );
                 break;
             }
- else if ( ff && ff->time )
+ else if ( ff && !timestamp_empty( &ff->time ) )
             {
                 if ( !file || ff->is_file )
                 {
@@ -200,7 +200,7 @@
             printf( "search %s: %s\n", object_str( target ), buf->value );
 
         key = object_new( buf->value );
- timestamp_from_target( key, time );
+ timestamp_from_path( time, key );
         object_free( key );
     }
 

Modified: trunk/tools/build/v2/engine/search.h
==============================================================================
--- trunk/tools/build/v2/engine/search.h (original)
+++ trunk/tools/build/v2/engine/search.h 2012-07-14 12:11:16 EDT (Sat, 14 Jul 2012)
@@ -12,10 +12,10 @@
 #define SEARCH_SW20111118_H
 
 #include "object.h"
-#include <time.h>
+#include "timestamp.h"
 
-OBJECT * search( OBJECT * target, time_t * time, OBJECT * * another_target,
- int file );
+OBJECT * search( OBJECT * target, timestamp * const time,
+ OBJECT * * another_target, int const file );
 void search_done( void );
 
 #endif

Modified: trunk/tools/build/v2/engine/timestamp.c
==============================================================================
--- trunk/tools/build/v2/engine/timestamp.c (original)
+++ trunk/tools/build/v2/engine/timestamp.c 2012-07-14 12:11:16 EDT (Sat, 14 Jul 2012)
@@ -14,8 +14,8 @@
  * timestamp.c - get the timestamp of a file or archive member
  *
  * External routines:
- * timestamp_from_target() - return timestamp on a file, if present
- * timestamp_done() - free timestamp tables
+ * timestamp_from_path() - return timestamp for a path, if present
+ * timestamp_done() - free timestamp tables
  *
  * Internal routines:
  * time_enter() - internal worker callback for scanning archives &
@@ -39,11 +39,11 @@
 
 typedef struct _binding {
     OBJECT * name;
- short flags;
+ short flags;
 
 #define BIND_SCANNED 0x01 /* if directory or arch, has been scanned */
 
- short progress;
+ short progress;
 
 #define BIND_INIT 0 /* never seen */
 #define BIND_NOENTRY 1 /* timestamp requested but file never found */
@@ -51,12 +51,13 @@
 #define BIND_MISSING 3 /* file found but can not get timestamp */
 #define BIND_FOUND 4 /* file found and time stamped */
 
- /* update time - 0 if not exist */
- time_t time;
+ /* update time - cleared if the there is nothing to bind */
+ timestamp time;
 } BINDING;
 
 static struct hash * bindhash = 0;
-static void time_enter( void *, OBJECT *, int const found, time_t );
+static void time_enter( void *, OBJECT *, int const found,
+ timestamp const * const );
 
 static char * time_progress[] =
 {
@@ -68,11 +69,35 @@
 };
 
 
+void timestamp_clear( timestamp * const time )
+{
+ time->secs = 0;
+}
+
+
+int timestamp_cmp( timestamp const * const lhs, timestamp const * const rhs )
+{
+ return lhs->secs - rhs->secs;
+}
+
+
+void timestamp_copy( timestamp * const target, timestamp const * const source )
+{
+ target->secs = source->secs;
+}
+
+
+int timestamp_empty( timestamp const * const time )
+{
+ return !time->secs;
+}
+
+
 /*
- * timestamp_from_target() - return timestamp on a file, if present
+ * timestamp_from_path() - return timestamp for a path, if present
  */
 
-void timestamp_from_target( OBJECT * target, time_t * time )
+void timestamp_from_path( timestamp * const time, OBJECT * path )
 {
     PROFILE_ENTER( timestamp );
 
@@ -82,7 +107,7 @@
     BINDING * b;
     string buf[ 1 ];
 
- target = path_as_key( target );
+ OBJECT * const normalized_path = path_as_key( path );
 
     string_new( buf );
 
@@ -91,12 +116,13 @@
 
     /* Quick path - is it there? */
 
- b = (BINDING *)hash_insert( bindhash, target, &found );
+ b = (BINDING *)hash_insert( bindhash, normalized_path, &found );
     if ( !found )
     {
- b->name = object_copy( target ); /* never freed */
- b->time = b->flags = 0;
+ b->name = object_copy( normalized_path ); /* never freed */
+ b->flags = 0;
         b->progress = BIND_INIT;
+ timestamp_clear( &b->time );
     }
 
     if ( b->progress != BIND_INIT )
@@ -105,7 +131,7 @@
     b->progress = BIND_NOENTRY;
 
     /* Not found - have to scan for it. */
- path_parse( object_str( target ), &f1 );
+ path_parse( object_str( normalized_path ), &f1 );
 
     /* Scan directory if not already done so. */
     {
@@ -124,8 +150,9 @@
         if ( !found )
         {
             b->name = object_copy( name );
- b->time = b->flags = 0;
+ b->flags = 0;
             b->progress = BIND_INIT;
+ timestamp_clear( &b->time );
         }
 
         if ( !( b->flags & BIND_SCANNED ) )
@@ -156,8 +183,9 @@
         if ( !found )
         {
             b->name = object_copy( name );
- b->time = b->flags = 0;
+ b->flags = 0;
             b->progress = BIND_INIT;
+ timestamp_clear( &b->time );
         }
 
         if ( !( b->flags & BIND_SCANNED ) )
@@ -178,21 +206,51 @@
             : BIND_FOUND;
     }
 
- *time = b->progress == BIND_FOUND ? b->time : 0;
+ if ( b->progress == BIND_FOUND )
+ timestamp_copy( time, &b->time );
+ else
+ timestamp_clear( time );
 
     string_free( buf );
- object_free( target );
+ object_free( normalized_path );
 
     PROFILE_EXIT( timestamp );
 }
 
 
+void timestamp_init( timestamp * const time, time_t const secs )
+{
+ time->secs = secs;
+}
+
+
+void timestamp_max( timestamp * const max, timestamp const * const lhs,
+ timestamp const * const rhs )
+{
+ if ( timestamp_cmp( lhs, rhs ) > 0 )
+ timestamp_copy( max, lhs );
+ else
+ timestamp_copy( max, rhs );
+}
+
+
+char const * timestamp_str( timestamp const * const time )
+{
+ static char result[ 500 ];
+ char format[ 500 ];
+ strftime( format, sizeof( result ) / sizeof( *result ),
+ "%Y-%m-%d %H:%M:%S.%%09d +0000", gmtime( &time->secs ) );
+ sprintf( result, format, 0 );
+ return result;
+}
+
+
 /*
  * time_enter() - internal worker callback for scanning archives & directories
  */
 
 static void time_enter( void * closure, OBJECT * target, int const found,
- time_t time )
+ timestamp const * const time )
 {
     int item_found;
     BINDING * b;
@@ -207,7 +265,7 @@
         b->flags = 0;
     }
 
- b->time = time;
+ timestamp_copy( &b->time, time );
     b->progress = found ? BIND_FOUND : BIND_SPOTTED;
 
     if ( DEBUG_BINDSCAN )

Modified: trunk/tools/build/v2/engine/timestamp.h
==============================================================================
--- trunk/tools/build/v2/engine/timestamp.h (original)
+++ trunk/tools/build/v2/engine/timestamp.h 2012-07-14 12:11:16 EDT (Sat, 14 Jul 2012)
@@ -15,7 +15,21 @@
 
 #include <time.h>
 
-void timestamp_from_target( OBJECT * target, time_t * time );
+typedef struct timestamp
+{
+ time_t secs;
+} timestamp;
+
+void timestamp_clear( timestamp * const time );
+int timestamp_cmp( timestamp const * const lhs, timestamp const * const rhs );
+void timestamp_copy( timestamp * const target, timestamp const * const source );
+int timestamp_empty( timestamp const * const time );
+void timestamp_from_path( timestamp * const time, OBJECT * path );
+void timestamp_init( timestamp * const time, time_t const secs );
+void timestamp_max( timestamp * const max, timestamp const * const lhs,
+ timestamp const * const rhs );
+char const * timestamp_str( timestamp const * const time );
+
 void timestamp_done();
 
 #endif


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