/* timer.h - Timer interface. Copyright (C) 2009 Free Software Foundation, Inc. Written by Neal H. Walfield . This file is part of the GNU Hurd. The GNU Hurd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. The GNU Hurd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef _VIENGOOS_TIMER_H #define _VIENGOOS_TIMER_H 1 #include #include #include #include extern volatile struct vg_time time_data; struct timer { struct timer *next; struct timer *prev; void (*callback) (struct timer *timer); uint64_t expire; }; /* Register a timer. TIMER->EXPIRE and TIMER->CALLBACK must be correctly initialized prior to calling this function. */ extern void timer_register (struct timer *timer); /* Cancel a previously registered and as of yet unfired timer. */ extern void timer_cancel (struct timer *timer); static inline void timer_check (void) { extern bool timer_bottom_half_pending; extern struct timer *timers; if (timers && unlikely (timers->expire <= time_data.ns_since_boot) && ! timer_bottom_half_pending) { extern void timer_check_hard (void); timer_check_hard (); } } extern void timer_bootstrap (void); #endif