Merge branch 'curlthreading2' into curlthreading3
This commit is contained in:
@@ -50,6 +50,7 @@ void AIThreadID::set_current_thread_id(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef LL_DARWIN
|
||||
void AIThreadID::reset(void)
|
||||
{
|
||||
mID = lCurrentThread;
|
||||
@@ -69,6 +70,7 @@ apr_os_thread_t AIThreadID::getCurrentThread(void)
|
||||
{
|
||||
return lCurrentThread;
|
||||
}
|
||||
#endif
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, AIThreadID const& id)
|
||||
{
|
||||
|
||||
@@ -62,11 +62,7 @@ public:
|
||||
friend LL_COMMON_API std::ostream& operator<<(std::ostream& os, AIThreadID const& id);
|
||||
static void set_main_thread_id(void); // Called once to set sMainThreadID.
|
||||
static void set_current_thread_id(void); // Called once for every thread to set lCurrentThread.
|
||||
#ifdef LL_DARWIN
|
||||
void reset(void) { mID = apr_os_thread_current(); }
|
||||
bool equals_current_thread(void) const { return apr_os_thread_equal(mID, apr_os_thread_current()); }
|
||||
static bool in_main_thread(void) { return apr_os_thread_equal(apr_os_thread_current(), sMainThreadID); }
|
||||
#else
|
||||
#ifndef LL_DARWIN
|
||||
LL_COMMON_API void reset(void);
|
||||
LL_COMMON_API bool equals_current_thread(void) const;
|
||||
LL_COMMON_API static bool in_main_thread(void);
|
||||
@@ -76,6 +72,16 @@ public:
|
||||
bool equals_current_thread_inline(void) const { return apr_os_thread_equal(mID, lCurrentThread); }
|
||||
static bool in_main_thread_inline(void) { return apr_os_thread_equal(lCurrentThread, sMainThreadID); }
|
||||
static apr_os_thread_t getCurrentThread_inline(void) { return lCurrentThread; }
|
||||
#else
|
||||
// Both variants are inline on OS X.
|
||||
void reset(void) { mID = apr_os_thread_current(); }
|
||||
void reset_inline(void) { mID = apr_os_thread_current(); }
|
||||
bool equals_current_thread(void) const { return apr_os_thread_equal(mID, apr_os_thread_current()); }
|
||||
bool equals_current_thread_inline(void) const { return apr_os_thread_equal(mID, apr_os_thread_current()); }
|
||||
static bool in_main_thread(void) { return apr_os_thread_equal(apr_os_thread_current(), sMainThreadID); }
|
||||
static bool in_main_thread_inline(void) { return apr_os_thread_equal(apr_os_thread_current(), sMainThreadID); }
|
||||
static apr_os_thread_t getCurrentThread(void) { return apr_os_thread_current(); }
|
||||
static apr_os_thread_t getCurrentThread_inline(void) { return apr_os_thread_current(); }
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -183,6 +183,10 @@ BOOL LLFastTimer::sMetricLog = FALSE;
|
||||
LLMutex* LLFastTimer::sLogLock = NULL;
|
||||
std::queue<LLSD> LLFastTimer::sLogQueue;
|
||||
|
||||
#if LL_WINDOWS
|
||||
#define USE_RDTSC 1
|
||||
#endif
|
||||
|
||||
std::vector<LLFastTimer::FrameState>* LLFastTimer::sTimerInfos = NULL;
|
||||
U64 LLFastTimer::sTimerCycles = 0;
|
||||
U32 LLFastTimer::sTimerCalls = 0;
|
||||
@@ -380,7 +384,9 @@ void LLFastTimer::updateCachedPointers()
|
||||
}
|
||||
|
||||
// See lltimer.cpp.
|
||||
#if LL_LINUX || LL_DARWIN || LL_SOLARIS
|
||||
#if USE_RDTSC
|
||||
std::string LLFastTimer::sClockType = "rdtsc";
|
||||
#elif LL_LINUX || LL_DARWIN || LL_SOLARIS
|
||||
std::string LLFastTimer::sClockType = "gettimeofday";
|
||||
#elif LL_WINDOWS
|
||||
std::string LLFastTimer::sClockType = "QueryPerformanceCounter";
|
||||
@@ -391,6 +397,9 @@ std::string LLFastTimer::sClockType = "QueryPerformanceCounter";
|
||||
//static
|
||||
U64 LLFastTimer::countsPerSecond() // counts per second for the *32-bit* timer
|
||||
{
|
||||
#if USE_RDTSC
|
||||
static U64 sCPUClockFrequency = U64(LLProcessorInfo().getCPUFrequency()*1000000.0);
|
||||
#else
|
||||
static bool firstcall = true;
|
||||
static U64 sCPUClockFrequency;
|
||||
if (firstcall)
|
||||
@@ -398,6 +407,7 @@ U64 LLFastTimer::countsPerSecond() // counts per second for the *32-bit* timer
|
||||
sCPUClockFrequency = calc_clock_frequency();
|
||||
firstcall = false;
|
||||
}
|
||||
#endif
|
||||
return sCPUClockFrequency >> 8;
|
||||
}
|
||||
|
||||
@@ -937,6 +947,38 @@ LLFastTimer::LLFastTimer(LLFastTimer::FrameState* state)
|
||||
// Important note: These implementations must be FAST!
|
||||
//
|
||||
|
||||
#if USE_RDTSC
|
||||
U32 LLFastTimer::getCPUClockCount32()
|
||||
{
|
||||
U32 ret_val;
|
||||
__asm
|
||||
{
|
||||
_emit 0x0f
|
||||
_emit 0x31
|
||||
shr eax,8
|
||||
shl edx,24
|
||||
or eax, edx
|
||||
mov dword ptr [ret_val], eax
|
||||
}
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
// return full timer value, *not* shifted by 8 bits
|
||||
U64 LLFastTimer::getCPUClockCount64()
|
||||
{
|
||||
U64 ret_val;
|
||||
__asm
|
||||
{
|
||||
_emit 0x0f
|
||||
_emit 0x31
|
||||
mov eax,eax
|
||||
mov edx,edx
|
||||
mov dword ptr [ret_val+4], edx
|
||||
mov dword ptr [ret_val], eax
|
||||
}
|
||||
return ret_val;
|
||||
}
|
||||
#else
|
||||
//LL_COMMON_API U64 get_clock_count(); // in lltimer.cpp
|
||||
// These use QueryPerformanceCounter, which is arguably fine and also works on AMD architectures.
|
||||
U32 LLFastTimer::getCPUClockCount32()
|
||||
@@ -948,4 +990,4 @@ U64 LLFastTimer::getCPUClockCount64()
|
||||
{
|
||||
return get_clock_count();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -53,7 +53,7 @@ std::string ll_safe_string(const char* in)
|
||||
|
||||
std::string ll_safe_string(const char* in, S32 maxlen)
|
||||
{
|
||||
if(in) return std::string(in, maxlen);
|
||||
if(in && maxlen > 0) return std::string(in, maxlen);
|
||||
return std::string();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
const S32 LL_VERSION_MAJOR = 1;
|
||||
const S32 LL_VERSION_MINOR = 7;
|
||||
const S32 LL_VERSION_PATCH = 0;
|
||||
const S32 LL_VERSION_PATCH = 1;
|
||||
const S32 LL_VERSION_BUILD = ${vBUILD};
|
||||
|
||||
const char * const LL_CHANNEL = "${VIEWER_CHANNEL}";
|
||||
|
||||
Reference in New Issue
Block a user