Created attachment 30970 [details] example code When a java program compiled with gcj asks how many processing units are in the system, it always returns 1. folkert@belle:~$ cat test2.java class test2 { public static void main(String [] args) { System.out.println("" + Runtime.getRuntime().availableProcessors()); } } folkert@belle:~$ javac test2.java folkert@belle:~$ java test2 12 folkert@belle:~$ gcj --main=test2 test2.java folkert@belle:~$ ./a.out 1
jint java::lang::Runtime::availableProcessors (void) { // FIXME: find the real value. return 1; } :)
This is easily fixed with sysconf(_SC_NPROCESSORS_ONLN);
Did some googling and with appropriate #ifdefs it should be at least on linux possible to retrieve this value: sysconf(_SC_NPROCESSORS_ONLN); If that function can't figure it out, it will return '1' which is somewhat sensible. On http://stackoverflow.com/questions/150355/programmatically-find-the-number-of-cores-on-a-machine I found a whole list of implementations for windows, *bsd, macos, aix, well I think all relevant platforms. Also http://stackoverflow.com/questions/4586405/get-number-of-cpus-in-linux-using-c gives some ideas. If there's any further help I can do; let me know.
Yes, I just said that above. I'll propose a patch when I get chance.
Thanks for reporting this. I'll let you know when a fix is committed.
http://gcc.gnu.org/ml/java-patches/2013-q4/msg00000.html
Closing as won't fix as the Java front-end has been removed from the trunk.