diff options
Diffstat (limited to '')
| -rw-r--r-- | project/Makefile | 2 | ||||
| -rw-r--r-- | project/dclib/dclib-file.c | 24 | ||||
| -rw-r--r-- | project/dclib/dclib-file.h | 115 | ||||
| -rw-r--r-- | project/makefiles-local/Makefile.local.mac | 6 | ||||
| -rw-r--r-- | project/revision.sh | 2 | ||||
| -rw-r--r-- | project/src/lib-std.c | 4 |
6 files changed, 107 insertions, 46 deletions
diff --git a/project/Makefile b/project/Makefile index bae1f88..a58d597 100644 --- a/project/Makefile +++ b/project/Makefile @@ -59,7 +59,7 @@ WSTRT_SHORT = wstrt WSTRT_LONG = Wiimms StaticR Tool VERSION_NUM = 2.20a -BETA_VERSION = 4 +BETA_VERSION = 5 # 0:off -1:"beta" >0:"beta#" URI_HOME = https://szs.wiimm.de/ diff --git a/project/dclib/dclib-file.c b/project/dclib/dclib-file.c index 2cc8fa1..ef14011 100644 --- a/project/dclib/dclib-file.c +++ b/project/dclib/dclib-file.c @@ -254,12 +254,18 @@ FileAttrib_t * SetFileAttrib memcpy(dest,src_fa,sizeof(*dest)); else if (src_stat) { - memset(dest,0,sizeof(*dest)); + ZeroFileAttrib(dest); if (S_ISREG(src_stat->st_mode)) { + #if HAVE_FILEATTRIB_NSEC dest->atime = src_stat->st_atim; dest->mtime = src_stat->st_mtim; dest->ctime = src_stat->st_ctim; + #else + dest->atime.tv_sec = src_stat->st_atime; + dest->mtime.tv_sec = src_stat->st_mtime; + dest->ctime.tv_sec = src_stat->st_ctime; + #endif dest->itime = CompareTimeSpec(&dest->mtime,&dest->ctime) > 0 ? dest->mtime : dest->ctime; dest->size = src_stat->st_size; @@ -320,6 +326,7 @@ FileAttrib_t * MaxFileAttrib { if ( S_ISREG(src_stat->st_mode) ) { + #if HAVE_STATTIME_NSEC if ( CompareTimeSpec(&dest->atime,&src_stat->st_atim) > 0 ) dest->atime = src_stat->st_atim; @@ -333,6 +340,21 @@ FileAttrib_t * MaxFileAttrib dest->itime = src_stat->st_mtim; if ( CompareTimeSpec(&dest->itime,&src_stat->st_ctim) > 0 ) dest->itime = src_stat->st_ctim; + #else + if ( CompareTimeSpecTime(&dest->atime,src_stat->st_atime) > 0 ) + dest->atime = src_stat->st_atim; + + if ( CompareTimeSpecTime(&dest->mtime,src_stat->st_mtime) > 0 ) + dest->mtime = src_stat->st_mtim; + + if ( CompareTimeSpecTime(&dest->ctime,src_stat->st_ctime) > 0 ) + dest->ctime = src_stat->st_ctim; + + if ( CompareTimeSpecTime(&dest->itime,src_stat->st_mtime) > 0 ) + dest->itime = src_stat->st_mtim; + if ( CompareTimeSpecTime(&dest->itime,src_stat->st_ctime) > 0 ) + dest->itime = src_stat->st_ctim; + #endif if ( dest->size < src_stat->st_size ) dest->size = src_stat->st_size; diff --git a/project/dclib/dclib-file.h b/project/dclib/dclib-file.h index 06f39b5..05e520e 100644 --- a/project/dclib/dclib-file.h +++ b/project/dclib/dclib-file.h @@ -124,6 +124,80 @@ ccp GetFileOpenMode // /////////////////////////////////////////////////////////////////////////////// +/////////////// nanoseconds: struct stat, struct timespec /////////////// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef HAVE_STATTIME_NSEC + #if defined(st_atime) && defined(st_mtime) && defined(st_ctime) && !defined(__APPLE__) + #define HAVE_STATTIME_NSEC 1 + #else + #define HAVE_STATTIME_NSEC 0 + #endif +#endif + +//----------------------------------------------------------------------------- + +#undef STATTIME_SEC +#undef STATTIME_NSEC +#if HAVE_STATTIME_NSEC + #define STATTIME_SEC(t) ((t).tv_sec) + #define STATTIME_NSEC(t) ((t).tv_nsec) +#else + #define STATTIME_SEC(t) (t) + #define STATTIME_NSEC(t) 0 +#endif + +/////////////////////////////////////////////////////////////////////////////// +// struct timespec helpers + +extern const struct timespec null_timespec; + +// NULL pointers allowed +int CompareTimeSpec0 ( const struct timespec *a, const struct timespec *b ); + +// NULL pointers forbidden +static inline int CompareTimeSpec + ( const struct timespec *a, const struct timespec *b ) +{ + DASSERT(a); + DASSERT(b); + return a->tv_sec < b->tv_sec ? -1 + : a->tv_sec > b->tv_sec ? 1 + : a->tv_nsec < b->tv_nsec ? -1 + : a->tv_nsec > b->tv_nsec; +} + +// NULL pointers forbidden +static inline int CompareTimeSpecVal + ( const struct timespec *a, const struct timeval *b ) +{ + DASSERT(a); + DASSERT(b); + return a->tv_sec < b->tv_sec ? -1 + : a->tv_sec > b->tv_sec ? 1 + : a->tv_nsec < b->tv_usec*1000 ? -1 + : a->tv_nsec > b->tv_usec*1000; +} + +// NULL pointers forbidden +static inline int CompareTimeSpecTime ( const struct timespec *a, const time_t tim ) +{ + DASSERT(a); + DASSERT(b); + return a->tv_sec < tim ? -1 + : a->tv_sec > tim ? 1 + : a->tv_nsec > 0; +} + +static inline bool IsTimeSpecNull ( const struct timespec *ts ) +{ + return !ts + || ts->tv_nsec > 1000000000 // includes UTIME_NOW || UTIME_OMIT + || !ts->tv_nsec && !ts->tv_sec; +} + +// +/////////////////////////////////////////////////////////////////////////////// /////////////// struct FileAttrib_t /////////////// /////////////////////////////////////////////////////////////////////////////// @@ -131,7 +205,7 @@ ccp GetFileOpenMode #if defined(st_mtime) && !defined(__APPLE__) #define HAVE_FILEATTRIB_NSEC 1 #else - #define HAVE_FILEATTRIB_NSEC 0 + #define HAVE_FILEATTRIB_NSEC 1 #endif #endif @@ -227,45 +301,6 @@ FileAttrib_t * NormalizeFileAttrib FileAttrib_t * fa // valid attribute ); -/////////////////////////////////////////////////////////////////////////////// -// struct timespec helpers - -extern const struct timespec null_timespec; - -// NULL pointers allowed -int CompareTimeSpec0 ( const struct timespec *a, const struct timespec *b ); - -// NULL pointers forbidden -static inline int CompareTimeSpec - ( const struct timespec *a, const struct timespec *b ) -{ - DASSERT(a); - DASSERT(b); - return a->tv_sec < b->tv_sec ? -1 - : a->tv_sec > b->tv_sec ? 1 - : a->tv_nsec < b->tv_nsec ? -1 - : a->tv_nsec > b->tv_nsec; -} - -// NULL pointers forbidden -static inline int CompareTimeSpecVal - ( const struct timespec *a, const struct timeval *b ) -{ - DASSERT(a); - DASSERT(b); - return a->tv_sec < b->tv_sec ? -1 - : a->tv_sec > b->tv_sec ? 1 - : a->tv_nsec < b->tv_usec*1000 ? -1 - : a->tv_nsec > b->tv_usec*1000; -} - -static inline bool IsTimeSpecNull ( const struct timespec *ts ) -{ - return !ts - || ts->tv_nsec > 1000000000 // includes UTIME_NOW || UTIME_OMIT - || !ts->tv_nsec && !ts->tv_sec; -} - // /////////////////////////////////////////////////////////////////////////////// /////////////// struct File_t /////////////// diff --git a/project/makefiles-local/Makefile.local.mac b/project/makefiles-local/Makefile.local.mac index 04e4c34..d8024e1 100644 --- a/project/makefiles-local/Makefile.local.mac +++ b/project/makefiles-local/Makefile.local.mac @@ -90,12 +90,14 @@ gen-mac-distrib: @cp -p $(DISTRIB_FILES) $(DISTRIB_PATH) @ln -f $(MAIN_TOOLS) $(WDF_LINKS) $(DISTRIB_PATH)/bin - cp -p $(DOC_FILES) $(DISTRIB_PATH)/doc + @cp -p $(DOC_FILES) $(DISTRIB_PATH)/doc @chmod -R 755 $(DISTRIB_PATH) - @chmod a+x $(DISTRIB_PATH)/*.sh $(DISTRIB_PATH)/bin*/* + @chmod a+x $(DISTRIB_PATH)/*.sh $(DISTRIB_PATH)/bin/* @chmod -R a+X $(DISTRIB_PATH) + @$(DISTRIB_PATH)/bin/wszst version -l + @tar -czf $(DISTRIB_PATH).tar.gz $(DISTRIB_PATH) @ln $(DISTRIB_PATH).tar.gz latest-mac.tar.gz diff --git a/project/revision.sh b/project/revision.sh index b54415f..236dbf3 100644 --- a/project/revision.sh +++ b/project/revision.sh @@ -1 +1 @@ -revision=8268M +revision=8269M diff --git a/project/src/lib-std.c b/project/src/lib-std.c index 95e6e64..d0a304f 100644 --- a/project/src/lib-std.c +++ b/project/src/lib-std.c @@ -3792,7 +3792,8 @@ void cmd_version_section ( bool sect_header, ccp name_short, ccp name_long ) "revision=" REVISION "\n" "system=" SYSTEM "\n" "endian=%u%u%u%u %s\n" - "have_nanosec=%d\n" + "have_stattime_nsec=%d\n" + "have_fileattrib_nsec=%d\n" "author=" AUTHOR "\n" "date=" DATE "\n" "url=" URI_HOME "%s\n" @@ -3803,6 +3804,7 @@ void cmd_version_section ( bool sect_header, ccp name_short, ccp name_long ) , e[0], e[1], e[2], e[3] , endian == 0x01020304 ? "little" : endian == 0x04030201 ? "big" : "mixed" + , HAVE_STATTIME_NSEC , HAVE_FILEATTRIB_NSEC , name_short ); |
