< prev index next >

src/hotspot/os/windows/os_windows.cpp

Print this page
rev 49101 : [mq]: fix


1501   // If an encoding error occurred (result < 0) then it's not clear
1502   // whether the buffer is NUL terminated, so ensure it is.
1503   if ((result < 0) && (len > 0)) {
1504     buf[len - 1] = '\0';
1505   }
1506   return result;
1507 #else
1508   // Before Visual Studio 2015, vsnprintf is not C99 compliant, so use
1509   // _vsnprintf, whose behavior seems to be *mostly* consistent across
1510   // versions.  However, when len == 0, avoid _vsnprintf too, and just
1511   // go straight to _vscprintf.  The output is going to be truncated in
1512   // that case, except in the unusual case of empty output.  More
1513   // importantly, the documentation for various versions of Visual Studio
1514   // are inconsistent about the behavior of _vsnprintf when len == 0,
1515   // including it possibly being an error.
1516   int result = -1;
1517   if (len > 0) {
1518     result = _vsnprintf(buf, len, fmt, args);
1519     // If output (including NUL terminator) is truncated, the buffer
1520     // won't be NUL terminated.  Add the trailing NUL specified by C99.
1521     if ((result < 0) || (result >= len)) {
1522       buf[len - 1] = '\0';
1523     }
1524   }
1525   if (result < 0) {
1526     result = _vscprintf(fmt, args);
1527   }
1528   return result;
1529 #endif // _MSC_VER dispatch
1530 }
1531 
1532 static inline time_t get_mtime(const char* filename) {
1533   struct stat st;
1534   int ret = os::stat(filename, &st);
1535   assert(ret == 0, "failed to stat() file '%s': %s", filename, strerror(errno));
1536   return st.st_mtime;
1537 }
1538 
1539 int os::compare_file_modified_times(const char* file1, const char* file2) {
1540   time_t t1 = get_mtime(file1);
1541   time_t t2 = get_mtime(file2);




1501   // If an encoding error occurred (result < 0) then it's not clear
1502   // whether the buffer is NUL terminated, so ensure it is.
1503   if ((result < 0) && (len > 0)) {
1504     buf[len - 1] = '\0';
1505   }
1506   return result;
1507 #else
1508   // Before Visual Studio 2015, vsnprintf is not C99 compliant, so use
1509   // _vsnprintf, whose behavior seems to be *mostly* consistent across
1510   // versions.  However, when len == 0, avoid _vsnprintf too, and just
1511   // go straight to _vscprintf.  The output is going to be truncated in
1512   // that case, except in the unusual case of empty output.  More
1513   // importantly, the documentation for various versions of Visual Studio
1514   // are inconsistent about the behavior of _vsnprintf when len == 0,
1515   // including it possibly being an error.
1516   int result = -1;
1517   if (len > 0) {
1518     result = _vsnprintf(buf, len, fmt, args);
1519     // If output (including NUL terminator) is truncated, the buffer
1520     // won't be NUL terminated.  Add the trailing NUL specified by C99.
1521     if ((result < 0) || ((size_t)result >= len)) {
1522       buf[len - 1] = '\0';
1523     }
1524   }
1525   if (result < 0) {
1526     result = _vscprintf(fmt, args);
1527   }
1528   return result;
1529 #endif // _MSC_VER dispatch
1530 }
1531 
1532 static inline time_t get_mtime(const char* filename) {
1533   struct stat st;
1534   int ret = os::stat(filename, &st);
1535   assert(ret == 0, "failed to stat() file '%s': %s", filename, strerror(errno));
1536   return st.st_mtime;
1537 }
1538 
1539 int os::compare_file_modified_times(const char* file1, const char* file2) {
1540   time_t t1 = get_mtime(file1);
1541   time_t t2 = get_mtime(file2);


< prev index next >