xref: /freebsd/sys/sys/_unrhdr.h (revision 95ee2897)
1dc872d46SKonstantin Belousov /*-
24d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3c4e20cadSPedro F. Giffuni  *
4dc872d46SKonstantin Belousov  * Copyright (c) 2004 Poul-Henning Kamp
5dc872d46SKonstantin Belousov  * All rights reserved.
6dc872d46SKonstantin Belousov  *
7dc872d46SKonstantin Belousov  * Redistribution and use in source and binary forms, with or without
8dc872d46SKonstantin Belousov  * modification, are permitted provided that the following conditions
9dc872d46SKonstantin Belousov  * are met:
10dc872d46SKonstantin Belousov  * 1. Redistributions of source code must retain the above copyright
11dc872d46SKonstantin Belousov  *    notice, this list of conditions and the following disclaimer.
12dc872d46SKonstantin Belousov  * 2. Redistributions in binary form must reproduce the above copyright
13dc872d46SKonstantin Belousov  *    notice, this list of conditions and the following disclaimer in the
14dc872d46SKonstantin Belousov  *    documentation and/or other materials provided with the distribution.
15dc872d46SKonstantin Belousov  *
16dc872d46SKonstantin Belousov  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17dc872d46SKonstantin Belousov  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18dc872d46SKonstantin Belousov  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19dc872d46SKonstantin Belousov  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20dc872d46SKonstantin Belousov  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21dc872d46SKonstantin Belousov  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22dc872d46SKonstantin Belousov  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23dc872d46SKonstantin Belousov  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24dc872d46SKonstantin Belousov  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25dc872d46SKonstantin Belousov  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26dc872d46SKonstantin Belousov  * SUCH DAMAGE.
27dc872d46SKonstantin Belousov  */
28dc872d46SKonstantin Belousov 
29dc872d46SKonstantin Belousov #ifndef _SYS_UNRHDR_H
30dc872d46SKonstantin Belousov #define _SYS_UNRHDR_H
31dc872d46SKonstantin Belousov 
32dc872d46SKonstantin Belousov #include <sys/queue.h>
33dc872d46SKonstantin Belousov 
34dc872d46SKonstantin Belousov struct mtx;
35dc872d46SKonstantin Belousov 
36dc872d46SKonstantin Belousov /* Header element for a unr number space. */
37dc872d46SKonstantin Belousov 
38dc872d46SKonstantin Belousov struct unrhdr {
39dc872d46SKonstantin Belousov 	TAILQ_HEAD(unrhd,unr)	head;
40dc872d46SKonstantin Belousov 	u_int			low;	/* Lowest item */
41dc872d46SKonstantin Belousov 	u_int			high;	/* Highest item */
42dc872d46SKonstantin Belousov 	u_int			busy;	/* Count of allocated items */
43dc872d46SKonstantin Belousov 	u_int			alloc;	/* Count of memory allocations */
44dc872d46SKonstantin Belousov 	u_int			first;	/* items in allocated from start */
45dc872d46SKonstantin Belousov 	u_int			last;	/* items free at end */
46dc872d46SKonstantin Belousov 	struct mtx		*mtx;
47dc872d46SKonstantin Belousov 	TAILQ_HEAD(unrfr,unr)	ppfree;	/* Items to be freed after mtx
48dc872d46SKonstantin Belousov 					   lock dropped */
49dc872d46SKonstantin Belousov };
50dc872d46SKonstantin Belousov 
51dc872d46SKonstantin Belousov #endif
52