Discussion:
[PATCH] PR58669: does not detect all cpu cores/threads
Andrew
2013-10-18 01:15:42 UTC
Permalink
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58669

Testing:

$ /usr/lib/jvm/icedtea-6/bin/java TestProcessors
Processors: 8

$ /usr/lib/jvm/gcj-jdk/bin/java -version
java version "1.5.0"
gij (GNU libgcj) version 4.8.1
$ /usr/lib/jvm/gcj-jdk/bin/java TestProcessors
Processors: 1

$ /home/andrew/build/gcj/bin/gij -version
java version "1.5.0"
gij (GNU libgcj) version 4.9.0 20131013 (experimental) [trunk revision 203508]
$ /home/andrew/build/gcj/bin/gij TestProcessors
Processors: 8

ChangeLog:

2013-10-12 Andrew John Hughes <***@member.fsf.org>

* java/lang/natRuntime.cc:
(availableProcessors()): Implement.
Fixes PR gcc/58669.

Ok for trunk and 4.8?
--
Andrew :)

Free Java Software Engineer
Red Hat, Inc. (http://www.redhat.com)

PGP Key: 248BDC07 (https://keys.indymedia.org/)
Fingerprint = EC5A 1F5E C0AD 1D15 8F1F 8F91 3B96 A578 248B DC07
Tom Tromey
2013-10-18 02:27:20 UTC
Permalink
Andrew> +#ifdef HAVE_UNISTD_H
Andrew> + procs = sysconf(_SC_NPROCESSORS_ONLN);
Andrew> +#endif

Space before the "(".

Technically you should probably check for sysconf in configure.ac.
I'm not sure whether it matters any more.

I think _SC_NPROCESSORS_ONLN is not portable though.

Tom
Andïï
2013-10-18 15:41:48 UTC
Permalink
Post by Tom Tromey
Andrew> +#ifdef HAVE_UNISTD_H
Andrew> + procs = sysconf(_SC_NPROCESSORS_ONLN);
Andrew> +#endif
Space before the "(".
Technically you should probably check for sysconf in configure.ac.
I'm not sure whether it matters any more.
I think _SC_NPROCESSORS_ONLN is not portable though.
Tom
I can add an #ifdef _SC_NPROCESSORS_ONLN around it too.
Is that enough to imply we have sysconf too?
--
Andii :-)
Loading...