diff options
author | Till Straumann <strauman@slac.stanford.edu> | 2009-04-23 04:26:07 +0000 |
---|---|---|
committer | Till Straumann <strauman@slac.stanford.edu> | 2009-04-23 04:26:07 +0000 |
commit | acc2a645a748497ba85d7d1763a84006b93dac3c (patch) | |
tree | db78372d5f7a3cd8469392167c6fe452719d2d98 /bsd_eth_drivers/libbsdport/callout.h | |
parent | - added definition for MA_NOTOWNED (diff) | |
download | libbsdport-acc2a645a748497ba85d7d1763a84006b93dac3c.tar.bz2 |
- callout_stop() and callout_reset() actually must return an 'int' value
indicating whether a callout was pending.
- added callout_active(), callout_pending(), callout_deactivate().
Diffstat (limited to '')
-rw-r--r-- | bsd_eth_drivers/libbsdport/callout.h | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/bsd_eth_drivers/libbsdport/callout.h b/bsd_eth_drivers/libbsdport/callout.h index 3f586bf..acc9de0 100644 --- a/bsd_eth_drivers/libbsdport/callout.h +++ b/bsd_eth_drivers/libbsdport/callout.h @@ -18,16 +18,56 @@ struct callout { void *c_arg; struct mtx *c_mtx; callout_time_t c_time; + unsigned c_flags; }; +#define CALLOUT_PENDING (1<<0) +#define CALLOUT_ACTIVE (1<<1) + +/* + * Strictly, we don't need any protection + * because the global network semaphore + * takes care; however we want to + */ +static inline int +callout_active(struct callout *p_c) +{ +int rval; +rtems_interrupt_level l; + rtems_interrupt_disable(l); + rval = p_c->c_flags & CALLOUT_ACTIVE; + rtems_interrupt_enable(l); + return rval; +} + +static inline int +callout_pending(struct callout *p_c) +{ +int rval; +rtems_interrupt_level l; + rtems_interrupt_disable(l); + rval = p_c->c_flags & CALLOUT_PENDING; + rtems_interrupt_enable(l); + return rval; +} + +static inline void +callout_decativate(struct callout *p_c) +{ +rtems_interrupt_level l; + rtems_interrupt_disable(l); + p_c->c_flags &= ~CALLOUT_ACTIVE; + rtems_interrupt_enable(l); +} + /* We cannot stop a callout that's in progress */ -void +int callout_stop(struct callout *c); #define callout_drain callout_stop -void +int callout_reset(struct callout *c, int ticks, void (*fn)(void*), void *arg); void |