Merge branch 'upstream-kwsys' into update-kwsys

This commit is contained in:
Brad King 2015-10-08 13:26:08 -04:00
commit 8083285d1b
4 changed files with 49 additions and 18 deletions

View File

@ -342,11 +342,6 @@ ENDIF()
# capabilities and parent project's request. Enforce 0/1 as only # capabilities and parent project's request. Enforce 0/1 as only
# possible values for configuration into Configure.hxx. # possible values for configuration into Configure.hxx.
IF(UNIX)
KWSYS_PLATFORM_CXX_TEST(KWSYS_STAT_HAS_ST_MTIM
"Checking whether struct stat has st_mtim member" DIRECT)
ENDIF()
# Check existence and uniqueness of long long and __int64. # Check existence and uniqueness of long long and __int64.
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_LONG_LONG KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_LONG_LONG
"Checking whether C++ compiler has 'long long'" DIRECT) "Checking whether C++ compiler has 'long long'" DIRECT)
@ -511,12 +506,18 @@ IF(KWSYS_USE_SystemTools)
"Checking whether CXX compiler has utimes" DIRECT) "Checking whether CXX compiler has utimes" DIRECT)
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_UTIMENSAT KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_UTIMENSAT
"Checking whether CXX compiler has utimensat" DIRECT) "Checking whether CXX compiler has utimensat" DIRECT)
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_STAT_HAS_ST_MTIM
"Checking whether CXX compiler struct stat has st_mtim member" DIRECT)
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_STAT_HAS_ST_MTIMESPEC
"Checking whether CXX compiler struct stat has st_mtimespec member" DIRECT)
SET_PROPERTY(SOURCE SystemTools.cxx APPEND PROPERTY COMPILE_DEFINITIONS SET_PROPERTY(SOURCE SystemTools.cxx APPEND PROPERTY COMPILE_DEFINITIONS
KWSYS_CXX_HAS_SETENV=${KWSYS_CXX_HAS_SETENV} KWSYS_CXX_HAS_SETENV=${KWSYS_CXX_HAS_SETENV}
KWSYS_CXX_HAS_UNSETENV=${KWSYS_CXX_HAS_UNSETENV} KWSYS_CXX_HAS_UNSETENV=${KWSYS_CXX_HAS_UNSETENV}
KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=${KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H} KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=${KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H}
KWSYS_CXX_HAS_UTIMES=${KWSYS_CXX_HAS_UTIMES} KWSYS_CXX_HAS_UTIMES=${KWSYS_CXX_HAS_UTIMES}
KWSYS_CXX_HAS_UTIMENSAT=${KWSYS_CXX_HAS_UTIMENSAT} KWSYS_CXX_HAS_UTIMENSAT=${KWSYS_CXX_HAS_UTIMENSAT}
KWSYS_CXX_STAT_HAS_ST_MTIM=${KWSYS_CXX_STAT_HAS_ST_MTIM}
KWSYS_CXX_STAT_HAS_ST_MTIMESPEC=${KWSYS_CXX_STAT_HAS_ST_MTIMESPEC}
) )
ENDIF() ENDIF()

View File

@ -18,9 +18,6 @@
/* Whether wstring is available. */ /* Whether wstring is available. */
#define @KWSYS_NAMESPACE@_STL_HAS_WSTRING @KWSYS_STL_HAS_WSTRING@ #define @KWSYS_NAMESPACE@_STL_HAS_WSTRING @KWSYS_STL_HAS_WSTRING@
/* Whether struct stat has the st_mtim member for high resolution times. */
#define @KWSYS_NAMESPACE@_STAT_HAS_ST_MTIM @KWSYS_STAT_HAS_ST_MTIM@
/* If building a C++ file in kwsys itself, give the source file /* If building a C++ file in kwsys itself, give the source file
access to the macros without a configured namespace. */ access to the macros without a configured namespace. */
#if defined(KWSYS_NAMESPACE) #if defined(KWSYS_NAMESPACE)
@ -28,7 +25,6 @@
# define kwsys @KWSYS_NAMESPACE@ # define kwsys @KWSYS_NAMESPACE@
# endif # endif
# define KWSYS_NAME_IS_KWSYS @KWSYS_NAMESPACE@_NAME_IS_KWSYS # define KWSYS_NAME_IS_KWSYS @KWSYS_NAMESPACE@_NAME_IS_KWSYS
# define KWSYS_STAT_HAS_ST_MTIM @KWSYS_NAMESPACE@_STAT_HAS_ST_MTIM
# define KWSYS_STL_HAS_WSTRING @KWSYS_NAMESPACE@_STL_HAS_WSTRING # define KWSYS_STL_HAS_WSTRING @KWSYS_NAMESPACE@_STL_HAS_WSTRING
#endif #endif

