From 63f02b0d42175c424d645ff875b9dfe1ab60f4d2 Mon Sep 17 00:00:00 2001
From: Drake Arconis <drake@alchemyviewer.org>
Date: Thu, 28 Jan 2016 11:47:44 -0500
Subject: [PATCH] Make PCH work somewhat

---
 indra/llappearance/llavatarappearance.cpp |  3 +-
 indra/llappearance/llwearable.cpp         |  5 ++--
 indra/llcommon/lldoubledispatch.h         |  8 ++---
 indra/llcommon/llfasttimer.cpp            | 18 +++++-------
 indra/llcommon/llsdparam.cpp              |  6 ++--
 indra/llcommon/llsdserialize.cpp          |  4 +++
 indra/llcommon/llsys.cpp                  |  2 ++
 indra/llcommon/llthread.cpp               | 36 +++++++++++------------
 indra/llmessage/llaescipher.cpp           | 12 ++++----
 indra/llmessage/llblowfishcipher.cpp      |  6 ++--
 10 files changed, 49 insertions(+), 51 deletions(-)

diff --git a/indra/llappearance/llavatarappearance.cpp b/indra/llappearance/llavatarappearance.cpp
index 1ddf94d950..17afe5b503 100755
--- a/indra/llappearance/llavatarappearance.cpp
+++ b/indra/llappearance/llavatarappearance.cpp
@@ -39,7 +39,6 @@
 #include "llwearabledata.h"
 
 using namespace LLAvatarAppearanceDefines;
-using namespace std::placeholders;
 
 //-----------------------------------------------------------------------------
 // Constants
@@ -936,7 +935,7 @@ BOOL LLAvatarAppearance::loadAvatar()
 			addVisualParam( driver_param );
 			driver_param->setParamLocation(isSelf() ? LOC_AV_SELF : LOC_AV_OTHER);
 			LLVisualParam*(LLAvatarAppearance::*avatar_function)(S32)const = &LLAvatarAppearance::getVisualParam; 
-			if( !driver_param->linkDrivenParams(std::bind(avatar_function,(LLAvatarAppearance*)this, _1 ), false))
+			if( !driver_param->linkDrivenParams(std::bind(avatar_function,(LLAvatarAppearance*)this, std::placeholders::_1 ), false))
 			{
 				LL_WARNS() << "could not link driven params for avatar " << getID().asString() << " param id: " << driver_param->getID() << LL_ENDL;
 				continue;
diff --git a/indra/llappearance/llwearable.cpp b/indra/llappearance/llwearable.cpp
index 1a2ca5b852..354cfeb815 100755
--- a/indra/llappearance/llwearable.cpp
+++ b/indra/llappearance/llwearable.cpp
@@ -35,7 +35,6 @@
 #include "llwearable.h"
 
 using namespace LLAvatarAppearanceDefines;
-using namespace std::placeholders;
 
 // static
 S32 LLWearable::sCurrentDefinitionVersion = 1;
@@ -169,9 +168,9 @@ void LLWearable::createVisualParams(LLAvatarAppearance *avatarp)
 		// need this line to disambiguate between versions of LLCharacter::getVisualParam()
 		LLVisualParam*(LLAvatarAppearance::*param_function)(S32)const = &LLAvatarAppearance::getVisualParam; 
 		param->resetDrivenParams();
-		if (!param->linkDrivenParams(std::bind(wearable_function,(LLWearable*)this, _1), false))
+		if (!param->linkDrivenParams(std::bind(wearable_function,(LLWearable*)this, std::placeholders::_1), false))
 		{
-			if (!param->linkDrivenParams(std::bind(param_function,avatarp, _1 ), true))
+			if (!param->linkDrivenParams(std::bind(param_function,avatarp, std::placeholders::_1 ), true))
 			{
 				LL_WARNS() << "could not link driven params for wearable " << getName() << " id: " << param->getID() << LL_ENDL;
 				continue;
diff --git a/indra/llcommon/lldoubledispatch.h b/indra/llcommon/lldoubledispatch.h
index 74326c1e4c..84a3e3613a 100755
--- a/indra/llcommon/lldoubledispatch.h
+++ b/indra/llcommon/lldoubledispatch.h
@@ -150,13 +150,12 @@ public:
     template<typename Type1, typename Type2, class Functor>
     void add(const Type<Type1>& t1, const Type<Type2>& t2, Functor func, bool symmetrical=false)
     {
-		using namespace std::placeholders;
         insert(t1, t2, func);
         if (symmetrical)
         {
             // Use boost::bind() to construct a param-swapping thunk. Don't
             // forget to reverse the parameters too.
-            insert(t2, t1, std::bind(func, _2, _1));
+            insert(t2, t1, std::bind(func, std::placeholders::_2, std::placeholders::_1));
         }
     }
 
@@ -177,7 +176,6 @@ public:
     template <typename Type1, typename Type2, class Functor>
     void add(const Type1& prototype1, const Type2& prototype2, Functor func, bool symmetrical=false)
     {
-		using namespace std::placeholders;
         // Because we expect our caller to pass leaf param types, we can just
         // perform an ordinary search to find the first matching iterator. If
         // we find an existing Entry that matches both params, either the
@@ -192,7 +190,7 @@ public:
         insert(Type<Type1>(), Type<Type2>(), func, insertion);
         if (symmetrical)
         {
-            insert(Type<Type2>(), Type<Type1>(), std::bind(func, _2, _1), insertion);
+            insert(Type<Type2>(), Type<Type1>(), std::bind(func, std::placeholders::_2, std::placeholders::_1), insertion);
         }
     }
 
@@ -270,7 +268,7 @@ private:
     typename DispatchTable::iterator find(const ParamBaseType& param1, const ParamBaseType& param2)
     {
         return std::find_if(mDispatch.begin(), mDispatch.end(),
-                            std::bind(&EntryBase::matches, _1,
+                            std::bind(&EntryBase::matches, std::placeholders::_1,
 									  std::ref(param1), std::ref(param2)));
     }
 
diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp
index 3ac738b3a5..1ff1347cee 100755
--- a/indra/llcommon/llfasttimer.cpp
+++ b/indra/llcommon/llfasttimer.cpp
@@ -53,8 +53,6 @@
 #error "architecture not supported"
 #endif
 
-using namespace std::placeholders;
-
 namespace LLTrace
 {
 
@@ -77,8 +75,8 @@ static std::queue<LLSD> sLogQueue;
 block_timer_tree_df_iterator_t begin_block_timer_tree_df(BlockTimerStatHandle& id) 
 { 
 	return block_timer_tree_df_iterator_t(&id, 
-		std::bind(std::mem_fn(&BlockTimerStatHandle::beginChildren), _1),
-		std::bind(std::mem_fn(&BlockTimerStatHandle::endChildren), _1));
+		std::bind(std::mem_fn(&BlockTimerStatHandle::beginChildren), std::placeholders::_1),
+		std::bind(std::mem_fn(&BlockTimerStatHandle::endChildren), std::placeholders::_1));
 }
 
 block_timer_tree_df_iterator_t end_block_timer_tree_df() 
@@ -89,8 +87,8 @@ block_timer_tree_df_iterator_t end_block_timer_tree_df()
 block_timer_tree_df_post_iterator_t begin_block_timer_tree_df_post(BlockTimerStatHandle& id) 
 { 
 	return block_timer_tree_df_post_iterator_t(&id, 
-							std::bind(std::mem_fn(&BlockTimerStatHandle::beginChildren), _1),
-							std::bind(std::mem_fn(&BlockTimerStatHandle::endChildren), _1));
+							std::bind(std::mem_fn(&BlockTimerStatHandle::beginChildren), std::placeholders::_1),
+							std::bind(std::mem_fn(&BlockTimerStatHandle::endChildren), std::placeholders::_1));
 }
 
 block_timer_tree_df_post_iterator_t end_block_timer_tree_df_post() 
@@ -101,8 +99,8 @@ block_timer_tree_df_post_iterator_t end_block_timer_tree_df_post()
 block_timer_tree_bf_iterator_t begin_block_timer_tree_bf(BlockTimerStatHandle& id)
 { 
 	return block_timer_tree_bf_iterator_t(&id, 
-		std::bind(std::mem_fn(&BlockTimerStatHandle::beginChildren), _1), 
-		std::bind(std::mem_fn(&BlockTimerStatHandle::endChildren), _1));
+		std::bind(std::mem_fn(&BlockTimerStatHandle::beginChildren), std::placeholders::_1),
+		std::bind(std::mem_fn(&BlockTimerStatHandle::endChildren), std::placeholders::_1));
 }
 
 block_timer_tree_bf_iterator_t end_block_timer_tree_bf()
@@ -113,8 +111,8 @@ block_timer_tree_bf_iterator_t end_block_timer_tree_bf()
 block_timer_tree_df_iterator_t begin_timer_tree(BlockTimerStatHandle& id) 
 	{
 	return block_timer_tree_df_iterator_t(&id, 
-		std::bind(std::mem_fn(&BlockTimerStatHandle::beginChildren), _1),
-				  std::bind(std::mem_fn(&BlockTimerStatHandle::endChildren), _1));
+		std::bind(std::mem_fn(&BlockTimerStatHandle::beginChildren), std::placeholders::_1),
+				  std::bind(std::mem_fn(&BlockTimerStatHandle::endChildren), std::placeholders::_1));
 	}
 
 block_timer_tree_df_iterator_t end_timer_tree() 
diff --git a/indra/llcommon/llsdparam.cpp b/indra/llcommon/llsdparam.cpp
index 89c5c5d94b..6d7965a8d4 100755
--- a/indra/llcommon/llsdparam.cpp
+++ b/indra/llcommon/llsdparam.cpp
@@ -93,12 +93,11 @@ void LLParamSDParser::submit(LLInitParam::BaseBlock& block, const LLSD& sd, LLIn
 
 void LLParamSDParser::readSD(const LLSD& sd, LLInitParam::BaseBlock& block, bool silent)
 {
-	using namespace std::placeholders;
 	mCurReadSD = NULL;
 	mNameStack.clear();
 	setParseSilently(silent);
 
-	LLParamSDParserUtilities::readSDValues(std::bind(&LLParamSDParser::submit, this, std::ref(block), _1, _2), sd, mNameStack);
+	LLParamSDParserUtilities::readSDValues(std::bind(&LLParamSDParser::submit, this, std::ref(block), std::placeholders::_1, std::placeholders::_2), sd, mNameStack);
 	//readSDValues(sd, block);
 }
 
@@ -332,12 +331,11 @@ namespace LLInitParam
 
 	bool ParamValue<LLSD, NOT_BLOCK>::serializeBlock(Parser& p, Parser::name_stack_t& name_stack_range, const predicate_rule_t predicate_rule, const BaseBlock* diff_block) const
 	{
-		using namespace std::placeholders;
 		// attempt to write LLSD out directly
 		if (!p.writeValue<LLSD>(mValue, name_stack_range))
 		{
 			// otherwise read from LLSD value and serialize out to parser (which could be LLSD, XUI, etc)
-			LLParamSDParserUtilities::readSDValues(std::bind(&serializeElement, std::ref(p), _1, _2), mValue, name_stack_range);
+			LLParamSDParserUtilities::readSDValues(std::bind(&serializeElement, std::ref(p), std::placeholders::_1, std::placeholders::_2), mValue, name_stack_range);
 		}
 		return true;
 	}
diff --git a/indra/llcommon/llsdserialize.cpp b/indra/llcommon/llsdserialize.cpp
index c9dfb20de6..9bdebaf840 100755
--- a/indra/llcommon/llsdserialize.cpp
+++ b/indra/llcommon/llsdserialize.cpp
@@ -90,6 +90,10 @@ void LLSDSerialize::serialize(const LLSD& sd, std::ostream& str, ELLSD_Serialize
 	}
 }
 
+#if LL_WINDOWS
+#pragma warning(disable :4996)
+#endif
+
 // static
 bool LLSDSerialize::deserialize(LLSD& sd, std::istream& str, S32 max_bytes)
 {
diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp
index 26202322c8..07c1ab8f3d 100755
--- a/indra/llcommon/llsys.cpp
+++ b/indra/llcommon/llsys.cpp
@@ -91,6 +91,8 @@ static const F32 MEM_INFO_WINDOW = 10*60;
 
 #if LL_WINDOWS
 
+#pragma warning(disable : 4996)
+
 #ifndef _WIN32_WINNT_WIN10
 #define _WIN32_WINNT_WIN10 0x0A00
 #endif
diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp
index 3fe16dc7ee..64620906a7 100755
--- a/indra/llcommon/llthread.cpp
+++ b/indra/llcommon/llthread.cpp
@@ -142,16 +142,16 @@ LLThread::LLThread(const std::string& name, apr_pool_t *poolp) :
 {
 	mID = ++sIDIter;
 
-	// Thread creation probably CAN be paranoid about APR being initialized, if necessary
-	if (poolp)
-	{
-		mIsLocalPool = FALSE;
-		mAPRPoolp = poolp;
-	}
-	else
-	{
-		mIsLocalPool = TRUE;
-		apr_pool_create(&mAPRPoolp, NULL); // Create a subpool for this thread
+	// Thread creation probably CAN be paranoid about APR being initialized, if necessary
+	if (poolp)
+	{
+		mIsLocalPool = FALSE;
+		mAPRPoolp = poolp;
+	}
+	else
+	{
+		mIsLocalPool = TRUE;
+		apr_pool_create(&mAPRPoolp, NULL); // Create a subpool for this thread
 	}
 	mRunCondition = new LLCondition();
 	mDataLock = new LLMutex();
@@ -163,10 +163,10 @@ LLThread::~LLThread()
 {
 	shutdown();
 
-	if (mLocalAPRFilePoolp)
-	{
-		delete mLocalAPRFilePoolp;
-		mLocalAPRFilePoolp = NULL;
+	if (mLocalAPRFilePoolp)
+	{
+		delete mLocalAPRFilePoolp;
+		mLocalAPRFilePoolp = NULL;
 	}
 }
 
@@ -213,10 +213,10 @@ void LLThread::shutdown()
 	delete mDataLock;
 	mDataLock = NULL;
 
-	if (mIsLocalPool && mAPRPoolp)
-	{
-		apr_pool_destroy(mAPRPoolp);
-		mAPRPoolp = 0;
+	if (mIsLocalPool && mAPRPoolp)
+	{
+		apr_pool_destroy(mAPRPoolp);
+		mAPRPoolp = 0;
 	}
 
 	if (mRecorder)
diff --git a/indra/llmessage/llaescipher.cpp b/indra/llmessage/llaescipher.cpp
index 641b3b783a..0776290d32 100644
--- a/indra/llmessage/llaescipher.cpp
+++ b/indra/llmessage/llaescipher.cpp
@@ -85,7 +85,7 @@ U32 LLAESCipher::encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len)
 						   src_len))
 	{
 		LL_WARNS("Crypto") << "EVP_EncryptUpdate failure" << LL_ENDL;
-		goto ERROR;
+		goto AES_ERROR;
 	}
 	
 	// There may be some final data left to encrypt if the input is
@@ -93,14 +93,14 @@ U32 LLAESCipher::encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len)
 	if (!EVP_EncryptFinal_ex(&context, (unsigned char*)(dst + output_len), &temp_len))
 	{
 		LL_WARNS("Crypto") << "EVP_EncryptFinal failure" << LL_ENDL;
-		goto ERROR;
+		goto AES_ERROR;
 	}
 	output_len += temp_len;
 	
 	EVP_CIPHER_CTX_cleanup(&context);
 	return output_len;
 	
-ERROR:
+AES_ERROR:
 	EVP_CIPHER_CTX_cleanup(&context);
 	return 0;
 }
@@ -129,12 +129,12 @@ U32 LLAESCipher::decrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len)
 	if (!EVP_DecryptUpdate(&context, dst, &out_len, src, src_len))
 	{
 		LL_WARNS("AES") << "EVP_DecryptUpdate failure" << LL_ENDL;
-		goto ERROR;
+		goto AES_ERROR;
 	}
 	if (!EVP_DecryptFinal_ex(&context, dst + out_len, &tmp_len))
 	{
 		LL_WARNS("AES") << "EVP_DecryptFinal failure" << LL_ENDL;
-		goto ERROR;
+		goto AES_ERROR;
 	}
 	
 	out_len += tmp_len;
