xref: /freebsd/sys/sys/_callout.h (revision 29363fb4)
1b2ad91f2SKonstantin Belousov /*-
251369649SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
351369649SPedro F. Giffuni  *
4b2ad91f2SKonstantin Belousov  * Copyright (c) 1990, 1993
5b2ad91f2SKonstantin Belousov  *	The Regents of the University of California.  All rights reserved.
6b2ad91f2SKonstantin Belousov  * (c) UNIX System Laboratories, Inc.
7b2ad91f2SKonstantin Belousov  * All or some portions of this file are derived from material licensed
8b2ad91f2SKonstantin Belousov  * to the University of California by American Telephone and Telegraph
9b2ad91f2SKonstantin Belousov  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10b2ad91f2SKonstantin Belousov  * the permission of UNIX System Laboratories, Inc.
11b2ad91f2SKonstantin Belousov  *
12b2ad91f2SKonstantin Belousov  * Redistribution and use in source and binary forms, with or without
13b2ad91f2SKonstantin Belousov  * modification, are permitted provided that the following conditions
14b2ad91f2SKonstantin Belousov  * are met:
15b2ad91f2SKonstantin Belousov  * 1. Redistributions of source code must retain the above copyright
16b2ad91f2SKonstantin Belousov  *    notice, this list of conditions and the following disclaimer.
17b2ad91f2SKonstantin Belousov  * 2. Redistributions in binary form must reproduce the above copyright
18b2ad91f2SKonstantin Belousov  *    notice, this list of conditions and the following disclaimer in the
19b2ad91f2SKonstantin Belousov  *    documentation and/or other materials provided with the distribution.
20fbbd9655SWarner Losh  * 3. Neither the name of the University nor the names of its contributors
21b2ad91f2SKonstantin Belousov  *    may be used to endorse or promote products derived from this software
22b2ad91f2SKonstantin Belousov  *    without specific prior written permission.
23b2ad91f2SKonstantin Belousov  *
24b2ad91f2SKonstantin Belousov  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25b2ad91f2SKonstantin Belousov  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26b2ad91f2SKonstantin Belousov  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27b2ad91f2SKonstantin Belousov  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28b2ad91f2SKonstantin Belousov  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29b2ad91f2SKonstantin Belousov  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30b2ad91f2SKonstantin Belousov  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31b2ad91f2SKonstantin Belousov  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32b2ad91f2SKonstantin Belousov  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33b2ad91f2SKonstantin Belousov  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34b2ad91f2SKonstantin Belousov  * SUCH DAMAGE.
35b2ad91f2SKonstantin Belousov  */
36b2ad91f2SKonstantin Belousov 
37b2ad91f2SKonstantin Belousov #ifndef _SYS__CALLOUT_H
38b2ad91f2SKonstantin Belousov #define	_SYS__CALLOUT_H
39b2ad91f2SKonstantin Belousov 
40959af5a8SKristof Provost #include <sys/_types.h>
41b2ad91f2SKonstantin Belousov #include <sys/queue.h>
42b2ad91f2SKonstantin Belousov 
43b2ad91f2SKonstantin Belousov struct lock_object;
44b2ad91f2SKonstantin Belousov 
455b999a6bSDavide Italiano LIST_HEAD(callout_list, callout);
465b999a6bSDavide Italiano SLIST_HEAD(callout_slist, callout);
47b2ad91f2SKonstantin Belousov TAILQ_HEAD(callout_tailq, callout);
48b2ad91f2SKonstantin Belousov 
49a8a03706SJohn Baldwin typedef void callout_func_t(void *);
50a8a03706SJohn Baldwin 
51b2ad91f2SKonstantin Belousov struct callout {
52b2ad91f2SKonstantin Belousov 	union {
535b999a6bSDavide Italiano 		LIST_ENTRY(callout) le;
54b2ad91f2SKonstantin Belousov 		SLIST_ENTRY(callout) sle;
55b2ad91f2SKonstantin Belousov 		TAILQ_ENTRY(callout) tqe;
56b2ad91f2SKonstantin Belousov 	} c_links;
57959af5a8SKristof Provost 	__sbintime_t c_time;			/* ticks to the event */
58959af5a8SKristof Provost 	__sbintime_t c_precision;		/* delta allowed wrt opt */
59b2ad91f2SKonstantin Belousov 	void	*c_arg;				/* function argument */
60a8a03706SJohn Baldwin 	callout_func_t *c_func;			/* function to call */
61a115fb62SHans Petter Selasky 	struct lock_object *c_lock;		/* lock to handle */
6290b887e0SRandall Stewart 	short	c_flags;			/* User State */
6390b887e0SRandall Stewart 	short	c_iflags;			/* Internal State */
64a115fb62SHans Petter Selasky 	volatile int c_cpu;			/* CPU we're scheduled on */
65b2ad91f2SKonstantin Belousov };
66b2ad91f2SKonstantin Belousov 
67b2ad91f2SKonstantin Belousov #endif
68