src/os/windows/vm/os_windows.cpp

Print this page
rev 6314 : imported patch nmtfix


 113 #elif _M_AMD64
 114 #define __CPU__ amd64
 115 #else
 116 #define __CPU__ i486
 117 #endif
 118 
 119 // save DLL module handle, used by GetModuleFileName
 120 
 121 HINSTANCE vm_lib_handle;
 122 
 123 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) {
 124   switch (reason) {
 125     case DLL_PROCESS_ATTACH:
 126       vm_lib_handle = hinst;
 127       if(ForceTimeHighResolution)
 128         timeBeginPeriod(1L);
 129       break;
 130     case DLL_PROCESS_DETACH:
 131       if(ForceTimeHighResolution)
 132         timeEndPeriod(1L);







 133       break;
 134     default:
 135       break;
 136   }
 137   return true;
 138 }
 139 
 140 static inline double fileTimeAsDouble(FILETIME* time) {
 141   const double high  = (double) ((unsigned int) ~0);
 142   const double split = 10000000.0;
 143   double result = (time->dwLowDateTime / split) +
 144                    time->dwHighDateTime * (high/split);
 145   return result;
 146 }
 147 
 148 // Implementation of os
 149 
 150 bool os::getenv(const char* name, char* buffer, int len) {
 151  int result = GetEnvironmentVariable(name, buffer, len);
 152  return result > 0 && result < len;




 113 #elif _M_AMD64
 114 #define __CPU__ amd64
 115 #else
 116 #define __CPU__ i486
 117 #endif
 118 
 119 // save DLL module handle, used by GetModuleFileName
 120 
 121 HINSTANCE vm_lib_handle;
 122 
 123 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) {
 124   switch (reason) {
 125     case DLL_PROCESS_ATTACH:
 126       vm_lib_handle = hinst;
 127       if(ForceTimeHighResolution)
 128         timeBeginPeriod(1L);
 129       break;
 130     case DLL_PROCESS_DETACH:
 131       if(ForceTimeHighResolution)
 132         timeEndPeriod(1L);
 133 
 134       // Workaround for issue when a custom launcher doesn't call
 135       // DestroyJavaVM and NMT is trying to track memory when free is
 136       // called from a static destructor
 137       if (MemTracker::is_on()) {
 138           MemTracker::shutdown(MemTracker::NMT_normal);
 139       }
 140       break;
 141     default:
 142       break;
 143   }
 144   return true;
 145 }
 146 
 147 static inline double fileTimeAsDouble(FILETIME* time) {
 148   const double high  = (double) ((unsigned int) ~0);
 149   const double split = 10000000.0;
 150   double result = (time->dwLowDateTime / split) +
 151                    time->dwHighDateTime * (high/split);
 152   return result;
 153 }
 154 
 155 // Implementation of os
 156 
 157 bool os::getenv(const char* name, char* buffer, int len) {
 158  int result = GetEnvironmentVariable(name, buffer, len);
 159  return result > 0 && result < len;