| To: | Stanislav Kholmanskikh <stanislav.kholmanskikh@xxxxxxxxxx> |
|---|---|
| Subject: | Re: [PATCH V2] xfstests: src/feature.c: print a number of online CPUs |
| From: | Dave Chinner <david@xxxxxxxxxxxxx> |
| Date: | Tue, 29 Oct 2013 09:15:40 +1100 |
| Cc: | xfs@xxxxxxxxxxx, vasily.isaenko@xxxxxxxxxx |
| Delivered-to: | xfs@xxxxxxxxxxx |
| In-reply-to: | <1382616640-23894-1-git-send-email-stanislav.kholmanskikh@xxxxxxxxxx> |
| References: | <20131024104042.GT2797@dastard> <1382616640-23894-1-git-send-email-stanislav.kholmanskikh@xxxxxxxxxx> |
| User-agent: | Mutt/1.5.21 (2010-09-15) |
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@xxxxxxxxxx>
> ---
....
> + 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@xxxxxxxxxxxxx
|
| Previous by Date: | [patch 3/3] xfstests: btrfs/023,024,025: test feature ioctl and sysfs interfaces, Jeff Mahoney |
|---|---|
| Next by Date: | I HAVE SOME MONEY TO DONATE TO THE CHARITY, CHARITY DONATION |
| Previous by Thread: | [PATCH V2] xfstests: src/feature.c: print a number of online CPUs, Stanislav Kholmanskikh |
| Next by Thread: | [PATCH V3] xfstests: src/feature.c: print a number of online CPUs, Stanislav Kholmanskikh |
| Indexes: | [Date] [Thread] [Top] [All Lists] |