xref: /f-stack/tools/compat/include/sys/_domainset.h (revision d4a07e70)
1*d4a07e70Sfengbojiang /*-
2*d4a07e70Sfengbojiang  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3*d4a07e70Sfengbojiang  *
4*d4a07e70Sfengbojiang  * Copyright (c) 2017,	Jeffrey Roberson <[email protected]>
5*d4a07e70Sfengbojiang  * All rights reserved.
6*d4a07e70Sfengbojiang  *
7*d4a07e70Sfengbojiang  * Redistribution and use in source and binary forms, with or without
8*d4a07e70Sfengbojiang  * modification, are permitted provided that the following conditions
9*d4a07e70Sfengbojiang  * are met:
10*d4a07e70Sfengbojiang  * 1. Redistributions of source code must retain the above copyright
11*d4a07e70Sfengbojiang  *    notice unmodified, this list of conditions, and the following
12*d4a07e70Sfengbojiang  *    disclaimer.
13*d4a07e70Sfengbojiang  * 2. Redistributions in binary form must reproduce the above copyright
14*d4a07e70Sfengbojiang  *    notice, this list of conditions and the following disclaimer in the
15*d4a07e70Sfengbojiang  *    documentation and/or other materials provided with the distribution.
16*d4a07e70Sfengbojiang  *
17*d4a07e70Sfengbojiang  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18*d4a07e70Sfengbojiang  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19*d4a07e70Sfengbojiang  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20*d4a07e70Sfengbojiang  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21*d4a07e70Sfengbojiang  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22*d4a07e70Sfengbojiang  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23*d4a07e70Sfengbojiang  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24*d4a07e70Sfengbojiang  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25*d4a07e70Sfengbojiang  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26*d4a07e70Sfengbojiang  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*d4a07e70Sfengbojiang  *
28*d4a07e70Sfengbojiang  * $FreeBSD$
29*d4a07e70Sfengbojiang  */
30*d4a07e70Sfengbojiang 
31*d4a07e70Sfengbojiang #ifndef _SYS__DOMAINSET_H_
32*d4a07e70Sfengbojiang #define	_SYS__DOMAINSET_H_
33*d4a07e70Sfengbojiang 
34*d4a07e70Sfengbojiang #include <sys/_bitset.h>
35*d4a07e70Sfengbojiang 
36*d4a07e70Sfengbojiang #ifdef _KERNEL
37*d4a07e70Sfengbojiang #define	DOMAINSET_SETSIZE	MAXMEMDOM
38*d4a07e70Sfengbojiang #endif
39*d4a07e70Sfengbojiang 
40*d4a07e70Sfengbojiang #define	DOMAINSET_MAXSIZE	256
41*d4a07e70Sfengbojiang 
42*d4a07e70Sfengbojiang #ifndef	DOMAINSET_SETSIZE
43*d4a07e70Sfengbojiang #define	DOMAINSET_SETSIZE	DOMAINSET_MAXSIZE
44*d4a07e70Sfengbojiang #endif
45*d4a07e70Sfengbojiang 
46*d4a07e70Sfengbojiang BITSET_DEFINE(_domainset, DOMAINSET_SETSIZE);
47*d4a07e70Sfengbojiang typedef struct _domainset domainset_t;
48*d4a07e70Sfengbojiang 
49*d4a07e70Sfengbojiang /*
50*d4a07e70Sfengbojiang  * This structure is intended to be embedded in objects which have policy
51*d4a07e70Sfengbojiang  * attributes.  Each object keeps its own iterator so round-robin is
52*d4a07e70Sfengbojiang  * synchronized and accurate.
53*d4a07e70Sfengbojiang  */
54*d4a07e70Sfengbojiang struct domainset;
55*d4a07e70Sfengbojiang struct domainset_ref {
56*d4a07e70Sfengbojiang 	struct domainset * volatile	dr_policy;
57*d4a07e70Sfengbojiang 	unsigned int			dr_iter;
58*d4a07e70Sfengbojiang };
59*d4a07e70Sfengbojiang 
60*d4a07e70Sfengbojiang #endif /* !_SYS__DOMAINSET_H_ */
61