Author: cfinck Date: Mon Nov 5 13:46:50 2007 New Revision: 30158
URL: http://svn.reactos.org/svn/reactos?rev=30158&view=rev Log: Import the additional parameters from RosBE-Windows' cpucount into the Unix version
Modified: trunk/tools/RosBE-Unix/tools/cpucount.c
Modified: trunk/tools/RosBE-Unix/tools/cpucount.c URL: http://svn.reactos.org/svn/reactos/trunk/tools/RosBE-Unix/tools/cpucount.c?r... ============================================================================== --- trunk/tools/RosBE-Unix/tools/cpucount.c (original) +++ trunk/tools/RosBE-Unix/tools/cpucount.c Mon Nov 5 13:46:50 2007 @@ -5,27 +5,51 @@ Released under GNU GPL v2 or any later version. */
-#include <stdio.h> -#include <unistd.h> -#ifdef __APPLE__ -#include <sys/sysctl.h> -#endif - -int -main(int argc, - char *argv[]) +#include <stdio.h> +#include <unistd.h> +#ifdef __APPLE__ +#include <sys/sysctl.h> +#endif + +int main(int argc, char *argv[]) { int cpuCount = 0; - -#ifdef __APPLE__ - size_t countSize = sizeof(cpuCount); - - sysctlbyname("hw.logicalcpu", &cpuCount, &countSize, NULL, 0); -#else - cpuCount = sysconf(_SC_NPROCESSORS_ONLN); -#endif - - printf( "%u\n", cpuCount); - - return 0; + + if(argc > 2) + { + fprintf(stderr, "%s: Error too many parameters specified.\n", argv[0]); + return -1; + } + +#ifdef __APPLE__ + size_t countSize = sizeof(cpuCount); + + sysctlbyname("hw.logicalcpu", &cpuCount, &countSize, NULL, 0); +#else + cpuCount = sysconf(_SC_NPROCESSORS_ONLN); +#endif + + if(argc != 1) + { + if(!strncmp(argv[1], "-x1", 3)) + { + cpuCount++; + } + else if(!strncmp(argv[1], "-x2", 3)) + { + cpuCount += cpuCount; + } + else + { + printf("Usage: %s [OPTIONS]\n", argv[0]); + printf("Running cpucount without options returns the number of\n"); + printf("processors in the system.\n"); + printf("-x1 - Number of processors in the system, plus 1.\n"); + printf("-x2 - Number of processors in the system, doubled.\n"); + return 0; + } + } + + printf("%u\n", cpuCount); + return 0; }