From 74c8b028d42a8c5b080bb861e427f38cedd4ad7c Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Fri, 15 Dec 2023 18:26:14 +0100 Subject: SL-20743 Use LLMutex in LLImageBase for internal data thread-safety --- indra/llcommon/llapr.cpp | 2 +- indra/llcommon/llapr.h | 2 +- indra/llcommon/llmutex.cpp | 186 +++++++++++++++++++++++++++++++++++++++++++-- indra/llcommon/llmutex.h | 79 ++++++++++++++++++- 4 files changed, 256 insertions(+), 13 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index 575c524219..834b0e7a3a 100644 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -571,7 +571,7 @@ S32 LLAPRFile::readEx(const std::string& filename, void *buf, S32 offset, S32 nb } //static -S32 LLAPRFile::writeEx(const std::string& filename, void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool) +S32 LLAPRFile::writeEx(const std::string& filename, const void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool) { LL_PROFILE_ZONE_SCOPED; apr_int32_t flags = APR_CREATE|APR_WRITE|APR_BINARY; diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index 565d7cfb63..f5717ea75e 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -193,7 +193,7 @@ public: // Returns bytes read/written, 0 if read/write fails: static S32 readEx(const std::string& filename, void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool = NULL); - static S32 writeEx(const std::string& filename, void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool = NULL); // offset<0 means append + static S32 writeEx(const std::string& filename, const void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool = NULL); // offset<0 means append //******************************************************************************************************************************* }; diff --git a/indra/llcommon/llmutex.cpp b/indra/llcommon/llmutex.cpp index 0273dd5970..f56c2d08a6 100644 --- a/indra/llcommon/llmutex.cpp +++ b/indra/llcommon/llmutex.cpp @@ -29,19 +29,20 @@ #include "llthread.h" #include "lltimer.h" -//============================================================================ +//--------------------------------------------------------------------- +// +// LLMutex +// LLMutex::LLMutex() : mCount(0) { } - LLMutex::~LLMutex() { } - void LLMutex::lock() { LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD @@ -112,7 +113,7 @@ LLThread::id_t LLMutex::lockingThread() const bool LLMutex::trylock() { LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD - if(isSelfLocked()) + if (isSelfLocked()) { //redundant lock mCount++; return true; @@ -135,19 +136,185 @@ bool LLMutex::trylock() return true; } -//============================================================================ +//--------------------------------------------------------------------- +// +// LLSharedMutex +// +LLSharedMutex::LLSharedMutex() +: mLockingThreads(2) // Reserve 2 slots in the map hash table +, mIsShared(false) +{ +} + +bool LLSharedMutex::isLocked() const +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + std::lock_guard lock(mLockMutex); + + return !mLockingThreads.empty(); +} + +bool LLSharedMutex::isThreadLocked() const +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LLThread::id_t current_thread = LLThread::currentID(); + std::lock_guard lock(mLockMutex); + + const_iterator it = mLockingThreads.find(current_thread); + return it != mLockingThreads.end(); +} + +void LLSharedMutex::lockShared() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LLThread::id_t current_thread = LLThread::currentID(); + + mLockMutex.lock(); + iterator it = mLockingThreads.find(current_thread); + if (it != mLockingThreads.end()) + { + it->second++; + } + else + { + // Acquire the mutex immediately if the mutex is not locked exclusively + // or enter a locking state if the mutex is already locked exclusively + mLockMutex.unlock(); + mSharedMutex.lock_shared(); + mLockMutex.lock(); + // Continue after acquiring the mutex + mLockingThreads.emplace(std::make_pair(current_thread, 1)); + mIsShared = true; + } + mLockMutex.unlock(); +} + +void LLSharedMutex::lockExclusive() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LLThread::id_t current_thread = LLThread::currentID(); + + mLockMutex.lock(); + if (mLockingThreads.size() == 1 && mLockingThreads.begin()->first == current_thread) + { + mLockingThreads.begin()->second++; + } + else + { + // Acquire the mutex immediately if mLockingThreads is empty + // or enter a locking state if mLockingThreads is not empty + mLockMutex.unlock(); + mSharedMutex.lock(); + mLockMutex.lock(); + // Continue after acquiring the mutex (and possible quitting the locking state) + mLockingThreads.emplace(std::make_pair(current_thread, 1)); + mIsShared = false; + } + mLockMutex.unlock(); +} + +bool LLSharedMutex::trylockShared() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LLThread::id_t current_thread = LLThread::currentID(); + std::lock_guard lock(mLockMutex); + + iterator it = mLockingThreads.find(current_thread); + if (it != mLockingThreads.end()) + { + it->second++; + } + else + { + if (!mSharedMutex.try_lock_shared()) + return false; + + mLockingThreads.emplace(std::make_pair(current_thread, 1)); + mIsShared = true; + } + + return true; +} + +bool LLSharedMutex::trylockExclusive() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LLThread::id_t current_thread = LLThread::currentID(); + std::lock_guard lock(mLockMutex); + + if (mLockingThreads.size() == 1 && mLockingThreads.begin()->first == current_thread) + { + mLockingThreads.begin()->second++; + } + else + { + if (!mSharedMutex.try_lock()) + return false; + + mLockingThreads.emplace(std::make_pair(current_thread, 1)); + mIsShared = false; + } + + return true; +} + +void LLSharedMutex::unlockShared() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LLThread::id_t current_thread = LLThread::currentID(); + std::lock_guard lock(mLockMutex); + + iterator it = mLockingThreads.find(current_thread); + if (it != mLockingThreads.end()) + { + if (it->second > 1) + { + it->second--; + } + else + { + mLockingThreads.erase(it); + mSharedMutex.unlock_shared(); + } + } +} + +void LLSharedMutex::unlockExclusive() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LLThread::id_t current_thread = LLThread::currentID(); + std::lock_guard lock(mLockMutex); + + iterator it = mLockingThreads.find(current_thread); + if (it != mLockingThreads.end()) + { + if (it->second > 1) + { + it->second--; + } + else + { + mLockingThreads.erase(it); + mSharedMutex.unlock(); + } + } +} + + +//--------------------------------------------------------------------- +// +// LLCondition +// LLCondition::LLCondition() : LLMutex() { } - LLCondition::~LLCondition() { } - void LLCondition::wait() { LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD @@ -168,7 +335,10 @@ void LLCondition::broadcast() } - +//--------------------------------------------------------------------- +// +// LLMutexTrylock +// LLMutexTrylock::LLMutexTrylock(LLMutex* mutex) : mMutex(mutex), mLocked(false) diff --git a/indra/llcommon/llmutex.h b/indra/llcommon/llmutex.h index 0d70da6178..077f810d61 100644 --- a/indra/llcommon/llmutex.h +++ b/indra/llcommon/llmutex.h @@ -32,6 +32,8 @@ #include #include "mutex.h" +#include +#include #include //============================================================================ @@ -66,6 +68,45 @@ protected: #endif }; +//============================================================================ + +class LL_COMMON_API LLSharedMutex +{ +public: + LLSharedMutex(); + + bool isLocked() const; + bool isThreadLocked() const; + bool isShared() const { return mIsShared; } + + void lockShared(); + void lockExclusive(); + template void lock(); + template<> void lock() { lockShared(); } + template<> void lock() { lockExclusive(); } + + bool trylockShared(); + bool trylockExclusive(); + template bool trylock(); + template<> bool trylock() { return trylockShared(); } + template<> bool trylock() { return trylockExclusive(); } + + void unlockShared(); + void unlockExclusive(); + template void unlock(); + template<> void unlock() { unlockShared(); } + template<> void unlock() { unlockExclusive(); } + +private: + std::shared_mutex mSharedMutex; + mutable std::mutex mLockMutex; + std::unordered_map mLockingThreads; + bool mIsShared; + + using iterator = std::unordered_map::iterator; + using const_iterator = std::unordered_map::const_iterator; +}; + // Actually a condition/mutex pair (since each condition needs to be associated with a mutex). class LL_COMMON_API LLCondition : public LLMutex { @@ -81,27 +122,57 @@ protected: std::condition_variable mCond; }; +//============================================================================ + class LLMutexLock { public: LLMutexLock(LLMutex* mutex) { mMutex = mutex; - - if(mMutex) + + if (mMutex) mMutex->lock(); } + ~LLMutexLock() { - if(mMutex) + if (mMutex) mMutex->unlock(); } + private: LLMutex* mMutex; }; //============================================================================ +template +class LLSharedMutexLockTemplate +{ +public: + LLSharedMutexLockTemplate(LLSharedMutex* mutex) + : mSharedMutex(mutex) + { + if (mSharedMutex) + mSharedMutex->lock(); + } + + ~LLSharedMutexLockTemplate() + { + if (mSharedMutex) + mSharedMutex->unlock(); + } + +private: + LLSharedMutex* mSharedMutex; +}; + +using LLSharedMutexLock = LLSharedMutexLockTemplate; +using LLExclusiveMutexLock = LLSharedMutexLockTemplate; + +//============================================================================ + // Scoped locking class similar in function to LLMutexLock but uses // the trylock() method to conditionally acquire lock without // blocking. Caller resolves the resulting condition by calling @@ -127,6 +198,8 @@ private: bool mLocked; }; +//============================================================================ + /** * @class LLScopedLock * @brief Small class to help lock and unlock mutexes. -- cgit v1.2.3 From e4a1feb83079965fbebd356aa694adf100fb7ee3 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Sun, 7 Jan 2024 14:44:52 +0100 Subject: SL-20743 Use LLMutex in LLImageBase for internal data thread-safety (update) --- indra/llcommon/llmutex.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llmutex.cpp b/indra/llcommon/llmutex.cpp index f56c2d08a6..973ecbc87b 100644 --- a/indra/llcommon/llmutex.cpp +++ b/indra/llcommon/llmutex.cpp @@ -196,9 +196,18 @@ void LLSharedMutex::lockExclusive() LLThread::id_t current_thread = LLThread::currentID(); mLockMutex.lock(); - if (mLockingThreads.size() == 1 && mLockingThreads.begin()->first == current_thread) + iterator it = mLockingThreads.find(current_thread); + if (it != mLockingThreads.end()) { - mLockingThreads.begin()->second++; + if (mIsShared) + { + // The mutex is already locked in the current thread + // but this lock is SHARED (not EXCLISIVE) + // We can't lock it again, the lock stays shared + // This can lead to a collision (theoretically) + llassert_always(!"The current thread is already locked SHARED and can't be locked EXCLUSIVE"); + } + it->second++; } else { -- cgit v1.2.3 From da967da9c7aa0d88f478d476e8bb059ba79ca818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20N=C3=A6sbye=20Christensen?= Date: Thu, 11 Jan 2024 11:32:15 +0100 Subject: Rename OS X to macOS, mostly in comments We only support 10.13+ now, and it's been called macOS since 10.12. References in code to older versions are unchanged. --- indra/llcommon/llerror.cpp | 2 +- indra/llcommon/llsys.cpp | 6 +++--- indra/llcommon/lluuid.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 414515854a..19c285ea5a 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -700,7 +700,7 @@ namespace bool shouldLogToStderr() { #if LL_DARWIN - // On Mac OS X, stderr from apps launched from the Finder goes to the + // On macOS, stderr from apps launched from the Finder goes to the // console log. It's generally considered bad form to spam too much // there. That scenario can be detected by noticing that stderr is a // character device (S_IFCHR). diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp index 938685bae6..d3f99a413d 100644 --- a/indra/llcommon/llsys.cpp +++ b/indra/llcommon/llsys.cpp @@ -269,9 +269,9 @@ LLOSInfo::LLOSInfo() : #elif LL_DARWIN // Initialize mOSStringSimple to something like: - // "Mac OS X 10.6.7" + // "macOS 10.13.1" { - const char * DARWIN_PRODUCT_NAME = "Mac OS X"; + const char * DARWIN_PRODUCT_NAME = "macOS"; int64_t major_version, minor_version, bugfix_version = 0; @@ -294,7 +294,7 @@ LLOSInfo::LLOSInfo() : } // Initialize mOSString to something like: - // "Mac OS X 10.6.7 Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386 i386" + // "macOS 10.13.1 Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386 i386" struct utsname un; if(uname(&un) != -1) { diff --git a/indra/llcommon/lluuid.cpp b/indra/llcommon/lluuid.cpp index 200add404f..285469f0d4 100644 --- a/indra/llcommon/lluuid.cpp +++ b/indra/llcommon/lluuid.cpp @@ -510,7 +510,7 @@ S32 LLUUID::getNodeID(unsigned char* node_id) } #elif LL_DARWIN -// Mac OS X version of the UUID generation code... +// macOS version of the UUID generation code... /* * Get an ethernet hardware address, if we can find it... */ -- cgit v1.2.3 From 4a03aa089009af9130076b438192e338bc202584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20N=C3=A6sbye=20Christensen?= Date: Thu, 11 Jan 2024 20:36:17 +0100 Subject: operatingSystemVersion and NSOperatingSystemVersion exis since OS X 10.10, and we require macOS 10.13+ now --- indra/llcommon/llsys_objc.mm | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llsys_objc.mm b/indra/llcommon/llsys_objc.mm index 3fd85fb1c9..1393ccea50 100644 --- a/indra/llcommon/llsys_objc.mm +++ b/indra/llcommon/llsys_objc.mm @@ -27,38 +27,12 @@ #import "llsys_objc.h" #import -static auto intAtStringIndex(NSArray *array, int index) -{ - return [(NSString *)[array objectAtIndex:index] integerValue]; -} - bool LLGetDarwinOSInfo(int64_t &major, int64_t &minor, int64_t &patch) { - if (NSAppKitVersionNumber > NSAppKitVersionNumber10_8) - { NSOperatingSystemVersion osVersion = [[NSProcessInfo processInfo] operatingSystemVersion]; major = osVersion.majorVersion; minor = osVersion.minorVersion; patch = osVersion.patchVersion; - } - else - { - NSString* versionString = [[NSDictionary dictionaryWithContentsOfFile: - @"/System/Library/CoreServices/SystemVersion.plist"] objectForKey:@"ProductVersion"]; - NSArray* versions = [versionString componentsSeparatedByString:@"."]; - NSUInteger count = [versions count]; - if (count > 0) - { - major = intAtStringIndex(versions, 0); - if (count > 1) - { - minor = intAtStringIndex(versions, 1); - if (count > 2) - { - patch = intAtStringIndex(versions, 2); - } - } - } - } + return true; } -- cgit v1.2.3 From ba4e7b989b6c20a49da0eeb450bd2f945b3eefc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20N=C3=A6sbye=20Christensen?= Date: Thu, 8 Feb 2024 02:51:51 +0100 Subject: llcommon: BOOL (int) to real bool/LSTATUS --- indra/llcommon/llapr.cpp | 10 +++--- indra/llcommon/llapr.h | 10 +++--- indra/llcommon/llassettype.cpp | 2 +- indra/llcommon/llcommon.cpp | 6 ++-- indra/llcommon/llcommon.h | 2 +- indra/llcommon/llcrc.cpp | 2 +- indra/llcommon/llcrc.h | 2 +- indra/llcommon/lleventemitter.h | 12 +++---- indra/llcommon/llframetimer.cpp | 14 ++++---- indra/llcommon/llframetimer.h | 10 +++--- indra/llcommon/llkeythrottle.h | 8 ++--- indra/llcommon/llmemory.cpp | 6 ++-- indra/llcommon/llmemory.h | 2 +- indra/llcommon/llmetricperformancetester.cpp | 12 +++---- indra/llcommon/llmetricperformancetester.h | 10 +++--- indra/llcommon/llmortician.cpp | 8 ++--- indra/llcommon/llmortician.h | 10 +++--- indra/llcommon/llmutex.cpp | 14 ++++---- indra/llcommon/llnametable.h | 6 ++-- indra/llcommon/llpriqueuemap.h | 14 ++++---- indra/llcommon/llqueuedthread.cpp | 20 ++++++------ indra/llcommon/llqueuedthread.h | 4 +-- indra/llcommon/llsdutil.cpp | 12 +++---- indra/llcommon/llsdutil.h | 2 +- indra/llcommon/llstacktrace.cpp | 8 ++--- indra/llcommon/llsys.cpp | 16 +++++----- indra/llcommon/llsys.h | 4 +-- indra/llcommon/llthread.cpp | 2 +- indra/llcommon/llthread.h | 2 +- indra/llcommon/lltimer.cpp | 24 +++++++------- indra/llcommon/lltimer.h | 14 ++++---- indra/llcommon/lluri.cpp | 6 ++-- indra/llcommon/lluri.h | 2 +- indra/llcommon/lluuid.cpp | 48 ++++++++++++++-------------- indra/llcommon/lluuid.h | 12 +++---- 35 files changed, 168 insertions(+), 168 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index 834b0e7a3a..8b99ee93b9 100644 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -56,7 +56,7 @@ void ll_init_apr() if(!LLAPRFile::sAPRFilePoolp) { - LLAPRFile::sAPRFilePoolp = new LLVolatileAPRPool(FALSE) ; + LLAPRFile::sAPRFilePoolp = new LLVolatileAPRPool(false) ; } gAPRInitialized = true; @@ -91,7 +91,7 @@ void ll_cleanup_apr() // //LLAPRPool // -LLAPRPool::LLAPRPool(apr_pool_t *parent, apr_size_t size, BOOL releasePoolFlag) +LLAPRPool::LLAPRPool(apr_pool_t *parent, apr_size_t size, bool releasePoolFlag) : mParent(parent), mReleasePoolFlag(releasePoolFlag), mMaxSize(size), @@ -145,7 +145,7 @@ apr_pool_t* LLAPRPool::getAPRPool() return mPool ; } -LLVolatileAPRPool::LLVolatileAPRPool(BOOL is_local, apr_pool_t *parent, apr_size_t size, BOOL releasePoolFlag) +LLVolatileAPRPool::LLVolatileAPRPool(bool is_local, apr_pool_t *parent, apr_size_t size, bool releasePoolFlag) : LLAPRPool(parent, size, releasePoolFlag), mNumActiveRef(0), mNumTotalRef(0) @@ -219,7 +219,7 @@ void LLVolatileAPRPool::clearVolatileAPRPool() llassert(mNumTotalRef <= (FULL_VOLATILE_APR_POOL << 2)) ; } -BOOL LLVolatileAPRPool::isFull() +bool LLVolatileAPRPool::isFull() { return mNumTotalRef > FULL_VOLATILE_APR_POOL ; } @@ -385,7 +385,7 @@ apr_status_t LLAPRFile::open(const std::string& filename, apr_int32_t flags, LLV } //use gAPRPoolp. -apr_status_t LLAPRFile::open(const std::string& filename, apr_int32_t flags, BOOL use_global_pool) +apr_status_t LLAPRFile::open(const std::string& filename, apr_int32_t flags, bool use_global_pool) { apr_status_t s; diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index f5717ea75e..acc4003d27 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -78,7 +78,7 @@ bool LL_COMMON_API ll_apr_is_initialized(); class LL_COMMON_API LLAPRPool { public: - LLAPRPool(apr_pool_t *parent = NULL, apr_size_t size = 0, BOOL releasePoolFlag = TRUE) ; + LLAPRPool(apr_pool_t *parent = NULL, apr_size_t size = 0, bool releasePoolFlag = true) ; virtual ~LLAPRPool() ; virtual apr_pool_t* getAPRPool() ; @@ -93,7 +93,7 @@ protected: apr_pool_t* mParent ; //parent pool apr_size_t mMaxSize ; //max size of mPool, mPool should return memory to system if allocated memory beyond this limit. However it seems not to work. apr_status_t mStatus ; //status when creating the pool - BOOL mReleasePoolFlag ; //if set, mPool is destroyed when LLAPRPool is deleted. default value is true. + bool mReleasePoolFlag ; //if set, mPool is destroyed when LLAPRPool is deleted. default value is true. }; // @@ -104,14 +104,14 @@ protected: class LL_COMMON_API LLVolatileAPRPool : public LLAPRPool { public: - LLVolatileAPRPool(BOOL is_local = TRUE, apr_pool_t *parent = NULL, apr_size_t size = 0, BOOL releasePoolFlag = TRUE); + LLVolatileAPRPool(bool is_local = true, apr_pool_t *parent = NULL, apr_size_t size = 0, bool releasePoolFlag = true); virtual ~LLVolatileAPRPool(); /*virtual*/ apr_pool_t* getAPRPool() ; //define this virtual function to avoid any mistakenly calling LLAPRPool::getAPRPool(). apr_pool_t* getVolatileAPRPool() ; void clearVolatileAPRPool() ; - BOOL isFull() ; + bool isFull() ; private: S32 mNumActiveRef ; //number of active pointers pointing to the apr_pool. @@ -158,7 +158,7 @@ public: ~LLAPRFile() ; apr_status_t open(const std::string& filename, apr_int32_t flags, LLVolatileAPRPool* pool = NULL, S32* sizep = NULL); - apr_status_t open(const std::string& filename, apr_int32_t flags, BOOL use_global_pool); //use gAPRPoolp. + apr_status_t open(const std::string& filename, apr_int32_t flags, bool use_global_pool); //use gAPRPoolp. apr_status_t close() ; // Returns actual offset, -1 if seek fails diff --git a/indra/llcommon/llassettype.cpp b/indra/llcommon/llassettype.cpp index 6492d888c1..beddfc53cd 100644 --- a/indra/llcommon/llassettype.cpp +++ b/indra/llcommon/llassettype.cpp @@ -98,7 +98,7 @@ LLAssetDictionary::LLAssetDictionary() addEntry(LLAssetType::AT_SETTINGS, new AssetEntry("SETTINGS", "settings", "settings blob", true, true, true)); addEntry(LLAssetType::AT_MATERIAL, new AssetEntry("MATERIAL", "material", "render material", true, true, true)); addEntry(LLAssetType::AT_UNKNOWN, new AssetEntry("UNKNOWN", "invalid", NULL, false, false, false)); - addEntry(LLAssetType::AT_NONE, new AssetEntry("NONE", "-1", NULL, FALSE, FALSE, FALSE)); + addEntry(LLAssetType::AT_NONE, new AssetEntry("NONE", "-1", NULL, false, false, false)); }; diff --git a/indra/llcommon/llcommon.cpp b/indra/llcommon/llcommon.cpp index 6e988260a9..335c586c1d 100644 --- a/indra/llcommon/llcommon.cpp +++ b/indra/llcommon/llcommon.cpp @@ -115,7 +115,7 @@ void tracy_aligned_free(void *memblock) #endif //static -BOOL LLCommon::sAprInitialized = FALSE; +bool LLCommon::sAprInitialized = false; static LLTrace::ThreadRecorder* sMasterThreadRecorder = NULL; @@ -125,7 +125,7 @@ void LLCommon::initClass() if (!sAprInitialized) { ll_init_apr(); - sAprInitialized = TRUE; + sAprInitialized = true; } LLTimer::initClass(); LLThreadSafeRefCount::initThreadSafeRefCount(); @@ -148,6 +148,6 @@ void LLCommon::cleanupClass() if (sAprInitialized) { ll_cleanup_apr(); - sAprInitialized = FALSE; + sAprInitialized = false; } } diff --git a/indra/llcommon/llcommon.h b/indra/llcommon/llcommon.h index ca9cad5d05..98c5ed3bc2 100644 --- a/indra/llcommon/llcommon.h +++ b/indra/llcommon/llcommon.h @@ -36,7 +36,7 @@ public: static void initClass(); static void cleanupClass(); private: - static BOOL sAprInitialized; + static bool sAprInitialized; }; #endif diff --git a/indra/llcommon/llcrc.cpp b/indra/llcommon/llcrc.cpp index 626bb1e564..144efa24a8 100644 --- a/indra/llcommon/llcrc.cpp +++ b/indra/llcommon/llcrc.cpp @@ -200,7 +200,7 @@ void LLCRC::update(const std::string& filename) #ifdef _DEBUG -BOOL LLCRC::testHarness() +bool LLCRC::testHarness() { const S32 TEST_BUFFER_SIZE = 16; const char TEST_BUFFER[TEST_BUFFER_SIZE] = "hello &#$)$&Nd0"; /* Flawfinder: ignore */ diff --git a/indra/llcommon/llcrc.h b/indra/llcommon/llcrc.h index 3f41b28ffa..322d5c9e27 100644 --- a/indra/llcommon/llcrc.h +++ b/indra/llcommon/llcrc.h @@ -60,7 +60,7 @@ public: #ifdef _DEBUG // This function runs tests to make sure the crc is // working. Returns TRUE if it is. - static BOOL testHarness(); + static bool testHarness(); #endif }; diff --git a/indra/llcommon/lleventemitter.h b/indra/llcommon/lleventemitter.h index cd82fc56f9..3663032b8c 100644 --- a/indra/llcommon/lleventemitter.h +++ b/indra/llcommon/lleventemitter.h @@ -57,14 +57,14 @@ class eventEmitter /////////////////////////////////////////////////////////////////////////////// // - BOOL addObserver ( T* observerIn ) + bool addObserver ( T* observerIn ) { if ( ! observerIn ) - return FALSE; + return false; // check if observer already exists if ( std::find ( observers.begin (), observers.end (), observerIn ) != observers.end () ) - return FALSE; + return false; // save it observers.push_back ( observerIn ); @@ -74,14 +74,14 @@ class eventEmitter /////////////////////////////////////////////////////////////////////////////// // - BOOL remObserver ( T* observerIn ) + bool remObserver ( T* observerIn ) { if ( ! observerIn ) - return FALSE; + return false; observers.remove ( observerIn ); - return TRUE; + return true; }; /////////////////////////////////////////////////////////////////////////////// diff --git a/indra/llcommon/llframetimer.cpp b/indra/llcommon/llframetimer.cpp index 1e9920746b..024ef27228 100644 --- a/indra/llcommon/llframetimer.cpp +++ b/indra/llcommon/llframetimer.cpp @@ -52,12 +52,12 @@ void LLFrameTimer::updateFrameTime() void LLFrameTimer::start() { reset(); - mStarted = TRUE; + mStarted = true; } void LLFrameTimer::stop() { - mStarted = FALSE; + mStarted = false; } void LLFrameTimer::reset() @@ -84,14 +84,14 @@ void LLFrameTimer::pause() { if (mStarted) mStartTime = sFrameTime - mStartTime; // save dtime - mStarted = FALSE; + mStarted = false; } void LLFrameTimer::unpause() { if (!mStarted) mStartTime = sFrameTime - mStartTime; // restore dtime - mStarted = TRUE; + mStarted = true; } void LLFrameTimer::setTimerExpirySec(F32 expiration) @@ -112,7 +112,7 @@ F64 LLFrameTimer::expiresAt() const return expires_at; } -BOOL LLFrameTimer::checkExpirationAndReset(F32 expiration) +bool LLFrameTimer::checkExpirationAndReset(F32 expiration) { //LL_INFOS() << "LLFrameTimer::checkExpirationAndReset()" << LL_ENDL; //LL_INFOS() << " mStartTime:" << mStartTime << LL_ENDL; @@ -123,9 +123,9 @@ BOOL LLFrameTimer::checkExpirationAndReset(F32 expiration) { reset(); setTimerExpirySec(expiration); - return TRUE; + return true; } - return FALSE; + return false; } // static diff --git a/indra/llcommon/llframetimer.h b/indra/llcommon/llframetimer.h index 81bd5da8a3..0d90eab2f4 100644 --- a/indra/llcommon/llframetimer.h +++ b/indra/llcommon/llframetimer.h @@ -39,7 +39,7 @@ class LL_COMMON_API LLFrameTimer { public: - LLFrameTimer() : mStartTime( sFrameTime ), mExpiry(0), mStarted(TRUE) {} + LLFrameTimer() : mStartTime( sFrameTime ), mExpiry(0), mStarted(true) {} // Return the number of seconds since the start of this // application instance. @@ -84,16 +84,16 @@ public: void unpause(); void setTimerExpirySec(F32 expiration); void setExpiryAt(F64 seconds_since_epoch); - BOOL checkExpirationAndReset(F32 expiration); + bool checkExpirationAndReset(F32 expiration); F32 getElapsedTimeAndResetF32() { F32 t = F32(sFrameTime - mStartTime); reset(); return t; } void setAge(const F64 age) { mStartTime = sFrameTime - age; } // ACCESSORS - BOOL hasExpired() const { return (sFrameTime >= mExpiry); } + bool hasExpired() const { return (sFrameTime >= mExpiry); } F32 getTimeToExpireF32() const { return (F32)(mExpiry - sFrameTime); } F32 getElapsedTimeF32() const { return mStarted ? (F32)(sFrameTime - mStartTime) : (F32)mStartTime; } - BOOL getStarted() const { return mStarted; } + bool getStarted() const { return mStarted; } // return the seconds since epoch when this timer will expire. F64 expiresAt() const; @@ -142,7 +142,7 @@ protected: // Useful bit of state usually associated with timers, but does // not affect actual functionality - BOOL mStarted; + bool mStarted; }; // Glue code for Havok (or anything else that doesn't want the full .h files) diff --git a/indra/llcommon/llkeythrottle.h b/indra/llcommon/llkeythrottle.h index 1f576cc19e..06667c2f86 100644 --- a/indra/llcommon/llkeythrottle.h +++ b/indra/llcommon/llkeythrottle.h @@ -93,7 +93,7 @@ class LLKeyThrottle public: // @param realtime = FALSE for frame-based throttle, TRUE for usec // real-time throttle - LLKeyThrottle(U32 limit, F32 interval, BOOL realtime = TRUE) + LLKeyThrottle(U32 limit, F32 interval, bool realtime = true) : m(* new LLKeyThrottleImpl) { setParameters( limit, interval, realtime ); @@ -287,7 +287,7 @@ public: } // Get the throttling parameters - void getParameters( U32 & out_limit, F32 & out_interval, BOOL & out_realtime ) + void getParameters( U32 & out_limit, F32 & out_interval, bool & out_realtime ) { out_limit = m.countLimit; out_interval = m.intervalLength; @@ -295,7 +295,7 @@ public: } // Set the throttling behavior - void setParameters( U32 limit, F32 interval, BOOL realtime = TRUE ) + void setParameters( U32 limit, F32 interval, bool realtime = true ) { // limit is the maximum number of keys // allowed per interval (in seconds or frames) @@ -325,7 +325,7 @@ public: protected: LLKeyThrottleImpl& m; - BOOL mIsRealtime; // TRUE to be time based (default), FALSE for frame based + bool mIsRealtime; // TRUE to be time based (default), FALSE for frame based }; #endif diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index 7cdf7254ff..196114cee9 100644 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -189,7 +189,7 @@ void* LLMemory::tryToAlloc(void* address, U32 size) } //static -void LLMemory::logMemoryInfo(BOOL update) +void LLMemory::logMemoryInfo(bool update) { LL_PROFILE_ZONE_SCOPED if(update) @@ -343,8 +343,8 @@ void* ll_aligned_malloc_fallback( size_t size, int align ) __asm int 3; } DWORD old; - BOOL Res = VirtualProtect((void*)((char*)p + for_alloc), sysinfo.dwPageSize, PAGE_NOACCESS, &old); - if(FALSE == Res) { + bool Res = VirtualProtect((void*)((char*)p + for_alloc), sysinfo.dwPageSize, PAGE_NOACCESS, &old); + if(false == Res) { // call debugger __asm int 3; } diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index ac6c969d70..d4d72c243f 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -390,7 +390,7 @@ public: static void* tryToAlloc(void* address, U32 size); static void initMaxHeapSizeGB(F32Gigabytes max_heap_size); static void updateMemoryInfo() ; - static void logMemoryInfo(BOOL update = FALSE); + static void logMemoryInfo(bool update = false); static U32Kilobytes getAvailableMemKB() ; static U32Kilobytes getMaxMemKB() ; diff --git a/indra/llcommon/llmetricperformancetester.cpp b/indra/llcommon/llmetricperformancetester.cpp index ab509b46eb..3b04947266 100644 --- a/indra/llcommon/llmetricperformancetester.cpp +++ b/indra/llcommon/llmetricperformancetester.cpp @@ -50,18 +50,18 @@ void LLMetricPerformanceTesterBasic::cleanupClass() } /*static*/ -BOOL LLMetricPerformanceTesterBasic::addTester(LLMetricPerformanceTesterBasic* tester) +bool LLMetricPerformanceTesterBasic::addTester(LLMetricPerformanceTesterBasic* tester) { llassert_always(tester != NULL); std::string name = tester->getTesterName() ; if (getTester(name)) { LL_ERRS() << "Tester name is already used by some other tester : " << name << LL_ENDL ; - return FALSE; + return false; } sTesterMap.insert(std::make_pair(name, tester)); - return TRUE; + return true; } /*static*/ @@ -89,7 +89,7 @@ LLMetricPerformanceTesterBasic* LLMetricPerformanceTesterBasic::getTester(std::s /*static*/ // Return TRUE if this metric is requested or if the general default "catch all" metric is requested -BOOL LLMetricPerformanceTesterBasic::isMetricLogRequested(std::string name) +bool LLMetricPerformanceTesterBasic::isMetricLogRequested(std::string name) { return (LLTrace::BlockTimer::sMetricLog && ((LLTrace::BlockTimer::sLogName == name) || (LLTrace::BlockTimer::sLogName == DEFAULT_METRIC_NAME))); } @@ -215,8 +215,8 @@ void LLMetricPerformanceTesterBasic::analyzePerformance(llofstream* os, LLSD* ba resetCurrentCount() ; std::string current_label = getCurrentLabelName(); - BOOL in_base = (*base).has(current_label) ; - BOOL in_current = (*current).has(current_label) ; + bool in_base = (*base).has(current_label) ; + bool in_current = (*current).has(current_label) ; while(in_base || in_current) { diff --git a/indra/llcommon/llmetricperformancetester.h b/indra/llcommon/llmetricperformancetester.h index 6561a78f03..678dda7490 100644 --- a/indra/llcommon/llmetricperformancetester.h +++ b/indra/llcommon/llmetricperformancetester.h @@ -48,7 +48,7 @@ public: * Need to be tested after creation of a tester instance so to know if the tester is correctly handled. * A tester might not be added to the map if another tester with the same name already exists. */ - BOOL isValid() const { return mValidInstance; } + bool isValid() const { return mValidInstance; } /** * @brief Write a set of test results to the log LLSD. @@ -122,7 +122,7 @@ private: std::string mName ; // Name of this tester instance S32 mCount ; // Current record count - BOOL mValidInstance; // TRUE if the instance is managed by the map + bool mValidInstance; // TRUE if the instance is managed by the map std::vector< std::string > mMetricStrings ; // Metrics strings // Static members managing the collection of testers @@ -147,12 +147,12 @@ public: * @return Returns TRUE if that metric *or* the default catch all metric has been requested to be logged * @param[in] name - Name of the tester queried. */ - static BOOL isMetricLogRequested(std::string name); + static bool isMetricLogRequested(std::string name); /** * @return Returns TRUE if there's a tester defined, FALSE otherwise. */ - static BOOL hasMetricPerformanceTesters() { return !sTesterMap.empty() ;} + static bool hasMetricPerformanceTesters() { return !sTesterMap.empty() ;} /** * @brief Delete all testers and reset the tester map */ @@ -160,7 +160,7 @@ public: private: // Add a tester to the map. Returns false if adding fails. - static BOOL addTester(LLMetricPerformanceTesterBasic* tester) ; + static bool addTester(LLMetricPerformanceTesterBasic* tester) ; }; /** diff --git a/indra/llcommon/llmortician.cpp b/indra/llcommon/llmortician.cpp index b6ad40c2af..b3e03bde3f 100644 --- a/indra/llcommon/llmortician.cpp +++ b/indra/llcommon/llmortician.cpp @@ -30,7 +30,7 @@ std::list LLMortician::sGraveyard; -BOOL LLMortician::sDestroyImmediate = FALSE; +bool LLMortician::sDestroyImmediate = false; LLMortician::~LLMortician() { @@ -88,19 +88,19 @@ void LLMortician::die() if (sDestroyImmediate) { // *NOTE: This is a hack to ensure destruction order on shutdown (relative to non-mortician controlled classes). - mIsDead = TRUE; + mIsDead = true; delete this; return; } else if (!mIsDead) { - mIsDead = TRUE; + mIsDead = true; sGraveyard.push_back(this); } } // static -void LLMortician::setZealous(BOOL b) +void LLMortician::setZealous(bool b) { sDestroyImmediate = b; } diff --git a/indra/llcommon/llmortician.h b/indra/llcommon/llmortician.h index f92c5a11db..e772b7d9c5 100644 --- a/indra/llcommon/llmortician.h +++ b/indra/llcommon/llmortician.h @@ -33,21 +33,21 @@ class LL_COMMON_API LLMortician { public: - LLMortician() { mIsDead = FALSE; } + LLMortician() { mIsDead = false; } static auto graveyardCount() { return sGraveyard.size(); }; static size_t logClass(std::stringstream &str); static void updateClass(); virtual ~LLMortician(); void die(); - BOOL isDead() { return mIsDead; } + bool isDead() { return mIsDead; } // sets destroy immediate true - static void setZealous(BOOL b); + static void setZealous(bool b); private: - static BOOL sDestroyImmediate; + static bool sDestroyImmediate; - BOOL mIsDead; + bool mIsDead; static std::list sGraveyard; }; diff --git a/indra/llcommon/llmutex.cpp b/indra/llcommon/llmutex.cpp index 973ecbc87b..1c025c286d 100644 --- a/indra/llcommon/llmutex.cpp +++ b/indra/llcommon/llmutex.cpp @@ -57,9 +57,9 @@ void LLMutex::lock() #if MUTEX_DEBUG // Have to have the lock before we can access the debug info auto id = LLThread::currentID(); - if (mIsLocked[id] != FALSE) + if (mIsLocked[id] != false) LL_ERRS() << "Already locked in Thread: " << id << LL_ENDL; - mIsLocked[id] = TRUE; + mIsLocked[id] = true; #endif mLockingThread = LLThread::currentID(); @@ -77,9 +77,9 @@ void LLMutex::unlock() #if MUTEX_DEBUG // Access the debug info while we have the lock auto id = LLThread::currentID(); - if (mIsLocked[id] != TRUE) - LL_ERRS() << "Not locked in Thread: " << id << LL_ENDL; - mIsLocked[id] = FALSE; + if (mIsLocked[id] != true) + LL_ERRS() << "Not locked in Thread: " << id << LL_ENDL; + mIsLocked[id] = false; #endif mLockingThread = LLThread::id_t(); @@ -127,9 +127,9 @@ bool LLMutex::trylock() #if MUTEX_DEBUG // Have to have the lock before we can access the debug info auto id = LLThread::currentID(); - if (mIsLocked[id] != FALSE) + if (mIsLocked[id] != false) LL_ERRS() << "Already locked in Thread: " << id << LL_ENDL; - mIsLocked[id] = TRUE; + mIsLocked[id] = true; #endif mLockingThread = LLThread::currentID(); diff --git a/indra/llcommon/llnametable.h b/indra/llcommon/llnametable.h index 2c8e71263e..4f11c595ed 100644 --- a/indra/llcommon/llnametable.h +++ b/indra/llcommon/llnametable.h @@ -55,16 +55,16 @@ public: mNameMap[tablename] = data; } - BOOL checkName(const std::string& name) const + bool checkName(const std::string& name) const { return checkName(name.c_str()); } // "logically const" even though it modifies the global nametable - BOOL checkName(const char *name) const + bool checkName(const char *name) const { char *tablename = gStringTable.addString(name); - return mNameMap.count(tablename) ? TRUE : FALSE; + return mNameMap.count(tablename) ? true : false; } DATA resolveName(const std::string& name) const diff --git a/indra/llcommon/llpriqueuemap.h b/indra/llcommon/llpriqueuemap.h index 030e2e0f21..7dd43d87ca 100644 --- a/indra/llcommon/llpriqueuemap.h +++ b/indra/llcommon/llpriqueuemap.h @@ -47,17 +47,17 @@ public: { if (mPriority > b.mPriority) { - return TRUE; + return true; } if (mPriority < b.mPriority) { - return FALSE; + return false; } if (mData > b.mData) { - return TRUE; + return true; } - return FALSE; + return false; } F32 mPriority; @@ -90,18 +90,18 @@ public: mMap.insert(pqm_pair(LLPQMKey(priority, data), data)); } - BOOL pop(DATA_TYPE *datap) + bool pop(DATA_TYPE *datap) { pqm_iter iter; iter = mMap.begin(); if (iter == mMap.end()) { - return FALSE; + return false; } *datap = (*(iter)).second; mMap.erase(iter); - return TRUE; + return true; } void reprioritize(const F32 new_priority, DATA_TYPE data) diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp index 394212ee0d..38a54337a1 100644 --- a/indra/llcommon/llqueuedthread.cpp +++ b/indra/llcommon/llqueuedthread.cpp @@ -37,9 +37,9 @@ // MAIN THREAD LLQueuedThread::LLQueuedThread(const std::string& name, bool threaded, bool should_pause) : LLThread(name), - mIdleThread(TRUE), + mIdleThread(true), mNextHandle(0), - mStarted(FALSE), + mStarted(false), mThreaded(threaded), mRequestQueue(name, 1024 * 1024) { @@ -131,7 +131,7 @@ size_t LLQueuedThread::update(F32 max_time_ms) if (!mThreaded) { startThread(); - mStarted = TRUE; + mStarted = true; } } return updateQueue(max_time_ms); @@ -149,9 +149,9 @@ size_t LLQueuedThread::updateQueue(F32 max_time_ms) mRequestQueue.post([=]() { LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("qt - update"); - mIdleThread = FALSE; + mIdleThread = false; threadedUpdate(); - mIdleThread = TRUE; + mIdleThread = true; } ); } @@ -392,7 +392,7 @@ void LLQueuedThread::processRequest(LLQueuedThread::QueuedRequest* req) { LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; - mIdleThread = FALSE; + mIdleThread = false; //threadedUpdate(); // Get next request from pool @@ -494,7 +494,7 @@ void LLQueuedThread::processRequest(LLQueuedThread::QueuedRequest* req) } } - mIdleThread = TRUE; + mIdleThread = true; } // virtual @@ -513,7 +513,7 @@ void LLQueuedThread::run() // call checPause() immediately so we don't try to do anything before the class is fully constructed checkPause(); startThread(); - mStarted = TRUE; + mStarted = true; /*while (1) @@ -522,7 +522,7 @@ void LLQueuedThread::run() // this will block on the condition until runCondition() returns true, the thread is unpaused, or the thread leaves the RUNNING state. checkPause(); - mIdleThread = FALSE; + mIdleThread = false; threadedUpdate(); @@ -531,7 +531,7 @@ void LLQueuedThread::run() if (pending_work == 0) { //LL_PROFILE_ZONE_NAMED("LLQueuedThread - sleep"); - mIdleThread = TRUE; + mIdleThread = true; //ms_sleep(1); } //LLThread::yield(); // thread should yield after each request diff --git a/indra/llcommon/llqueuedthread.h b/indra/llcommon/llqueuedthread.h index 814dbc4c38..eac4a3e2cb 100644 --- a/indra/llcommon/llqueuedthread.h +++ b/indra/llcommon/llqueuedthread.h @@ -159,8 +159,8 @@ public: bool check(); protected: - BOOL mThreaded; // if false, run on main thread and do updates during update() - BOOL mStarted; // required when mThreaded is false to call startThread() from update() + bool mThreaded; // if false, run on main thread and do updates during update() + bool mStarted; // required when mThreaded is false to call startThread() from update() LLAtomicBool mIdleThread; // request queue is empty (or we are quitting) and the thread is idle //typedef std::set request_queue_t; diff --git a/indra/llcommon/llsdutil.cpp b/indra/llcommon/llsdutil.cpp index e98fc0285a..f31b9a1d14 100644 --- a/indra/llcommon/llsdutil.cpp +++ b/indra/llcommon/llsdutil.cpp @@ -209,7 +209,7 @@ std::string ll_stream_notation_sd(const LLSD& sd) //are not of the same type, false is returned or if the LLSDs are not //of the same value. Ordering of arrays matters //Otherwise, returns true -BOOL compare_llsd_with_template( +bool compare_llsd_with_template( const LLSD& llsd_to_test, const LLSD& template_llsd, LLSD& resultant_llsd) @@ -221,12 +221,12 @@ BOOL compare_llsd_with_template( template_llsd.isDefined() ) { resultant_llsd = template_llsd; - return TRUE; + return true; } else if ( llsd_to_test.type() != template_llsd.type() ) { resultant_llsd = LLSD(); - return FALSE; + return false; } if ( llsd_to_test.isArray() ) @@ -255,7 +255,7 @@ BOOL compare_llsd_with_template( data) ) { resultant_llsd = LLSD(); - return FALSE; + return false; } else { @@ -298,7 +298,7 @@ BOOL compare_llsd_with_template( value) ) { resultant_llsd = LLSD(); - return FALSE; + return false; } else { @@ -321,7 +321,7 @@ BOOL compare_llsd_with_template( } - return TRUE; + return true; } // filter_llsd_with_template() is a direct clone (copy-n-paste) of diff --git a/indra/llcommon/llsdutil.h b/indra/llcommon/llsdutil.h index ad54d1b0be..a2b29604b9 100644 --- a/indra/llcommon/llsdutil.h +++ b/indra/llcommon/llsdutil.h @@ -72,7 +72,7 @@ LL_COMMON_API std::string ll_stream_notation_sd(const LLSD& sd); //Returns false if the test is of same type but values differ in type //Otherwise, returns true -LL_COMMON_API BOOL compare_llsd_with_template( +LL_COMMON_API bool compare_llsd_with_template( const LLSD& llsd_to_test, const LLSD& template_llsd, LLSD& resultant_llsd); diff --git a/indra/llcommon/llstacktrace.cpp b/indra/llcommon/llstacktrace.cpp index 80057bf0f2..285bdb83ec 100644 --- a/indra/llcommon/llstacktrace.cpp +++ b/indra/llcommon/llstacktrace.cpp @@ -53,8 +53,8 @@ bool ll_get_stack_trace(std::vector& lines) const S32 MAX_STACK_DEPTH = 32; const S32 STRING_NAME_LENGTH = 200; const S32 FRAME_SKIP = 2; - static BOOL symbolsLoaded = false; - static BOOL firstCall = true; + static bool symbolsLoaded = false; + static bool firstCall = true; HANDLE hProc = GetCurrentProcess(); @@ -92,7 +92,7 @@ bool ll_get_stack_trace(std::vector& lines) for(S32 i=0; i < depth; i++) { std::stringstream stack_line; - BOOL ret; + bool ret; DWORD64 addr = (DWORD64)frames[i]; ret = SymGetSymFromAddr64(hProc, addr, 0, pSym); @@ -134,7 +134,7 @@ void ll_get_stack_trace_internal(std::vector& lines) const S32 STRING_NAME_LENGTH = 256; HANDLE process = GetCurrentProcess(); - SymInitialize( process, NULL, TRUE ); + SymInitialize( process, NULL, true ); void *stack[MAX_STACK_DEPTH]; diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp index d3f99a413d..8c5f78b3a7 100644 --- a/indra/llcommon/llsys.cpp +++ b/indra/llcommon/llsys.cpp @@ -214,7 +214,7 @@ LLOSInfo::LLOSInfo() : DWORD cbData(sizeof(DWORD)); DWORD data(0); HKEY key; - BOOL ret_code = RegOpenKeyExW(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), 0, KEY_READ, &key); + LSTATUS ret_code = RegOpenKeyExW(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), 0, KEY_READ, &key); if (ERROR_SUCCESS == ret_code) { ret_code = RegQueryValueExW(key, L"UBR", 0, NULL, reinterpret_cast(&data), &cbData); @@ -571,7 +571,7 @@ bool LLOSInfo::is64Bit() 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; + bool f64 = false; return IsWow64Process(GetCurrentProcess(), &f64) && f64; #else return false; @@ -1321,11 +1321,11 @@ private: // Need an instance of FrameWatcher before it does any good static FrameWatcher sFrameWatcher; -BOOL gunzip_file(const std::string& srcfile, const std::string& dstfile) +bool gunzip_file(const std::string& srcfile, const std::string& dstfile) { std::string tmpfile; const S32 UNCOMPRESS_BUFFER_SIZE = 32768; - BOOL retval = FALSE; + bool retval = false; gzFile src = NULL; U8 buffer[UNCOMPRESS_BUFFER_SIZE]; LLFILE *dst = NULL; @@ -1353,18 +1353,18 @@ BOOL gunzip_file(const std::string& srcfile, const std::string& dstfile) fclose(dst); dst = NULL; if (LLFile::rename(tmpfile, dstfile) == -1) goto err; /* Flawfinder: ignore */ - retval = TRUE; + retval = true; err: if (src != NULL) gzclose(src); if (dst != NULL) fclose(dst); return retval; } -BOOL gzip_file(const std::string& srcfile, const std::string& dstfile) +bool gzip_file(const std::string& srcfile, const std::string& dstfile) { const S32 COMPRESS_BUFFER_SIZE = 32768; std::string tmpfile; - BOOL retval = FALSE; + bool retval = false; U8 buffer[COMPRESS_BUFFER_SIZE]; gzFile dst = NULL; LLFILE *src = NULL; @@ -1404,7 +1404,7 @@ BOOL gzip_file(const std::string& srcfile, const std::string& dstfile) LLFile::remove(dstfile); #endif if (LLFile::rename(tmpfile, dstfile) == -1) goto err; /* Flawfinder: ignore */ - retval = TRUE; + retval = true; err: if (src != NULL) fclose(src); if (dst != NULL) gzclose(dst); diff --git a/indra/llcommon/llsys.h b/indra/llcommon/llsys.h index 08d4abffa2..ef94a283c8 100644 --- a/indra/llcommon/llsys.h +++ b/indra/llcommon/llsys.h @@ -165,9 +165,9 @@ LL_COMMON_API std::ostream& operator<<(std::ostream& s, const LLCPUInfo& info); LL_COMMON_API std::ostream& operator<<(std::ostream& s, const LLMemoryInfo& info); // gunzip srcfile into dstfile. Returns FALSE on error. -BOOL LL_COMMON_API gunzip_file(const std::string& srcfile, const std::string& dstfile); +bool LL_COMMON_API gunzip_file(const std::string& srcfile, const std::string& dstfile); // gzip srcfile into dstfile. Returns FALSE on error. -BOOL LL_COMMON_API gzip_file(const std::string& srcfile, const std::string& dstfile); +bool LL_COMMON_API gzip_file(const std::string& srcfile, const std::string& dstfile); extern LL_COMMON_API LLCPUInfo gSysCPU; diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index 4eaa05c335..b2142c6361 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -188,7 +188,7 @@ void LLThread::threadRun() } LLThread::LLThread(const std::string& name, apr_pool_t *poolp) : - mPaused(FALSE), + mPaused(false), mName(name), mThreadp(NULL), mStatus(STOPPED), diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 50202631e7..c18a0363c7 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -68,7 +68,7 @@ public: // Called from MAIN THREAD. void pause(); void unpause(); - bool isPaused() { return isStopped() || mPaused == TRUE; } + bool isPaused() { return isStopped() || mPaused == true; } // Cause the thread to wake up and check its condition void wake(); diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 1a99ac2886..42c4911ff1 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -96,7 +96,7 @@ U32 micro_sleep(U64 us, U32 max_yields) LARGE_INTEGER ft; ft.QuadPart = -static_cast(us * 10); // '-' using relative time - HANDLE timer = CreateWaitableTimer(NULL, TRUE, NULL); + HANDLE timer = CreateWaitableTimer(NULL, true, NULL); SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0); WaitForSingleObject(timer, INFINITE); CloseHandle(timer); @@ -324,7 +324,7 @@ LLTimer::LLTimer() get_timer_info().update(); } - mStarted = TRUE; + mStarted = true; reset(); } @@ -441,31 +441,31 @@ F32SecondsImplicit LLTimer::getRemainingTimeF32() const } -BOOL LLTimer::checkExpirationAndReset(F32 expiration) +bool LLTimer::checkExpirationAndReset(F32 expiration) { U64 cur_ticks = get_clock_count(); if (cur_ticks < mExpirationTicks) { - return FALSE; + return false; } mExpirationTicks = cur_ticks + (U64)((F32)(expiration * get_timer_info().mClockFrequency)); - return TRUE; + return true; } -BOOL LLTimer::hasExpired() const +bool LLTimer::hasExpired() const { return (get_clock_count() >= mExpirationTicks) - ? TRUE : FALSE; + ? true : false; } /////////////////////////////////////////////////////////////////////////////// -BOOL LLTimer::knownBadTimer() +bool LLTimer::knownBadTimer() { - BOOL failed = FALSE; + bool failed = false; #if LL_WINDOWS WCHAR bad_pci_list[][10] = {L"1039:0530", @@ -507,7 +507,7 @@ BOOL LLTimer::knownBadTimer() if (!wcscmp(pci_id, bad_pci_list[check])) { // LL_WARNS() << "unreliable PCI chipset found!! " << pci_id << endl; - failed = TRUE; + failed = true; break; } } @@ -533,7 +533,7 @@ time_t time_corrected() // Is the current computer (in its current time zone) // observing daylight savings time? -BOOL is_daylight_savings() +bool is_daylight_savings() { time_t now = time(NULL); @@ -547,7 +547,7 @@ BOOL is_daylight_savings() } -struct tm* utc_to_pacific_time(time_t utc_time, BOOL pacific_daylight_time) +struct tm* utc_to_pacific_time(time_t utc_time, bool pacific_daylight_time) { S32Hours pacific_offset_hours; if (pacific_daylight_time) diff --git a/indra/llcommon/lltimer.h b/indra/llcommon/lltimer.h index 010f290b24..8fea02eb92 100644 --- a/indra/llcommon/lltimer.h +++ b/indra/llcommon/lltimer.h @@ -87,19 +87,19 @@ public: // MANIPULATORS - void start() { reset(); mStarted = TRUE; } - void stop() { mStarted = FALSE; } + void start() { reset(); mStarted = true; } + void stop() { mStarted = false; } void reset(); // Resets the timer void setLastClockCount(U64 current_count); // Sets the timer so that the next elapsed call will be relative to this time void setTimerExpirySec(F32SecondsImplicit expiration); - BOOL checkExpirationAndReset(F32 expiration); - BOOL hasExpired() const; + bool checkExpirationAndReset(F32 expiration); + bool hasExpired() const; F32SecondsImplicit getElapsedTimeAndResetF32(); // Returns elapsed time in seconds with reset F64SecondsImplicit getElapsedTimeAndResetF64(); F32SecondsImplicit getRemainingTimeF32() const; - static BOOL knownBadTimer(); + static bool knownBadTimer(); // ACCESSORS F32SecondsImplicit getElapsedTimeF32() const; // Returns elapsed time in seconds @@ -171,14 +171,14 @@ extern LL_COMMON_API S32 gUTCOffset; // Is the current computer (in its current time zone) // observing daylight savings time? -LL_COMMON_API BOOL is_daylight_savings(); +LL_COMMON_API bool is_daylight_savings(); // Converts internal "struct tm" time buffer to Pacific Standard/Daylight Time // Usage: // S32 utc_time; // utc_time = time_corrected(); // struct tm* internal_time = utc_to_pacific_time(utc_time, gDaylight); -LL_COMMON_API struct tm* utc_to_pacific_time(time_t utc_time, BOOL pacific_daylight_time); +LL_COMMON_API struct tm* utc_to_pacific_time(time_t utc_time, bool pacific_daylight_time); LL_COMMON_API void microsecondsToTimecodeString(U64MicrosecondsImplicit current_time, std::string& tcstring); LL_COMMON_API void secondsToTimecodeString(F32SecondsImplicit current_time, std::string& tcstring); diff --git a/indra/llcommon/lluri.cpp b/indra/llcommon/lluri.cpp index 4fb92a8f3e..50ff0f9de0 100644 --- a/indra/llcommon/lluri.cpp +++ b/indra/llcommon/lluri.cpp @@ -330,7 +330,7 @@ LLURI::LLURI(const std::string& escaped_str) } } -static BOOL isDefault(const std::string& scheme, U16 port) +static bool isDefault(const std::string& scheme, U16 port) { if (scheme == "http") return port == 80; @@ -339,7 +339,7 @@ static BOOL isDefault(const std::string& scheme, U16 port) if (scheme == "ftp") return port == 21; - return FALSE; + return false; } void LLURI::parseAuthorityAndPathUsingOpaque() @@ -627,7 +627,7 @@ std::string LLURI::password() const return unescape(pass); } -BOOL LLURI::defaultPort() const +bool LLURI::defaultPort() const { return isDefault(mScheme, hostPort()); } diff --git a/indra/llcommon/lluri.h b/indra/llcommon/lluri.h index b8fca0ca51..d6b10bd564 100644 --- a/indra/llcommon/lluri.h +++ b/indra/llcommon/lluri.h @@ -99,7 +99,7 @@ public: std::string userName() const; std::string password() const; U16 hostPort() const; // ex.: 80, will include implicit port - BOOL defaultPort() const; // true if port is default for scheme + bool defaultPort() const; // true if port is default for scheme const std::string& escapedPath() const { return mEscapedPath; } std::string path() const; // ex.: "/abc/def", includes leading slash LLSD pathArray() const; // above decoded into an array of strings diff --git a/indra/llcommon/lluuid.cpp b/indra/llcommon/lluuid.cpp index 285469f0d4..b670273da3 100644 --- a/indra/llcommon/lluuid.cpp +++ b/indra/llcommon/lluuid.cpp @@ -211,20 +211,20 @@ std::string LLUUID::asString() const return str; } -BOOL LLUUID::set(const char* in_string, BOOL emit) +bool LLUUID::set(const char* in_string, bool emit) { return set(ll_safe_string(in_string), emit); } -BOOL LLUUID::set(const std::string& in_string, BOOL emit) +bool LLUUID::set(const std::string& in_string, bool emit) { - BOOL broken_format = FALSE; + bool broken_format = false; // empty strings should make NULL uuid if (in_string.empty()) { setNull(); - return TRUE; + return true; } if (in_string.length() != (UUID_STR_LENGTH - 1)) /* Flawfinder: ignore */ @@ -237,7 +237,7 @@ BOOL LLUUID::set(const std::string& in_string, BOOL emit) { LL_WARNS() << "Warning! Using broken UUID string format" << LL_ENDL; } - broken_format = TRUE; + broken_format = true; } else { @@ -248,7 +248,7 @@ BOOL LLUUID::set(const std::string& in_string, BOOL emit) LL_WARNS() << "Bad UUID string: " << in_string << LL_ENDL; } setNull(); - return FALSE; + return false; } } @@ -287,7 +287,7 @@ BOOL LLUUID::set(const std::string& in_string, BOOL emit) LL_WARNS() << "Invalid UUID string character" << LL_ENDL; } setNull(); - return FALSE; + return false; } mData[i] = mData[i] << 4; @@ -312,27 +312,27 @@ BOOL LLUUID::set(const std::string& in_string, BOOL emit) LL_WARNS() << "Invalid UUID string character" << LL_ENDL; } setNull(); - return FALSE; + return false; } cur_pos++; } - return TRUE; + return true; } -BOOL LLUUID::validate(const std::string& in_string) +bool LLUUID::validate(const std::string& in_string) { - BOOL broken_format = FALSE; + bool broken_format = false; if (in_string.length() != (UUID_STR_LENGTH - 1)) /* Flawfinder: ignore */ { // I'm a moron. First implementation didn't have the right UUID format. if (in_string.length() == (UUID_STR_LENGTH - 2)) /* Flawfinder: ignore */ { - broken_format = TRUE; + broken_format = true; } else { - return FALSE; + return false; } } @@ -360,7 +360,7 @@ BOOL LLUUID::validate(const std::string& in_string) } else { - return FALSE; + return false; } cur_pos++; @@ -376,11 +376,11 @@ BOOL LLUUID::validate(const std::string& in_string) } else { - return FALSE; + return false; } cur_pos++; } - return TRUE; + return true; } const LLUUID& LLUUID::operator^=(const LLUUID& rhs) @@ -736,12 +736,12 @@ void LLUUID::getCurrentTime(uuid_time_t* timestamp) static uuid_time_t time_last; static U32 uuids_this_tick; - static BOOL init = FALSE; + static bool init = false; if (!init) { getSystemTime(&time_last); uuids_this_tick = uuids_per_tick; - init = TRUE; + init = true; mMutex = new LLMutex(); } @@ -889,11 +889,11 @@ U32 LLUUID::getRandomSeed() return U32(seed64) ^ U32(seed64 >> 32); } -BOOL LLUUID::parseUUID(const std::string& buf, LLUUID* value) +bool LLUUID::parseUUID(const std::string& buf, LLUUID* value) { if (buf.empty() || value == NULL) { - return FALSE; + return false; } std::string temp(buf); @@ -901,9 +901,9 @@ BOOL LLUUID::parseUUID(const std::string& buf, LLUUID* value) if (LLUUID::validate(temp)) { value->set(temp); - return TRUE; + return true; } - return FALSE; + return false; } //static @@ -989,7 +989,7 @@ bool LLUUID::operator!=(const LLUUID& rhs) const } */ -BOOL LLUUID::notNull() const +bool LLUUID::notNull() const { U32* word = (U32*)mData; return (word[0] | word[1] | word[2] | word[3]) > 0; @@ -997,7 +997,7 @@ BOOL LLUUID::notNull() const // Faster than == LLUUID::null because doesn't require // as much memory access. -BOOL LLUUID::isNull() const +bool LLUUID::isNull() const { U32* word = (U32*)mData; // If all bits are zero, return !0 == TRUE diff --git a/indra/llcommon/lluuid.h b/indra/llcommon/lluuid.h index 80597fa186..89c512ecf7 100644 --- a/indra/llcommon/lluuid.h +++ b/indra/llcommon/lluuid.h @@ -65,8 +65,8 @@ public: static LLUUID generateNewID(std::string stream = ""); //static version of above for use in initializer expressions such as constructor params, etc. - BOOL set(const char *in_string, BOOL emit = TRUE); // Convert from string, if emit is FALSE, do not emit warnings - BOOL set(const std::string& in_string, BOOL emit = TRUE); // Convert from string, if emit is FALSE, do not emit warnings + bool set(const char *in_string, bool emit = true); // Convert from string, if emit is FALSE, do not emit warnings + bool set(const std::string& in_string, bool emit = true); // Convert from string, if emit is FALSE, do not emit warnings void setNull(); // Faster than setting to LLUUID::null. S32 cmpTime(uuid_time_t *t1, uuid_time_t *t2); @@ -76,8 +76,8 @@ public: // // ACCESSORS // - BOOL isNull() const; // Faster than comparing to LLUUID::null. - BOOL notNull() const; // Faster than comparing to LLUUID::null. + bool isNull() const; // Faster than comparing to LLUUID::null. + bool notNull() const; // Faster than comparing to LLUUID::null. // JC: This is dangerous. It allows UUIDs to be cast automatically // to integers, among other things. Use isNull() or notNull(). // operator bool() const; @@ -124,7 +124,7 @@ public: return tmp[0] ^ tmp[1]; } - static BOOL validate(const std::string& in_string); // Validate that the UUID string is legal. + static bool validate(const std::string& in_string); // Validate that the UUID string is legal. static const LLUUID null; static LLMutex * mMutex; @@ -132,7 +132,7 @@ public: static U32 getRandomSeed(); static S32 getNodeID(unsigned char * node_id); - static BOOL parseUUID(const std::string& buf, LLUUID* value); + static bool parseUUID(const std::string& buf, LLUUID* value); U8 mData[UUID_BYTES]; }; -- cgit v1.2.3 From 364bd17304dd96ccf62fcee49de1df650b655e74 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Thu, 8 Feb 2024 22:26:52 +0100 Subject: Replace remaining BOOL with bool in llcommon and remove dead code --- indra/llcommon/StackWalker.cpp | 72 ++++++++++++------------ indra/llcommon/StackWalker.h | 6 +- indra/llcommon/llapp.cpp | 124 +++-------------------------------------- indra/llcommon/llapp.h | 6 +- 4 files changed, 50 insertions(+), 158 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/StackWalker.cpp b/indra/llcommon/StackWalker.cpp index 56defc6465..7808c36757 100644 --- a/indra/llcommon/StackWalker.cpp +++ b/indra/llcommon/StackWalker.cpp @@ -292,10 +292,10 @@ public: free(m_szSymPath); m_szSymPath = NULL; } - BOOL Init(LPCSTR szSymPath) + bool Init(LPCSTR szSymPath) { if (m_parent == NULL) - return FALSE; + return false; // Dynamically load the Entry-Points for dbghelp.dll: // First try to load the newsest one from TCHAR szTemp[4096]; @@ -364,7 +364,7 @@ public: if (m_hDbhHelp == NULL) // if not already loaded, try to load a default-one m_hDbhHelp = LoadLibrary( _T("dbghelp.dll") ); if (m_hDbhHelp == NULL) - return FALSE; + return false; pSI = (tSI) GetProcAddress(m_hDbhHelp, "SymInitialize" ); pSC = (tSC) GetProcAddress(m_hDbhHelp, "SymCleanup" ); @@ -388,7 +388,7 @@ public: FreeLibrary(m_hDbhHelp); m_hDbhHelp = NULL; pSC = NULL; - return FALSE; + return false; } // SymInitialize @@ -415,7 +415,7 @@ public: GetUserNameA(szUserName, &dwSize); this->m_parent->OnSymInit(buf, symOptions, szUserName); - return TRUE; + return false; } StackWalker *m_parent; @@ -555,7 +555,7 @@ private: typedef MODULEENTRY32 * LPMODULEENTRY32; #pragma pack( pop ) - BOOL GetModuleListTH32(HANDLE hProcess, DWORD pid) + bool GetModuleListTH32(HANDLE hProcess, DWORD pid) { // CreateToolhelp32Snapshot() typedef HANDLE (__stdcall *tCT32S)(DWORD dwFlags, DWORD th32ProcessID); @@ -592,13 +592,13 @@ private: } if (hToolhelp == NULL) - return FALSE; + return false; hSnap = pCT32S( TH32CS_SNAPMODULE, pid ); if (hSnap == (HANDLE) -1) { FreeLibrary(hToolhelp); - return FALSE; + return false; } keepGoing = !!pM32F( hSnap, &me ); @@ -612,8 +612,8 @@ private: CloseHandle(hSnap); FreeLibrary(hToolhelp); if (cnt <= 0) - return FALSE; - return TRUE; + return false; + return true; } // GetModuleListTH32 // **************************************** PSAPI ************************ @@ -623,7 +623,7 @@ private: LPVOID EntryPoint; } MODULEINFO, *LPMODULEINFO; - BOOL GetModuleListPSAPI(HANDLE hProcess) + bool GetModuleListPSAPI(HANDLE hProcess) { // EnumProcessModules() typedef BOOL (__stdcall *tEPM)(HANDLE hProcess, HMODULE *lphModule, DWORD cb, LPDWORD lpcbNeeded ); @@ -652,7 +652,7 @@ private: hPsapi = LoadLibrary( _T("psapi.dll") ); if (hPsapi == NULL) - return FALSE; + return false; pEPM = (tEPM) GetProcAddress( hPsapi, "EnumProcessModules" ); pGMFNE = (tGMFNE) GetProcAddress( hPsapi, "GetModuleFileNameExA" ); @@ -662,7 +662,7 @@ private: { // we couldn't find all functions FreeLibrary(hPsapi); - return FALSE; + return false; } hMods = (HMODULE*) malloc(sizeof(HMODULE) * (TTBUFLEN / sizeof(HMODULE))); @@ -797,7 +797,7 @@ private: return result; } public: - BOOL LoadModules(HANDLE hProcess, DWORD dwProcessId) + bool LoadModules(HANDLE hProcess, DWORD dwProcessId) { // first try toolhelp32 if (GetModuleListTH32(hProcess, dwProcessId)) @@ -807,13 +807,13 @@ public: } - BOOL GetModuleInfo(HANDLE hProcess, DWORD64 baseAddr, IMAGEHLP_MODULE64_V3 *pModuleInfo) + bool GetModuleInfo(HANDLE hProcess, DWORD64 baseAddr, IMAGEHLP_MODULE64_V3 *pModuleInfo) { memset(pModuleInfo, 0, sizeof(IMAGEHLP_MODULE64_V3)); if(this->pSGMI == NULL) { SetLastError(ERROR_DLL_INIT_FAILED); - return FALSE; + return false; } // First try to use the larger ModuleInfo-Structure pModuleInfo->SizeOfStruct = sizeof(IMAGEHLP_MODULE64_V3); @@ -821,7 +821,7 @@ public: if (pData == NULL) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; + return false; } memcpy(pData, pModuleInfo, sizeof(IMAGEHLP_MODULE64_V3)); static bool s_useV3Version = true; @@ -833,7 +833,7 @@ public: memcpy(pModuleInfo, pData, sizeof(IMAGEHLP_MODULE64_V3)); pModuleInfo->SizeOfStruct = sizeof(IMAGEHLP_MODULE64_V3); free(pData); - return TRUE; + return true; } s_useV3Version = false; // to prevent unneccessarry calls with the larger struct... } @@ -847,11 +847,11 @@ public: memcpy(pModuleInfo, pData, sizeof(IMAGEHLP_MODULE64_V2)); pModuleInfo->SizeOfStruct = sizeof(IMAGEHLP_MODULE64_V2); free(pData); - return TRUE; + return true; } free(pData); SetLastError(ERROR_DLL_INIT_FAILED); - return FALSE; + return false; } }; @@ -860,7 +860,7 @@ StackWalker::StackWalker(DWORD dwProcessId, HANDLE hProcess) { this->m_verbose = true; this->m_options = OptionsAll; - this->m_modulesLoaded = FALSE; + this->m_modulesLoaded = false; this->m_hProcess = hProcess; this->m_sw = new StackWalkerInternal(this, this->m_hProcess); this->m_dwProcessId = dwProcessId; @@ -871,7 +871,7 @@ StackWalker::StackWalker(bool verbose, int options, LPCSTR szSymPath, DWORD dwPr { this->m_verbose = verbose; this->m_options = options; - this->m_modulesLoaded = FALSE; + this->m_modulesLoaded = false; this->m_hProcess = hProcess; this->m_sw = new StackWalkerInternal(this, this->m_hProcess); this->m_dwProcessId = dwProcessId; @@ -895,15 +895,15 @@ StackWalker::~StackWalker() this->m_sw = NULL; } -BOOL StackWalker::LoadModules() +bool StackWalker::LoadModules() { if (this->m_sw == NULL) { SetLastError(ERROR_DLL_INIT_FAILED); - return FALSE; + return false; } if (m_modulesLoaded != FALSE) - return TRUE; + return true; // Build the sym-path: char *szSymPath = NULL; @@ -914,7 +914,7 @@ BOOL StackWalker::LoadModules() if (szSymPath == NULL) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; + return false; } szSymPath[0] = 0; // Now first add the (optional) provided sympath: @@ -994,18 +994,18 @@ BOOL StackWalker::LoadModules() } // if SymBuildPath // First Init the whole stuff... - BOOL bRet = this->m_sw->Init(szSymPath); + bool bRet = this->m_sw->Init(szSymPath); if (szSymPath != NULL) free(szSymPath); szSymPath = NULL; - if (bRet == FALSE) + if (!bRet) { this->OnDbgHelpErr("Error while initializing dbghelp.dll", 0, 0); SetLastError(ERROR_DLL_INIT_FAILED); - return FALSE; + return false; } bRet = this->m_sw->LoadModules(this->m_hProcess, this->m_dwProcessId); - if (bRet != FALSE) - m_modulesLoaded = TRUE; + if (bRet) + m_modulesLoaded = true; return bRet; } @@ -1017,7 +1017,7 @@ BOOL StackWalker::LoadModules() static StackWalker::PReadProcessMemoryRoutine s_readMemoryFunction = NULL; static LPVOID s_readMemoryFunction_UserData = NULL; -BOOL StackWalker::ShowCallstack(bool verbose, HANDLE hThread, const CONTEXT *context, PReadProcessMemoryRoutine readMemoryFunction, LPVOID pUserData) +bool StackWalker::ShowCallstack(bool verbose, HANDLE hThread, const CONTEXT *context, PReadProcessMemoryRoutine readMemoryFunction, LPVOID pUserData) { m_verbose = verbose; CONTEXT c; @@ -1029,13 +1029,13 @@ BOOL StackWalker::ShowCallstack(bool verbose, HANDLE hThread, const CONTEXT *con bool bLastEntryCalled = true; int curRecursionCount = 0; - if (m_modulesLoaded == FALSE) + if (!m_modulesLoaded) this->LoadModules(); // ignore the result... if (this->m_sw->m_hDbhHelp == NULL) { SetLastError(ERROR_DLL_INIT_FAILED); - return FALSE; + return false; } s_readMemoryFunction = readMemoryFunction; @@ -1062,7 +1062,7 @@ BOOL StackWalker::ShowCallstack(bool verbose, HANDLE hThread, const CONTEXT *con if (GetThreadContext(hThread, &c) == FALSE) { ResumeThread(hThread); - return FALSE; + return false; } } } @@ -1262,7 +1262,7 @@ BOOL StackWalker::ShowCallstack(bool verbose, HANDLE hThread, const CONTEXT *con if (context == NULL) ResumeThread(hThread); - return TRUE; + return true; } BOOL __stdcall StackWalker::myReadProcMem( diff --git a/indra/llcommon/StackWalker.h b/indra/llcommon/StackWalker.h index 4634765d0b..3667f59b38 100644 --- a/indra/llcommon/StackWalker.h +++ b/indra/llcommon/StackWalker.h @@ -112,9 +112,9 @@ public: LPVOID pUserData // optional data, which was passed in "ShowCallstack" ); - BOOL LoadModules(); + bool LoadModules(); - BOOL ShowCallstack( + bool ShowCallstack( bool verbose, HANDLE hThread = GetCurrentThread(), const CONTEXT *context = NULL, @@ -159,7 +159,7 @@ protected: StackWalkerInternal *m_sw; HANDLE m_hProcess; DWORD m_dwProcessId; - BOOL m_modulesLoaded; + bool m_modulesLoaded; LPSTR m_szSymPath; bool m_verbose; diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp index b99166991f..0837ece80d 100644 --- a/indra/llcommon/llapp.cpp +++ b/indra/llcommon/llapp.cpp @@ -52,15 +52,7 @@ // // Signal handling -// -// Windows uses structured exceptions, so it's handled a bit differently. -// -#if LL_WINDOWS -#include "windows.h" - -LONG WINAPI default_windows_exception_handler(struct _EXCEPTION_POINTERS *exception_infop); -BOOL ConsoleCtrlHandler(DWORD fdwCtrlType); -#else +#ifndef LL_WINDOWS # include # include // for fork() void setup_signals(); @@ -87,24 +79,24 @@ S32 LL_HEARTBEAT_SIGNAL = SIGUSR2; S32 LL_SMACKDOWN_SIGNAL = (SIGRTMAX >= 0) ? (SIGRTMAX-1) : SIGUSR1; S32 LL_HEARTBEAT_SIGNAL = (SIGRTMAX >= 0) ? (SIGRTMAX-0) : SIGUSR2; # endif // LL_DARWIN -#endif // LL_WINDOWS +#endif // !LL_WINDOWS // the static application instance LLApp* LLApp::sApplication = NULL; // Allows the generation of core files for post mortem under gdb // and disables crashlogger -BOOL LLApp::sDisableCrashlogger = FALSE; +bool LLApp::sDisableCrashlogger = false; // Local flag for whether or not to do logging in signal handlers. //static -BOOL LLApp::sLogInSignal = FALSE; +bool LLApp::sLogInSignal = false; // static // Keeps track of application status LLScalarCond LLApp::sStatus{LLApp::APP_STATUS_STOPPED}; LLAppErrorHandler LLApp::sErrorHandler = NULL; -BOOL LLApp::sErrorThreadRunning = FALSE; +bool LLApp::sErrorThreadRunning = false; LLApp::LLApp() @@ -327,33 +319,6 @@ void LLApp::stepFrame() mRunner.run(); } -#if LL_WINDOWS -//The following code is needed for 32-bit apps on 64-bit windows to keep it from eating -//crashes. It is a lovely undocumented 'feature' in SP1 of Windows 7. An excellent -//in-depth article on the issue may be found here: http://randomascii.wordpress.com/2012/07/05/when-even-crashing-doesn-work/ -void EnableCrashingOnCrashes() -{ - typedef BOOL (WINAPI *tGetPolicy)(LPDWORD lpFlags); - typedef BOOL (WINAPI *tSetPolicy)(DWORD dwFlags); - const DWORD EXCEPTION_SWALLOWING = 0x1; - - HMODULE kernel32 = LoadLibraryA("kernel32.dll"); - tGetPolicy pGetPolicy = (tGetPolicy)GetProcAddress(kernel32, - "GetProcessUserModeExceptionPolicy"); - tSetPolicy pSetPolicy = (tSetPolicy)GetProcAddress(kernel32, - "SetProcessUserModeExceptionPolicy"); - if (pGetPolicy && pSetPolicy) - { - DWORD dwFlags; - if (pGetPolicy(&dwFlags)) - { - // Turn off the filter - pSetPolicy(dwFlags & ~EXCEPTION_SWALLOWING); - } - } -} -#endif - void LLApp::setupErrorHandling(bool second_instance) { // Error handling is done by starting up an error handling thread, which just sleeps and @@ -504,13 +469,13 @@ bool LLApp::isExiting() void LLApp::disableCrashlogger() { - sDisableCrashlogger = TRUE; + sDisableCrashlogger = true; } // static bool LLApp::isCrashloggerDisabled() { - return (sDisableCrashlogger == TRUE); + return (sDisableCrashlogger == true); } // static @@ -523,77 +488,7 @@ int LLApp::getPid() #endif } -#if LL_WINDOWS -LONG WINAPI default_windows_exception_handler(struct _EXCEPTION_POINTERS *exception_infop) -{ - // Translate the signals/exceptions into cross-platform stuff - // Windows implementation - - // Make sure the user sees something to indicate that the app crashed. - LONG retval; - - if (LLApp::isError()) - { - LL_WARNS() << "Got another fatal signal while in the error handler, die now!" << LL_ENDL; - retval = EXCEPTION_EXECUTE_HANDLER; - return retval; - } - - // Flag status to error, so thread_error starts its work - LLApp::setError(); - - // Block in the exception handler until the app has stopped - // This is pretty sketchy, but appears to work just fine - while (!LLApp::isStopped()) - { - ms_sleep(10); - } - - // - // Generate a minidump if we can. - // - // TODO: This needs to be ported over form the viewer-specific - // LLWinDebug class - - // - // At this point, we always want to exit the app. There's no graceful - // recovery for an unhandled exception. - // - // Just kill the process. - retval = EXCEPTION_EXECUTE_HANDLER; - return retval; -} - -// Win32 doesn't support signals. This is used instead. -BOOL ConsoleCtrlHandler(DWORD fdwCtrlType) -{ - switch (fdwCtrlType) - { - case CTRL_BREAK_EVENT: - case CTRL_LOGOFF_EVENT: - case CTRL_SHUTDOWN_EVENT: - case CTRL_CLOSE_EVENT: // From end task or the window close button. - case CTRL_C_EVENT: // from CTRL-C on the keyboard - // Just set our state to quitting, not error - if (LLApp::isQuitting() || LLApp::isError()) - { - // We're already trying to die, just ignore this signal - if (LLApp::sLogInSignal) - { - LL_INFOS() << "Signal handler - Already trying to quit, ignoring signal!" << LL_ENDL; - } - return TRUE; - } - LLApp::setQuitting(); - return TRUE; - - default: - return FALSE; - } -} - -#else //!LL_WINDOWS - +#ifndef LL_WINDOWS void setup_signals() { // @@ -811,9 +706,6 @@ void default_unix_signal_handler(int signum, siginfo_t *info, void *) } } -#if LL_LINUX -#endif - bool unix_post_minidump_callback(const char *dump_dir, const char *minidump_id, void *context, bool succeeded) diff --git a/indra/llcommon/llapp.h b/indra/llcommon/llapp.h index c832c8b142..997fc5a951 100644 --- a/indra/llcommon/llapp.h +++ b/indra/llcommon/llapp.h @@ -291,8 +291,8 @@ protected: static void setStatus(EAppStatus status); // Use this to change the application status. static LLScalarCond sStatus; // Reflects current application status - static BOOL sErrorThreadRunning; // Set while the error thread is running - static BOOL sDisableCrashlogger; // Let the OS handle crashes for us. + static bool sErrorThreadRunning; // Set while the error thread is running + static bool sDisableCrashlogger; // Let the OS handle crashes for us. std::wstring mCrashReportPipeStr; //Name of pipe to use for crash reporting. std::string mDumpPath; //output path for google breakpad. Dependency workaround. @@ -337,7 +337,7 @@ private: #endif public: - static BOOL sLogInSignal; + static bool sLogInSignal; }; #endif // LL_LLAPP_H -- cgit v1.2.3 From 67876e6cb01871201048955868151971883aeaf4 Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Fri, 9 Feb 2024 02:18:20 +0200 Subject: Follow up 364bd17: restore return value --- indra/llcommon/StackWalker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/StackWalker.cpp b/indra/llcommon/StackWalker.cpp index 7808c36757..4ecff4ee69 100644 --- a/indra/llcommon/StackWalker.cpp +++ b/indra/llcommon/StackWalker.cpp @@ -415,7 +415,7 @@ public: GetUserNameA(szUserName, &dwSize); this->m_parent->OnSymInit(buf, symOptions, szUserName); - return false; + return true; } StackWalker *m_parent; -- cgit v1.2.3 From b8952923ac2564f85b83da6893f89a6a45c952fd Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 9 Feb 2024 23:06:55 +0200 Subject: Triage Issue #49 Better inspection of data urls in media --- indra/llcommon/llbase64.cpp | 16 ++++++++++++++++ indra/llcommon/llbase64.h | 1 + 2 files changed, 17 insertions(+) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llbase64.cpp b/indra/llcommon/llbase64.cpp index bb85fe32a3..6591e9b49a 100644 --- a/indra/llcommon/llbase64.cpp +++ b/indra/llcommon/llbase64.cpp @@ -59,3 +59,19 @@ std::string LLBase64::encode(const U8* input, size_t input_size) return output; } +std::string LLBase64::decodeAsString(const std::string &input) +{ + int b64_buffer_length = apr_base64_decode_len(input.c_str()); + char* b64_buffer = new char[b64_buffer_length]; + + // This is faster than apr_base64_encode() if you know + // you're not on an EBCDIC machine. Also, the output is + // null terminated, even though the documentation doesn't + // specify. See apr_base64.c for details. JC + b64_buffer_length = apr_base64_decode(b64_buffer, input.c_str()); + std::string res; + res.assign(b64_buffer); + delete[] b64_buffer; + return res; +} + diff --git a/indra/llcommon/llbase64.h b/indra/llcommon/llbase64.h index 16d2c217d0..b985963fc4 100644 --- a/indra/llcommon/llbase64.h +++ b/indra/llcommon/llbase64.h @@ -32,6 +32,7 @@ class LL_COMMON_API LLBase64 { public: static std::string encode(const U8* input, size_t input_size); + static std::string decodeAsString(const std::string& input); }; #endif -- cgit v1.2.3 From 04a02e83e9dcc29d4649e8003d523621b5119d7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20N=C3=A6sbye=20Christensen?= Date: Fri, 9 Feb 2024 23:22:06 +0100 Subject: misc: BOOL (int) to real bool --- indra/llcommon/llcallbacklist.cpp | 8 ++++---- indra/llcommon/llstring.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llcallbacklist.cpp b/indra/llcommon/llcallbacklist.cpp index 9f23ce5317..4ccf08cbbb 100644 --- a/indra/llcommon/llcallbacklist.cpp +++ b/indra/llcommon/llcallbacklist.cpp @@ -70,11 +70,11 @@ bool LLCallbackList::containsFunction( callback_t func, void *data) callback_list_t::iterator iter = find(func,data); if (iter != mCallbackList.end()) { - return TRUE; + return true; } else { - return FALSE; + return false; } } @@ -85,11 +85,11 @@ bool LLCallbackList::deleteFunction( callback_t func, void *data) if (iter != mCallbackList.end()) { mCallbackList.erase(iter); - return TRUE; + return true; } else { - return FALSE; + return false; } } diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h index 1fd6cac14a..66ee42af2a 100644 --- a/indra/llcommon/llstring.h +++ b/indra/llcommon/llstring.h @@ -1598,12 +1598,12 @@ template BOOL LLStringUtilBase::containsNonprintable(const string_type& string) { const char MIN = 32; - BOOL rv = FALSE; + BOOL rv = false; for (size_type i = 0; i < string.size(); i++) { if(string[i] < MIN) { - rv = TRUE; + rv = true; break; } } -- cgit v1.2.3 From 70f8dc7a4f4be217fea5439e474fc75e567c23c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20N=C3=A6sbye=20Christensen?= Date: Sat, 10 Feb 2024 22:37:52 +0100 Subject: miscellaneous: BOOL (int) to real bool --- indra/llcommon/is_approx_equal_fraction.h | 4 +- indra/llcommon/llcallbacklist.cpp | 2 +- indra/llcommon/llmainthreadtask.h | 2 +- indra/llcommon/llstring.h | 118 +++++++++++++++--------------- 4 files changed, 63 insertions(+), 63 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/is_approx_equal_fraction.h b/indra/llcommon/is_approx_equal_fraction.h index 4a9b2e2725..e86d58b70f 100644 --- a/indra/llcommon/is_approx_equal_fraction.h +++ b/indra/llcommon/is_approx_equal_fraction.h @@ -45,7 +45,7 @@ template inline BOOL is_approx_equal_fraction_impl(FTYPE x, FTYPE y, U32 frac_bits) { - BOOL ret = TRUE; + BOOL ret = true; FTYPE diff = (FTYPE) fabs(x - y); S32 diffInt = (S32) diff; @@ -58,7 +58,7 @@ inline BOOL is_approx_equal_fraction_impl(FTYPE x, FTYPE y, U32 frac_bits) // based on the number of bits used for packing decimal portion. if (diffInt != 0 || diffFracTolerance > 1) { - ret = FALSE; + ret = false; } return ret; diff --git a/indra/llcommon/llcallbacklist.cpp b/indra/llcommon/llcallbacklist.cpp index 4ccf08cbbb..3b63d8f95a 100644 --- a/indra/llcommon/llcallbacklist.cpp +++ b/indra/llcommon/llcallbacklist.cpp @@ -194,7 +194,7 @@ private: BOOL tick() { mCallable(); - return TRUE; + return true; } nullary_func_t mCallable; diff --git a/indra/llcommon/llmainthreadtask.h b/indra/llcommon/llmainthreadtask.h index d509b687c0..878f57cab6 100644 --- a/indra/llcommon/llmainthreadtask.h +++ b/indra/llcommon/llmainthreadtask.h @@ -85,7 +85,7 @@ private: // obtained by get_future() mTask(); // tell LLEventTimer we're done (one shot) - return TRUE; + return true; } // Given arbitrary CALLABLE, which might be a lambda, how are we // supposed to obtain its signature for std::packaged_task? It seems diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h index 66ee42af2a..3620a5b211 100644 --- a/indra/llcommon/llstring.h +++ b/indra/llcommon/llstring.h @@ -314,7 +314,7 @@ public: static void toLower(string_type& string); // True if this is the head of s. - static BOOL isHead( const string_type& string, const T* s ); + static bool isHead( const string_type& string, const T* s ); /** * @brief Returns true if string starts with substr @@ -356,7 +356,7 @@ public: static void replaceChar( string_type& string, T target, T replacement ); static void replaceString( string_type& string, string_type target, string_type replacement ); - static BOOL containsNonprintable(const string_type& string); + static bool containsNonprintable(const string_type& string); static void stripNonprintable(string_type& string); /** @@ -382,15 +382,15 @@ public: static void _makeASCII(string_type& string); // Conversion to other data types - static BOOL convertToBOOL(const string_type& string, BOOL& value); - static BOOL convertToU8(const string_type& string, U8& value); - static BOOL convertToS8(const string_type& string, S8& value); - static BOOL convertToS16(const string_type& string, S16& value); - static BOOL convertToU16(const string_type& string, U16& value); - static BOOL convertToU32(const string_type& string, U32& value); - static BOOL convertToS32(const string_type& string, S32& value); - static BOOL convertToF32(const string_type& string, F32& value); - static BOOL convertToF64(const string_type& string, F64& value); + static bool convertToBOOL(const string_type& string, BOOL& value); + static bool convertToU8(const string_type& string, U8& value); + static bool convertToS8(const string_type& string, S8& value); + static bool convertToS16(const string_type& string, S16& value); + static bool convertToU16(const string_type& string, U16& value); + static bool convertToU32(const string_type& string, U32& value); + static bool convertToS32(const string_type& string, S32& value); + static bool convertToF32(const string_type& string, F32& value); + static bool convertToF64(const string_type& string, F64& value); ///////////////////////////////////////////////////////////////////////////////////////// // Utility functions for working with char*'s and strings @@ -415,7 +415,7 @@ public: static S32 compareDictInsensitive(const string_type& a, const string_type& b); // Puts compareDict() in a form appropriate for LL container classes to use for sorting. - static BOOL precedesDict( const string_type& a, const string_type& b ); + static bool precedesDict( const string_type& a, const string_type& b ); // A replacement for strncpy. // If the dst buffer is dst_size bytes long or more, ensures that dst is null terminated and holds @@ -1362,7 +1362,7 @@ S32 LLStringUtilBase::compareDictInsensitive(const string_type& astr, const s // Puts compareDict() in a form appropriate for LL container classes to use for sorting. // static template -BOOL LLStringUtilBase::precedesDict( const string_type& a, const string_type& b ) +bool LLStringUtilBase::precedesDict( const string_type& a, const string_type& b ) { if( a.size() && b.size() ) { @@ -1595,10 +1595,10 @@ void LLStringUtilBase::replaceTabsWithSpaces( string_type& str, size_type spa //static template -BOOL LLStringUtilBase::containsNonprintable(const string_type& string) +bool LLStringUtilBase::containsNonprintable(const string_type& string) { const char MIN = 32; - BOOL rv = false; + bool rv = false; for (size_type i = 0; i < string.size(); i++) { if(string[i] < MIN) @@ -1732,12 +1732,12 @@ void LLStringUtilBase::copyInto(string_type& dst, const string_type& src, siz // True if this is the head of s. //static template -BOOL LLStringUtilBase::isHead( const string_type& string, const T* s ) -{ +bool LLStringUtilBase::isHead( const string_type& string, const T* s ) +{ if( string.empty() ) { // Early exit - return FALSE; + return false; } else { @@ -1804,11 +1804,11 @@ auto LLStringUtilBase::getenv(const std::string& key, const string_type& dflt } template -BOOL LLStringUtilBase::convertToBOOL(const string_type& string, BOOL& value) +bool LLStringUtilBase::convertToBOOL(const string_type& string, BOOL& value) { if( string.empty() ) { - return FALSE; + return false; } string_type temp( string ); @@ -1821,8 +1821,8 @@ BOOL LLStringUtilBase::convertToBOOL(const string_type& string, BOOL& value) (temp == "true") || (temp == "True") ) { - value = TRUE; - return TRUE; + value = true; + return true; } else if( @@ -1833,71 +1833,71 @@ BOOL LLStringUtilBase::convertToBOOL(const string_type& string, BOOL& value) (temp == "false") || (temp == "False") ) { - value = FALSE; - return TRUE; + value = false; + return true; } - return FALSE; + return false; } template -BOOL LLStringUtilBase::convertToU8(const string_type& string, U8& value) +bool LLStringUtilBase::convertToU8(const string_type& string, U8& value) { S32 value32 = 0; - BOOL success = convertToS32(string, value32); + bool success = convertToS32(string, value32); if( success && (U8_MIN <= value32) && (value32 <= U8_MAX) ) { value = (U8) value32; - return TRUE; + return true; } - return FALSE; + return false; } template -BOOL LLStringUtilBase::convertToS8(const string_type& string, S8& value) +bool LLStringUtilBase::convertToS8(const string_type& string, S8& value) { S32 value32 = 0; - BOOL success = convertToS32(string, value32); + bool success = convertToS32(string, value32); if( success && (S8_MIN <= value32) && (value32 <= S8_MAX) ) { value = (S8) value32; - return TRUE; + return true; } - return FALSE; + return false; } template -BOOL LLStringUtilBase::convertToS16(const string_type& string, S16& value) +bool LLStringUtilBase::convertToS16(const string_type& string, S16& value) { S32 value32 = 0; - BOOL success = convertToS32(string, value32); + bool success = convertToS32(string, value32); if( success && (S16_MIN <= value32) && (value32 <= S16_MAX) ) { value = (S16) value32; - return TRUE; + return true; } - return FALSE; + return false; } template -BOOL LLStringUtilBase::convertToU16(const string_type& string, U16& value) +bool LLStringUtilBase::convertToU16(const string_type& string, U16& value) { S32 value32 = 0; - BOOL success = convertToS32(string, value32); + bool success = convertToS32(string, value32); if( success && (U16_MIN <= value32) && (value32 <= U16_MAX) ) { value = (U16) value32; - return TRUE; + return true; } - return FALSE; + return false; } template -BOOL LLStringUtilBase::convertToU32(const string_type& string, U32& value) +bool LLStringUtilBase::convertToU32(const string_type& string, U32& value) { if( string.empty() ) { - return FALSE; + return false; } string_type temp( string ); @@ -1907,17 +1907,17 @@ BOOL LLStringUtilBase::convertToU32(const string_type& string, U32& value) if(i_stream >> v) { value = v; - return TRUE; + return true; } - return FALSE; + return false; } template -BOOL LLStringUtilBase::convertToS32(const string_type& string, S32& value) +bool LLStringUtilBase::convertToS32(const string_type& string, S32& value) { if( string.empty() ) { - return FALSE; + return false; } string_type temp( string ); @@ -1930,34 +1930,34 @@ BOOL LLStringUtilBase::convertToS32(const string_type& string, S32& value) //if((LONG_MAX == v) || (LONG_MIN == v)) //{ // // Underflow or overflow - // return FALSE; + // return false; //} value = v; - return TRUE; + return true; } - return FALSE; + return false; } template -BOOL LLStringUtilBase::convertToF32(const string_type& string, F32& value) +bool LLStringUtilBase::convertToF32(const string_type& string, F32& value) { F64 value64 = 0.0; - BOOL success = convertToF64(string, value64); + bool success = convertToF64(string, value64); if( success && (-F32_MAX <= value64) && (value64 <= F32_MAX) ) { value = (F32) value64; - return TRUE; + return true; } - return FALSE; + return false; } template -BOOL LLStringUtilBase::convertToF64(const string_type& string, F64& value) +bool LLStringUtilBase::convertToF64(const string_type& string, F64& value) { if( string.empty() ) { - return FALSE; + return false; } string_type temp( string ); @@ -1970,13 +1970,13 @@ BOOL LLStringUtilBase::convertToF64(const string_type& string, F64& value) //if( ((-HUGE_VAL == v) || (HUGE_VAL == v))) ) //{ // // Underflow or overflow - // return FALSE; + // return false; //} value = v; - return TRUE; + return true; } - return FALSE; + return false; } template -- cgit v1.2.3 From 4419bb870986c6900fc096338622d27b999cd771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20N=C3=A6sbye=20Christensen?= Date: Sun, 11 Feb 2024 01:23:28 +0100 Subject: more misc: BOOL (int) to real bool --- indra/llcommon/is_approx_equal_fraction.h | 8 ++++---- indra/llcommon/llcallbacklist.cpp | 4 ++-- indra/llcommon/lleventtimer.h | 4 ++-- indra/llcommon/lllivefile.cpp | 6 +++--- indra/llcommon/llmainthreadtask.h | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/is_approx_equal_fraction.h b/indra/llcommon/is_approx_equal_fraction.h index e86d58b70f..732d168986 100644 --- a/indra/llcommon/is_approx_equal_fraction.h +++ b/indra/llcommon/is_approx_equal_fraction.h @@ -43,9 +43,9 @@ * signatures. */ template -inline BOOL is_approx_equal_fraction_impl(FTYPE x, FTYPE y, U32 frac_bits) +inline bool is_approx_equal_fraction_impl(FTYPE x, FTYPE y, U32 frac_bits) { - BOOL ret = true; + bool ret = true; FTYPE diff = (FTYPE) fabs(x - y); S32 diffInt = (S32) diff; @@ -65,13 +65,13 @@ inline BOOL is_approx_equal_fraction_impl(FTYPE x, FTYPE y, U32 frac_bits) } /// F32 flavor -inline BOOL is_approx_equal_fraction(F32 x, F32 y, U32 frac_bits) +inline bool is_approx_equal_fraction(F32 x, F32 y, U32 frac_bits) { return is_approx_equal_fraction_impl(x, y, frac_bits); } /// F64 flavor -inline BOOL is_approx_equal_fraction(F64 x, F64 y, U32 frac_bits) +inline bool is_approx_equal_fraction(F64 x, F64 y, U32 frac_bits) { return is_approx_equal_fraction_impl(x, y, frac_bits); } diff --git a/indra/llcommon/llcallbacklist.cpp b/indra/llcommon/llcallbacklist.cpp index 3b63d8f95a..a2800d42ce 100644 --- a/indra/llcommon/llcallbacklist.cpp +++ b/indra/llcommon/llcallbacklist.cpp @@ -191,7 +191,7 @@ public: } private: - BOOL tick() + bool tick() { mCallable(); return true; @@ -215,7 +215,7 @@ public: { } private: - BOOL tick() + bool tick() { return mCallable(); } diff --git a/indra/llcommon/lleventtimer.h b/indra/llcommon/lleventtimer.h index dbbfe0c6e6..9bd34915a5 100644 --- a/indra/llcommon/lleventtimer.h +++ b/indra/llcommon/lleventtimer.h @@ -43,7 +43,7 @@ public: //function to be called at the supplied frequency // Normally return FALSE; TRUE will delete the timer after the function returns. - virtual BOOL tick() = 0; + virtual bool tick() = 0; static void updateClass(); @@ -86,7 +86,7 @@ public: mOnce(once), mCallable(callable) {} - BOOL tick() override + bool tick() override { mCallable(); // true tells updateClass() to delete this instance diff --git a/indra/llcommon/lllivefile.cpp b/indra/llcommon/lllivefile.cpp index ea485c2d86..852ddb45e9 100644 --- a/indra/llcommon/lllivefile.cpp +++ b/indra/llcommon/lllivefile.cpp @@ -170,10 +170,10 @@ namespace : LLEventTimer(refresh), mLiveFile(f) { } - BOOL tick() - { + bool tick() + { mLiveFile.checkAndReload(); - return FALSE; + return false; } private: diff --git a/indra/llcommon/llmainthreadtask.h b/indra/llcommon/llmainthreadtask.h index 878f57cab6..5fae0212c4 100644 --- a/indra/llcommon/llmainthreadtask.h +++ b/indra/llcommon/llmainthreadtask.h @@ -79,7 +79,7 @@ private: LLEventTimer(0), mTask(std::forward(callable)) {} - BOOL tick() override + bool tick() override { // run the task on the main thread, will populate the future // obtained by get_future() -- cgit v1.2.3 From 9480a98cffaafa5826b8daad20020cf399bbbefc Mon Sep 17 00:00:00 2001 From: Ansariel Date: Fri, 16 Feb 2024 00:07:58 +0100 Subject: Replace most of BOOL with bool in llmath --- indra/llcommon/llstring.cpp | 4 ++-- indra/llcommon/llstring.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index f6629803ee..4358e80125 100644 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -308,10 +308,10 @@ S32 wstring_utf16_length(const LLWString &wstr, const S32 woffset, const S32 wle // Given a wstring and an offset in it, returns the length as wstring (i.e., // number of llwchars) of the longest substring that starts at the offset // and whose equivalent utf-16 string does not exceeds the given utf16_length. -S32 wstring_wstring_length_from_utf16_length(const LLWString & wstr, const S32 woffset, const S32 utf16_length, BOOL *unaligned) +S32 wstring_wstring_length_from_utf16_length(const LLWString & wstr, const S32 woffset, const S32 utf16_length, bool *unaligned) { const auto end = wstr.length(); - BOOL u = FALSE; + bool u = FALSE; S32 n = woffset + utf16_length; S32 i = woffset; while (i < end) diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h index 3620a5b211..47dbf967cf 100644 --- a/indra/llcommon/llstring.h +++ b/indra/llcommon/llstring.h @@ -687,7 +687,7 @@ LL_COMMON_API S32 utf16str_wstring_length(const llutf16string &utf16str, S32 len LL_COMMON_API S32 wstring_utf16_length(const LLWString & wstr, S32 woffset, S32 wlen); // Length in wstring (i.e., llwchar count) of a part of a wstring specified by utf16 length (i.e., utf16 units.) -LL_COMMON_API S32 wstring_wstring_length_from_utf16_length(const LLWString & wstr, S32 woffset, S32 utf16_length, BOOL *unaligned = NULL); +LL_COMMON_API S32 wstring_wstring_length_from_utf16_length(const LLWString & wstr, S32 woffset, S32 utf16_length, bool *unaligned = nullptr); /** * @brief Properly truncate a utf8 string to a maximum byte count. -- cgit v1.2.3 From 07f54e72766d903292fec985e7c5eb46a6a325ca Mon Sep 17 00:00:00 2001 From: Ansariel Date: Fri, 16 Feb 2024 00:12:57 +0100 Subject: Replaced one overlooked FALSE --- indra/llcommon/llstring.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index 4358e80125..ef77b0b1c8 100644 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -311,7 +311,7 @@ S32 wstring_utf16_length(const LLWString &wstr, const S32 woffset, const S32 wle S32 wstring_wstring_length_from_utf16_length(const LLWString & wstr, const S32 woffset, const S32 utf16_length, bool *unaligned) { const auto end = wstr.length(); - bool u = FALSE; + bool u{ false }; S32 n = woffset + utf16_length; S32 i = woffset; while (i < end) -- cgit v1.2.3 From d0e82ca55670645eacc61fca39bf8667c0840de9 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 16 Feb 2024 00:02:04 +0200 Subject: jira-archive-internal#67837 Windows' bulk export of snapshots and textures SL-17661 Viewer was silently failing to 'save selection as' --- indra/llcommon/threadpool.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/llcommon') diff --git a/indra/llcommon/threadpool.cpp b/indra/llcommon/threadpool.cpp index 3a9a5a2062..e22013312d 100644 --- a/indra/llcommon/threadpool.cpp +++ b/indra/llcommon/threadpool.cpp @@ -99,6 +99,10 @@ void LL::ThreadPoolBase::start() LL::ThreadPoolBase::~ThreadPoolBase() { close(); + if (!LLEventPumps::wasDeleted()) + { + LLEventPumps::instance().obtain("LLApp").stopListening(mName); + } } void LL::ThreadPoolBase::close() -- cgit v1.2.3 From 9e854b697a06abed2a0917fb6120445f176764f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20N=C3=A6sbye=20Christensen?= Date: Fri, 16 Feb 2024 19:29:51 +0100 Subject: misc: BOOL to bool --- indra/llcommon/llstring.cpp | 2 +- indra/llcommon/llstring.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index ef77b0b1c8..6e6797312b 100644 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -1359,7 +1359,7 @@ S32 LLStringUtil::format(std::string& s, const format_map_t& substitutions) if (iter != substitutions.end()) { S32 secFromEpoch = 0; - BOOL r = LLStringUtil::convertToS32(iter->second, secFromEpoch); + bool r = LLStringUtil::convertToS32(iter->second, secFromEpoch); if (r) { found_replacement = formatDatetime(replacement, tokens[0], param, secFromEpoch); diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h index 47dbf967cf..f2741a0e1f 100644 --- a/indra/llcommon/llstring.h +++ b/indra/llcommon/llstring.h @@ -382,7 +382,7 @@ public: static void _makeASCII(string_type& string); // Conversion to other data types - static bool convertToBOOL(const string_type& string, BOOL& value); + static bool convertToBOOL(const string_type& string, bool& value); static bool convertToU8(const string_type& string, U8& value); static bool convertToS8(const string_type& string, S8& value); static bool convertToS16(const string_type& string, S16& value); @@ -1804,7 +1804,7 @@ auto LLStringUtilBase::getenv(const std::string& key, const string_type& dflt } template -bool LLStringUtilBase::convertToBOOL(const string_type& string, BOOL& value) +bool LLStringUtilBase::convertToBOOL(const string_type& string, bool& value) { if( string.empty() ) { -- cgit v1.2.3 From 088f2f4f6545ebc2ee01945938a40ae5c87ad27a Mon Sep 17 00:00:00 2001 From: Ansariel Date: Sat, 17 Feb 2024 00:51:13 +0100 Subject: More BOOL to bool replacements primarily in llappearance and llxml --- indra/llcommon/tests/llstring_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/tests/llstring_test.cpp b/indra/llcommon/tests/llstring_test.cpp index a7aa347222..3e31a5d667 100644 --- a/indra/llcommon/tests/llstring_test.cpp +++ b/indra/llcommon/tests/llstring_test.cpp @@ -231,7 +231,7 @@ namespace tut template<> template<> void string_index_object_t::test<17>() { - BOOL value; + bool value; std::string str_val("1"); ensure("convertToBOOL 1 failed", LLStringUtil::convertToBOOL(str_val, value) && value); str_val = "T"; -- cgit v1.2.3 From 321f283032688f0feddc696654e86f62af07121a Mon Sep 17 00:00:00 2001 From: Ansariel Date: Mon, 19 Feb 2024 15:01:44 +0100 Subject: Replace remaining BOOL with bool llinventory and llmessage --- indra/llcommon/llstringtable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llstringtable.h b/indra/llcommon/llstringtable.h index 0a292c8bac..bbf61bb8ac 100644 --- a/indra/llcommon/llstringtable.h +++ b/indra/llcommon/llstringtable.h @@ -51,7 +51,7 @@ public: ~LLStringTableEntry(); void incCount() { mCount++; } - BOOL decCount() { return --mCount; } + bool decCount() { return --mCount != 0; } char *mString; S32 mCount; -- cgit v1.2.3 From fd7f817171f9842470e83832c67d48065e81ca01 Mon Sep 17 00:00:00 2001 From: Beq Date: Mon, 19 Feb 2024 15:13:25 +0000 Subject: [Linux]gcc is broken for in place template instantiation. --- indra/llcommon/llmutex.h | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llmutex.h b/indra/llcommon/llmutex.h index 077f810d61..cef58c1c9d 100644 --- a/indra/llcommon/llmutex.h +++ b/indra/llcommon/llmutex.h @@ -82,20 +82,14 @@ public: void lockShared(); void lockExclusive(); template void lock(); - template<> void lock() { lockShared(); } - template<> void lock() { lockExclusive(); } bool trylockShared(); bool trylockExclusive(); template bool trylock(); - template<> bool trylock() { return trylockShared(); } - template<> bool trylock() { return trylockExclusive(); } void unlockShared(); void unlockExclusive(); template void unlock(); - template<> void unlock() { unlockShared(); } - template<> void unlock() { unlockExclusive(); } private: std::shared_mutex mSharedMutex; @@ -107,6 +101,42 @@ private: using const_iterator = std::unordered_map::const_iterator; }; +template<> +inline void LLSharedMutex::lock() +{ + lockShared(); +} + +template<> +inline void LLSharedMutex::lock() +{ + lockExclusive(); +} + +template<> +inline bool LLSharedMutex::trylock() +{ + return trylockShared(); +} + +template<> +inline bool LLSharedMutex::trylock() +{ + return trylockExclusive(); +} + +template<> +inline void LLSharedMutex::unlock() +{ + unlockShared(); +} + +template<> +inline void LLSharedMutex::unlock() +{ + unlockExclusive(); +} + // Actually a condition/mutex pair (since each condition needs to be associated with a mutex). class LL_COMMON_API LLCondition : public LLMutex { -- cgit v1.2.3 From 8312a4e5470066d0219ef6e9ec9fc8d90e9e595a Mon Sep 17 00:00:00 2001 From: Ansariel Date: Mon, 19 Feb 2024 18:56:51 +0100 Subject: Include missing llmutex.h in CMake file --- indra/llcommon/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llcommon') diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 5f4ed2fffa..80bc95ffba 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -194,6 +194,7 @@ set(llcommon_HEADER_FILES llmetrics.h llmetricperformancetester.h llmortician.h + llmutex.h llnametable.h llpointer.h llprofiler.h -- cgit v1.2.3 From b2c271367296744fbbe2262e55d0ea4f8f5ccdc9 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Tue, 20 Feb 2024 00:50:39 +0100 Subject: Convert BOOL to bool in llrender --- indra/llcommon/llmutex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llmutex.h b/indra/llcommon/llmutex.h index cef58c1c9d..2b2435da4d 100644 --- a/indra/llcommon/llmutex.h +++ b/indra/llcommon/llmutex.h @@ -64,7 +64,7 @@ protected: mutable LLThread::id_t mLockingThread; #if MUTEX_DEBUG - std::unordered_map mIsLocked; + std::unordered_map mIsLocked; #endif }; -- cgit v1.2.3 From 3ffe63b8a4e8a3ceda3f6d204e4b5bb0c80d0870 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 21 Feb 2024 16:49:48 +0100 Subject: Convert remaining BOOLs in llxml and introduce std::string_view --- indra/llcommon/llstring.cpp | 14 +++++++------- indra/llcommon/llstring.h | 15 ++++++++------- 2 files changed, 15 insertions(+), 14 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index 6e6797312b..bdd4c2c4bb 100644 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -765,7 +765,7 @@ std::wstring windows_message(DWORD error) return out.str(); } -boost::optional llstring_getoptenv(const std::string& key) +std::optional llstring_getoptenv(const std::string& key) { auto wkey = ll_convert_string_to_wide(key); // Take a wild guess as to how big the buffer should be. @@ -783,8 +783,8 @@ boost::optional llstring_getoptenv(const std::string& key) // did that (ultimately) succeed? if (n) { - // great, return populated boost::optional - return boost::optional(&buffer[0]); + // great, return populated std::optional + return std::make_optional(&buffer[0]); } // not successful @@ -795,7 +795,7 @@ boost::optional llstring_getoptenv(const std::string& key) LL_WARNS() << "GetEnvironmentVariableW('" << key << "') failed: " << windows_message(last_error) << LL_ENDL; } - // return empty boost::optional + // return empty std::optional return {}; } @@ -806,12 +806,12 @@ boost::optional llstring_getoptenv(const std::string& key) auto found = getenv(key.c_str()); if (found) { - // return populated boost::optional - return boost::optional(found); + // return populated std::optional + return std::make_optional(found); } else { - // return empty boost::optional + // return empty std::optional return {}; } } diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h index f2741a0e1f..6893b8ebff 100644 --- a/indra/llcommon/llstring.h +++ b/indra/llcommon/llstring.h @@ -28,8 +28,9 @@ #define LL_LLSTRING_H #include -#include +#include #include +#include #include #include // std::wcslen() //#include @@ -345,7 +346,7 @@ public: * (key is always UTF-8) * detect absence by (! return value) */ - static boost::optional getoptenv(const std::string& key); + static std::optional getoptenv(const std::string& key); static void addCRLF(string_type& string); static void removeCRLF(string_type& string); @@ -819,11 +820,11 @@ STRING windows_message() { return windows_message(GetLastError()); } //@} -LL_COMMON_API boost::optional llstring_getoptenv(const std::string& key); +LL_COMMON_API std::optional llstring_getoptenv(const std::string& key); #else // ! LL_WINDOWS -LL_COMMON_API boost::optional llstring_getoptenv(const std::string& key); +LL_COMMON_API std::optional llstring_getoptenv(const std::string& key); #endif // ! LL_WINDOWS @@ -1773,17 +1774,17 @@ bool LLStringUtilBase::endsWith( // static template -auto LLStringUtilBase::getoptenv(const std::string& key) -> boost::optional +auto LLStringUtilBase::getoptenv(const std::string& key) -> std::optional { auto found(llstring_getoptenv(key)); if (found) { - // return populated boost::optional + // return populated std::optional return { ll_convert(*found) }; } else { - // empty boost::optional + // empty std::optional return {}; } } -- cgit v1.2.3 From 855eea7ddf9e1de9226036ca94ccb03ac0e311b9 Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Wed, 21 Feb 2024 19:19:57 +0200 Subject: viewer#851 Xcode buildfix --- indra/llcommon/llstring.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index bdd4c2c4bb..48551ab375 100644 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -801,7 +801,7 @@ std::optional llstring_getoptenv(const std::string& key) #else // ! LL_WINDOWS -boost::optional llstring_getoptenv(const std::string& key) +std::optional llstring_getoptenv(const std::string& key) { auto found = getenv(key.c_str()); if (found) -- cgit v1.2.3 From 60d3dd98a44230c21803c1606552ee098ed9fa7c Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 21 Feb 2024 21:05:14 +0100 Subject: Convert remaining BOOL to bool --- indra/llcommon/tests/llstring_test.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/tests/llstring_test.cpp b/indra/llcommon/tests/llstring_test.cpp index 3e31a5d667..1e4bc1c910 100644 --- a/indra/llcommon/tests/llstring_test.cpp +++ b/indra/llcommon/tests/llstring_test.cpp @@ -80,12 +80,12 @@ namespace tut void string_index_object_t::test<3>() { std::string str("Len=5"); - ensure("isValidIndex failed", LLStringUtil::isValidIndex(str, 0) == TRUE && - LLStringUtil::isValidIndex(str, 5) == TRUE && - LLStringUtil::isValidIndex(str, 6) == FALSE); + ensure("isValidIndex failed", LLStringUtil::isValidIndex(str, 0) == true && + LLStringUtil::isValidIndex(str, 5) == true && + LLStringUtil::isValidIndex(str, 6) == false); std::string str1; - ensure("isValidIndex failed fo rempty string", LLStringUtil::isValidIndex(str1, 0) == FALSE); + ensure("isValidIndex failed fo rempty string", LLStringUtil::isValidIndex(str1, 0) == false); } template<> template<> @@ -153,10 +153,10 @@ namespace tut void string_index_object_t::test<10>() { std::string str_val("Second"); - ensure("1. isHead failed", LLStringUtil::isHead(str_val, "SecondLife Source") == TRUE); - ensure("2. isHead failed", LLStringUtil::isHead(str_val, " SecondLife Source") == FALSE); + ensure("1. isHead failed", LLStringUtil::isHead(str_val, "SecondLife Source") == true); + ensure("2. isHead failed", LLStringUtil::isHead(str_val, " SecondLife Source") == false); std::string str_val2(""); - ensure("3. isHead failed", LLStringUtil::isHead(str_val2, "") == FALSE); + ensure("3. isHead failed", LLStringUtil::isHead(str_val2, "") == false); } template<> template<> @@ -206,10 +206,10 @@ namespace tut void string_index_object_t::test<15>() { std::string str_val("Hello.\n\r\t"); - ensure("containsNonprintable failed", LLStringUtil::containsNonprintable(str_val) == TRUE); + ensure("containsNonprintable failed", LLStringUtil::containsNonprintable(str_val) == true); str_val = "ABC "; - ensure("containsNonprintable failed", LLStringUtil::containsNonprintable(str_val) == FALSE); + ensure("containsNonprintable failed", LLStringUtil::containsNonprintable(str_val) == false); } template<> template<> @@ -457,17 +457,17 @@ namespace tut std::string lhs_str("PROgraM12files"); std::string rhs_str("PROgram12Files"); ensure("compareDict 1 failed", LLStringUtil::compareDict(lhs_str, rhs_str) < 0); - ensure("precedesDict 1 failed", LLStringUtil::precedesDict(lhs_str, rhs_str) == TRUE); + ensure("precedesDict 1 failed", LLStringUtil::precedesDict(lhs_str, rhs_str) == true); lhs_str = "PROgram12Files"; rhs_str = "PROgram12Files"; ensure("compareDict 2 failed", LLStringUtil::compareDict(lhs_str, rhs_str) == 0); - ensure("precedesDict 2 failed", LLStringUtil::precedesDict(lhs_str, rhs_str) == FALSE); + ensure("precedesDict 2 failed", LLStringUtil::precedesDict(lhs_str, rhs_str) == false); lhs_str = "PROgram12Files"; rhs_str = "PROgRAM12FILES"; ensure("compareDict 3 failed", LLStringUtil::compareDict(lhs_str, rhs_str) > 0); - ensure("precedesDict 3 failed", LLStringUtil::precedesDict(lhs_str, rhs_str) == FALSE); + ensure("precedesDict 3 failed", LLStringUtil::precedesDict(lhs_str, rhs_str) == false); } template<> template<> -- cgit v1.2.3 From 0cc3a4bf680da63f48a1fcaf1c4b94ce4d8dffb7 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 13 Mar 2024 09:40:20 +0100 Subject: Remove obsolete LLSINGLETON_C11 and LLSINGLETON_EMPTY_CTOR_C11 macros --- indra/llcommon/llsingleton.h | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h index cbe5ab6406..5ca6b65259 100644 --- a/indra/llcommon/llsingleton.h +++ b/indra/llcommon/llsingleton.h @@ -806,17 +806,6 @@ private: \ friend class LLSingleton; \ DERIVED_CLASS(__VA_ARGS__) -/** - * A slight variance from the above, but includes the "override" keyword - */ -#define LLSINGLETON_C11(DERIVED_CLASS) \ -private: \ - /* implement LLSingleton pure virtual method whose sole purpose */ \ - /* is to remind people to use this macro */ \ - virtual void you_must_use_LLSINGLETON_macro() override {} \ - friend class LLSingleton; \ - DERIVED_CLASS() - /** * Use LLSINGLETON_EMPTY_CTOR(Foo); at the start of an LLSingleton * subclass body when the constructor is trivial: @@ -835,10 +824,6 @@ private: \ /* LLSINGLETON() is carefully implemented to permit exactly this */ \ LLSINGLETON(DERIVED_CLASS) {} -#define LLSINGLETON_EMPTY_CTOR_C11(DERIVED_CLASS) \ - /* LLSINGLETON() is carefully implemented to permit exactly this */ \ - LLSINGLETON_C11(DERIVED_CLASS) {} - // Relatively unsafe singleton implementation that is much faster // and simpler than LLSingleton, but has no dependency tracking // or inherent thread safety and requires manual invocation of -- cgit v1.2.3 From 17e1f3692c5c1e9cbc6ba6895b312a8baae9aec2 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Fri, 5 Apr 2024 19:03:58 -0400 Subject: Port from JsonCPP to Boost.Json for json parsing and serializing (#1054) --- indra/llcommon/CMakeLists.txt | 2 -- indra/llcommon/llsdjson.cpp | 80 +++++++++++++++++++++++++------------------ indra/llcommon/llsdjson.h | 6 ++-- 3 files changed, 50 insertions(+), 38 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 26955cfc08..50079abb96 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -9,7 +9,6 @@ include(bugsplat) include(Linking) include(Boost) include(LLSharedLibs) -include(JsonCpp) include(Copy3rdPartyLibs) include(ZLIBNG) include(URIPARSER) @@ -278,7 +277,6 @@ target_link_libraries( llcommon ll::apr ll::expat - ll::jsoncpp ll::zlib-ng ll::boost ll::uriparser diff --git a/indra/llcommon/llsdjson.cpp b/indra/llcommon/llsdjson.cpp index 8caaaee534..2fe24693dd 100644 --- a/indra/llcommon/llsdjson.cpp +++ b/indra/llcommon/llsdjson.cpp @@ -31,46 +31,56 @@ #include "llsdjson.h" +#include "llsdutil.h" #include "llerror.h" #include "../llmath/llmath.h" +#if LL_WINDOWS +#pragma warning (push) +#pragma warning (disable : 4702) // compiler thinks unreachable code +#endif +#include +#if LL_WINDOWS +#pragma warning (pop) +#endif + + + //========================================================================= -LLSD LlsdFromJson(const Json::Value &val) +LLSD LlsdFromJson(const boost::json::value& val) { LLSD result; - switch (val.type()) + switch (val.kind()) { default: - case Json::nullValue: - break; - case Json::intValue: - result = LLSD(static_cast(val.asInt())); + case boost::json::kind::null: break; - case Json::uintValue: - result = LLSD(static_cast(val.asUInt())); + case boost::json::kind::int64: + case boost::json::kind::uint64: + result = LLSD(val.to_number()); break; - case Json::realValue: - result = LLSD(static_cast(val.asDouble())); + case boost::json::kind::double_: + result = LLSD(val.to_number()); break; - case Json::stringValue: - result = LLSD(static_cast(val.asString())); + case boost::json::kind::string: + result = LLSD(boost::json::value_to(val)); break; - case Json::booleanValue: - result = LLSD(static_cast(val.asBool())); + case boost::json::kind::bool_: + result = LLSD(val.as_bool()); break; - case Json::arrayValue: + case boost::json::kind::array: result = LLSD::emptyArray(); - for (Json::ValueConstIterator it = val.begin(); it != val.end(); ++it) + for (const auto &element : val.as_array()) { - result.append(LlsdFromJson((*it))); + result.append(LlsdFromJson(element)); } break; - case Json::objectValue: + case boost::json::kind::object: result = LLSD::emptyMap(); - for (Json::ValueConstIterator it = val.begin(); it != val.end(); ++it) + for (const auto& element : val.as_object()) { - result[it.memberName()] = LlsdFromJson((*it)); + result[element.key()] = LlsdFromJson(element.value()); } break; } @@ -78,44 +88,48 @@ LLSD LlsdFromJson(const Json::Value &val) } //========================================================================= -Json::Value LlsdToJson(const LLSD &val) +boost::json::value LlsdToJson(const LLSD &val) { - Json::Value result; + boost::json::value result; switch (val.type()) { case LLSD::TypeUndefined: - result = Json::Value::null; + result = nullptr; break; case LLSD::TypeBoolean: - result = Json::Value(static_cast(val.asBoolean())); + result = val.asBoolean(); break; case LLSD::TypeInteger: - result = Json::Value(static_cast(val.asInteger())); + result = val.asInteger(); break; case LLSD::TypeReal: - result = Json::Value(static_cast(val.asReal())); + result = val.asReal(); break; case LLSD::TypeURI: case LLSD::TypeDate: case LLSD::TypeUUID: case LLSD::TypeString: - result = Json::Value(val.asString()); + result = val.asString(); break; case LLSD::TypeMap: - result = Json::Value(Json::objectValue); - for (LLSD::map_const_iterator it = val.beginMap(); it != val.endMap(); ++it) + { + boost::json::object& obj = result.emplace_object(); + for (const auto& llsd_dat : llsd::inMap(val)) { - result[it->first] = LlsdToJson(it->second); + obj[llsd_dat.first] = LlsdToJson(llsd_dat.second); } break; + } case LLSD::TypeArray: - result = Json::Value(Json::arrayValue); - for (LLSD::array_const_iterator it = val.beginArray(); it != val.endArray(); ++it) + { + boost::json::array& json_array = result.emplace_array(); + for (const auto& llsd_dat : llsd::inArray(val)) { - result.append(LlsdToJson(*it)); + json_array.push_back(LlsdToJson(llsd_dat)); } break; + } case LLSD::TypeBinary: default: LL_ERRS("LlsdToJson") << "Unsupported conversion to JSON from LLSD type (" << val.type() << ")." << LL_ENDL; diff --git a/indra/llcommon/llsdjson.h b/indra/llcommon/llsdjson.h index e56cf03b45..7173e26046 100644 --- a/indra/llcommon/llsdjson.h +++ b/indra/llcommon/llsdjson.h @@ -34,7 +34,7 @@ #include "stdtypes.h" #include "llsd.h" -#include "json/value.h" +#include /// Convert a parsed JSON structure into LLSD maintaining member names and /// array indexes. @@ -53,7 +53,7 @@ /// /// For maps and arrays child entries will be converted and added to the structure. /// Order is preserved for an array but not for objects. -LLSD LlsdFromJson(const Json::Value &val); +LLSD LlsdFromJson(const boost::json::value &val); /// Convert an LLSD object into Parsed JSON object maintaining member names and /// array indexs. @@ -72,6 +72,6 @@ LLSD LlsdFromJson(const Json::Value &val); /// TypeMap | object /// TypeArray | array /// TypeBinary | unsupported -Json::Value LlsdToJson(const LLSD &val); +boost::json::value LlsdToJson(const LLSD &val); #endif // LL_LLSDJSON_H -- cgit v1.2.3