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