From c136b432140f892a56d4996d5ed77e903ff0b32d Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 15 Nov 2012 19:46:09 -0800
Subject: [PATCH] SH-3406 WIP convert fast timers to lltrace system eliminated
 min and max macros from windows.h got rest of viewer to compile against
 llfasttimer changes

---
 indra/cmake/00-Common.cmake             | 1 +
 indra/llcommon/llapr.h                  | 1 +
 indra/llcommon/llfasttimer.cpp          | 5 +++++
 indra/llcommon/llfasttimer.h            | 3 ++-
 indra/llcommon/llthread.h               | 2 ++
 indra/llcommon/lltrace.cpp              | 1 -
 indra/llcommon/llwin32headers.h         | 2 --
 indra/llcommon/llwin32headerslean.h     | 1 -
 indra/llmessage/lliopipe.h              | 1 +
 indra/llmessage/lliosocket.h            | 2 +-
 indra/newview/llappviewer.cpp           | 2 +-
 indra/newview/llfasttimerview.cpp       | 8 ++++----
 indra/newview/llfloatermodelpreview.cpp | 2 --
 indra/newview/llviewerstatsrecorder.h   | 2 +-
 indra/newview/llxmlrpctransaction.cpp   | 2 ++
 indra/test/test.cpp                     | 4 +++-
 16 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake
index 21cb87237dd..180714c9c9c 100644
--- a/indra/cmake/00-Common.cmake
+++ b/indra/cmake/00-Common.cmake
@@ -58,6 +58,7 @@ if (WINDOWS)
 
   add_definitions(
       /DLL_WINDOWS=1
+      /DNOMINMAX
       /DDOM_DYNAMIC
       /DUNICODE
       /D_UNICODE 
diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h
index c77d96c1c9c..d9fe257e865 100644
--- a/indra/llcommon/llapr.h
+++ b/indra/llcommon/llapr.h
@@ -40,6 +40,7 @@
 #include "apr_getopt.h"
 #include "apr_signal.h"
 #include "apr_atomic.h"
+
 #include "llstring.h"
 #include "llinstancetracker.h"
 
diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp
index d007f76e5ff..4ecca12832d 100644
--- a/indra/llcommon/llfasttimer.cpp
+++ b/indra/llcommon/llfasttimer.cpp
@@ -121,6 +121,11 @@ void BlockTimer::pushLog(LLSD log)
 	sLogQueue.push(log);
 }
 
+void BlockTimer::setLogLock(LLMutex* lock)
+{
+	sLogLock = lock;
+}
+
 
 //static
 #if (LL_DARWIN || LL_LINUX || LL_SOLARIS) && !(defined(__i386__) || defined(__amd64__))
diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h
index 69a6773b12f..af9b360e01e 100644
--- a/indra/llcommon/llfasttimer.h
+++ b/indra/llcommon/llfasttimer.h
@@ -98,6 +98,7 @@ class BlockTimer
 
 	static BlockTimer& getRootTimer();
 	static void pushLog(LLSD sd);
+	static void setLogLock(LLMutex* mutex);
 	friend class Time;
 
 
@@ -329,6 +330,6 @@ LL_FORCE_INLINE Time::~Time()
 
 }
 
-typedef LLTrace::Time LLFastTimer;
+typedef LLTrace::Time LLFastTimer; 
 
 #endif // LL_LLFASTTIMER_H
diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h
index 82ab5f47d2d..93c752754db 100644
--- a/indra/llcommon/llthread.h
+++ b/indra/llcommon/llthread.h
@@ -32,6 +32,8 @@
 #include "apr_thread_cond.h"
 #include "llmutex.h"
 
+LL_COMMON_API void assert_main_thread();
+
 class LL_COMMON_API LLThread
 {
 private:
diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp
index 9346aa7a45c..9bf9ae6c8e2 100644
--- a/indra/llcommon/lltrace.cpp
+++ b/indra/llcommon/lltrace.cpp
@@ -59,7 +59,6 @@ LLThreadLocalPointer<ThreadRecorder>& get_thread_recorder()
 {
 	static LLThreadLocalPointer<ThreadRecorder> s_thread_recorder;
 	return s_thread_recorder;
-
 }
 
 }
diff --git a/indra/llcommon/llwin32headers.h b/indra/llcommon/llwin32headers.h
index 80fd2e1768e..9c89b6b280f 100644
--- a/indra/llcommon/llwin32headers.h
+++ b/indra/llcommon/llwin32headers.h
@@ -28,11 +28,9 @@
 #define LL_LLWINDOWS_H
 
 #ifdef LL_WINDOWS
-#define NOMINMAX
 #undef WIN32_LEAN_AND_MEAN
 #include <winsock2.h>
 #include <windows.h>
-#undef NOMINMAX
 #endif
 
 #endif
diff --git a/indra/llcommon/llwin32headerslean.h b/indra/llcommon/llwin32headerslean.h
index ab6e9c09e26..d3fb90d4b18 100644
--- a/indra/llcommon/llwin32headerslean.h
+++ b/indra/llcommon/llwin32headerslean.h
@@ -28,7 +28,6 @@
 #define LL_LLWINDOWS_H
 
 #ifdef LL_WINDOWS
-#define NOMINMAX
 #define WIN32_LEAN_AND_MEAN
 #include <winsock2.h>
 #include <windows.h>
diff --git a/indra/llmessage/lliopipe.h b/indra/llmessage/lliopipe.h
index cbd17b5a3d9..9a0a427efd0 100644
--- a/indra/llmessage/lliopipe.h
+++ b/indra/llmessage/lliopipe.h
@@ -31,6 +31,7 @@
 
 #include <boost/intrusive_ptr.hpp>
 #include <boost/shared_ptr.hpp>
+#include "llwin32headerslean.h"
 #include "apr_poll.h"
 
 #include "llsd.h"
diff --git a/indra/llmessage/lliosocket.h b/indra/llmessage/lliosocket.h
index 4e07963af85..ec998552d02 100644
--- a/indra/llmessage/lliosocket.h
+++ b/indra/llmessage/lliosocket.h
@@ -38,8 +38,8 @@
  */
 
 #include "lliopipe.h"
-#include "apr_pools.h"
 #include "llwin32headerslean.h"
+#include "apr_pools.h"
 #include "apr_network_io.h"
 #include "llchainio.h"
 
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index c6ed8d5071c..9d4ed833b82 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -2033,7 +2033,7 @@ bool LLAppViewer::initThreads()
 
 	if (LLTrace::BlockTimer::sLog || LLTrace::BlockTimer::sMetricLog)
 	{
-		LLTrace::BlockTimer::sLogLock = new LLMutex(NULL);
+		LLTrace::BlockTimer::setLogLock(new LLMutex(NULL));
 		mFastTimerLogThread = new LLFastTimerLogThread(LLTrace::BlockTimer::sLogName);
 		mFastTimerLogThread->start();
 	}
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index d0bb75225c3..7a5c9dba46c 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -92,7 +92,7 @@ LLFastTimerView::LLFastTimerView(const LLSD& key)
 	mScrollIndex = 0;
 	mHoverID = NULL;
 	mHoverBarIndex = -1;
-	FTV_NUM_TIMERS = LLTrace::BlockTimer::instanceCount();
+	FTV_NUM_TIMERS = LLInstanceTracker<LLTrace::BlockTimer>::instanceCount();
 	mPrintStats = -1;	
 }
 
@@ -235,7 +235,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 
 	if(LLTrace::BlockTimer::sPauseHistory && mBarRect.pointInRect(x, y))
 	{
-		mHoverBarIndex = llmin(LLFastTimer::getCurFrameIndex() - 1, 
+		mHoverBarIndex = llmin(LLTrace::BlockTimer::getCurFrameIndex() - 1, 
 								MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight()));
 		if (mHoverBarIndex == 0)
 		{
@@ -292,7 +292,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 
 static std::string get_tooltip(LLTrace::BlockTimer& timer, S32 history_index = -1)
 {
-	F64 ms_multiplier = 1000.0 / (F64)LLFastTimer::countsPerSecond();
+	F64 ms_multiplier = 1000.0 / (F64)LLTrace::BlockTimer::countsPerSecond();
 
 	std::string tooltip;
 	if (history_index < 0)
@@ -364,7 +364,7 @@ void LLFastTimerView::draw()
 	
 	std::string tdesc;
 
-	F64 clock_freq = (F64)LLFastTimer::countsPerSecond();
+	F64 clock_freq = (F64)LLTrace::BlockTimer::countsPerSecond();
 	F64 iclock_freq = 1000.0 / clock_freq;
 	
 	S32 margin = 10;
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index a071f338bac..a5e3cd404d7 100755
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -113,8 +113,6 @@
 #include "llviewernetwork.h"
 #include "llviewershadermgr.h"
 #include "glod/glod.h"
-#include <boost/algorithm/string.hpp>
-
 
 const S32 SLM_SUPPORTED_VERSION = 3;
 
diff --git a/indra/newview/llviewerstatsrecorder.h b/indra/newview/llviewerstatsrecorder.h
index ce6dd63ec56..d1744f4910d 100644
--- a/indra/newview/llviewerstatsrecorder.h
+++ b/indra/newview/llviewerstatsrecorder.h
@@ -32,7 +32,7 @@
 // for analysis.
 
 // This is normally 0.  Set to 1 to enable viewer stats recording
-#define LL_RECORD_VIEWER_STATS	1
+#define LL_RECORD_VIEWER_STATS	0
 
 
 #include "llframetimer.h"
diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp
index 0da70d398b0..583196fb7a6 100644
--- a/indra/newview/llxmlrpctransaction.cpp
+++ b/indra/newview/llxmlrpctransaction.cpp
@@ -25,6 +25,8 @@
  */
 
 #include "llviewerprecompiledheaders.h"
+// include this to get winsock2 because openssl attempts to include winsock1
+#include "llwin32headerslean.h"
 #include <openssl/x509_vfy.h>
 #include <openssl/ssl.h>
 #include "llsecapi.h"
diff --git a/indra/test/test.cpp b/indra/test/test.cpp
index 2b66c6aa265..8bd302ce7a9 100644
--- a/indra/test/test.cpp
+++ b/indra/test/test.cpp
@@ -40,6 +40,7 @@
 #include "tests/wrapllerrs.h"             // RecorderProxy
 #include "stringize.h"
 #include "namedtempfile.h"
+#include "lltrace.h"
 
 #include "apr_pools.h"
 #include "apr_getopt.h"
@@ -513,7 +514,8 @@ int main(int argc, char **argv)
 #endif
 
 	ll_init_apr();
-
+	LLTrace::init();
+	
 	apr_getopt_t* os = NULL;
 	if(APR_SUCCESS != apr_getopt_init(&os, gAPRPoolp, argc, argv))
 	{
-- 
GitLab