* [PATCH] PR58669: does not detect all cpu cores/threads
@ 2013-10-18 1:16 Andrew
2013-10-18 2:27 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Andrew @ 2013-10-18 1:16 UTC (permalink / raw)
To: java-patches; +Cc: gcc-patches
[-- Attachment #1.1: Type: text/plain, Size: 898 bytes --]
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 <gnu.andrew@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
[-- Attachment #1.2: pr58669.patch --]
[-- Type: text/x-diff, Size: 667 bytes --]
Index: libjava/java/lang/natRuntime.cc
===================================================================
--- libjava/java/lang/natRuntime.cc (revision 203508)
+++ libjava/java/lang/natRuntime.cc (working copy)
@@ -48,6 +48,10 @@
#include <langinfo.h>
#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
\f
#ifdef USE_LTDL
@@ -303,8 +307,15 @@
jint
java::lang::Runtime::availableProcessors (void)
{
- // FIXME: find the real value.
- return 1;
+ long procs = -1;
+
+#ifdef HAVE_UNISTD_H
+ procs = sysconf(_SC_NPROCESSORS_ONLN);
+#endif
+
+ if (procs == -1)
+ return 1;
+ return (jint) procs;
}
jstring
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] PR58669: does not detect all cpu cores/threads
2013-10-18 1:16 [PATCH] PR58669: does not detect all cpu cores/threads Andrew
@ 2013-10-18 2:27 ` Tom Tromey
2013-10-18 15:42 ` Andïï
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2013-10-18 2:27 UTC (permalink / raw)
To: Andrew; +Cc: java-patches, gcc-patches
>>>>> "Andrew" == Andrew <gnu_andrew@member.fsf.org> writes:
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] PR58669: does not detect all cpu cores/threads
2013-10-18 2:27 ` Tom Tromey
@ 2013-10-18 15:42 ` Andïï
0 siblings, 0 replies; 3+ messages in thread
From: Andïï @ 2013-10-18 15:42 UTC (permalink / raw)
To: Tom Tromey; +Cc: Java Patch List, gcc-patches
On 18 October 2013 03:27, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Andrew" == Andrew <gnu_andrew@member.fsf.org> writes:
>
> 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 :-)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-10-18 15:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-18 1:16 [PATCH] PR58669: does not detect all cpu cores/threads Andrew
2013-10-18 2:27 ` Tom Tromey
2013-10-18 15:42 ` Andïï
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).