diff options
| author | Wiimm <wiimm@wiimm.de> | 2020-10-03 14:59:19 +0200 |
|---|---|---|
| committer | Wiimm <wiimm@wiimm.de> | 2020-10-03 14:59:19 +0200 |
| commit | a0815499b2d9014695e6e261c909476729445360 (patch) | |
| tree | 7a31ed50ee3c1c62b86f7ddc09273c4cd7eadc8d /project/src | |
| parent | 89f00e8e4730b4834e6cc0c96e14f137ca4ac169 (diff) | |
SZS v2.20a
Diffstat (limited to 'project/src')
| -rw-r--r-- | project/src/lib-kmp-text.c | 4 | ||||
| -rw-r--r-- | project/src/lib-std.c | 27 | ||||
| -rw-r--r-- | project/src/lib-std.h | 3 | ||||
| -rw-r--r-- | project/src/lib-szs-create.c | 7 | ||||
| -rw-r--r-- | project/src/ui/tab-wszst.inc | 3 | ||||
| -rw-r--r-- | project/src/ui/ui-wszst.c | 3 | ||||
| -rw-r--r-- | project/src/ui/ui.def | 3 | ||||
| -rw-r--r-- | project/src/wbmgt.c | 2 | ||||
| -rw-r--r-- | project/src/wctct.c | 2 | ||||
| -rw-r--r-- | project/src/wimgt.c | 2 | ||||
| -rw-r--r-- | project/src/wkclt.c | 2 | ||||
| -rw-r--r-- | project/src/wkmpt.c | 2 | ||||
| -rw-r--r-- | project/src/wlect.c | 2 | ||||
| -rw-r--r-- | project/src/wmdlt.c | 2 | ||||
| -rw-r--r-- | project/src/wpatt.c | 2 | ||||
| -rw-r--r-- | project/src/wstrt.c | 2 | ||||
| -rw-r--r-- | project/src/wszst.c | 4 | ||||
| -rw-r--r-- | project/src/wtest.c | 118 |
18 files changed, 153 insertions, 37 deletions
diff --git a/project/src/lib-kmp-text.c b/project/src/lib-kmp-text.c index 6e6ab87..15f93c8 100644 --- a/project/src/lib-kmp-text.c +++ b/project/src/lib-kmp-text.c @@ -6330,11 +6330,7 @@ enumError SaveTextKMP DASSERT(kmp); DASSERT(fname); - #if HAVE_FILEATTRIB_NSEC PRINT("SaveTextKMP(%s,%d) mtime=%lu\n",fname,set_time,kmp->fatt.mtime.tv_sec); - #else - PRINT("SaveTextKMP(%s,%d) mtime=%lu\n",fname,set_time,kmp->fatt.mtime); - #endif KMP_ACTION_LOG(false,"SaveTextKMP() %s\n",fname); char temp_buf[100]; diff --git a/project/src/lib-std.c b/project/src/lib-std.c index d0a304f..9346208 100644 --- a/project/src/lib-std.c +++ b/project/src/lib-std.c @@ -3776,7 +3776,8 @@ int ScanOptSort ( ccp arg ) /////////////// command version/section /////////////// /////////////////////////////////////////////////////////////////////////////// -void cmd_version_section ( bool sect_header, ccp name_short, ccp name_long ) +void cmd_version_section + ( bool sect_header, ccp name_short, ccp name_long, int verbose ) { if (sect_header) fputs("[version]\n",stdout); @@ -3785,29 +3786,41 @@ void cmd_version_section ( bool sect_header, ccp name_short, ccp name_long ) const u8 * e = (u8*)&base; const u32 endian = be32(e); - printf( "prog=%s\n" + printf( + "prog=%s\n" "name=%s\n" "version=" VERSION "\n" "beta=%d\n" "revision=" REVISION "\n" "system=" SYSTEM "\n" "endian=%u%u%u%u %s\n" - "have_stattime_nsec=%d\n" - "have_fileattrib_nsec=%d\n" "author=" AUTHOR "\n" "date=" DATE "\n" "url=" URI_HOME "%s\n" - "\n" , name_short , name_long , BETA_VERSION , e[0], e[1], e[2], e[3] , endian == 0x01020304 ? "little" : endian == 0x04030201 ? "big" : "mixed" - , HAVE_STATTIME_NSEC - , HAVE_FILEATTRIB_NSEC , name_short ); + + if ( verbose > 0 ) + printf( + #ifdef _POSIX_C_SOURCE + "posix_c_source=%s\n" + #endif + "have_clock_gettime=%d\n" + "have_stattime_nsec=%d\n" + #ifdef _POSIX_C_SOURCE + ,CONVERT_TO_STRING(_POSIX_C_SOURCE) + #endif + , HAVE_CLOCK_GETTIME + , HAVE_STATTIME_NSEC + ); + + putchar('\n'); } // diff --git a/project/src/lib-std.h b/project/src/lib-std.h index ffda6b9..e049a64 100644 --- a/project/src/lib-std.h +++ b/project/src/lib-std.h @@ -2017,7 +2017,8 @@ data_tab_t; /////////////////////////////////////////////////////////////////////////////// -void cmd_version_section ( bool sect_header, ccp name_short, ccp name_long ); +void cmd_version_section + ( bool sect_header, ccp name_short, ccp name_long, int verbose ); enumError cmd_argtest ( int argc, char ** argv ); enumError cmd_error(); diff --git a/project/src/lib-szs-create.c b/project/src/lib-szs-create.c index 77b0fc0..ccf4f1d 100644 --- a/project/src/lib-szs-create.c +++ b/project/src/lib-szs-create.c @@ -808,11 +808,10 @@ enumError CreateSZS { StringCopyE( sd.path_rel, sd.path+sizeof(sd.path), *ptr ); struct stat st; - #if HAVE_FILEATTRIB_NSEC - if ( stat(sd.path,&st) || CompareTimeSpec(&st.st_mtim,&szs.fatt.mtime) < 0 ) + #if HAVE_STATTIME_NSEC + if ( stat(sd.path,&st) || CompareTimeSpec(&szs.fatt.mtime,&st.st_mtim) > 0 ) #else - const time_t mtime = stat(sd.path,&st) ? 0 : st.st_mtime; - if ( mtime < szs.fatt.mtime ) + if ( stat(sd.path,&st) || CompareTimeSpecTime(&szs.fatt.mtime,st.st_mtime) > 0 ) #endif { const bool is_compressed = IsCompressedFF(setup_param2.fform_file); diff --git a/project/src/ui/tab-wszst.inc b/project/src/ui/tab-wszst.inc index 4dcea57..e8f85a2 100644 --- a/project/src/ui/tab-wszst.inc +++ b/project/src/ui/tab-wszst.inc @@ -2497,7 +2497,8 @@ " If set twice, print only the version number." }, { T_COPT, "SECTIONS", 0,0,0 }, { T_COPT, "LONG", 0,0, - "Print in long format. Ignored if option {--sections} is set." }, + "Print in long format (like --sections without section header)." + " If set twice, append developing settings." }, //---------- COMMAND wszst HELP ---------- diff --git a/project/src/ui/ui-wszst.c b/project/src/ui/ui-wszst.c index c4dc814..f6a0afc 100644 --- a/project/src/ui/ui-wszst.c +++ b/project/src/ui/ui-wszst.c @@ -1719,7 +1719,8 @@ static const InfoOption_t option_cmd_VERSION_BRIEF = static const InfoOption_t option_cmd_VERSION_LONG = { OPT_LONG, false, false, false, false, false, 'l', "long", 0, - "Print in long format. Ignored if option --sections is set." + "Print in long format (like --sections without section header). If set" + " twice, append developing settings." }; static const InfoOption_t option_cmd_TEST_VERBOSE = diff --git a/project/src/ui/ui.def b/project/src/ui/ui.def index ec5d3ae..b0b8a3c 100644 --- a/project/src/ui/ui.def +++ b/project/src/ui/ui.def @@ -1850,7 +1850,8 @@ #:def_cmd_opt( "VERSION", "LONG", \ "", \ - "Print in long format. Ignored if option {--sections} is set." ) + "Print in long format (like --sections without section header). If set" \ + " twice, append developing settings." ) #:def_cmd_opt( "HELP", "WIDTH", \ "", \ diff --git a/project/src/wbmgt.c b/project/src/wbmgt.c index 163d9cc..25ba0a9 100644 --- a/project/src/wbmgt.c +++ b/project/src/wbmgt.c @@ -86,7 +86,7 @@ static void help_exit ( bool xmode ) static void print_version_section ( bool print_sect_header ) { - cmd_version_section(print_sect_header,WBMGT_SHORT,WBMGT_LONG); + cmd_version_section(print_sect_header,WBMGT_SHORT,WBMGT_LONG,long_count-1); } /////////////////////////////////////////////////////////////////////////////// diff --git a/project/src/wctct.c b/project/src/wctct.c index 8b5d4a4..e31671e 100644 --- a/project/src/wctct.c +++ b/project/src/wctct.c @@ -76,7 +76,7 @@ static void help_exit ( bool xmode ) static void print_version_section ( bool print_sect_header ) { - cmd_version_section(print_sect_header,WCTCT_SHORT,WCTCT_LONG); + cmd_version_section(print_sect_header,WCTCT_SHORT,WCTCT_LONG,long_count-1); } /////////////////////////////////////////////////////////////////////////////// diff --git a/project/src/wimgt.c b/project/src/wimgt.c index 4abd6b6..d252be9 100644 --- a/project/src/wimgt.c +++ b/project/src/wimgt.c @@ -82,7 +82,7 @@ static void help_exit ( bool xmode ) static void print_version_section ( bool print_sect_header ) { - cmd_version_section(print_sect_header,WIMGT_SHORT,WIMGT_LONG); + cmd_version_section(print_sect_header,WIMGT_SHORT,WIMGT_LONG,long_count-1); } /////////////////////////////////////////////////////////////////////////////// diff --git a/project/src/wkclt.c b/project/src/wkclt.c index 80eed98..2ef0bf5 100644 --- a/project/src/wkclt.c +++ b/project/src/wkclt.c @@ -76,7 +76,7 @@ static void help_exit ( bool xmode ) static void print_version_section ( bool print_sect_header ) { - cmd_version_section(print_sect_header,WKCLT_SHORT,WKCLT_LONG); + cmd_version_section(print_sect_header,WKCLT_SHORT,WKCLT_LONG,long_count-1); } /////////////////////////////////////////////////////////////////////////////// diff --git a/project/src/wkmpt.c b/project/src/wkmpt.c index 1903e53..b1709c2 100644 --- a/project/src/wkmpt.c +++ b/project/src/wkmpt.c @@ -77,7 +77,7 @@ static void help_exit ( bool xmode ) static void print_version_section ( bool print_sect_header ) { - cmd_version_section(print_sect_header,WKMPT_SHORT,WKMPT_LONG); + cmd_version_section(print_sect_header,WKMPT_SHORT,WKMPT_LONG,long_count-1); } /////////////////////////////////////////////////////////////////////////////// diff --git a/project/src/wlect.c b/project/src/wlect.c index d33c3df..b5deded 100644 --- a/project/src/wlect.c +++ b/project/src/wlect.c @@ -78,7 +78,7 @@ static void help_exit ( bool xmode ) static void print_version_section ( bool print_sect_header ) { - cmd_version_section(print_sect_header,WLECT_SHORT,WLECT_LONG); + cmd_version_section(print_sect_header,WLECT_SHORT,WLECT_LONG,long_count-1); } /////////////////////////////////////////////////////////////////////////////// diff --git a/project/src/wmdlt.c b/project/src/wmdlt.c index 868dfe7..8b112a3 100644 --- a/project/src/wmdlt.c +++ b/project/src/wmdlt.c @@ -71,7 +71,7 @@ static void help_exit ( bool xmode ) static void print_version_section ( bool print_sect_header ) { - cmd_version_section(print_sect_header,WMDLT_SHORT,WMDLT_LONG); + cmd_version_section(print_sect_header,WMDLT_SHORT,WMDLT_LONG,long_count-1); } /////////////////////////////////////////////////////////////////////////////// diff --git a/project/src/wpatt.c b/project/src/wpatt.c index 02ce122..09c9814 100644 --- a/project/src/wpatt.c +++ b/project/src/wpatt.c @@ -71,7 +71,7 @@ static void help_exit ( bool xmode ) static void print_version_section ( bool print_sect_header ) { - cmd_version_section(print_sect_header,WPATT_SHORT,WPATT_LONG); + cmd_version_section(print_sect_header,WPATT_SHORT,WPATT_LONG,long_count-1); } /////////////////////////////////////////////////////////////////////////////// diff --git a/project/src/wstrt.c b/project/src/wstrt.c index f2e9c89..a73248a 100644 --- a/project/src/wstrt.c +++ b/project/src/wstrt.c @@ -83,7 +83,7 @@ static void help_exit ( bool xmode ) static void print_version_section ( bool print_sect_header ) { - cmd_version_section(print_sect_header,WSTRT_SHORT,WSTRT_LONG); + cmd_version_section(print_sect_header,WSTRT_SHORT,WSTRT_LONG,long_count-1); } /////////////////////////////////////////////////////////////////////////////// diff --git a/project/src/wszst.c b/project/src/wszst.c index 595d1d9..366f4a7 100644 --- a/project/src/wszst.c +++ b/project/src/wszst.c @@ -177,7 +177,7 @@ static void list_compressions_exit() static void print_version_section ( bool print_sect_header ) { - cmd_version_section(print_sect_header,WSZST_SHORT,WSZST_LONG); + cmd_version_section(print_sect_header,WSZST_SHORT,WSZST_LONG,long_count-1); } /////////////////////////////////////////////////////////////////////////////// @@ -1785,7 +1785,7 @@ static enumError cmd_sha1() { if (long_count>1) { - struct tm * tm = localtime(&FILEATTRIB_SEC(szs.fatt.mtime)); + struct tm * tm = localtime(&szs.fatt.mtime.tv_sec); char timbuf[40]; strftime(timbuf,sizeof(timbuf),"%F %T ",tm); fputs(timbuf,stdout); diff --git a/project/src/wtest.c b/project/src/wtest.c index 79f45c6..83e2d81 100644 --- a/project/src/wtest.c +++ b/project/src/wtest.c @@ -3357,11 +3357,12 @@ static enumError test_timezone ( int argc, char ** argv ) for(;;) { - u_usec_t start = GetTimerUSec(); - ccp t1 = PrintTimevalByFormatUTC("%F %T.@@@@@@ %z",0); - ccp t2 = PrintTimevalByFormat("%F %T.@@@@@@ %z",0); - u_usec_t dur = GetTimerUSec() - start; - printf("%s : %s : in %llu usec\n",t1,t2,dur); + u_nsec_t start = GetTimerNSec(); + ccp t1 = PrintTimespecByFormatUTC("%F %T.@@@@@@@@@ %z",0); + ccp t2 = PrintTimespecByFormat("%F %T.@@@@@@@@@ %z",0); + + u_nsec_t dur = GetTimerNSec() - start; + printf("%s : %s : in %llu nsec\n",t1,t2,dur); fflush(stdout); sleep(1800); } @@ -3373,8 +3374,6 @@ static enumError test_timezone ( int argc, char ** argv ) /////////////// test_timeadjust() /////////////// /////////////////////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - static enumError test_timeadjust ( int argc, char ** argv ) { SetupTimezone(true); @@ -3657,6 +3656,108 @@ static enumError test_slot_info ( int argc, char ** argv ) // /////////////////////////////////////////////////////////////////////////////// +/////////////// test_clock() /////////////// +/////////////////////////////////////////////////////////////////////////////// + +static void print_clock ( u64 sec, u64 nsec, ccp info ) +{ + char sbuf[20], nbuf[20]; + snprintf(sbuf,sizeof(sbuf),"%12llu",sec); + snprintf(nbuf,sizeof(nbuf),"%09llu",nsec); + printf(" %.3s %.3s %.3s %.3s . %.3s %.3s %.3s : %s\n", + sbuf, sbuf+3, sbuf+6, sbuf+9, + nbuf, nbuf+3, nbuf+6, + info ); +} + +static enumError test_clock ( int argc, char ** argv ) +{ + struct timeval tv; + struct timespec ts; + + print_clock(1234567890,123456789,"test"); + + #if HAVE_CLOCK_GETTIME + clock_getres(CLOCK_REALTIME,&ts); + print_clock(ts.tv_sec,ts.tv_nsec,"clock_getres(CLOCK_REALTIME)"); + clock_getres(CLOCK_REALTIME_COARSE,&ts); + print_clock(ts.tv_sec,ts.tv_nsec,"clock_getres(CLOCK_REALTIME_COARSE)"); + #endif + + putchar('\n'); + gettimeofday(&tv,0); + print_clock(tv.tv_sec,1000*tv.tv_usec,"gettimeofday()"); + + #if HAVE_CLOCK_GETTIME + clock_gettime(CLOCK_REALTIME,&ts); + print_clock(ts.tv_sec,ts.tv_nsec,"clock_gettime(CLOCK_REALTIME)"); + clock_gettime(CLOCK_REALTIME_COARSE,&ts); + print_clock(ts.tv_sec,ts.tv_nsec,"clock_gettime(CLOCK_REALTIME_COARSE)"); + #endif + + u_usec_t usec = GetTimeUSec(false); + print_clock(usec/USEC_PER_SEC,usec%USEC_PER_SEC*NSEC_PER_USEC,"GetTimeUSec(false)"); + usec = GetTimeUSec(true); + print_clock(usec/USEC_PER_SEC,usec%USEC_PER_SEC*NSEC_PER_USEC,"GetTimeUSec(true)"); + + u_usec_t nsec = GetTimeNSec(false); + print_clock(nsec/NSEC_PER_SEC,nsec%NSEC_PER_SEC,"GetTimeNSec(false)"); + nsec = GetTimeNSec(true); + print_clock(nsec/NSEC_PER_SEC,nsec%NSEC_PER_SEC,"GetTimeNSec(true)"); + + DayTime_t dt = GetDayTime(false); + print_clock(dt.time,dt.usec*NSEC_PER_USEC,"GetDayTime(false) USec"); + print_clock(dt.time,dt.nsec,"GetDayTime(false) NSec"); + dt = GetDayTime(true); + print_clock(dt.time,dt.usec*NSEC_PER_USEC,"GetDayTime(true) USec"); + print_clock(dt.time,dt.nsec,"GetDayTime(true) NSec"); + + //------------------------------------------------------------------------- + + if ( argc < 2 ) + { + putchar('\n'); + const uint N = 100000000; + + int i; + u_usec_t start = GetTimerUSec(); + for ( i = 0; i < N; i++ ) + gettimeofday(&tv,0); + printf("%9.3f nsec / gettimeofday()\n", + (double)(GetTimerUSec()-start)/N); + + #if HAVE_CLOCK_GETTIME + start = GetTimerUSec(); + for ( i = 0; i < N; i++ ) + clock_gettime(CLOCK_REALTIME,&ts); + printf("%9.3f nsec / clock_gettime(CLOCK_REALTIME)\n", + (double)(GetTimerUSec()-start)/N); + + start = GetTimerUSec(); + for ( i = 0; i < N; i++ ) + clock_gettime(CLOCK_REALTIME_COARSE,&ts); + printf("%9.3f nsec / clock_gettime(CLOCK_REALTIME_COARSE)\n", + (double)(GetTimerUSec()-start)/N); + #endif + } + + //------------------------------------------------------------------------- + + int i; + for ( i = 1; i < argc; i++ ) + { + printf("\n> %s\n",argv[i]); + ccp end = ScanIntervalTS(&ts,argv[i]); + const u_nsec_t nsec = ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec; + printf(" %s | %s\n",PrintTimerNSec(0,0,nsec,9),end); + } + + putchar('\n'); + return 0; +} + +// +/////////////////////////////////////////////////////////////////////////////// /////////////// develop() /////////////// /////////////////////////////////////////////////////////////////////////////// @@ -3888,6 +3989,7 @@ enum CMD_IN_ARCH, // test_in_arch(argc,argv) CMD_SLOT_ATTRIB, // test_slot_attrib(argc,argv) CMD_SLOT_INFO, // test_slot_info(argc,argv) + CMD_CLOCK, // test_clock(argc,argv) CMD__N }; @@ -3944,6 +4046,7 @@ static const KeywordTab_t CommandTab[] = { CMD_IN_ARCH, "IN-ARCH", "INARCH", 0 }, { CMD_SLOT_ATTRIB, "SLOT-ATTRIB", "SA", 0 }, { CMD_SLOT_INFO, "SLOT-INFO", "SI", 0 }, + { CMD_CLOCK, "CLOCK", 0, 0 }, { CMD__N,0,0,0 } }; @@ -4071,6 +4174,7 @@ int main ( int argc, char ** argv ) case CMD_IN_ARCH: test_in_arch(argc,argv); break; case CMD_SLOT_ATTRIB: test_slot_attrib(argc,argv); break; case CMD_SLOT_INFO: test_slot_info(argc,argv); break; + case CMD_CLOCK: test_clock(argc,argv); break; //case CMD_HELP: default: help_exit(); |
