fixed minor warnings in debug code
This commit is contained in:
parent
34cc487d05
commit
eea7858e2b
@ -44,26 +44,26 @@
|
|||||||
DEBUGLOGRAW(l, " \n"); \
|
DEBUGLOGRAW(l, " \n"); \
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long long GetCurrentClockTimeMicroseconds()
|
static unsigned long long GetCurrentClockTimeMicroseconds(void)
|
||||||
{
|
{
|
||||||
static clock_t _ticksPerSecond = 0;
|
static clock_t _ticksPerSecond = 0;
|
||||||
if (_ticksPerSecond <= 0) _ticksPerSecond = sysconf(_SC_CLK_TCK);
|
if (_ticksPerSecond <= 0) _ticksPerSecond = sysconf(_SC_CLK_TCK);
|
||||||
|
|
||||||
struct tms junk; clock_t newTicks = (clock_t) times(&junk);
|
{ struct tms junk; clock_t newTicks = (clock_t) times(&junk);
|
||||||
return ((((unsigned long long)newTicks)*(1000000))/_ticksPerSecond);
|
return ((((unsigned long long)newTicks)*(1000000))/_ticksPerSecond); }
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MUTEX_WAIT_TIME_DLEVEL 5
|
#define MUTEX_WAIT_TIME_DLEVEL 5
|
||||||
#define PTHREAD_MUTEX_LOCK(mutex) \
|
#define PTHREAD_MUTEX_LOCK(mutex) \
|
||||||
if (g_debugLevel>=MUTEX_WAIT_TIME_DLEVEL) { \
|
if (g_debugLevel>=MUTEX_WAIT_TIME_DLEVEL) { \
|
||||||
unsigned long long beforeTime = GetCurrentClockTimeMicroseconds(); \
|
unsigned long long const beforeTime = GetCurrentClockTimeMicroseconds(); \
|
||||||
pthread_mutex_lock(mutex); \
|
pthread_mutex_lock(mutex); \
|
||||||
unsigned long long afterTime = GetCurrentClockTimeMicroseconds(); \
|
{ unsigned long long const afterTime = GetCurrentClockTimeMicroseconds(); \
|
||||||
unsigned long long elapsedTime = (afterTime-beforeTime); \
|
unsigned long long const elapsedTime = (afterTime-beforeTime); \
|
||||||
if (elapsedTime > 1000) { /* or whatever threshold you like; I'm using 1 millisecond here */ \
|
if (elapsedTime > 1000) { /* or whatever threshold you like; I'm using 1 millisecond here */ \
|
||||||
DEBUGLOG(MUTEX_WAIT_TIME_DLEVEL, "Thread took %llu microseconds to acquire mutex %s \n", \
|
DEBUGLOG(MUTEX_WAIT_TIME_DLEVEL, "Thread took %llu microseconds to acquire mutex %s \n", \
|
||||||
elapsedTime, #mutex); \
|
elapsedTime, #mutex); \
|
||||||
} \
|
} } \
|
||||||
} else pthread_mutex_lock(mutex);
|
} else pthread_mutex_lock(mutex);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user