1 /* 2 * Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License as 6 * published by the Free Software Foundation; either version 2 of 7 * the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it would be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 /* 19 * Some old libcs (like glibc < 2.7) do not provide interfaces for 20 * dynamically sized cpu sets, but provide only static cpu_set_t type 21 * with no more than CPU_SETSIZE cpus in it. 22 * 23 * This file is a wrapper of the dynamic interfaces using the static ones. 24 * 25 * If the number of cpus available on the system is greater than 26 * CPU_SETSIZE, this interface will not work. Update libc in this case :) 27 */ 28 29 #define _GNU_SOURCE 30 #include <sched.h> 31 32 #ifndef LTP_CPUSET_H 33 #define LTP_CPUSET_H 34 35 #ifndef CPU_ALLOC 36 #define CPU_ALLOC(ncpus) malloc(sizeof(cpu_set_t)); \ 37 if (ncpus > CPU_SETSIZE) { \ 38 tst_brkm(TCONF, cleanup, \ 39 "Your libc does not support masks with %ld cpus", ncpus); \ 40 } 41 #endif 42 43 #ifndef CPU_FREE 44 #define CPU_FREE(ptr) free(ptr) 45 #endif 46 47 #ifndef CPU_ALLOC_SIZE 48 #define CPU_ALLOC_SIZE(size) sizeof(cpu_set_t) 49 #endif 50 51 #ifndef CPU_ZERO_S 52 #define CPU_ZERO_S(size, mask) CPU_ZERO(mask) 53 #endif 54 55 #ifndef CPU_SET_S 56 #define CPU_SET_S(cpu, size, mask) CPU_SET(cpu, mask) 57 #endif 58 59 #ifndef CPU_ISSET_S 60 #define CPU_ISSET_S(cpu, size, mask) CPU_ISSET(cpu, mask) 61 #endif 62 63 #endif /* LTP_CPUSET_H */ 64