autoconf
[Top][All Lists]
Advanced

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

Re: number of processors


From: Philipp Gortan
Subject: Re: number of processors
Date: Thu, 29 Aug 2002 08:46:34 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Eric Siegerman wrote:
|>I'd suggest the following C code be used:
|>
|>#include <unistd.h>
|>#include <stdio.h>
|>#include <stdlib.h>
|>
|>int main() {
|>  long nprocs;
|>  nprocs = sysconf(_SC_NPROCESSORS_ONLN);
|>  if (nprocs < 1)
|>    nprocs = 1;
|
|
| Rather:
|     if (nprocs == -1)         /* Value unavailable */
|       exit(EXIT_ERROR);
|     else if (nprocs == 0)
|       nprocs = 1;
|
|
|>  printf ("%ld\n",nprocs);
|>  exit (EXIT_SUCCESS);
|>}
|

Hi all,
thanks for all interesting answers. Well, using the sysconf() function
looks like the smoothest way to do the job, even though it's not as
easily nested into autoconf as my dirty hack... how would you add the c
code to the program? can is be easily compiled while configure is
running und its output be used, e.g. via AC_TRY_RUN()?

cu, philipp

- --
+------------------------------------------+
|            Philipp Gortan                |
+------------+-----------------------------+
| department | PSE KB B1                   |
+------------+-----------------------------+
|            | Siemens AG                  |
|    address | Gudrunstr. 11               |
|            | A-1100 Vienna               |
+------------+-----------------------------+
|       mail | <address@hidden> |
+------------+-----------------------------+
|      phone | +43/5/1707-45887            |
+------------+-----------------------------+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE9bcNB6My5N1RlryQRAoTWAKDHjg/Hjazyu9sN1urXHdt1Q3ZZDwCg50YT
RyI4PgSoHIAx11P3cWFqOrY=
=ONbl
-----END PGP SIGNATURE-----





reply via email to

[Prev in Thread] Current Thread [Next in Thread]