On 10/17/2012 09:00 PM, [email protected] wrote: > Hi! >> lib/tst_cpu.c | 50 >> +++++++++++++++++++++++++++++++++++++++++++++++ > > Hmm, aren't you missing header for tst_ncpus() and tst_ncpus_max()?
Oops, thank you. > >> +/* >> + * Copyright (c) 2012 Fujitsu Ltd. >> + * Author: Wanlong Gao <[email protected]> >> + * >> + * This program is free software; you can redistribute it and/or modify >> + * it under the terms of the GNU General Public License as published by >> + * the Free Software Foundation; either version 2 of the License, or >> + * (at your option) any later version. >> + * >> + * This program is distributed in the hope that it will be useful, >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See >> + * the GNU General Public License for more details. >> + * >> + * You should have received a copy of the GNU General Public License >> + * along with this program; if not, write to the Free Software >> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA >> + */ >> + >> +#include <stdlib.h> >> +#include <unistd.h> >> +#include "test.h" >> + >> +long tst_ncpus(void) >> +{ >> + long ncpus = -1; >> +#ifdef _SC_NPROCESSORS_ONLN >> + ncpus = sysconf(_SC_NPROCESSORS_ONLN); >> + if (ncpus < 1) >> + tst_brkm(TBROK|TERRNO, NULL, >> + "failed to determine number of CPUs online"); >> +#else >> + tst_brkm(TBROK, NULL, "could not determine number of CPUs online"); >> +#endif >> + return ncpus; >> +} >> + >> +long tst_ncpus_max(void) >> +{ >> +#ifdef _SC_NPROCESSORS_CONF >> + long ncpus_max = -1; >> + ncpus_max = sysconf(_SC_NPROCESSORS_CONF); >> + if (ncpus_max < 1) >> + tst_brkm(TBROK|TERRNO, NULL, >> + "failed to determine number of CPUs configured"); >> +#else >> + tst_brkm(TBROK, NULL, "could not determine number of CPUs configured"); >> +#endif >> + return ncpus_max; >> +} > > Looking at the code makes me wonder if creating SAFE_SYSCONF() wouldn't > be more universal solution. OK, I defer to this. Will send V2. Thanks, Wanlong Gao > >> diff --git a/tools/apicmds/Makefile b/tools/apicmds/Makefile >> index 59ce6be..faa49b5 100644 >> --- a/tools/apicmds/Makefile >> +++ b/tools/apicmds/Makefile >> @@ -26,7 +26,8 @@ include $(top_srcdir)/include/mk/testcases.mk >> >> CPPFLAGS += -D_GNU_SOURCE >> >> -MAKE_TARGETS := $(addprefix tst_,brk brkm exit flush kvercmp >> res resm) >> +MAKE_TARGETS := $(addprefix tst_,brk brkm exit flush kvercmp >> res resm \ >> + ncpus ncpus_max) >> >> include $(top_srcdir)/include/mk/generic_leaf_target.mk >> >> diff --git a/tools/apicmds/ltpapicmd.c b/tools/apicmds/ltpapicmd.c >> index fe7349b..a1ddb5c 100644 >> --- a/tools/apicmds/ltpapicmd.c >> +++ b/tools/apicmds/ltpapicmd.c >> @@ -266,6 +266,12 @@ int main(int argc, char *argv[]) >> else if (exit_value > 0) >> exit_value = 2; >> exit(exit_value); >> + } else if (strcmp(cmd_name, "tst_ncpus") == 0) { >> + long exit_ncpus = tst_ncpus(); >> + exit(exit_ncpus); >> + } else if (strcmp(cmd_name, "tst_ncpus_max") == 0) { >> + long exit_ncpus_max = tst_ncpus_max(); >> + exit(exit_ncpus_max); >> } > > That part looks okay. > ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_sfd2d_oct _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
