[BACK]Return to timer.h CVS log [TXT][DIR] Up to [local] / prex-old / sys / include

Annotation of prex-old/sys/include/timer.h, Revision 1.1

1.1     ! nbrk        1: /*-
        !             2:  * Copyright (c) 2005-2007, Kohsuke Ohtani
        !             3:  * All rights reserved.
        !             4:  *
        !             5:  * Redistribution and use in source and binary forms, with or without
        !             6:  * modification, are permitted provided that the following conditions
        !             7:  * are met:
        !             8:  * 1. Redistributions of source code must retain the above copyright
        !             9:  *    notice, this list of conditions and the following disclaimer.
        !            10:  * 2. Redistributions in binary form must reproduce the above copyright
        !            11:  *    notice, this list of conditions and the following disclaimer in the
        !            12:  *    documentation and/or other materials provided with the distribution.
        !            13:  * 3. Neither the name of the author nor the names of any co-contributors
        !            14:  *    may be used to endorse or promote products derived from this software
        !            15:  *    without specific prior written permission.
        !            16:  *
        !            17:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
        !            18:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            19:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            20:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
        !            21:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            22:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            23:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            24:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            25:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            26:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            27:  * SUCH DAMAGE.
        !            28:  */
        !            29:
        !            30: #ifndef _TIMER_H
        !            31: #define _TIMER_H
        !            32:
        !            33: #include <event.h>
        !            34:
        !            35: struct timer {
        !            36:        struct list     link;           /* linkage on timer chain */
        !            37:        int             active;         /* true if active */
        !            38:        u_long          expire;         /* expire time (ticks) */
        !            39:        u_long          interval;       /* time interval */
        !            40:        struct event    event;          /* event for this timer */
        !            41:        void (*func)(void *);           /* function to call */
        !            42:        void            *arg;           /* function argument */
        !            43: };
        !            44:
        !            45: /*
        !            46:  * Macro to compare two timer counts.
        !            47:  * time_after() returns true if a is after b.
        !            48:  */
        !            49: #define time_after(a,b)                (((long)(b) - (long)(a)) < 0)
        !            50: #define time_before(a,b)       time_after(b,a)
        !            51:
        !            52: #define time_after_eq(a,b)     (((long)(a) - (long)(b)) >= 0)
        !            53: #define time_before_eq(a,b)    time_after_eq(b,a)
        !            54:
        !            55: /*
        !            56:  * Macro to convert milliseconds and tick.
        !            57:  */
        !            58: #define msec_to_tick(ms)       (((ms) >= 0x20000) ? \
        !            59:                                 ((ms) / 1000UL) * HZ : ((ms) * HZ) / 1000UL)
        !            60:
        !            61: #define tick_to_msec(tick)     (((tick) * 1000) / HZ)
        !            62:
        !            63:
        !            64: extern void     timer_callout(struct timer *, void (*)(void *), void *,
        !            65:                               u_long);
        !            66: extern void     timer_stop(struct timer *);
        !            67: extern u_long   timer_delay(u_long);
        !            68: extern int      timer_sleep(u_long, u_long *);
        !            69: extern int      timer_alarm(u_long, u_long *);
        !            70: extern int      timer_periodic(struct thread *, u_long, u_long);
        !            71: extern int      timer_waitperiod(void);
        !            72: extern void     timer_cleanup(struct thread *);
        !            73: extern int      timer_hook(void (*)(int));
        !            74: extern void     timer_tick(void);
        !            75: extern u_long   timer_count(void);
        !            76: extern void     timer_info(struct info_timer *);
        !            77: extern void     timer_dump(void);
        !            78: extern void     timer_init(void);
        !            79:
        !            80: #endif /* !_TIMER_H */

CVSweb