Wanlong Gao | 3b535a8 | 2012-10-18 16:35:14 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 Fujitsu Ltd. |
| 3 | * Author: Wanlong Gao <gaowanlong@cn.fujitsu.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
| 13 | * the GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
Wanlong Gao | 4548c6c | 2012-10-19 18:03:36 +0800 | [diff] [blame] | 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
Wanlong Gao | 3b535a8 | 2012-10-18 16:35:14 +0800 | [diff] [blame] | 18 | */ |
| 19 | |
| 20 | #include <stdlib.h> |
| 21 | #include <unistd.h> |
| 22 | #include "test.h" |
| 23 | #include "safe_macros.h" |
| 24 | |
| 25 | long tst_ncpus(void) |
| 26 | { |
| 27 | long ncpus = -1; |
| 28 | #ifdef _SC_NPROCESSORS_ONLN |
| 29 | ncpus = SAFE_SYSCONF(NULL, _SC_NPROCESSORS_ONLN); |
| 30 | #else |
| 31 | tst_brkm(TBROK, NULL, "could not determine number of CPUs online"); |
| 32 | #endif |
| 33 | return ncpus; |
| 34 | } |
| 35 | |
| 36 | long tst_ncpus_max(void) |
| 37 | { |
| 38 | long ncpus_max = -1; |
| 39 | #ifdef _SC_NPROCESSORS_CONF |
| 40 | ncpus_max = SAFE_SYSCONF(NULL, _SC_NPROCESSORS_CONF); |
| 41 | #else |
| 42 | tst_brkm(TBROK, NULL, "could not determine number of CPUs configured"); |
| 43 | #endif |
| 44 | return ncpus_max; |
| 45 | } |