From c82995f3e67ed1947c29fa1d27f1dfe015513ab0 Mon Sep 17 00:00:00 2001
From: Mnikolenko Productengine <mnikolenko@productengine.com>
Date: Tue, 7 Sep 2021 18:46:40 +0300
Subject: SL-15832 Add OS bitness to ViewerStats

---
 indra/llcommon/llsys.cpp        | 26 ++++++++++++++++++++++++++
 indra/llcommon/llsys.h          |  4 ++++
 indra/newview/llviewerstats.cpp |  1 +
 3 files changed, 31 insertions(+)

(limited to 'indra')

diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp
index 4e61fb8a58..b3a93e3254 100644
--- a/indra/llcommon/llsys.cpp
+++ b/indra/llcommon/llsys.cpp
@@ -474,6 +474,8 @@ LLOSInfo::LLOSInfo() :
 	dotted_version_string << mMajorVer << "." << mMinorVer << "." << mBuild;
 	mOSVersionString.append(dotted_version_string.str());
 
+	mOSBitness = is64Bit() ? 64 : 32;
+	LL_INFOS("LLOSInfo") << "OS bitness: " << mOSBitness << LL_ENDL;
 }
 
 #ifndef LL_WINDOWS
@@ -529,6 +531,11 @@ const std::string& LLOSInfo::getOSVersionString() const
 	return mOSVersionString;
 }
 
+const S32 LLOSInfo::getOSBitness() const
+{
+	return mOSBitness;
+}
+
 //static
 U32 LLOSInfo::getProcessVirtualSizeKB()
 {
@@ -582,6 +589,25 @@ U32 LLOSInfo::getProcessResidentSizeKB()
 	return resident_size;
 }
 
+//static
+bool LLOSInfo::is64Bit()
+{
+#if LL_WINDOWS
+#if defined(_WIN64)
+    return true;
+#elif defined(_WIN32)
+    // 32-bit viewer may be run on both 32-bit and 64-bit Windows, need to elaborate
+    BOOL f64 = FALSE;
+    return IsWow64Process(GetCurrentProcess(), &f64) && f64;
+#else
+    return false;
+#endif
+#else // ! LL_WINDOWS
+    // we only build a 64-bit mac viewer and currently we don't build for linux at all
+    return true; 
+#endif
+}
+
 LLCPUInfo::LLCPUInfo()
 {
 	std::ostringstream out;
diff --git a/indra/llcommon/llsys.h b/indra/llcommon/llsys.h
index 5ab97939b9..cb92cb0ac6 100644
--- a/indra/llcommon/llsys.h
+++ b/indra/llcommon/llsys.h
@@ -51,6 +51,8 @@ public:
 	const std::string& getOSStringSimple() const;
 
 	const std::string& getOSVersionString() const;
+
+	const S32 getOSBitness() const;
 	
 	S32 mMajorVer;
 	S32 mMinorVer;
@@ -59,6 +61,7 @@ public:
 #ifndef LL_WINDOWS
 	static S32 getMaxOpenFiles();
 #endif
+	static bool is64Bit();
 
 	static U32 getProcessVirtualSizeKB();
 	static U32 getProcessResidentSizeKB();
@@ -66,6 +69,7 @@ private:
 	std::string mOSString;
 	std::string mOSStringSimple;
 	std::string mOSVersionString;
+	S32 mOSBitness;
 };
 
 
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 314c1a1f1e..c29fdeb943 100644
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -496,6 +496,7 @@ void send_viewer_stats(bool include_preferences)
 	system["os"] = LLOSInfo::instance().getOSStringSimple();
 	system["cpu"] = gSysCPU.getCPUString();
 	system["address_size"] = ADDRESS_SIZE;
+	system["os_bitness"] = LLOSInfo::instance().getOSBitness();
 	unsigned char MACAddress[MAC_ADDRESS_BYTES];
 	LLUUID::getNodeID(MACAddress);
 	std::string macAddressString = llformat("%02x-%02x-%02x-%02x-%02x-%02x",
-- 
cgit v1.2.3