public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
Cc: vasily.isaenko@oracle.com, xfs@oss.sgi.com
Subject: Re: [PATCH V2] xfstests: src/feature.c: print a number of online CPUs
Date: Tue, 29 Oct 2013 09:15:40 +1100	[thread overview]
Message-ID: <20131028221540.GF2797@dastard> (raw)
In-Reply-To: <1382616640-23894-1-git-send-email-stanislav.kholmanskikh@oracle.com>

On Thu, Oct 24, 2013 at 04:10:40PM +0400, Stanislav Kholmanskikh wrote:
> For this purpose we use sysconf() as it is the
> preferred platform neutral interface for getting this
> sort of information.
> 
> Based on Dave Chinner proposal.
> 
> Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
> ---
....
> +	if (oflag) {
> +		long ncpus;
> +
> +#if defined(_SC_NPROCESSORS_ONLN)
> +		/* Linux */
> +		ncpus = sysconf(_SC_NPROCESSORS_ONLN);
> +#elif defined(_SC_NPROC_ONLN)
> +		/* IRIX */
> +		ncpus = sysconf(_SC_NPROC_ONLN);
> +#else
> +		ncpus = 1;
> +#endif
> +		if (ncpus == -1)
> +			ncpus = 1;

That can be simplified, and there's probably not much point in
listing the OS's that the different calls are for.

	if (oflag) {
		long ncpus = -1;

#if defined(_SC_NPROCESSORS_ONLN)
		ncpus = sysconf(_SC_NPROCESSORS_ONLN);
#elif defined(_SC_NPROC_ONLN)
		ncpus = sysconf(_SC_NPROC_ONLN);
#endif
		if (ncpus == -1)
			ncpus = 1;

		....

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2013-10-28 22:15 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-23 11:58 Avoid of using /proc/cpuinfo in generic tests Stanislav Kholmanskikh
2013-10-23 11:58 ` [PATCH 1/2] xfstests: implemented _no_of_online_cpus() function Stanislav Kholmanskikh
2013-10-23 13:08   ` Carlos Maiolino
2013-10-23 21:31   ` Dave Chinner
2013-10-24  8:56     ` [PATCH] xfstests: src/feature.c: print a number of online CPUs Stanislav Kholmanskikh
2013-10-24 10:40       ` Dave Chinner
2013-10-24 12:10         ` [PATCH V2] " Stanislav Kholmanskikh
2013-10-28 22:15           ` Dave Chinner [this message]
2013-10-29 10:03             ` [PATCH V3] " Stanislav Kholmanskikh
2013-11-05 12:41               ` Stanislav Kholmanskikh
2013-11-10  1:19               ` Rich Johnston
2013-11-10  1:20               ` Rich Johnston
2013-10-24 13:18         ` [PATCH] " Carlos Maiolino
2013-10-24 14:33           ` Stanislav Kholmanskikh
2013-10-24 21:23           ` Dave Chinner
2013-10-28  7:23             ` Stanislav Kholmanskikh
2013-10-28 12:23               ` Carlos Maiolino
2013-10-23 11:58 ` [PATCH 2/2] xfstests: generic/273: do not use /proc/cpuinfo Stanislav Kholmanskikh
2013-10-23 13:09   ` Carlos Maiolino
2013-10-24  0:14   ` Rich Johnston
2013-10-24  1:09     ` Dave Chinner
2013-11-11  9:34       ` [PATCH] xfstests: generic/273: use src/feature -o Stanislav Kholmanskikh
2013-11-11 11:10         ` Jeff Liu
2013-11-11 16:05         ` Rich Johnston
2013-11-11 16:06           ` Rich Johnston
2013-11-11 14:50       ` [PATCH 2/2] xfstests: generic/273: do not use /proc/cpuinfo Rich Johnston

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131028221540.GF2797@dastard \
    --to=david@fromorbit.com \
    --cc=stanislav.kholmanskikh@oracle.com \
    --cc=vasily.isaenko@oracle.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox