From 087733f39811d13d3376d8453e140f91e2167a8a Mon Sep 17 00:00:00 2001 From: Rye Date: Tue, 14 Oct 2025 11:12:34 -0400 Subject: Cherrypick LLProcessor cleanup from 57d423745fd1d3d0ea6a0c69b869a20c27e27fc5 Signed-off-by: Rye --- indra/llcommon/llprocessor.cpp | 65 +++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 17 deletions(-) (limited to 'indra/llcommon/llprocessor.cpp') diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp index 718f471321..9ca7ad4674 100644 --- a/indra/llcommon/llprocessor.cpp +++ b/indra/llcommon/llprocessor.cpp @@ -808,6 +808,20 @@ private: }; #elif LL_LINUX + +// *NOTE:Mani - eww, macros! srry. +#define LLPI_SET_INFO_STRING(llpi_id, cpuinfo_id) \ + if (!cpuinfo[cpuinfo_id].empty()) \ + { setInfo(llpi_id, cpuinfo[cpuinfo_id]);} + +#define LLPI_SET_INFO_INT(llpi_id, cpuinfo_id) \ + {\ + S32 result; \ + if (!cpuinfo[cpuinfo_id].empty() \ + && LLStringUtil::convertToS32(cpuinfo[cpuinfo_id], result)) \ + { setInfo(llpi_id, result);} \ + } + const char CPUINFO_FILE[] = "/proc/cpuinfo"; class LLProcessorInfoLinuxImpl : public LLProcessorInfoImpl @@ -819,8 +833,32 @@ public: } virtual ~LLProcessorInfoLinuxImpl() {} + private: + F64 getCPUMaxMHZ() + { + // Nicky: We just look into cpu0. In theory we could iterate over all cores + // "/sys/devices/system/cpu/cpu*/cpufreq/cpuinfo_max_freq" + // But those should not fluctuate that much? + std::ifstream fIn { "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq" }; + + if( !fIn.is_open() ) + return 0.0; + + std::string strLine; + fIn >> strLine; + if( strLine.empty() ) + return 0.0l; + + F64 mhz {}; + if( !LLStringUtil::convertToF64(strLine, mhz ) ) + return 0.0; + + mhz = mhz / 1000.0; + return mhz; + } + void get_proc_cpuinfo() { std::map< std::string, std::string > cpuinfo; @@ -855,24 +893,17 @@ private: } # if LL_X86 -// *NOTE:Mani - eww, macros! srry. -#define LLPI_SET_INFO_STRING(llpi_id, cpuinfo_id) \ - if (!cpuinfo[cpuinfo_id].empty()) \ - { setInfo(llpi_id, cpuinfo[cpuinfo_id]);} - -#define LLPI_SET_INFO_INT(llpi_id, cpuinfo_id) \ - {\ - S32 result; \ - if (!cpuinfo[cpuinfo_id].empty() \ - && LLStringUtil::convertToS32(cpuinfo[cpuinfo_id], result)) \ - { setInfo(llpi_id, result);} \ + F64 mhzFromSys = getCPUMaxMHZ(); + F64 mhzFromProc {}; + if( !LLStringUtil::convertToF64(cpuinfo["cpu mhz"], mhzFromProc ) ) + mhzFromProc = 0.0; + if (mhzFromSys > 1.0 && mhzFromSys > mhzFromProc ) + { + setInfo( eFrequency, mhzFromSys ); } - - F64 mhz; - if (LLStringUtil::convertToF64(cpuinfo["cpu mhz"], mhz) - && 200.0 < mhz && mhz < 10000.0) + else if ( 200.0 < mhzFromProc && mhzFromProc < 10000.0) { - setInfo(eFrequency,(F64)(mhz)); + setInfo(eFrequency,(F64)(mhzFromProc)); } LLPI_SET_INFO_STRING(eBrandName, "model name"); @@ -882,7 +913,7 @@ private: LLPI_SET_INFO_INT(eModel, "model"); - S32 family; + S32 family{}; if (!cpuinfo["cpu family"].empty() && LLStringUtil::convertToS32(cpuinfo["cpu family"], family)) { -- cgit v1.3 From f33eb2c2d4715607c8821f5d694e94a3b9663826 Mon Sep 17 00:00:00 2001 From: Rye Date: Thu, 23 Oct 2025 02:17:32 -0400 Subject: Fix RelWithDebInfo build on mac universal Signed-off-by: Rye --- indra/llcommon/llprocessor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/llprocessor.cpp') diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp index 9ca7ad4674..012b4ffb59 100644 --- a/indra/llcommon/llprocessor.cpp +++ b/indra/llcommon/llprocessor.cpp @@ -741,7 +741,7 @@ private: // *NOTE:Mani - I didn't find any docs that assure me that machdep.cpu.feature_bits will always be // The feature bits I think it is. Here's a test: -#ifndef LL_RELEASE_FOR_DOWNLOAD +#if !defined(LL_RELEASE_FOR_DOWNLOAD) && !defined(LL_ARM64) #if defined(__i386__) && defined(__PIC__) /* %ebx may be the PIC register. */ #define __cpuid(level, a, b, c, d) \ -- cgit v1.3 From 7429ee1f84161103affefa97a7d4f40803445364 Mon Sep 17 00:00:00 2001 From: Rye Date: Tue, 28 Oct 2025 09:28:55 -0400 Subject: Fix multiple unicode file io handling issues with llofstream and llifstream Signed-off-by: Rye --- indra/integration_tests/llimage_libtest/llimage_libtest.cpp | 2 +- indra/llcommon/llprocessor.cpp | 2 +- indra/llcommon/tests/llprocess_test.cpp | 8 ++++---- indra/llcommon/tests/llsdserialize_test.cpp | 2 +- indra/llfilesystem/lldir_win32.cpp | 4 ++-- indra/llui/llviewereventrecorder.h | 2 +- indra/newview/gltf/accessor.cpp | 2 +- indra/newview/gltf/asset.cpp | 4 ++-- indra/newview/gltf/llgltfloader.cpp | 2 +- indra/newview/llsettingsvo.cpp | 4 ++-- indra/newview/llviewerdisplay.cpp | 2 +- indra/newview/tests/llsechandler_basic_test.cpp | 4 ++-- indra/test/test.cpp | 2 +- 13 files changed, 20 insertions(+), 20 deletions(-) (limited to 'indra/llcommon/llprocessor.cpp') diff --git a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp index c45bd6fd01..1bd1bb2d2b 100644 --- a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp +++ b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp @@ -329,7 +329,7 @@ public: void run() { - std::ofstream os(mFile.c_str()); + llofstream os(mFile.c_str()); while (!sAllDone) { diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp index 012b4ffb59..464578c2d9 100644 --- a/indra/llcommon/llprocessor.cpp +++ b/indra/llcommon/llprocessor.cpp @@ -841,7 +841,7 @@ private: // Nicky: We just look into cpu0. In theory we could iterate over all cores // "/sys/devices/system/cpu/cpu*/cpufreq/cpuinfo_max_freq" // But those should not fluctuate that much? - std::ifstream fIn { "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq" }; + llifstream fIn{ "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq" }; if( !fIn.is_open() ) return 0.0; diff --git a/indra/llcommon/tests/llprocess_test.cpp b/indra/llcommon/tests/llprocess_test.cpp index 9eaf5bf3e3..4a88d69ded 100644 --- a/indra/llcommon/tests/llprocess_test.cpp +++ b/indra/llcommon/tests/llprocess_test.cpp @@ -95,7 +95,7 @@ static std::string readfile(const std::string& pathname, const std::string& desc { use_desc = "in " + pathname; } - std::ifstream inf(pathname.c_str()); + llifstream inf(pathname.c_str()); std::string output; if (!std::getline(inf, output)) { @@ -186,7 +186,7 @@ struct PythonProcessLauncher const char* APR_LOG = getenv("APR_LOG"); if (APR_LOG && *APR_LOG) { - std::ifstream inf(APR_LOG); + llifstream inf(APR_LOG); if (! inf.is_open()) { LL_WARNS() << "Couldn't open '" << APR_LOG << "'" << LL_ENDL; @@ -838,7 +838,7 @@ namespace tut // How do we know it's not terminated? By making it respond to // a specific stimulus in a specific way. { - std::ofstream outf(to.getName().c_str()); + llofstream outf(to.getName().c_str()); outf << "go"; } // flush and close. // now wait for the script to terminate... one way or another. @@ -901,7 +901,7 @@ namespace tut // How do we know it's not terminated? By making it respond to // a specific stimulus in a specific way. { - std::ofstream outf(to.getName().c_str()); + llofstream outf(to.getName().c_str()); outf << "go"; } // flush and close. // now wait for the script to terminate... one way or another. diff --git a/indra/llcommon/tests/llsdserialize_test.cpp b/indra/llcommon/tests/llsdserialize_test.cpp index fae9f7023f..ee315051d8 100644 --- a/indra/llcommon/tests/llsdserialize_test.cpp +++ b/indra/llcommon/tests/llsdserialize_test.cpp @@ -2117,7 +2117,7 @@ namespace tut " f.write(lenformat.pack(len(serialized)))\n" " f.write(serialized)\n";}); - std::ifstream inf(file.getName().c_str()); + llifstream inf(file.getName().c_str()); LLSD item; try { diff --git a/indra/llfilesystem/lldir_win32.cpp b/indra/llfilesystem/lldir_win32.cpp index 58c080c982..9624b1197f 100644 --- a/indra/llfilesystem/lldir_win32.cpp +++ b/indra/llfilesystem/lldir_win32.cpp @@ -52,7 +52,7 @@ namespace // This is called so early that we can't count on static objects being // properly constructed yet, so declare a pointer instead of an instance. - std::ofstream* prelogf = nullptr; + llofstream* prelogf = nullptr; void prelog(const std::string& message) { @@ -208,7 +208,7 @@ LLDir_Win32::LLDir_Win32() { // successfully created logdir, plunk a log file there std::string logfilename(add(mOSUserDir, "lldir.log")); - std::ofstream logfile(logfilename.c_str()); + llofstream logfile(logfilename.c_str()); if (! logfile.is_open()) { report(std::cerr); diff --git a/indra/llui/llviewereventrecorder.h b/indra/llui/llviewereventrecorder.h index 5636c068d8..3bd8eb1f75 100644 --- a/indra/llui/llviewereventrecorder.h +++ b/indra/llui/llviewereventrecorder.h @@ -75,7 +75,7 @@ public: bool logEvents; std::string mLogFilename; - llofstream mLog; + llofstream mLog; private: diff --git a/indra/newview/gltf/accessor.cpp b/indra/newview/gltf/accessor.cpp index f0ad3fa594..900c1da170 100644 --- a/indra/newview/gltf/accessor.cpp +++ b/indra/newview/gltf/accessor.cpp @@ -213,7 +213,7 @@ bool Buffer::save(Asset& asset, const std::string& folder) bin_file += mUri; - std::ofstream file(bin_file, std::ios::binary); + llofstream file(bin_file, std::ios::binary); if (!file.is_open()) { LL_WARNS("GLTF") << "Failed to open file: " << bin_file << LL_ENDL; diff --git a/indra/newview/gltf/asset.cpp b/indra/newview/gltf/asset.cpp index 28f30ae1c9..daa992b269 100644 --- a/indra/newview/gltf/asset.cpp +++ b/indra/newview/gltf/asset.cpp @@ -928,7 +928,7 @@ bool Asset::save(const std::string& filename) object obj; serialize(obj); std::string buffer = boost::json::serialize(obj, {}); - std::ofstream file(filename, std::ios::binary); + llofstream file(filename, std::ios::binary); file.write(buffer.c_str(), buffer.size()); return true; @@ -1090,7 +1090,7 @@ bool Image::save(Asset& asset, const std::string& folder) // set URI to non-j2c file for now, but later we'll want to reference the j2c hash mUri = name + extension; - std::ofstream file(filename, std::ios::binary); + llofstream file(filename, std::ios::binary); file.write((const char*)buffer.mData.data() + bufferView.mByteOffset, bufferView.mByteLength); } else if (mTexture.notNull()) diff --git a/indra/newview/gltf/llgltfloader.cpp b/indra/newview/gltf/llgltfloader.cpp index 12bd5661d2..c7e598beb7 100644 --- a/indra/newview/gltf/llgltfloader.cpp +++ b/indra/newview/gltf/llgltfloader.cpp @@ -1762,7 +1762,7 @@ std::string LLGLTFLoader::extractTextureToTempFile(S32 textureIndex, const std:: "gltf_embedded_" + texture_type + "_" + std::to_string(sourceIndex) + extension; // Write the image data to the temporary file - std::ofstream temp_file(temp_filename, std::ios::binary); + llofstream temp_file(temp_filename, std::ios::binary); if (temp_file.is_open()) { temp_file.write(reinterpret_cast(data_ptr), data_size); diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 6023f6885d..8329ed86da 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -364,7 +364,7 @@ bool LLSettingsVOBase::exportFile(const LLSettingsBase::ptr_t &settings, const s { try { - std::ofstream file(filename, std::ios::out | std::ios::trunc); + llofstream file(filename, std::ios::out | std::ios::trunc); file.exceptions(std::ios_base::failbit | std::ios_base::badbit); if (!file) @@ -390,7 +390,7 @@ LLSettingsBase::ptr_t LLSettingsVOBase::importFile(const std::string &filename) try { - std::ifstream file(filename, std::ios::in); + llifstream file(filename, std::ios::in); file.exceptions(std::ios_base::failbit | std::ios_base::badbit); if (!file) diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index eaff660a78..61c5aa4da4 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -1070,7 +1070,7 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) LLGLSLShader::finishProfile(stats); auto report_name = getProfileStatsFilename(); - std::ofstream outf(report_name); + llofstream outf(report_name); if (! outf) { LL_WARNS() << "Couldn't write to " << std::quoted(report_name) << LL_ENDL; diff --git a/indra/newview/tests/llsechandler_basic_test.cpp b/indra/newview/tests/llsechandler_basic_test.cpp index f4ee15319e..acbadbc85a 100644 --- a/indra/newview/tests/llsechandler_basic_test.cpp +++ b/indra/newview/tests/llsechandler_basic_test.cpp @@ -773,7 +773,7 @@ namespace tut LLMachineID::getUniqueID(unique_id, sizeof(unique_id)); LLXORCipher cipher2(unique_id, sizeof(unique_id)); cipher2.encrypt(&binary_data[0], 16); - std::ofstream temp_file("sechandler_settings.tmp", std::ofstream::binary); + llofstream temp_file("sechandler_settings.tmp", std::ofstream::binary); temp_file.write((const char *)&binary_data[0], binary_data.size()); temp_file.close(); @@ -846,7 +846,7 @@ namespace tut // rewrite the initial file to verify reloads handler = NULL; - std::ofstream temp_file2("sechandler_settings.tmp", std::ofstream::binary); + llofstream temp_file2("sechandler_settings.tmp", std::ofstream::binary); temp_file2.write((const char *)&binary_data[0], binary_data.size()); temp_file2.close(); diff --git a/indra/test/test.cpp b/indra/test/test.cpp index 172b6e3542..b611e52835 100644 --- a/indra/test/test.cpp +++ b/indra/test/test.cpp @@ -108,7 +108,7 @@ public: void replay(std::ostream& out) { mFile.close(); - std::ifstream inf(mTempFile.getName().c_str()); + llifstream inf(mTempFile.getName().c_str()); std::string line; while (std::getline(inf, line)) { -- cgit v1.3 From bf4cd86a80459d1a3cbab457cd6e827eac594bd2 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Mon, 10 Nov 2025 16:07:24 -0500 Subject: Remove cpuid feature bits verification in llprocessor.cpp (#4959) * Remove cpuid feature bits verification in llprocessor.cpp --- indra/llcommon/llprocessor.cpp | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) (limited to 'indra/llcommon/llprocessor.cpp') diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp index 718f471321..0778b123ea 100644 --- a/indra/llcommon/llprocessor.cpp +++ b/indra/llcommon/llprocessor.cpp @@ -739,32 +739,7 @@ private: } } - // *NOTE:Mani - I didn't find any docs that assure me that machdep.cpu.feature_bits will always be - // The feature bits I think it is. Here's a test: -#ifndef LL_RELEASE_FOR_DOWNLOAD - #if defined(__i386__) && defined(__PIC__) - /* %ebx may be the PIC register. */ - #define __cpuid(level, a, b, c, d) \ - __asm__ ("xchgl\t%%ebx, %1\n\t" \ - "cpuid\n\t" \ - "xchgl\t%%ebx, %1\n\t" \ - : "=a" (a), "=r" (b), "=c" (c), "=d" (d) \ - : "0" (level)) - #else - #define __cpuid(level, a, b, c, d) \ - __asm__ ("cpuid\n\t" \ - : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ - : "0" (level)) - #endif - - unsigned int eax, ebx, ecx, edx; - __cpuid(0x1, eax, ebx, ecx, edx); - if(feature_infos[0] != (S32)edx) - { - LL_WARNS() << "machdep.cpu.feature_bits doesn't match expected cpuid result!" << LL_ENDL; - } -#endif // LL_RELEASE_FOR_DOWNLOAD - + // @TODO: Audit our usage of machdep.cpu.feature_bits. uint64_t ext_feature_info = getSysctlInt64("machdep.cpu.extfeature_bits"); S32 *ext_feature_infos = (S32*)(&ext_feature_info); -- cgit v1.3 From 08da1479f59cce54549de52782ea861741ac2533 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Mon, 10 Nov 2025 16:07:24 -0500 Subject: Remove cpuid feature bits verification in llprocessor.cpp (#4959) --- indra/llcommon/llprocessor.cpp | 26 -------------------------- 1 file changed, 26 deletions(-) (limited to 'indra/llcommon/llprocessor.cpp') diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp index 090e62b114..37d1c60f91 100644 --- a/indra/llcommon/llprocessor.cpp +++ b/indra/llcommon/llprocessor.cpp @@ -739,32 +739,6 @@ private: } } - // *NOTE:Mani - I didn't find any docs that assure me that machdep.cpu.feature_bits will always be - // The feature bits I think it is. Here's a test: -#if !defined(LL_RELEASE_FOR_DOWNLOAD) && !defined(LL_ARM64) - #if defined(__i386__) && defined(__PIC__) - /* %ebx may be the PIC register. */ - #define __cpuid(level, a, b, c, d) \ - __asm__ ("xchgl\t%%ebx, %1\n\t" \ - "cpuid\n\t" \ - "xchgl\t%%ebx, %1\n\t" \ - : "=a" (a), "=r" (b), "=c" (c), "=d" (d) \ - : "0" (level)) - #else - #define __cpuid(level, a, b, c, d) \ - __asm__ ("cpuid\n\t" \ - : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ - : "0" (level)) - #endif - - unsigned int eax, ebx, ecx, edx; - __cpuid(0x1, eax, ebx, ecx, edx); - if(feature_infos[0] != (S32)edx) - { - LL_WARNS() << "machdep.cpu.feature_bits doesn't match expected cpuid result!" << LL_ENDL; - } -#endif // LL_RELEASE_FOR_DOWNLOAD - // @TODO: Audit our usage of machdep.cpu.feature_bits. uint64_t ext_feature_info = getSysctlInt64("machdep.cpu.extfeature_bits"); -- cgit v1.3