7 #ifndef __platform_SystemTicker_h__ 8 #define __platform_SystemTicker_h__ 17 #include <sys/times.h> 30 void FE_DL_EXPORT
milliSleep(
long milliseconds);
39 void FE_DL_EXPORT
microSleep(
long microseconds);
60 void FE_DL_EXPORT
nanoSpin(
long nanoseconds);
71 inline void nanoSleep(
long seconds,
long nanoseconds)
73 FE_SLEEP(seconds, nanoseconds);
85 inline void yield(
void)
102 #if FE_HW==FE_X86 || FE_HW==FE_ARM 104 #if FE_COMPILER==FE_MICROSOFT || FE_COMPILER==FE_INTEL 105 #if FE_COMPILER==FE_MICROSOFT 110 BOOL success=QueryPerformanceCounter(&tick);
111 return success? tick.LowPart: 0;
114 #pragma warning( push ) 115 #pragma warning( disable : 4035 ) 116 inline unsigned long systemTick(
void) { __asm { rdtsc } };
117 #pragma warning( pop ) 126 return s_tms.tms_cutime;
128 #elif FE_OS==FE_LINUX && FE_HW==FE_X86 133 __asm__ __volatile__ (
"rdtsc" :
"=a" (low) ,
"=d" (high) );
137 inline unsigned long systemTick(
void) { __asm { rdtsc };
return 0; };
140 #elif FE_COMPILER==FE_GNU && FE_OS!=FE_OSX 141 #ifndef FE_SUPPRESS_GetSystemTick 142 #define GetSystemTick2(low,high) __asm__ __volatile__ ( "rdtsc" : "=a" (low) , "=d" (high) ) 147 __asm__ __volatile__ (
"rdtsc" :
"=a" (low) ,
"=d" (high) );
151 inline unsigned long systemTick(
void) {
return 0; }
153 #elif defined(FE_HAS_TIMES) 159 return s_tms.tms_cutime;
162 inline unsigned long systemTick(
void) {
return 0; }
165 inline unsigned long systemTick(
void) {
return 0; }
186 unsigned long timeMS(
void);
192 static void FE_CDECL calibrate(
void) { staticInit(); }
196 static unsigned long ticksPerMS(
void) {
return ms_ticksPerMS; }
204 unsigned long finish)
208 return finish - start;
210 return finish + (UINT_MAX-start);
217 void log(
const char *fmt, ...);
221 static void staticInit(
void);
223 static unsigned long ms_ticksPerMS;
224 static float ms_usPerTick;
226 unsigned long m_lastincl;
227 unsigned long m_lastexcl;
230 unsigned long m_lasttick;
231 struct timeval m_timer;
kernel
Definition: namespace.dox:3
High precision timer.
Definition: SystemTicker.h:174
static float microsecondsPerTick()
Returns the fractional number of microseonds for each processor clock tick.
Definition: SystemTicker.h:215
static unsigned long ticksPerMS(void)
Returns the approximate number of processor clock ticks that occur every millisecond.
Definition: SystemTicker.h:196
Automatically reference-counted string container.
Definition: String.h:128
static unsigned long tickDifference(unsigned long start, unsigned long finish)
Return the reltive tick change between two absolute tick values.
Definition: SystemTicker.h:203