@@ -142,7 +142,7 @@ U32 LLAESCipher::decrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len)
 	EVP_CIPHER_CTX_cleanup(&context);
 	return out_len;
 	
-ERROR:
+AES_ERROR:
 	EVP_CIPHER_CTX_cleanup(&context);
 	return 0;
 }
diff --git a/indra/llmessage/llblowfishcipher.cpp b/indra/llmessage/llblowfishcipher.cpp
index 0b5025a422..602f1213fc 100755
--- a/indra/llmessage/llblowfishcipher.cpp
+++ b/indra/llmessage/llblowfishcipher.cpp
@@ -84,7 +84,7 @@ U32 LLBlowfishCipher::encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len)
 			src_len))
 	{
 		LL_WARNS() << "LLBlowfishCipher::encrypt EVP_EncryptUpdate failure" << LL_ENDL;
-		goto ERROR;
+		goto BLOWFISH_ERROR;
 	}
 
 	// There may be some final data left to encrypt if the input is
@@ -92,14 +92,14 @@ U32 LLBlowfishCipher::encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len)
 	if (!EVP_EncryptFinal_ex(&context, (unsigned char*)(dst + output_len), &temp_len))
 	{
 		LL_WARNS() << "LLBlowfishCipher::encrypt EVP_EncryptFinal failure" << LL_ENDL;
-		goto ERROR;
+		goto BLOWFISH_ERROR;
 	}
 	output_len += temp_len;
 
 	EVP_CIPHER_CTX_cleanup(&context);
 	return output_len;
 
-ERROR:
+BLOWFISH_ERROR:
 	EVP_CIPHER_CTX_cleanup(&context);
 	return 0;
 }
-- 
GitLab