xref: /haiku/src/libs/compat/freebsd_network/compat/sys/_task.h (revision 97f11716bfaa0f385eb0e28a52bf56a5023b9e99)
1*01631912SAugustin Cavalier /*-
2*01631912SAugustin Cavalier  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3*01631912SAugustin Cavalier  *
4*01631912SAugustin Cavalier  * Copyright (c) 2000 Doug Rabson
5*01631912SAugustin Cavalier  * All rights reserved.
6*01631912SAugustin Cavalier  *
7*01631912SAugustin Cavalier  * Redistribution and use in source and binary forms, with or without
8*01631912SAugustin Cavalier  * modification, are permitted provided that the following conditions
9*01631912SAugustin Cavalier  * are met:
10*01631912SAugustin Cavalier  * 1. Redistributions of source code must retain the above copyright
11*01631912SAugustin Cavalier  *    notice, this list of conditions and the following disclaimer.
12*01631912SAugustin Cavalier  * 2. Redistributions in binary form must reproduce the above copyright
13*01631912SAugustin Cavalier  *    notice, this list of conditions and the following disclaimer in the
14*01631912SAugustin Cavalier  *    documentation and/or other materials provided with the distribution.
15*01631912SAugustin Cavalier  *
16*01631912SAugustin Cavalier  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17*01631912SAugustin Cavalier  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18*01631912SAugustin Cavalier  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19*01631912SAugustin Cavalier  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20*01631912SAugustin Cavalier  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21*01631912SAugustin Cavalier  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22*01631912SAugustin Cavalier  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23*01631912SAugustin Cavalier  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24*01631912SAugustin Cavalier  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25*01631912SAugustin Cavalier  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26*01631912SAugustin Cavalier  * SUCH DAMAGE.
27*01631912SAugustin Cavalier  *
28*01631912SAugustin Cavalier  * $FreeBSD$
29dba28784SAugustin Cavalier  */
30dba28784SAugustin Cavalier 
31*01631912SAugustin Cavalier #ifndef _SYS__TASK_H_
32*01631912SAugustin Cavalier #define _SYS__TASK_H_
33dba28784SAugustin Cavalier 
34*01631912SAugustin Cavalier #include <sys/queue.h>
35dba28784SAugustin Cavalier 
36*01631912SAugustin Cavalier /*
37*01631912SAugustin Cavalier  * Each task includes a function which is called from
38*01631912SAugustin Cavalier  * taskqueue_run().  The first argument is taken from the 'ta_context'
39*01631912SAugustin Cavalier  * field of struct task and the second argument is a count of how many
40*01631912SAugustin Cavalier  * times the task was enqueued before the call to taskqueue_run().
41*01631912SAugustin Cavalier  *
42*01631912SAugustin Cavalier  * List of locks
43*01631912SAugustin Cavalier  * (c)	const after init
44*01631912SAugustin Cavalier  * (q)	taskqueue lock
45*01631912SAugustin Cavalier  */
46*01631912SAugustin Cavalier typedef void task_fn_t(void *context, int pending);
47dba28784SAugustin Cavalier 
48dba28784SAugustin Cavalier struct task {
49*01631912SAugustin Cavalier 	STAILQ_ENTRY(task) ta_link;	/* (q) link for queue */
50*01631912SAugustin Cavalier 	uint16_t ta_pending;		/* (q) count times queued */
51*01631912SAugustin Cavalier 	uint8_t	ta_priority;		/* (c) Priority */
52*01631912SAugustin Cavalier 	uint8_t	ta_flags;		/* (c) Flags */
53*01631912SAugustin Cavalier 	task_fn_t *ta_func;		/* (c) task handler */
54*01631912SAugustin Cavalier 	void	*ta_context;		/* (c) argument for handler */
55dba28784SAugustin Cavalier };
56dba28784SAugustin Cavalier 
57*01631912SAugustin Cavalier #define	TASK_ENQUEUED		(1<<0)
58*01631912SAugustin Cavalier #define	TASK_NOENQUEUE		(1<<1)
59*01631912SAugustin Cavalier #define TASK_SKIP_WAKEUP	(1<<2)
608548a4adSAugustin Cavalier 
61*01631912SAugustin Cavalier #define TASK_NEEDSGIANT		(1<<3) /* Haiku extension, OpenBSD compatibility */
628548a4adSAugustin Cavalier 
63*01631912SAugustin Cavalier #endif /* !_SYS__TASK_H_ */
64