1*6ee513e5Sjca /* $OpenBSD: timer.h,v 1.9 2017/12/05 20:31:45 jca Exp $ */ 2944370e4Sniklas /* $EOM: timer.h,v 1.6 1999/04/11 22:35:55 ho Exp $ */ 32040585eSniklas 42040585eSniklas /* 5944370e4Sniklas * Copyright (c) 1998, 1999 Niklas Hallqvist. All rights reserved. 62040585eSniklas * 72040585eSniklas * Redistribution and use in source and binary forms, with or without 82040585eSniklas * modification, are permitted provided that the following conditions 92040585eSniklas * are met: 102040585eSniklas * 1. Redistributions of source code must retain the above copyright 112040585eSniklas * notice, this list of conditions and the following disclaimer. 122040585eSniklas * 2. Redistributions in binary form must reproduce the above copyright 132040585eSniklas * notice, this list of conditions and the following disclaimer in the 142040585eSniklas * documentation and/or other materials provided with the distribution. 152040585eSniklas * 162040585eSniklas * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 172040585eSniklas * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 182040585eSniklas * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 192040585eSniklas * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 202040585eSniklas * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 212040585eSniklas * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 222040585eSniklas * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 232040585eSniklas * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 242040585eSniklas * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 252040585eSniklas * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 262040585eSniklas */ 272040585eSniklas 282040585eSniklas /* 292040585eSniklas * This code was written under funding by Ericsson Radio Systems. 302040585eSniklas */ 312040585eSniklas 322040585eSniklas #ifndef _TIMER_H_ 332040585eSniklas #define _TIMER_H_ 342040585eSniklas 352040585eSniklas #include <sys/queue.h> 36*6ee513e5Sjca 37*6ee513e5Sjca #include <time.h> 382040585eSniklas 392040585eSniklas struct event { 402040585eSniklas TAILQ_ENTRY(event) link; 412040585eSniklas char *name; 422040585eSniklas void (*func) (void *); 432040585eSniklas void *arg; 44*6ee513e5Sjca struct timespec expiration; 452040585eSniklas }; 462040585eSniklas 472040585eSniklas extern void timer_init(void); 48*6ee513e5Sjca extern void timer_next_event(struct timespec **); 492040585eSniklas extern void timer_handle_expirations(void); 502040585eSniklas extern struct event *timer_add_event(char *, void (*) (void *), void *, 51*6ee513e5Sjca struct timespec *); 522040585eSniklas extern void timer_remove_event(struct event *); 53944370e4Sniklas extern void timer_report(void); 542040585eSniklas 552040585eSniklas #endif /* _TIMER_H_ */ 56