xref: /dragonfly/sys/sys/cpumask.h (revision da82a65a2885f0d063716beb9a62f7d2633a10c3)
1 /*
2  * Copyright (c) 2019 The DragonFly Project.  All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
14  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
15  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
16  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
17  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
19  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
21  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
23  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  */
26 
27 #ifndef _SYS_CPUMASK_H_
28 #define _SYS_CPUMASK_H_
29 
30 #include <machine/cpumask.h>
31 #include <machine/stdint.h>
32 
33 typedef   __cpumask_t         cpumask_t;
34 
35 #ifndef _KERNEL
36 #define   CPU_SETSIZE                   ((int)(sizeof(cpumask_t) * 8))
37 #define   CPU_ZERO(set)                           __CPU_ZERO(set)
38 #define   CPU_SET(cpu, set)             __CPU_SET(cpu, set)
39 #define   CPU_CLR(cpu, set)             __CPU_CLR(cpu, set)
40 #define   CPU_ISSET(cpu, set)           __CPU_ISSET(cpu, set)
41 #define   CPU_COUNT(set)                          __CPU_COUNT(set)
42 #define   CPU_AND(dst, set1, set2)      __CPU_AND(dst, set1, set2)
43 #define   CPU_OR(dst, set1, set2)                 __CPU_OR(dst, set1, set2)
44 #define   CPU_XOR(dst, set1, set2)      __CPU_XOR(dst, set1, set2)
45 #define   CPU_EQUAL(set1, set2)                   __CPU_EQUAL(set1, set2)
46 #endif
47 
48 /*
49  * It is convenient to place this type here due to its proximity to the
50  * cpumask_t use cases in structs.  Keep public for easier access to
51  * struct proc for now.
52  */
53 typedef   __uint32_t          cpulock_t;          /* count and exclusive lock */
54 
55 #define   CPULOCK_EXCLBIT     0                   /* exclusive lock bit number */
56 #define   CPULOCK_EXCL        0x00000001          /* exclusive lock */
57 #define   CPULOCK_INCR        0x00000002          /* auxillary counter add/sub */
58 #define   CPULOCK_CNTMASK     0x7FFFFFFE
59 
60 #endif /* !_SYS_CPUMASK_H_ */
61