View File

@ -1366,15 +1366,18 @@ bool SystemTools::Touch(const std::string& filename, bool create)
struct timeval mtime; struct timeval mtime;
gettimeofday(&mtime, 0); gettimeofday(&mtime, 0);
# if KWSYS_CXX_HAS_UTIMES # if KWSYS_CXX_HAS_UTIMES
struct timeval times[2] = struct timeval atime;
{ # if KWSYS_CXX_STAT_HAS_ST_MTIM
# if KWSYS_STAT_HAS_ST_MTIM atime.tv_sec = st.st_atim.tv_sec;
{st.st_atim.tv_sec, st.st_atim.tv_nsec/1000}, /* tv_sec, tv_usec */ atime.tv_usec = st.st_atim.tv_nsec/1000;
# elif KWSYS_CXX_STAT_HAS_ST_MTIMESPEC
atime.tv_sec = st.st_atimespec.tv_sec;
atime.tv_usec = st.st_atimespec.tv_nsec/1000;
# else # else
{st.st_atime, 0}, atime.tv_sec = st.st_atime;
atime.tv_usec = 0;
# endif # endif
mtime struct timeval times[2] = { atime, mtime };
};
if(utimes(filename.c_str(), times) < 0) if(utimes(filename.c_str(), times) < 0)
{ {
return false; return false;
@ -1408,7 +1411,7 @@ bool SystemTools::FileTimeCompare(const std::string& f1,
{ {
return false; return false;
} }
# if KWSYS_STAT_HAS_ST_MTIM # if KWSYS_CXX_STAT_HAS_ST_MTIM
// Compare using nanosecond resolution. // Compare using nanosecond resolution.
if(s1.st_mtim.tv_sec < s2.st_mtim.tv_sec) if(s1.st_mtim.tv_sec < s2.st_mtim.tv_sec)
{ {
@ -1426,6 +1429,24 @@ bool SystemTools::FileTimeCompare(const std::string& f1,
{ {
*result = 1; *result = 1;
} }
# elif KWSYS_CXX_STAT_HAS_ST_MTIMESPEC
// Compare using nanosecond resolution.
if(s1.st_mtimespec.tv_sec < s2.st_mtimespec.tv_sec)
{
*result = -1;
}
else if(s1.st_mtimespec.tv_sec > s2.st_mtimespec.tv_sec)
{
*result = 1;
}
else if(s1.st_mtimespec.tv_nsec < s2.st_mtimespec.tv_nsec)
{
*result = -1;
}
else if(s1.st_mtimespec.tv_nsec > s2.st_mtimespec.tv_nsec)
{
*result = 1;
}
# else # else
// Compare using 1 second resolution. // Compare using 1 second resolution.
if(s1.st_mtime < s2.st_mtime) if(s1.st_mtime < s2.st_mtime)

View File

@ -32,7 +32,7 @@ int main()
} }
#endif #endif
#ifdef TEST_KWSYS_STAT_HAS_ST_MTIM #ifdef TEST_KWSYS_CXX_STAT_HAS_ST_MTIM
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
@ -45,6 +45,19 @@ int main()
} }
#endif #endif
#ifdef TEST_KWSYS_CXX_STAT_HAS_ST_MTIMESPEC
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int main()
{
struct stat stat1;
(void)stat1.st_mtimespec.tv_sec;
(void)stat1.st_mtimespec.tv_nsec;
return 0;
}
#endif
#ifdef TEST_KWSYS_CXX_SAME_LONG_AND___INT64 #ifdef TEST_KWSYS_CXX_SAME_LONG_AND___INT64
void function(long**) {} void function(long**) {}
int main() int main()