public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew <gnu_andrew@member.fsf.org>
To: java-patches@gcc.gnu.org
Cc: gcc-patches@gcc.gnu.org
Subject: [PATCH] PR58669: does not detect all cpu cores/threads
Date: Fri, 18 Oct 2013 01:16:00 -0000	[thread overview]
Message-ID: <20131018011541.GA29495@carrie.the212.com> (raw)


[-- 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 --]

             reply	other threads:[~2013-10-18  1:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-18  1:16 Andrew [this message]
2013-10-18  2:27 ` Tom Tromey
2013-10-18 15:42   ` Andïï

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=20131018011541.GA29495@carrie.the212.com \
    --to=gnu_andrew@member.fsf.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=java-patches@gcc.gnu.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).