Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r79506 - trunk/tools/build/v2/engine
From: jurko.gospodnetic_at_[hidden]
Date: 2012-07-14 13:17:11


Author: jurko
Date: 2012-07-14 13:17:09 EDT (Sat, 14 Jul 2012)
New Revision: 79506
URL: http://svn.boost.org/trac/boost/changeset/79506

Log:
Boost Jam's internal timestamp data structure now holds a member for nanosecond information. This information is still always set to 0 but, if set, is used when needed. Updated Boost Jam's header cache file format to hold the new extended timestamp information (bumped format version up to 5).
Text files modified:
   trunk/tools/build/v2/engine/execunix.c | 4 ++--
   trunk/tools/build/v2/engine/filent.c | 9 +++++----
   trunk/tools/build/v2/engine/filesys.c | 4 ++--
   trunk/tools/build/v2/engine/fileunix.c | 8 ++++----
   trunk/tools/build/v2/engine/hcache.c | 32 ++++++++++++++++++++------------
   trunk/tools/build/v2/engine/jam.c | 2 +-
   trunk/tools/build/v2/engine/make1.c | 2 +-
   trunk/tools/build/v2/engine/timestamp.c | 15 ++++++++++-----
   trunk/tools/build/v2/engine/timestamp.h | 6 ++++--
   9 files changed, 49 insertions(+), 33 deletions(-)

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 13:17:09 EDT (Sat, 14 Jul 2012)
@@ -184,7 +184,7 @@
 
     /* Start the command */
 
- timestamp_init( &cmdtab[ slot ].start_dt, time( 0 ) );
+ timestamp_init( &cmdtab[ slot ].start_dt, time( 0 ), 0 );
 
     if ( 0 < globs.timeout )
     {
@@ -506,7 +506,7 @@
                     time_info.user = (double)( new_time.tms_cutime -
                         old_time.tms_cutime ) / CLOCKS_PER_SEC;
                     timestamp_copy( &time_info.start, &cmdtab[ i ].start_dt );
- timestamp_init( &time_info.end, time( 0 ) );
+ timestamp_init( &time_info.end, time( 0 ), 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 13:17:09 EDT (Sat, 14 Jul 2012)
@@ -111,7 +111,7 @@
             ff->is_dir = !ff->is_file;
             ff->size = finfo->ff_fsize;
             timestamp_init( &ff->time, ( finfo->ff_ftime << 16 ) |
- finfo->ff_ftime );
+ finfo->ff_ftime, 0 );
         }
     }
     while ( !findnext( finfo ) );
@@ -142,7 +142,7 @@
                 ff->is_file = finfo->attrib & _A_SUBDIR ? 0 : 1;
                 ff->is_dir = !ff->is_file;
                 ff->size = finfo->size;
- timestamp_init( &ff->time, finfo->time_write );
+ timestamp_init( &ff->time, finfo->time_write, 0 );
             }
         }
         while ( !_findnext( handle, finfo ) );
@@ -339,7 +339,7 @@
         {
             OBJECT * const member = object_new( buf );
             timestamp time;
- timestamp_init( &time, (time_t)lar_date );
+ timestamp_init( &time, (time_t)lar_date, 0 );
             (*func)( closure, member, 1 /* time valid */, &time );
             object_free( member );
         }
@@ -388,7 +388,8 @@
     /* For resolutions finer than 1 second use the following:
      * nsec = (int)( in % 10000000 ) * 100;
      */
- timestamp_init( time, (time_t)( ( in / 10000000 ) - secs_between_epochs ) );
+ timestamp_init( time, (time_t)( ( in / 10000000 ) - secs_between_epochs ), 0
+ );
 }
 
 #endif /* OS_NT */

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 13:17:09 EDT (Sat, 14 Jul 2012)
@@ -205,7 +205,7 @@
          * confusion with non-existing paths.
          */
         if ( timestamp_empty( &ff->time ) )
- timestamp_init( &ff->time, 1 );
+ timestamp_init( &ff->time, 1, 0 );
     }
     return ff;
 }
@@ -231,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;
- timestamp_init( &info->time, statbuf.st_mtime );
+ timestamp_init( &info->time, statbuf.st_mtime, 0 );
     return 0;
 }
 

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 13:17:09 EDT (Sat, 14 Jul 2012)
@@ -276,7 +276,7 @@
         {
             OBJECT * const member = object_new( buf );
             timestamp time;
- timestamp_init( &time, (time_t)lar_date );
+ timestamp_init( &time, (time_t)lar_date, 0 );
             (*func)( closure, member, 1 /* time valid */, &time );
             object_free( member );
         }
