< prev index next >

src/os/windows/vm/os_windows.cpp

Print this page
rev 10386 : imported patch 8146879.03


1577   return (GetComputerNameEx(ComputerNameDnsHostname, buf, &size) == TRUE);
1578 }
1579 
1580 void os::get_summary_os_info(char* buf, size_t buflen) {
1581   stringStream sst(buf, buflen);
1582   os::win32::print_windows_version(&sst);
1583   // chop off newline character
1584   char* nl = strchr(buf, '\n');
1585   if (nl != NULL) *nl = '\0';
1586 }
1587 
1588 int os::log_vsnprintf(char* buf, size_t len, const char* fmt, va_list args) {
1589   int ret = vsnprintf(buf, len, fmt, args);
1590   // Get the correct buffer size if buf is too small
1591   if (ret < 0) {
1592     return _vscprintf(fmt, args);
1593   }
1594   return ret;
1595 }
1596 















1597 void os::print_os_info_brief(outputStream* st) {
1598   os::print_os_info(st);
1599 }
1600 
1601 void os::print_os_info(outputStream* st) {
1602 #ifdef ASSERT
1603   char buffer[1024];
1604   st->print("HostName: ");
1605   if (get_host_name(buffer, sizeof(buffer))) {
1606     st->print("%s ", buffer);
1607   } else {
1608     st->print("N/A ");
1609   }
1610 #endif
1611   st->print("OS:");
1612   os::win32::print_windows_version(st);
1613 }
1614 
1615 void os::win32::print_windows_version(outputStream* st) {
1616   OSVERSIONINFOEX osvi;


4596   HANDLE h = (HANDLE)::_get_osfhandle(fd);
4597   long high = (long)(length >> 32);
4598   DWORD ret;
4599 
4600   if (h == (HANDLE)(-1)) {
4601     return -1;
4602   }
4603 
4604   ret = ::SetFilePointer(h, (long)(length), &high, FILE_BEGIN);
4605   if ((ret == 0xFFFFFFFF) && (::GetLastError() != NO_ERROR)) {
4606     return -1;
4607   }
4608 
4609   if (::SetEndOfFile(h) == FALSE) {
4610     return -1;
4611   }
4612 
4613   return 0;
4614 }
4615 



4616 
4617 // This code is a copy of JDK's sysSync
4618 // from src/windows/hpi/src/sys_api_md.c
4619 // except for the legacy workaround for a bug in Win 98
4620 
4621 int os::fsync(int fd) {
4622   HANDLE handle = (HANDLE)::_get_osfhandle(fd);
4623 
4624   if ((!::FlushFileBuffers(handle)) &&
4625       (GetLastError() != ERROR_ACCESS_DENIED)) {
4626     // from winerror.h
4627     return -1;
4628   }
4629   return 0;
4630 }
4631 
4632 static int nonSeekAvailable(int, long *);
4633 static int stdinAvailable(int, long *);
4634 
4635 #define S_ISCHR(mode)   (((mode) & _S_IFCHR) == _S_IFCHR)




1577   return (GetComputerNameEx(ComputerNameDnsHostname, buf, &size) == TRUE);
1578 }
1579 
1580 void os::get_summary_os_info(char* buf, size_t buflen) {
1581   stringStream sst(buf, buflen);
1582   os::win32::print_windows_version(&sst);
1583   // chop off newline character
1584   char* nl = strchr(buf, '\n');
1585   if (nl != NULL) *nl = '\0';
1586 }
1587 
1588 int os::log_vsnprintf(char* buf, size_t len, const char* fmt, va_list args) {
1589   int ret = vsnprintf(buf, len, fmt, args);
1590   // Get the correct buffer size if buf is too small
1591   if (ret < 0) {
1592     return _vscprintf(fmt, args);
1593   }
1594   return ret;
1595 }
1596 
1597 int os::compare_file_modified_times(const char* file1, const char* file2) {
1598   FILETIME ft[2];
1599 
1600   for (int i = 0; i < 2; i++) {
1601     const char* file = (i == 0 ? file1 : file2);
1602     HANDLE fhandle = CreateFile(file, GENERIC_READ, 0, NULL,
1603                                 OPEN_EXISTING, 0, NULL);
1604     BOOL ret = GetFileTime(fhandle, NULL, NULL, &ft[i]);
1605     assert(ret, "GetFileTime for file %s failed: %d", file, GetLastError());
1606     CloseHandle(fhandle);
1607   }
1608 
1609   return CompareFileTime(&ft[0], &ft[2]);
1610 }
1611 
1612 void os::print_os_info_brief(outputStream* st) {
1613   os::print_os_info(st);
1614 }
1615 
1616 void os::print_os_info(outputStream* st) {
1617 #ifdef ASSERT
1618   char buffer[1024];
1619   st->print("HostName: ");
1620   if (get_host_name(buffer, sizeof(buffer))) {
1621     st->print("%s ", buffer);
1622   } else {
1623     st->print("N/A ");
1624   }
1625 #endif
1626   st->print("OS:");
1627   os::win32::print_windows_version(st);
1628 }
1629 
1630 void os::win32::print_windows_version(outputStream* st) {
1631   OSVERSIONINFOEX osvi;


4611   HANDLE h = (HANDLE)::_get_osfhandle(fd);
4612   long high = (long)(length >> 32);
4613   DWORD ret;
4614 
4615   if (h == (HANDLE)(-1)) {
4616     return -1;
4617   }
4618 
4619   ret = ::SetFilePointer(h, (long)(length), &high, FILE_BEGIN);
4620   if ((ret == 0xFFFFFFFF) && (::GetLastError() != NO_ERROR)) {
4621     return -1;
4622   }
4623 
4624   if (::SetEndOfFile(h) == FALSE) {
4625     return -1;
4626   }
4627 
4628   return 0;
4629 }
4630 
4631 int os::fileno(FILE* fp) {
4632   return _fileno(fp);
4633 }
4634 
4635 // This code is a copy of JDK's sysSync
4636 // from src/windows/hpi/src/sys_api_md.c
4637 // except for the legacy workaround for a bug in Win 98
4638 
4639 int os::fsync(int fd) {
4640   HANDLE handle = (HANDLE)::_get_osfhandle(fd);
4641 
4642   if ((!::FlushFileBuffers(handle)) &&
4643       (GetLastError() != ERROR_ACCESS_DENIED)) {
4644     // from winerror.h
4645     return -1;
4646   }
4647   return 0;
4648 }
4649 
4650 static int nonSeekAvailable(int, long *);
4651 static int stdinAvailable(int, long *);
4652 
4653 #define S_ISCHR(mode)   (((mode) & _S_IFCHR) == _S_IFCHR)


< prev index next >