1
/* Definitions of constants and data structure for POSIX 1003.1b-1993
3
Copyright (C) 1996-1999,2001-2003,2005,2006,2007,2008
4
Free Software Foundation, Inc.
5
This file is part of the GNU C Library.
7
The GNU C Library is free software; you can redistribute it and/or
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.
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
15
Lesser General Public License for more details.
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
22
#ifndef __need_schedparam
25
# error "Never include <bits/sched.h> directly; use <sched.h> instead."
29
/* Scheduling algorithms. */
37
# define CSIGNAL 0x000000ff /* Signal mask to be sent at exit. */
38
# define CLONE_VM 0x00000100 /* Set if VM shared between processes. */
39
# define CLONE_FS 0x00000200 /* Set if fs info shared between processes. */
40
# define CLONE_FILES 0x00000400 /* Set if open files shared between processes. */
41
# define CLONE_SIGHAND 0x00000800 /* Set if signal handlers shared. */
42
# define CLONE_PTRACE 0x00002000 /* Set if tracing continues on the child. */
43
# define CLONE_VFORK 0x00004000 /* Set if the parent wants the child to
44
wake it up on mm_release. */
45
# define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
48
/* The official definition. */
57
/* Clone current process. */
58
extern int clone (int (*__fn) (void *__arg), void *__child_stack,
59
int __flags, void *__arg) __THROW;
61
/* Unshare the specified resources. */
62
extern int unshare (int __flags) __THROW;
64
/* Get index of currently used CPU. */
65
extern int sched_getcpu (void) __THROW;
70
#endif /* need schedparam */
72
#if !defined __defined_schedparam \
73
&& (defined __need_schedparam || defined _SCHED_H)
74
# define __defined_schedparam 1
75
/* Data structure to describe a process' schedulability. */
80
# undef __need_schedparam
84
#if defined _SCHED_H && !defined __cpu_set_t_defined
85
# define __cpu_set_t_defined
86
/* Size definition for CPU sets. */
87
# define __CPU_SETSIZE 128
88
# define __NCPUBITS (8 * sizeof (__cpu_mask))
90
/* Type for array elements in 'cpu_set_t'. */
91
typedef unsigned long int __cpu_mask;
93
/* Basic access functions. */
94
# define __CPUELT(cpu) ((cpu) / __NCPUBITS)
95
# define __CPUMASK(cpu) ((__cpu_mask) 1 << ((cpu) % __NCPUBITS))
97
/* Data structure to describe CPU mask. */
100
__cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS];
103
/* Access functions for CPU masks. */
104
# if __GNUC_PREREQ (2, 91)
105
# define __CPU_ZERO_S(setsize, cpusetp) \
106
do __builtin_memset (cpusetp, '\0', setsize); while (0)
108
# define __CPU_ZERO_S(setsize, cpusetp) \
111
size_t __imax = (setsize) / sizeof (__cpu_mask); \
112
__cpu_mask *__bits = (cpusetp)->__bits; \
113
for (__i = 0; __i < __imax; ++__i) \
117
# define __CPU_SET_S(cpu, setsize, cpusetp) \
119
({ size_t __cpu = (cpu); \
120
__cpu < 8 * (setsize) \
121
? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
122
|= __CPUMASK (__cpu)) \
124
# define __CPU_CLR_S(cpu, setsize, cpusetp) \
126
({ size_t __cpu = (cpu); \
127
__cpu < 8 * (setsize) \
128
? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
129
&= ~__CPUMASK (__cpu)) \
131
# define __CPU_ISSET_S(cpu, setsize, cpusetp) \
133
({ size_t __cpu = (cpu); \
134
__cpu < 8 * (setsize) \
135
? ((((__const __cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
136
& __CPUMASK (__cpu))) != 0 \
139
# define __CPU_COUNT_S(setsize, cpusetp) \
140
__sched_cpucount (setsize, cpusetp)
142
# if __GNUC_PREREQ (2, 91)
143
# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
144
(__builtin_memcmp (cpusetp1, cpusetp2, setsize) == 0)
146
# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
148
({ __const __cpu_mask *__arr1 = (cpusetp1)->__bits; \
149
__const __cpu_mask *__arr2 = (cpusetp2)->__bits; \
150
size_t __imax = (setsize) / sizeof (__cpu_mask); \
152
for (__i = 0; __i < __imax; ++__i) \
153
if (__bits[__i] != __bits[__i]) \
158
# define __CPU_OP_S(setsize, destset, srcset1, srcset2, op) \
160
({ cpu_set_t *__dest = (destset); \
161
__const __cpu_mask *__arr1 = (srcset1)->__bits; \
162
__const __cpu_mask *__arr2 = (srcset2)->__bits; \
163
size_t __imax = (setsize) / sizeof (__cpu_mask); \
165
for (__i = 0; __i < __imax; ++__i) \
166
((__cpu_mask *) __dest->__bits)[__i] = __arr1[__i] op __arr2[__i]; \
169
# define __CPU_ALLOC_SIZE(count) \
170
((((count) + __NCPUBITS - 1) / __NCPUBITS) * sizeof (__cpu_mask))
171
# define __CPU_ALLOC(count) __sched_cpualloc (count)
172
# define __CPU_FREE(cpuset) __sched_cpufree (cpuset)
176
extern int __sched_cpucount (size_t __setsize, const cpu_set_t *__setp)
178
extern cpu_set_t *__sched_cpualloc (size_t __count) __THROW __wur;
179
extern void __sched_cpufree (cpu_set_t *__set) __THROW;