20#ifndef _COBALT_KERNEL_STAT_H
21#define _COBALT_KERNEL_STAT_H
23#include <cobalt/kernel/clock.h>
30#ifdef CONFIG_XENO_OPT_STATS
32typedef struct xnstat_exectime {
42#define xnstat_exectime_now() xnclock_core_read_raw()
45#define xnstat_exectime_update(sched, date) \
47 xnticks_t __date = date; \
48 (sched)->current_account->total += \
49 __date - (sched)->last_account_switch; \
50 (sched)->last_account_switch = __date; \
57#define xnstat_exectime_set_current(sched, new_account) \
59 xnstat_exectime_t *__prev; \
60 __prev = (xnstat_exectime_t *) \
61 atomic_long_xchg((atomic_long_t *)&(sched)->current_account, \
62 (long)(new_account)); \
67#define xnstat_exectime_get_current(sched) ((sched)->current_account)
71#define xnstat_exectime_finalize(sched, new_account) \
73 (sched)->last_account_switch = xnclock_core_read_raw(); \
74 (sched)->current_account = (new_account); \
78#define xnstat_exectime_get_start(account) ((account)->start)
79#define xnstat_exectime_get_total(account) ((account)->total)
82#define xnstat_exectime_get_last_switch(sched) ((sched)->last_account_switch)
86#define xnstat_exectime_reset_stats(stat) \
89 (stat)->start = xnclock_core_read_raw(); \
93typedef struct xnstat_counter {
94 unsigned long counter;
97static inline unsigned long xnstat_counter_inc(xnstat_counter_t *c)
102static inline unsigned long xnstat_counter_get(xnstat_counter_t *c)
107static inline void xnstat_counter_set(xnstat_counter_t *c,
unsigned long value)
113typedef struct xnstat_exectime {
116#define xnstat_exectime_now() ({ 0; })
117#define xnstat_exectime_update(sched, date) do { } while (0)
118#define xnstat_exectime_set_current(sched, new_account) ({ (void)sched; NULL; })
119#define xnstat_exectime_get_current(sched) ({ (void)sched; NULL; })
120#define xnstat_exectime_finalize(sched, new_account) do { } while (0)
121#define xnstat_exectime_get_start(account) ({ 0; })
122#define xnstat_exectime_get_total(account) ({ 0; })
123#define xnstat_exectime_get_last_switch(sched) ({ 0; })
124#define xnstat_exectime_reset_stats(account) do { } while (0)
126typedef struct xnstat_counter {
129#define xnstat_counter_inc(c) ({ do { } while(0); 0; })
130#define xnstat_counter_get(c) ({ 0; })
131#define xnstat_counter_set(c, value) do { } while (0)
136#define xnstat_exectime_switch(sched, new_account) \
138 xnstat_exectime_update(sched, xnstat_exectime_now()); \
139 xnstat_exectime_set_current(sched, new_account); \
144#define xnstat_exectime_lazy_switch(sched, new_account, date) \
146 xnstat_exectime_update(sched, date); \
147 xnstat_exectime_set_current(sched, new_account); \