|
Packit |
6c4009 |
/* Definition of the cpu_set_t structure used by the POSIX 1003.1b-1993
|
|
Packit |
6c4009 |
scheduling interface.
|
|
Packit |
6c4009 |
Copyright (C) 1996-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifndef _BITS_CPU_SET_H
|
|
Packit |
6c4009 |
#define _BITS_CPU_SET_H 1
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifndef _SCHED_H
|
|
Packit |
6c4009 |
# error "Never include <bits/cpu-set.h> directly; use <sched.h> instead."
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Size definition for CPU sets. */
|
|
Packit |
6c4009 |
#define __CPU_SETSIZE 1024
|
|
Packit |
6c4009 |
#define __NCPUBITS (8 * sizeof (__cpu_mask))
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Type for array elements in 'cpu_set_t'. */
|
|
Packit |
6c4009 |
typedef __CPU_MASK_TYPE __cpu_mask;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Basic access functions. */
|
|
Packit |
6c4009 |
#define __CPUELT(cpu) ((cpu) / __NCPUBITS)
|
|
Packit |
6c4009 |
#define __CPUMASK(cpu) ((__cpu_mask) 1 << ((cpu) % __NCPUBITS))
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Data structure to describe CPU mask. */
|
|
Packit |
6c4009 |
typedef struct
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
__cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS];
|
|
Packit |
6c4009 |
} cpu_set_t;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Access functions for CPU masks. */
|
|
Packit |
6c4009 |
#if __GNUC_PREREQ (2, 91)
|
|
Packit |
6c4009 |
# define __CPU_ZERO_S(setsize, cpusetp) \
|
|
Packit |
6c4009 |
do __builtin_memset (cpusetp, '\0', setsize); while (0)
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
# define __CPU_ZERO_S(setsize, cpusetp) \
|
|
Packit |
6c4009 |
do { \
|
|
Packit |
6c4009 |
size_t __i; \
|
|
Packit |
6c4009 |
size_t __imax = (setsize) / sizeof (__cpu_mask); \
|
|
Packit |
6c4009 |
__cpu_mask *__bits = (cpusetp)->__bits; \
|
|
Packit |
6c4009 |
for (__i = 0; __i < __imax; ++__i) \
|
|
Packit |
6c4009 |
__bits[__i] = 0; \
|
|
Packit |
6c4009 |
} while (0)
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
#define __CPU_SET_S(cpu, setsize, cpusetp) \
|
|
Packit |
6c4009 |
(__extension__ \
|
|
Packit |
6c4009 |
({ size_t __cpu = (cpu); \
|
|
Packit |
6c4009 |
__cpu / 8 < (setsize) \
|
|
Packit |
6c4009 |
? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
|
|
Packit |
6c4009 |
|= __CPUMASK (__cpu)) \
|
|
Packit |
6c4009 |
: 0; }))
|
|
Packit |
6c4009 |
#define __CPU_CLR_S(cpu, setsize, cpusetp) \
|
|
Packit |
6c4009 |
(__extension__ \
|
|
Packit |
6c4009 |
({ size_t __cpu = (cpu); \
|
|
Packit |
6c4009 |
__cpu / 8 < (setsize) \
|
|
Packit |
6c4009 |
? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
|
|
Packit |
6c4009 |
&= ~__CPUMASK (__cpu)) \
|
|
Packit |
6c4009 |
: 0; }))
|
|
Packit |
6c4009 |
#define __CPU_ISSET_S(cpu, setsize, cpusetp) \
|
|
Packit |
6c4009 |
(__extension__ \
|
|
Packit |
6c4009 |
({ size_t __cpu = (cpu); \
|
|
Packit |
6c4009 |
__cpu / 8 < (setsize) \
|
|
Packit |
6c4009 |
? ((((const __cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
|
|
Packit |
6c4009 |
& __CPUMASK (__cpu))) != 0 \
|
|
Packit |
6c4009 |
: 0; }))
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define __CPU_COUNT_S(setsize, cpusetp) \
|
|
Packit |
6c4009 |
__sched_cpucount (setsize, cpusetp)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#if __GNUC_PREREQ (2, 91)
|
|
Packit |
6c4009 |
# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
|
|
Packit |
6c4009 |
(__builtin_memcmp (cpusetp1, cpusetp2, setsize) == 0)
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
|
|
Packit |
6c4009 |
(__extension__ \
|
|
Packit |
6c4009 |
({ const __cpu_mask *__arr1 = (cpusetp1)->__bits; \
|
|
Packit |
6c4009 |
const __cpu_mask *__arr2 = (cpusetp2)->__bits; \
|
|
Packit |
6c4009 |
size_t __imax = (setsize) / sizeof (__cpu_mask); \
|
|
Packit |
6c4009 |
size_t __i; \
|
|
Packit |
6c4009 |
for (__i = 0; __i < __imax; ++__i) \
|
|
Packit |
6c4009 |
if (__arr1[__i] != __arr2[__i]) \
|
|
Packit |
6c4009 |
break; \
|
|
Packit |
6c4009 |
__i == __imax; }))
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define __CPU_OP_S(setsize, destset, srcset1, srcset2, op) \
|
|
Packit |
6c4009 |
(__extension__ \
|
|
Packit |
6c4009 |
({ cpu_set_t *__dest = (destset); \
|
|
Packit |
6c4009 |
const __cpu_mask *__arr1 = (srcset1)->__bits; \
|
|
Packit |
6c4009 |
const __cpu_mask *__arr2 = (srcset2)->__bits; \
|
|
Packit |
6c4009 |
size_t __imax = (setsize) / sizeof (__cpu_mask); \
|
|
Packit |
6c4009 |
size_t __i; \
|
|
Packit |
6c4009 |
for (__i = 0; __i < __imax; ++__i) \
|
|
Packit |
6c4009 |
((__cpu_mask *) __dest->__bits)[__i] = __arr1[__i] op __arr2[__i]; \
|
|
Packit |
6c4009 |
__dest; }))
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define __CPU_ALLOC_SIZE(count) \
|
|
Packit |
6c4009 |
((((count) + __NCPUBITS - 1) / __NCPUBITS) * sizeof (__cpu_mask))
|
|
Packit |
6c4009 |
#define __CPU_ALLOC(count) __sched_cpualloc (count)
|
|
Packit |
6c4009 |
#define __CPU_FREE(cpuset) __sched_cpufree (cpuset)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
__BEGIN_DECLS
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
extern int __sched_cpucount (size_t __setsize, const cpu_set_t *__setp)
|
|
Packit |
6c4009 |
__THROW;
|
|
Packit |
6c4009 |
extern cpu_set_t *__sched_cpualloc (size_t __count) __THROW __wur;
|
|
Packit |
6c4009 |
extern void __sched_cpufree (cpu_set_t *__set) __THROW;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
__END_DECLS
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#endif /* bits/cpu-set.h */
|