]>
Commit | Line | Data |
---|---|---|
5107cf1d UD |
1 | /* Definitions of constants and data structure for POSIX 1003.1b-1993 |
2 | scheduling interface. | |
bfff8b1b | 3 | Copyright (C) 1996-2017 Free Software Foundation, Inc. |
54d79e99 | 4 | This file is part of the GNU C Library. |
92777700 | 5 | |
54d79e99 | 6 | The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
7 | modify it under the terms of the GNU Lesser General Public |
8 | License as published by the Free Software Foundation; either | |
9 | version 2.1 of the License, or (at your option) any later version. | |
92777700 | 10 | |
54d79e99 UD |
11 | The GNU C Library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 14 | Lesser General Public License for more details. |
92777700 | 15 | |
41bdb6e2 | 16 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
17 | License along with the GNU C Library; if not, see |
18 | <http://www.gnu.org/licenses/>. */ | |
92777700 | 19 | |
ece29840 ST |
20 | #ifndef __need_schedparam |
21 | ||
5107cf1d | 22 | #ifndef _SCHED_H |
f4017d20 | 23 | # error "Never include <bits/sched.h> directly; use <sched.h> instead." |
5107cf1d UD |
24 | #endif |
25 | ||
26 | ||
27 | /* Scheduling algorithms. */ | |
28 | #define SCHED_OTHER 0 | |
29 | #define SCHED_FIFO 1 | |
30 | #define SCHED_RR 2 | |
31 | ||
32 | /* Data structure to describe a process' schedulability. */ | |
33 | struct sched_param | |
34 | { | |
4a2c9975 | 35 | int __sched_priority; |
5107cf1d | 36 | }; |
949ec764 | 37 | |
ece29840 ST |
38 | #endif /* need schedparam */ |
39 | ||
40 | #if !defined __defined_schedparam \ | |
41 | && (defined __need_schedparam || defined _SCHED_H) | |
42 | # define __defined_schedparam 1 | |
43 | /* Data structure to describe a process' schedulability. */ | |
44 | struct __sched_param | |
45 | { | |
46 | int __sched_priority; | |
47 | }; | |
48 | # undef __need_schedparam | |
49 | #endif | |
50 | ||
949ec764 | 51 | |
0e563cd6 UD |
52 | #if defined _SCHED_H && !defined __cpu_set_t_defined |
53 | # define __cpu_set_t_defined | |
949ec764 | 54 | /* Size definition for CPU sets. */ |
0e563cd6 UD |
55 | # define __CPU_SETSIZE 1024 |
56 | # define __NCPUBITS (8 * sizeof (__cpu_mask)) | |
949ec764 | 57 | |
2b7e92df | 58 | /* Type for array elements in 'cpu_set_t'. */ |
949ec764 UD |
59 | typedef unsigned long int __cpu_mask; |
60 | ||
61 | /* Basic access functions. */ | |
0e563cd6 UD |
62 | # define __CPUELT(cpu) ((cpu) / __NCPUBITS) |
63 | # define __CPUMASK(cpu) ((__cpu_mask) 1 << ((cpu) % __NCPUBITS)) | |
949ec764 UD |
64 | |
65 | /* Data structure to describe CPU mask. */ | |
66 | typedef struct | |
67 | { | |
68 | __cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS]; | |
69 | } cpu_set_t; | |
70 | ||
71 | /* Access functions for CPU masks. */ | |
2b7e92df ST |
72 | # if __GNUC_PREREQ (2, 91) |
73 | # define __CPU_ZERO_S(setsize, cpusetp) \ | |
74 | do __builtin_memset (cpusetp, '\0', setsize); while (0) | |
75 | # else | |
76 | # define __CPU_ZERO_S(setsize, cpusetp) \ | |
949ec764 | 77 | do { \ |
2b7e92df ST |
78 | size_t __i; \ |
79 | size_t __imax = (setsize) / sizeof (__cpu_mask); \ | |
80 | __cpu_mask *__bits = (cpusetp)->__bits; \ | |
81 | for (__i = 0; __i < __imax; ++__i) \ | |
82 | __bits[__i] = 0; \ | |
949ec764 | 83 | } while (0) |
2b7e92df ST |
84 | # endif |
85 | # define __CPU_SET_S(cpu, setsize, cpusetp) \ | |
86 | (__extension__ \ | |
87 | ({ size_t __cpu = (cpu); \ | |
88 | __cpu < 8 * (setsize) \ | |
89 | ? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \ | |
90 | |= __CPUMASK (__cpu)) \ | |
91 | : 0; })) | |
92 | # define __CPU_CLR_S(cpu, setsize, cpusetp) \ | |
93 | (__extension__ \ | |
94 | ({ size_t __cpu = (cpu); \ | |
95 | __cpu < 8 * (setsize) \ | |
96 | ? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \ | |
97 | &= ~__CPUMASK (__cpu)) \ | |
98 | : 0; })) | |
99 | # define __CPU_ISSET_S(cpu, setsize, cpusetp) \ | |
100 | (__extension__ \ | |
101 | ({ size_t __cpu = (cpu); \ | |
102 | __cpu < 8 * (setsize) \ | |
a784e502 | 103 | ? ((((const __cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \ |
2b7e92df ST |
104 | & __CPUMASK (__cpu))) != 0 \ |
105 | : 0; })) | |
106 | ||
107 | # define __CPU_COUNT_S(setsize, cpusetp) \ | |
108 | __sched_cpucount (setsize, cpusetp) | |
109 | ||
110 | # if __GNUC_PREREQ (2, 91) | |
111 | # define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \ | |
112 | (__builtin_memcmp (cpusetp1, cpusetp2, setsize) == 0) | |
113 | # else | |
114 | # define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \ | |
115 | (__extension__ \ | |
a784e502 UD |
116 | ({ const __cpu_mask *__arr1 = (cpusetp1)->__bits; \ |
117 | const __cpu_mask *__arr2 = (cpusetp2)->__bits; \ | |
2b7e92df ST |
118 | size_t __imax = (setsize) / sizeof (__cpu_mask); \ |
119 | size_t __i; \ | |
120 | for (__i = 0; __i < __imax; ++__i) \ | |
298711ff | 121 | if (__arr1[__i] != __arr2[__i]) \ |
2b7e92df ST |
122 | break; \ |
123 | __i == __imax; })) | |
124 | # endif | |
125 | ||
126 | # define __CPU_OP_S(setsize, destset, srcset1, srcset2, op) \ | |
127 | (__extension__ \ | |
128 | ({ cpu_set_t *__dest = (destset); \ | |
a784e502 UD |
129 | const __cpu_mask *__arr1 = (srcset1)->__bits; \ |
130 | const __cpu_mask *__arr2 = (srcset2)->__bits; \ | |
2b7e92df ST |
131 | size_t __imax = (setsize) / sizeof (__cpu_mask); \ |
132 | size_t __i; \ | |
133 | for (__i = 0; __i < __imax; ++__i) \ | |
134 | ((__cpu_mask *) __dest->__bits)[__i] = __arr1[__i] op __arr2[__i]; \ | |
135 | __dest; })) | |
136 | ||
137 | # define __CPU_ALLOC_SIZE(count) \ | |
138 | ((((count) + __NCPUBITS - 1) / __NCPUBITS) * sizeof (__cpu_mask)) | |
139 | # define __CPU_ALLOC(count) __sched_cpualloc (count) | |
140 | # define __CPU_FREE(cpuset) __sched_cpufree (cpuset) | |
8381e467 UD |
141 | |
142 | __BEGIN_DECLS | |
143 | ||
144 | extern int __sched_cpucount (size_t __setsize, const cpu_set_t *__setp) | |
145 | __THROW; | |
2b7e92df ST |
146 | extern cpu_set_t *__sched_cpualloc (size_t __count) __THROW __wur; |
147 | extern void __sched_cpufree (cpu_set_t *__set) __THROW; | |
8381e467 UD |
148 | |
149 | __END_DECLS | |
150 | ||
0e563cd6 | 151 | #endif |