/**
* A timer.
*/
-struct _ir_timer_t {
+struct ir_timer_t {
ir_timer_val_t elapsed; /**< the elapsed time so far */
ir_timer_val_t start; /**< the start value of the timer */
ir_timer_t *link; /**< link to the next entry in the timer stack */
static inline void _time_get(ir_timer_val_t *val)
{
- if(!QueryPerformanceCounter(&val->hi_prec))
+ if (!QueryPerformanceCounter(&val->hi_prec))
val->lo_prec = timeGetTime();
}
{
LARGE_INTEGER freq;
- if(!QueryPerformanceFrequency(&freq))
+ if (!QueryPerformanceFrequency(&freq))
return (unsigned long) elapsed->lo_prec;
return (unsigned long) ((elapsed->hi_prec.QuadPart * 1000) / freq.QuadPart);
{
LARGE_INTEGER freq;
- if(!QueryPerformanceFrequency(&freq))
+ if (!QueryPerformanceFrequency(&freq))
return (unsigned long) elapsed->lo_prec;
return (unsigned long) ((elapsed->hi_prec.QuadPart * 1000000) / freq.QuadPart);
static inline ir_timer_val_t *_time_add(ir_timer_val_t *res, const ir_timer_val_t *lhs, const ir_timer_val_t *rhs)
{
LARGE_INTEGER dummy;
- if(QueryPerformanceFrequency(&dummy))
+ if (QueryPerformanceFrequency(&dummy))
res->hi_prec.QuadPart = lhs->hi_prec.QuadPart + rhs->hi_prec.QuadPart;
else
res->lo_prec = lhs->lo_prec + rhs->lo_prec;
static inline ir_timer_val_t *_time_sub(ir_timer_val_t *res, const ir_timer_val_t *lhs, const ir_timer_val_t *rhs)
{
LARGE_INTEGER dummy;
- if(QueryPerformanceFrequency(&dummy))
+ if (QueryPerformanceFrequency(&dummy))
res->hi_prec.QuadPart = lhs->hi_prec.QuadPart - rhs->hi_prec.QuadPart;
else
res->lo_prec = lhs->lo_prec - rhs->lo_prec;
struct sched_param p;
int res, max, algo;
- if(!std_sched_param_init) {
+ if (!std_sched_param_init) {
res = sched_getparam(pid, &std_sched_param);
std_sched_param_init = 1;
}
int res = 0;
pid_t pid = getpid();
- if(std_sched_param_init)
+ if (std_sched_param_init)
res = sched_setparam(pid, &std_sched_param);
return res;
int ir_timer_leave_high_priority(void)
{
int res = 0;
- if(!SetThreadPriority(GetCurrentThread(), initial_priority)) {
+ if (!SetThreadPriority(GetCurrentThread(), initial_priority)) {
fprintf(stderr, "Failed to leave high priority (%d)\n", GetLastError());
res = GetLastError();
}
{
int res = 0;
initial_priority = GetThreadPriority(GetCurrentThread());
- if(!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST)) {
+ if (!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST)) {
fprintf(stderr, "Failed to enter high priority (%d)\n", GetLastError());
res = GetLastError();
}
int heapstatus;
size_t res = 0;
hinfo._pentry = NULL;
- while((heapstatus = _heapwalk(&hinfo)) == _HEAPOK)
+ while ((heapstatus = _heapwalk(&hinfo)) == _HEAPOK)
res += hinfo._useflag == _USEDENTRY ? hinfo._size : 0;
return res;
}
{
/* If the timer is running stop, measure the time and add it to the
* elapsed time. */
- if(timer->running) {
+ if (timer->running) {
ir_timer_val_t val;
ir_timer_val_t tgt;
ir_timer_val_t v;
const ir_timer_val_t *elapsed = &timer->elapsed;
- if(timer->running) {
+ if (timer->running) {
elapsed = &v;
_time_get(&v);
_time_add(&v, &timer->elapsed, _time_sub(&v, &v, &timer->start));
ir_timer_val_t v;
const ir_timer_val_t *elapsed = &timer->elapsed;
- if(timer->running) {
+ if (timer->running) {
elapsed = &v;
_time_get(&v);
_time_add(&v, &timer->elapsed, _time_sub(&v, &v, &timer->start));