@@ -335,7 +335,7 @@
         {
             OBJECT * const member = object_new( buf );
             timestamp time;
- timestamp_init( &time, (time_t)lar_date );
+ timestamp_init( &time, (time_t)lar_date, 0 );
             (*func)( closure, member, 1 /* time valid */, &time );
             object_free( member );
         }
@@ -370,7 +370,7 @@
         read( fd, &ar_hdr, sizeof( ar_hdr ) ) >= sizeof( ar_hdr.hdr ) )
     {
         long lar_date;
- int lar_namlen;
+ int lar_namlen;
 
         sscanf( ar_hdr.hdr.ar_namlen, "%d" , &lar_namlen );
         sscanf( ar_hdr.hdr.ar_date , "%ld" , &lar_date );
@@ -386,7 +386,7 @@
         {
             OBJECT * const member = object_new( buf );
             timestamp time;
- timestamp_init( &time, (time_t)lar_date );
+ timestamp_init( &time, (time_t)lar_date, 0 );
             (*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 13:17:09 EDT (Sat, 14 Jul 2012)
@@ -22,7 +22,7 @@
  *
  * The dependency file format is an ASCII file with 1 line per target. Each line
  * has the following fields:
- * @boundname@ timestamp @file@ @file@ @file@ ...
+ * @boundname@ timestamp_sec timestamp_nsec @file@ @file@ @file@ ...
  */
 
 #ifdef OPT_HEADER_CACHE_EXT
@@ -61,7 +61,7 @@
 static int queries = 0;
 static int hits = 0;
 
-#define CACHE_FILE_VERSION "version 4"
+#define CACHE_FILE_VERSION "version 5"
 #define CACHE_RECORD_HEADER "header"
 #define CACHE_RECORD_END "end"
 
@@ -201,7 +201,8 @@
         HCACHEDATA cachedata;
         HCACHEDATA * c;
         OBJECT * record_type = 0;
- OBJECT * time_str = 0;
+ OBJECT * time_secs_str = 0;
+ OBJECT * time_nsecs_str = 0;
         OBJECT * age_str = 0;
         OBJECT * includes_count_str = 0;
         OBJECT * hdrscan_count_str = 0;
@@ -233,18 +234,20 @@
         }
 
         cachedata.boundname = read_netstring( f );
- time_str = read_netstring( f );
+ time_secs_str = read_netstring( f );
+ time_nsecs_str = read_netstring( f );
         age_str = read_netstring( f );
         includes_count_str = read_netstring( f );
 
- if ( !cachedata.boundname || !time_str || !age_str ||
- !includes_count_str )
+ if ( !cachedata.boundname || !time_secs_str || !time_nsecs_str ||
+ !age_str || !includes_count_str )
         {
             fprintf( stderr, "invalid %s\n", hcachename );
             goto cleanup;
         }
 
- timestamp_init( &cachedata.time, atoi( object_str( time_str ) ) );
+ timestamp_init( &cachedata.time, atoi( object_str( time_secs_str ) ),
+ atoi( object_str( time_nsecs_str ) ) );
         cachedata.age = atoi( object_str( age_str ) ) + 1;
 
         count = atoi( object_str( includes_count_str ) );
@@ -305,7 +308,8 @@
         ++header_count;
 
         object_free( record_type );
- object_free( time_str );
+ object_free( time_secs_str );
+ object_free( time_nsecs_str );
         object_free( age_str );
         object_free( includes_count_str );
         object_free( hdrscan_count_str );
@@ -314,7 +318,8 @@
 cleanup:
 
         if ( record_type ) object_free( record_type );
- if ( time_str ) object_free( time_str );
+ if ( time_secs_str ) object_free( time_secs_str );
+ if ( time_nsecs_str ) object_free( time_nsecs_str );
         if ( age_str ) object_free( age_str );
         if ( includes_count_str ) object_free( includes_count_str );
         if ( hdrscan_count_str ) object_free( hdrscan_count_str );
@@ -363,7 +368,8 @@
     {
         LISTITER iter;
         LISTITER end;
- char time_str[ 30 ];
+ char time_secs_str[ 30 ];
+ char time_nsecs_str[ 30 ];
         char age_str[ 30 ];
         char includes_count_str[ 30 ];
         char hdrscan_count_str[ 30 ];
@@ -377,12 +383,14 @@
             c->includes ) );
         sprintf( hdrscan_count_str, "%lu", (long unsigned)list_length(
             c->hdrscan ) );
- sprintf( time_str, "%lu", (long unsigned)c->time.secs );
+ sprintf( time_secs_str, "%lu", (long unsigned)c->time.secs );
+ sprintf( time_nsecs_str, "%lu", (long unsigned)c->time.nsecs );
         sprintf( age_str, "%lu", (long unsigned)c->age );
 
         write_netstring( f, CACHE_RECORD_HEADER );
         write_netstring( f, object_str( c->boundname ) );
- write_netstring( f, time_str );
+ write_netstring( f, time_secs_str );
+ write_netstring( f, time_nsecs_str );
         write_netstring( f, age_str );
         write_netstring( f, includes_count_str );
         for ( iter = list_begin( c->includes ), end = list_end( c->includes );

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 13:17:09 EDT (Sat, 14 Jul 2012)
@@ -388,7 +388,7 @@
         /* Set JAMDATE. */
         {
             timestamp current;
- timestamp_init( &current, time( 0 ) );
+ timestamp_init( &current, time( 0 ), 0 );
             var_set( root_module(), constant_JAMDATE, list_new( outf_time(
                 &current ) ), VAR_SET );
         }

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 13:17:09 EDT (Sat, 14 Jul 2012)
@@ -513,7 +513,7 @@
         if ( globs.noexec || cmd->noop )
         {
             timing_info time_info = { 0 };
- timestamp_init( &time_info.start, time( 0 ) );
+ timestamp_init( &time_info.start, time( 0 ), 0 );
             timestamp_copy( &time_info.end, &time_info.start );
             make1c_closure( t, EXEC_CMD_OK, &time_info, "", "", EXIT_OK );
         }

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 13:17:09 EDT (Sat, 14 Jul 2012)
@@ -71,12 +71,14 @@
 
 void timestamp_clear( timestamp * const time )
 {
- time->secs = 0;
+ time->secs = time->nsecs = 0;
 }
 
 
 int timestamp_cmp( timestamp const * const lhs, timestamp const * const rhs )
 {
+ if ( lhs->secs == rhs->secs )
+ return lhs->nsecs - rhs->nsecs;
     return lhs->secs - rhs->secs;
 }
 
@@ -84,12 +86,13 @@
 void timestamp_copy( timestamp * const target, timestamp const * const source )
 {
     target->secs = source->secs;
+ target->nsecs = source->nsecs;
 }
 
 
 int timestamp_empty( timestamp const * const time )
 {
- return !time->secs;
+ return !time->secs && !time->nsecs;
 }
 
 
@@ -97,7 +100,7 @@
  * timestamp_from_path() - return timestamp for a path, if present
  */
 
-void timestamp_from_path( timestamp * const time, OBJECT * path )
+void timestamp_from_path( timestamp * const time, OBJECT * const path )
 {
     PROFILE_ENTER( timestamp );
 
@@ -218,9 +221,11 @@
 }
 
 
-void timestamp_init( timestamp * const time, time_t const secs )
+void timestamp_init( timestamp * const time, time_t const secs, int const nsecs
+ )
 {
     time->secs = secs;
+ time->nsecs = nsecs;
 }
 
 
@@ -240,7 +245,7 @@
     char format[ 500 ];
     strftime( format, sizeof( result ) / sizeof( *result ),
         "%Y-%m-%d %H:%M:%S.%%09d +0000", gmtime( &time->secs ) );
- sprintf( result, format, 0 );
+ sprintf( result, format, time->nsecs );
     return result;
 }
 

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 13:17:09 EDT (Sat, 14 Jul 2012)
@@ -18,14 +18,16 @@
 typedef struct timestamp
 {
     time_t secs;
+ int nsecs;
 } 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_from_path( timestamp * const time, OBJECT * const path );
+void timestamp_init( timestamp * const time, time_t const secs, int const nsecs
+ );
 void timestamp_max( timestamp * const max, timestamp const * const lhs,
     timestamp const * const rhs );
 char const * timestamp_str( timestamp const * const time );


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