0b8e20c89e
- The primary reason is that mkfs and installboot need to run natively during the cross compilation (host and target versions are compiled). There is a collision of include files though. E.g. a.out.h is very minix-specific. Therefore some files we moved and replaced by stubs that include the original file if compiling on or for Minix : include/a.out.h -> include/minix/a.out.h include/sys/dir.h -> include/minix/dir.h include/dirent.h -> include/minix/dirent.h include/sys/types.h -> include/minix/types.h - This does not break any native compilation on Minix. Other headers that were including the original files are changed according to include directly the new, minix specific location not to pick up the host system includes while cross-compiling. - role of this patch is to make rebasing of the build branch simpler until the new build system is merged
63 lines
2.4 KiB
C
63 lines
2.4 KiB
C
/* This library provides generic watchdog timer management functionality.
|
|
* The functions operate on a timer queue provided by the caller. Note that
|
|
* the timers must use absolute time to allow sorting. The library provides:
|
|
*
|
|
* tmrs_settimer: (re)set a new watchdog timer in the timers queue
|
|
* tmrs_clrtimer: remove a timer from both the timers queue
|
|
* tmrs_exptimers: check for expired timers and run watchdog functions
|
|
*
|
|
* Author:
|
|
* Jorrit N. Herder <jnherder@cs.vu.nl>
|
|
* Adapted from tmr_settimer and tmr_clrtimer in src/kernel/clock.c.
|
|
* Last modified: September 30, 2004.
|
|
*/
|
|
|
|
#ifndef _TIMERS_H
|
|
#define _TIMERS_H
|
|
|
|
#include <limits.h>
|
|
#include <minix/types.h>
|
|
|
|
struct timer;
|
|
typedef void (*tmr_func_t)(struct timer *tp);
|
|
typedef union { int ta_int; long ta_long; void *ta_ptr; } tmr_arg_t;
|
|
|
|
/* A timer_t variable must be declare for each distinct timer to be used.
|
|
* The timers watchdog function and expiration time are automatically set
|
|
* by the library function tmrs_settimer, but its argument is not.
|
|
*/
|
|
typedef struct timer
|
|
{
|
|
struct timer *tmr_next; /* next in a timer chain */
|
|
clock_t tmr_exp_time; /* expiration time */
|
|
tmr_func_t tmr_func; /* function to call when expired */
|
|
tmr_arg_t tmr_arg; /* random argument */
|
|
} timer_t;
|
|
|
|
/* Used when the timer is not active. */
|
|
#define TMR_NEVER ((clock_t) -1 < 0) ? ((clock_t) LONG_MAX) : ((clock_t) -1)
|
|
#undef TMR_NEVER
|
|
#define TMR_NEVER ((clock_t) LONG_MAX)
|
|
|
|
/* These definitions can be used to set or get data from a timer variable. */
|
|
#define tmr_arg(tp) (&(tp)->tmr_arg)
|
|
#define tmr_exp_time(tp) (&(tp)->tmr_exp_time)
|
|
|
|
/* Timers should be initialized once before they are being used. Be careful
|
|
* not to reinitialize a timer that is in a list of timers, or the chain
|
|
* will be broken.
|
|
*/
|
|
#define tmr_inittimer(tp) (void)((tp)->tmr_exp_time = TMR_NEVER, \
|
|
(tp)->tmr_next = NULL)
|
|
|
|
/* The following generic timer management functions are available. They
|
|
* can be used to operate on the lists of timers. Adding a timer to a list
|
|
* automatically takes care of removing it.
|
|
*/
|
|
_PROTOTYPE( clock_t tmrs_clrtimer, (timer_t **tmrs, timer_t *tp, clock_t *new_head) );
|
|
_PROTOTYPE( void tmrs_exptimers, (timer_t **tmrs, clock_t now, clock_t *new_head) );
|
|
_PROTOTYPE( clock_t tmrs_settimer, (timer_t **tmrs, timer_t *tp,
|
|
clock_t exp_time, tmr_func_t watchdog, clock_t *new_head) );
|
|
|
|
#endif /* _TIMERS_H */
|
|
|