diff options
Diffstat (limited to 'linden/indra/llcommon')
-rw-r--r-- | linden/indra/llcommon/imageids.cpp | 2 | ||||
-rw-r--r-- | linden/indra/llcommon/imageids.h | 1 | ||||
-rw-r--r-- | linden/indra/llcommon/llstring.cpp | 3 | ||||
-rw-r--r-- | linden/indra/llcommon/llsys.cpp | 186 | ||||
-rw-r--r-- | linden/indra/llcommon/llsys.h | 7 |
5 files changed, 170 insertions, 29 deletions
diff --git a/linden/indra/llcommon/imageids.cpp b/linden/indra/llcommon/imageids.cpp index 6b4fcd3..e5343fe 100644 --- a/linden/indra/llcommon/imageids.cpp +++ b/linden/indra/llcommon/imageids.cpp | |||
@@ -75,3 +75,5 @@ const LLUUID TERRAIN_MOUNTAIN_DETAIL ("303cd381-8560-7579-23f1-f0a880799740"); / | |||
75 | const LLUUID TERRAIN_ROCK_DETAIL ("53a2f406-4895-1d13-d541-d2e3b86bc19c"); // VIEWER | 75 | const LLUUID TERRAIN_ROCK_DETAIL ("53a2f406-4895-1d13-d541-d2e3b86bc19c"); // VIEWER |
76 | 76 | ||
77 | const LLUUID DEFAULT_WATER_NORMAL ("822ded49-9a6c-f61c-cb89-6df54f42cdf4"); // VIEWER | 77 | const LLUUID DEFAULT_WATER_NORMAL ("822ded49-9a6c-f61c-cb89-6df54f42cdf4"); // VIEWER |
78 | |||
79 | const LLUUID DEFAULT_UNREZZED_AVATAR_PARTICLE ("c6e07fda-aea5-4149-acb6-6f09980e0db5"); // VIEWER only | ||
diff --git a/linden/indra/llcommon/imageids.h b/linden/indra/llcommon/imageids.h index dc726dc..516fda1 100644 --- a/linden/indra/llcommon/imageids.h +++ b/linden/indra/llcommon/imageids.h | |||
@@ -72,4 +72,5 @@ LL_COMMON_API extern const LLUUID TERRAIN_ROCK_DETAIL; | |||
72 | 72 | ||
73 | LL_COMMON_API extern const LLUUID DEFAULT_WATER_NORMAL; | 73 | LL_COMMON_API extern const LLUUID DEFAULT_WATER_NORMAL; |
74 | 74 | ||
75 | LL_COMMON_API extern const LLUUID DEFAULT_UNREZZED_AVATAR_PARTICLE; | ||
75 | #endif | 76 | #endif |
diff --git a/linden/indra/llcommon/llstring.cpp b/linden/indra/llcommon/llstring.cpp index 32a75c0..069365b 100644 --- a/linden/indra/llcommon/llstring.cpp +++ b/linden/indra/llcommon/llstring.cpp | |||
@@ -50,7 +50,8 @@ std::string ll_safe_string(const char* in) | |||
50 | 50 | ||
51 | std::string ll_safe_string(const char* in, S32 maxlen) | 51 | std::string ll_safe_string(const char* in, S32 maxlen) |
52 | { | 52 | { |
53 | if(in) return std::string(in, maxlen); | 53 | //KOKUA FIXME: Which wormhole all the antistrings (strings with negative length) come from ? |
54 | if(in && maxlen > 0) return std::string(in, maxlen); | ||
54 | return std::string(); | 55 | return std::string(); |
55 | } | 56 | } |
56 | 57 | ||
diff --git a/linden/indra/llcommon/llsys.cpp b/linden/indra/llcommon/llsys.cpp index a56ac47..95dd2e5 100644 --- a/linden/indra/llcommon/llsys.cpp +++ b/linden/indra/llcommon/llsys.cpp | |||
@@ -76,6 +76,75 @@ extern int errno; | |||
76 | static const S32 CPUINFO_BUFFER_SIZE = 16383; | 76 | static const S32 CPUINFO_BUFFER_SIZE = 16383; |
77 | LLCPUInfo gSysCPU; | 77 | LLCPUInfo gSysCPU; |
78 | 78 | ||
79 | #if LL_WINDOWS | ||
80 | #ifndef DLLVERSIONINFO | ||
81 | typedef struct _DllVersionInfo | ||
82 | { | ||
83 | DWORD cbSize; | ||
84 | DWORD dwMajorVersion; | ||
85 | DWORD dwMinorVersion; | ||
86 | DWORD dwBuildNumber; | ||
87 | DWORD dwPlatformID; | ||
88 | }DLLVERSIONINFO; | ||
89 | #endif | ||
90 | |||
91 | #ifndef DLLGETVERSIONPROC | ||
92 | typedef int (FAR WINAPI *DLLGETVERSIONPROC) (DLLVERSIONINFO *); | ||
93 | #endif | ||
94 | |||
95 | bool get_shell32_dll_version(DWORD& major, DWORD& minor, DWORD& build_number) | ||
96 | { | ||
97 | bool result = false; | ||
98 | const U32 BUFF_SIZE = 32767; | ||
99 | WCHAR tempBuf[BUFF_SIZE]; | ||
100 | if(GetSystemDirectory((LPWSTR)&tempBuf, BUFF_SIZE)) | ||
101 | { | ||
102 | |||
103 | std::basic_string<WCHAR> shell32_path(tempBuf); | ||
104 | |||
105 | // Shell32.dll contains the DLLGetVersion function. | ||
106 | // according to msdn its not part of the API | ||
107 | // so you have to go in and get it. | ||
108 | // http://msdn.microsoft.com/en-us/library/bb776404(VS.85).aspx | ||
109 | shell32_path += TEXT("\\shell32.dll"); | ||
110 | |||
111 | HMODULE hDllInst = LoadLibrary(shell32_path.c_str()); //load the DLL | ||
112 | if(hDllInst) | ||
113 | { // Could successfully load the DLL | ||
114 | DLLGETVERSIONPROC pDllGetVersion; | ||
115 | /* | ||
116 | You must get this function explicitly because earlier versions of the DLL | ||
117 | don't implement this function. That makes the lack of implementation of the | ||
118 | function a version marker in itself. | ||
119 | */ | ||
120 | pDllGetVersion = (DLLGETVERSIONPROC) GetProcAddress(hDllInst, | ||
121 | "DllGetVersion"); | ||
122 | |||
123 | if(pDllGetVersion) | ||
124 | { | ||
125 | // DLL supports version retrieval function | ||
126 | DLLVERSIONINFO dvi; | ||
127 | |||
128 | ZeroMemory(&dvi, sizeof(dvi)); | ||
129 | dvi.cbSize = sizeof(dvi); | ||
130 | HRESULT hr = (*pDllGetVersion)(&dvi); | ||
131 | |||
132 | if(SUCCEEDED(hr)) | ||
133 | { // Finally, the version is at our hands | ||
134 | major = dvi.dwMajorVersion; | ||
135 | minor = dvi.dwMinorVersion; | ||
136 | build_number = dvi.dwBuildNumber; | ||
137 | result = true; | ||
138 | } | ||
139 | } | ||
140 | |||
141 | FreeLibrary(hDllInst); // Release DLL | ||
142 | } | ||
143 | } | ||
144 | return result; | ||
145 | } | ||
146 | #endif // LL_WINDOWS | ||
147 | |||
79 | LLOSInfo::LLOSInfo() : | 148 | LLOSInfo::LLOSInfo() : |
80 | mMajorVer(0), mMinorVer(0), mBuild(0) | 149 | mMajorVer(0), mMinorVer(0), mBuild(0) |
81 | { | 150 | { |
@@ -98,44 +167,74 @@ LLOSInfo::LLOSInfo() : | |||
98 | mMinorVer = osvi.dwMinorVersion; | 167 | mMinorVer = osvi.dwMinorVersion; |
99 | mBuild = osvi.dwBuildNumber; | 168 | mBuild = osvi.dwBuildNumber; |
100 | 169 | ||
170 | DWORD shell32_major, shell32_minor, shell32_build; | ||
171 | bool got_shell32_version = get_shell32_dll_version(shell32_major, | ||
172 | shell32_minor, | ||
173 | shell32_build); | ||
174 | |||
101 | switch(osvi.dwPlatformId) | 175 | switch(osvi.dwPlatformId) |
102 | { | 176 | { |
103 | case VER_PLATFORM_WIN32_NT: | 177 | case VER_PLATFORM_WIN32_NT: |
104 | { | 178 | { |
105 | // Test for the product. | 179 | // Test for the product. |
106 | if(osvi.dwMajorVersion <= 4) | 180 | if (osvi.dwMajorVersion <= 4) |
107 | { | 181 | { |
108 | mOSStringSimple = "Microsoft Windows NT "; | 182 | mOSStringSimple = "Microsoft Windows NT "; |
109 | } | 183 | } |
110 | else if(osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) | 184 | else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) |
111 | { | 185 | { |
112 | mOSStringSimple = "Microsoft Windows 2000 "; | 186 | mOSStringSimple = "Microsoft Windows 2000 "; |
113 | } | 187 | } |
114 | else if(osvi.dwMajorVersion ==5 && osvi.dwMinorVersion == 1) | 188 | else if (osvi.dwMajorVersion ==5 && osvi.dwMinorVersion == 1) |
115 | { | 189 | { |
116 | mOSStringSimple = "Microsoft Windows XP "; | 190 | mOSStringSimple = "Microsoft Windows XP "; |
117 | } | 191 | } |
118 | else if(osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) | 192 | else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) |
119 | { | 193 | { |
120 | if(osvi.wProductType == VER_NT_WORKSTATION) | 194 | if (osvi.wProductType == VER_NT_WORKSTATION) |
195 | { | ||
121 | mOSStringSimple = "Microsoft Windows XP x64 Edition "; | 196 | mOSStringSimple = "Microsoft Windows XP x64 Edition "; |
122 | else | 197 | } |
123 | mOSStringSimple = "Microsoft Windows Server 2003 "; | 198 | else |
199 | { | ||
200 | mOSStringSimple = "Microsoft Windows Server 2003 "; | ||
201 | } | ||
124 | } | 202 | } |
125 | else if(osvi.dwMajorVersion == 6 && osvi.dwMinorVersion <= 1) | 203 | else if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion <= 2) |
126 | { | 204 | { |
127 | if(osvi.dwMinorVersion == 0) | 205 | if (osvi.dwMinorVersion == 0) |
128 | { | 206 | { |
129 | mOSStringSimple = "Microsoft Windows Vista "; | 207 | if (osvi.wProductType == VER_NT_WORKSTATION) |
208 | { | ||
209 | mOSStringSimple = "Microsoft Windows Vista "; | ||
210 | } | ||
211 | else | ||
212 | { | ||
213 | mOSStringSimple = "Windows Server 2008 "; | ||
214 | } | ||
215 | |||
130 | } | 216 | } |
131 | else if(osvi.dwMinorVersion == 1) | 217 | else if (osvi.dwMinorVersion == 1) |
132 | { | 218 | { |
133 | mOSStringSimple = "Microsoft Windows 7 "; | 219 | if (osvi.wProductType == VER_NT_WORKSTATION) |
220 | { | ||
221 | mOSStringSimple = "Microsoft Windows 7 "; | ||
222 | } | ||
223 | else | ||
224 | { | ||
225 | mOSStringSimple = "Windows Server 2008 R2 "; | ||
226 | } | ||
134 | } | 227 | } |
135 | 228 | else if (osvi.dwMinorVersion == 2) | |
136 | if(osvi.wProductType != VER_NT_WORKSTATION) | ||
137 | { | 229 | { |
138 | mOSStringSimple += "Server "; | 230 | if (osvi.wProductType == VER_NT_WORKSTATION) |
231 | { | ||
232 | mOSStringSimple = "Microsoft Windows 8 "; | ||
233 | } | ||
234 | else | ||
235 | { | ||
236 | mOSStringSimple = "Windows Server 2012 "; | ||
237 | } | ||
139 | } | 238 | } |
140 | 239 | ||
141 | ///get native system info if available.. | 240 | ///get native system info if available.. |
@@ -146,8 +245,8 @@ LLOSInfo::LLOSInfo() : | |||
146 | pGNSI = (PGNSI) GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo"); //load kernel32 get function | 245 | pGNSI = (PGNSI) GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo"); //load kernel32 get function |
147 | if(NULL != pGNSI) //check if it has failed | 246 | if(NULL != pGNSI) //check if it has failed |
148 | pGNSI(&si); //success | 247 | pGNSI(&si); //success |
149 | else | 248 | else |
150 | GetSystemInfo(&si); //if it fails get regular system info | 249 | GetSystemInfo(&si); //if it fails get regular system info |
151 | //(Warning: If GetSystemInfo it may result in incorrect information in a WOW64 machine, if the kernel fails to load) | 250 | //(Warning: If GetSystemInfo it may result in incorrect information in a WOW64 machine, if the kernel fails to load) |
152 | 251 | ||
153 | //msdn microsoft finds 32 bit and 64 bit flavors this way.. | 252 | //msdn microsoft finds 32 bit and 64 bit flavors this way.. |
@@ -206,6 +305,7 @@ LLOSInfo::LLOSInfo() : | |||
206 | csdversion.c_str(), | 305 | csdversion.c_str(), |
207 | (osvi.dwBuildNumber & 0xffff)); | 306 | (osvi.dwBuildNumber & 0xffff)); |
208 | } | 307 | } |
308 | |||
209 | mOSString = mOSStringSimple + tmpstr; | 309 | mOSString = mOSStringSimple + tmpstr; |
210 | } | 310 | } |
211 | break; | 311 | break; |
@@ -235,6 +335,20 @@ LLOSInfo::LLOSInfo() : | |||
235 | mOSString = mOSStringSimple; | 335 | mOSString = mOSStringSimple; |
236 | break; | 336 | break; |
237 | } | 337 | } |
338 | |||
339 | std::string compatibility_mode; | ||
340 | if(got_shell32_version) | ||
341 | { | ||
342 | if(osvi.dwMajorVersion != shell32_major || osvi.dwMinorVersion != shell32_minor) | ||
343 | { | ||
344 | compatibility_mode = llformat(" compatibility mode. real ver: %d.%d (Build %d)", | ||
345 | shell32_major, | ||
346 | shell32_minor, | ||
347 | shell32_build); | ||
348 | } | ||
349 | } | ||
350 | mOSString += compatibility_mode; | ||
351 | |||
238 | #else | 352 | #else |
239 | struct utsname un; | 353 | struct utsname un; |
240 | if(uname(&un) != -1) | 354 | if(uname(&un) != -1) |
@@ -262,8 +376,8 @@ LLOSInfo::LLOSInfo() : | |||
262 | else if (ostype == "Linux") | 376 | else if (ostype == "Linux") |
263 | { | 377 | { |
264 | // Only care about major and minor Linux versions, truncate at second '.' | 378 | // Only care about major and minor Linux versions, truncate at second '.' |
265 | S32 idx1 = mOSStringSimple.find_first_of(".", 0); | 379 | std::string::size_type idx1 = mOSStringSimple.find_first_of(".", 0); |
266 | S32 idx2 = (idx1 != std::string::npos) ? mOSStringSimple.find_first_of(".", idx1+1) : std::string::npos; | 380 | std::string::size_type idx2 = (idx1 != std::string::npos) ? mOSStringSimple.find_first_of(".", idx1+1) : std::string::npos; |
267 | std::string simple = mOSStringSimple.substr(0, idx2); | 381 | std::string simple = mOSStringSimple.substr(0, idx2); |
268 | if (simple.length() > 0) | 382 | if (simple.length() > 0) |
269 | mOSStringSimple = simple; | 383 | mOSStringSimple = simple; |
@@ -429,15 +543,15 @@ LLCPUInfo::LLCPUInfo() | |||
429 | mHasSSE = info->_Ext.SSE_StreamingSIMD_Extensions; | 543 | mHasSSE = info->_Ext.SSE_StreamingSIMD_Extensions; |
430 | mHasSSE2 = info->_Ext.SSE2_StreamingSIMD2_Extensions; | 544 | mHasSSE2 = info->_Ext.SSE2_StreamingSIMD2_Extensions; |
431 | mHasAltivec = info->_Ext.Altivec_Extensions; | 545 | mHasAltivec = info->_Ext.Altivec_Extensions; |
432 | mCPUMhz = (S32)(proc.GetCPUFrequency(50)/1000000.0); | 546 | mCPUMHz = (F64)(proc.GetCPUFrequency(50)/1000000.0); |
433 | mFamily.assign( info->strFamily ); | 547 | mFamily.assign( info->strFamily ); |
434 | mCPUString = "Unknown"; | 548 | mCPUString = "Unknown"; |
435 | 549 | ||
436 | #if LL_WINDOWS || LL_DARWIN || LL_SOLARIS | 550 | #if LL_WINDOWS || LL_DARWIN || LL_SOLARIS |
437 | out << proc.strCPUName; | 551 | out << proc.strCPUName; |
438 | if (200 < mCPUMhz && mCPUMhz < 10000) // *NOTE: cpu speed is often way wrong, do a sanity check | 552 | if (200 < mCPUMHz && mCPUMHz < 10000) // *NOTE: cpu speed is often way wrong, do a sanity check |
439 | { | 553 | { |
440 | out << " (" << mCPUMhz << " MHz)"; | 554 | out << " (" << mCPUMHz << " MHz)"; |
441 | } | 555 | } |
442 | mCPUString = out.str(); | 556 | mCPUString = out.str(); |
443 | 557 | ||
@@ -482,7 +596,7 @@ LLCPUInfo::LLCPUInfo() | |||
482 | if (LLStringUtil::convertToF64(cpuinfo["cpu mhz"], mhz) | 596 | if (LLStringUtil::convertToF64(cpuinfo["cpu mhz"], mhz) |
483 | && 200.0 < mhz && mhz < 10000.0) | 597 | && 200.0 < mhz && mhz < 10000.0) |
484 | { | 598 | { |
485 | mCPUMhz = (S32)llrint(mhz); | 599 | mCPUMHz = (F64)llrint(mhz); |
486 | } | 600 | } |
487 | if (!cpuinfo["model name"].empty()) | 601 | if (!cpuinfo["model name"].empty()) |
488 | mCPUString = cpuinfo["model name"]; | 602 | mCPUString = cpuinfo["model name"]; |
@@ -505,9 +619,9 @@ bool LLCPUInfo::hasSSE2() const | |||
505 | return mHasSSE2; | 619 | return mHasSSE2; |
506 | } | 620 | } |
507 | 621 | ||
508 | S32 LLCPUInfo::getMhz() const | 622 | F64 LLCPUInfo::getMHz() const |
509 | { | 623 | { |
510 | return mCPUMhz; | 624 | return mCPUMHz; |
511 | } | 625 | } |
512 | 626 | ||
513 | std::string LLCPUInfo::getCPUString() const | 627 | std::string LLCPUInfo::getCPUString() const |
@@ -554,7 +668,7 @@ void LLCPUInfo::stream(std::ostream& s) const | |||
554 | s << "->mHasSSE: " << (U32)mHasSSE << std::endl; | 668 | s << "->mHasSSE: " << (U32)mHasSSE << std::endl; |
555 | s << "->mHasSSE2: " << (U32)mHasSSE2 << std::endl; | 669 | s << "->mHasSSE2: " << (U32)mHasSSE2 << std::endl; |
556 | s << "->mHasAltivec: " << (U32)mHasAltivec << std::endl; | 670 | s << "->mHasAltivec: " << (U32)mHasAltivec << std::endl; |
557 | s << "->mCPUMhz: " << mCPUMhz << std::endl; | 671 | s << "->mCPUMHz: " << mCPUMHz << std::endl; |
558 | s << "->mCPUString: " << mCPUString << std::endl; | 672 | s << "->mCPUString: " << mCPUString << std::endl; |
559 | } | 673 | } |
560 | 674 | ||
@@ -631,6 +745,26 @@ U32 LLMemoryInfo::getPhysicalMemoryClamped() const | |||
631 | } | 745 | } |
632 | } | 746 | } |
633 | 747 | ||
748 | //static | ||
749 | void LLMemoryInfo::getAvailableMemoryKB(U32& avail_physical_mem_kb, U32& avail_virtual_mem_kb) | ||
750 | { | ||
751 | #if LL_WINDOWS | ||
752 | MEMORYSTATUSEX state; | ||
753 | state.dwLength = sizeof(state); | ||
754 | GlobalMemoryStatusEx(&state); | ||
755 | |||
756 | avail_physical_mem_kb = (U32)(state.ullAvailPhys/1024) ; | ||
757 | avail_virtual_mem_kb = (U32)(state.ullAvailVirtual/1024) ; | ||
758 | |||
759 | #else | ||
760 | //do not know how to collect available memory info for other systems. | ||
761 | //leave it blank here for now. | ||
762 | |||
763 | avail_physical_mem_kb = -1 ; | ||
764 | avail_virtual_mem_kb = -1 ; | ||
765 | #endif | ||
766 | } | ||
767 | |||
634 | void LLMemoryInfo::stream(std::ostream& s) const | 768 | void LLMemoryInfo::stream(std::ostream& s) const |
635 | { | 769 | { |
636 | #if LL_WINDOWS | 770 | #if LL_WINDOWS |
diff --git a/linden/indra/llcommon/llsys.h b/linden/indra/llcommon/llsys.h index d5575b2..e481c88 100644 --- a/linden/indra/llcommon/llsys.h +++ b/linden/indra/llcommon/llsys.h | |||
@@ -81,7 +81,7 @@ public: | |||
81 | bool hasAltivec() const; | 81 | bool hasAltivec() const; |
82 | bool hasSSE() const; | 82 | bool hasSSE() const; |
83 | bool hasSSE2() const; | 83 | bool hasSSE2() const; |
84 | S32 getMhz() const; | 84 | F64 getMHz() const; |
85 | 85 | ||
86 | // Family is "AMD Duron" or "Intel Pentium Pro" | 86 | // Family is "AMD Duron" or "Intel Pentium Pro" |
87 | const std::string& getFamily() const { return mFamily; } | 87 | const std::string& getFamily() const { return mFamily; } |
@@ -90,7 +90,7 @@ private: | |||
90 | bool mHasSSE; | 90 | bool mHasSSE; |
91 | bool mHasSSE2; | 91 | bool mHasSSE2; |
92 | bool mHasAltivec; | 92 | bool mHasAltivec; |
93 | S32 mCPUMhz; | 93 | F64 mCPUMHz; |
94 | std::string mFamily; | 94 | std::string mFamily; |
95 | std::string mCPUString; | 95 | std::string mCPUString; |
96 | }; | 96 | }; |
@@ -120,6 +120,9 @@ public: | |||
120 | ** be returned. | 120 | ** be returned. |
121 | */ | 121 | */ |
122 | U32 getPhysicalMemoryClamped() const; ///< Memory size in clamped bytes | 122 | U32 getPhysicalMemoryClamped() const; ///< Memory size in clamped bytes |
123 | |||
124 | //get the available memory infomation in KiloBytes. | ||
125 | static void getAvailableMemoryKB(U32& avail_physical_mem_kb, U32& avail_virtual_mem_kb); | ||
123 | }; | 126 | }; |
124 | 127 | ||
125 | 128 | ||