Re: [PATCH] core-count: A new program to count the number of cpu cores (original) (raw)

[Top][All Lists]


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Jim Meyering
Subject: Re: [PATCH] core-count: A new program to count the number of cpu cores
Date: Sat, 31 Oct 2009 18:34:34 +0100

Giuseppe Scrivano wrote:

I included what we have discussed into my patch. I renamed the new program to `nproc', now it accepts two options: --available and --installed. By default --available is used, if --available is not know then --installed is used.

I added another test to ensure nproc --available <= nproc --installed.

Any comment?

Sure. That didn't apply via "git am FILE", so I applied via patch. Please rebase against latest, before posting.

Here's a quick and superficial review.

A few changes were required for "make syntax-check" and ./configure --enable-gcc-warnings:

...

+void +usage (int status) +{ + if (status != EXITSUCCESS) + fprintf (stderr, ("Try `%s --help' for more information.\n"), + programname); + else + { + printf (("Usage: %s [OPTION]...\n"), programname); _+ fputs (("_ _+Print the number of online cpu cores.\n_ _+\n_ +"), stdout); _+ fputs (("_ + --available report the number of processors available to _the\n _

s/report/print/

_+ current process.\n _ _+ --installed return the number of installed processors\n_

s/return/print/

+"), stdout); + + fputs (HELPOPTIONDESCRIPTION, stdout); + fputs (VERSIONOPTIONDESCRIPTION, stdout); + emitancillaryinfo (); + } + exit (status); +} + +/* Compute the number of available processors. Return 0 on error. */ + +static ulong

u_long? No thanks. There are no other uses of that type in the coreutils.

This first was for a syntax-check violation.

diff --git a/README b/README index 7545eab..0951b62 100644 --- a/README +++ b/README @@ -11,7 +11,7 @@ The programs that can be built with this package are: csplit cut date dd df dir dircolors dirname du echo env expand expr factor false fmt fold groups head hostid hostname id install join kill link ln logname ls md5sum mkdir mkfifo mknod mktemp mv nice nl nohup

/* Compute the number of available processors. Return 0 on error. */

-static u_long -nproc_available () +static unsigned long +nproc_available (void) {

#ifdef CPU_SETSIZE size_t j; @@ -100,12 +100,12 @@ nproc_available () can't be computed rollback to the installed processors. The result is guaranteed to be at least 1. */

-static u_long +static unsigned long nproc (bool available) { if (available) {

}