mbligh | 9f0d48b | 2008-08-25 19:12:54 +0000 | [diff] [blame] | 1 | #include <sched.h> |
| 2 | /* |
| 3 | * if we have an ancient sched.h we need to provide |
| 4 | * definitions for cpu_set_t and associated macros |
| 5 | */ |
| 6 | #if !defined __cpu_set_t_defined |
| 7 | # define __cpu_set_t_defined |
| 8 | /* Size definition for CPU sets. */ |
| 9 | # define __CPU_SETSIZE 1024 |
| 10 | # define __NCPUBITS (8 * sizeof (__cpu_mask)) |
| 11 | |
| 12 | /* Type for array elements in 'cpu_set'. */ |
| 13 | typedef unsigned long int __cpu_mask; |
| 14 | |
| 15 | /* Basic access functions. */ |
| 16 | # define __CPUELT(cpu) ((cpu) / __NCPUBITS) |
| 17 | # define __CPUMASK(cpu) ((__cpu_mask) 1 << ((cpu) % __NCPUBITS)) |
| 18 | |
| 19 | /* Data structure to describe CPU mask. */ |
| 20 | typedef struct |
| 21 | { |
| 22 | __cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS]; |
| 23 | } cpu_set_t; |
| 24 | |
| 25 | /* Access functions for CPU masks. */ |
| 26 | # define __CPU_ZERO(cpusetp) \ |
| 27 | do { \ |
| 28 | unsigned int __i; \ |
| 29 | cpu_set_t *__arr = (cpusetp); \ |
| 30 | for (__i = 0; __i < sizeof (cpu_set_t) / sizeof (__cpu_mask); ++__i) \ |
| 31 | __arr->__bits[__i] = 0; \ |
| 32 | } while (0) |
| 33 | # define __CPU_SET(cpu, cpusetp) \ |
| 34 | ((cpusetp)->__bits[__CPUELT (cpu)] |= __CPUMASK (cpu)) |
| 35 | # define __CPU_CLR(cpu, cpusetp) \ |
| 36 | ((cpusetp)->__bits[__CPUELT (cpu)] &= ~__CPUMASK (cpu)) |
| 37 | # define __CPU_ISSET(cpu, cpusetp) \ |
| 38 | (((cpusetp)->__bits[__CPUELT (cpu)] & __CPUMASK (cpu)) != 0) |
| 39 | |
| 40 | /* Access macros for `cpu_set'. */ |
| 41 | #define CPU_SETSIZE __CPU_SETSIZE |
| 42 | #define CPU_SET(cpu, cpusetp) __CPU_SET (cpu, cpusetp) |
| 43 | #define CPU_CLR(cpu, cpusetp) __CPU_CLR (cpu, cpusetp) |
| 44 | #define CPU_ISSET(cpu, cpusetp) __CPU_ISSET (cpu, cpusetp) |
| 45 | #define CPU_ZERO(cpusetp) __CPU_ZERO (cpusetp) |
| 46 | |
| 47 | #endif |