[kaffe] CVS kaffe (robilad): Merged in availableProcessors implementation from CACAO and added glibc support
Kaffe CVS
cvs-commits at kaffe.org
Wed Sep 14 20:41:00 PDT 2005
PatchSet 6903
Date: 2005/09/15 03:35:37
Author: robilad
Branch: HEAD
Tag: (none)
Log:
Merged in availableProcessors implementation from CACAO and added glibc support
2005-09-15 Dalibor Topic <robilad at kaffe.org>
* libraries/clib/native/VMRuntime.c:
New file. Taken from CACAO, and improved the
availableProcessors implementation.
Licensed under the GPL.
* THIRDPARTY: Updated to reflect CACAO code.
Members:
ChangeLog:1.4424->1.4425
THIRDPARTY:1.36->1.37
configure:1.484->1.485
configure.ac:1.166->1.167
config/config.h.in:1.151->1.152
libraries/clib/native/Makefile.am:1.48->1.49
libraries/clib/native/Makefile.in:1.189->1.190
libraries/clib/native/Runtime.c:1.37->1.38
libraries/clib/native/VMRuntime.c:INITIAL->1.1
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4424 kaffe/ChangeLog:1.4425
--- kaffe/ChangeLog:1.4424 Thu Sep 15 02:25:31 2005
+++ kaffe/ChangeLog Thu Sep 15 03:35:37 2005
@@ -1,5 +1,14 @@
2005-09-15 Dalibor Topic <robilad at kaffe.org>
+ * libraries/clib/native/VMRuntime.c:
+ New file. Taken from CACAO, and improved the
+ availableProcessors implementation.
+ Licensed under the GPL.
+
+ * THIRDPARTY: Updated to reflect CACAO code.
+
+2005-09-15 Dalibor Topic <robilad at kaffe.org>
+
Resynced with GNU Classpath.
2005-09-14 Roman Kennke <kennke at aicas.com>
Index: kaffe/THIRDPARTY
diff -u kaffe/THIRDPARTY:1.36 kaffe/THIRDPARTY:1.37
--- kaffe/THIRDPARTY:1.36 Thu Jul 7 00:37:58 2005
+++ kaffe/THIRDPARTY Thu Sep 15 03:35:40 2005
@@ -761,3 +761,26 @@
shall not be used in advertising or otherwise to promote the sale, use
or other dealings in these Data Files or Software without prior
written authorization of the copyright holder.
+
+* libraries/clib/native/VMRuntime.c
+
+ This file comes from CACAO. More information on CACAO is available from
+ http://www.cacaojvm.org. Kaffe tracks this file's CVS HEAD.
+
+ This file is distributed under the following terms:
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+
Index: kaffe/configure
diff -u kaffe/configure:1.484 kaffe/configure:1.485
--- kaffe/configure:1.484 Fri Sep 9 15:54:18 2005
+++ kaffe/configure Thu Sep 15 03:35:40 2005
@@ -30060,6 +30060,7 @@
+
for ac_header in stdarg.h \
alloca.h \
bsd/libc.h \
@@ -30072,6 +30073,7 @@
jpeglib.h \
kernel/OS.h \
limits.h \
+mach/mach.h \
mach-o/rld.h \
malloc.h \
memory.h \
@@ -30096,16 +30098,16 @@
sys/param.h \
sys/poll.h \
sys/select.h \
+sys/signal.h \
sys/socket.h \
+sys/sockio.h \
sys/stat.h \
+sys/sysctl.h \
+sys/sysinfo.h \
sys/time.h \
sys/types.h \
sys/utsname.h \
-sys/sysctl.h \
-sys/param.h \
-sys/signal.h \
sys/ucontext.h \
-sys/sockio.h \
syslog.h \
time.h \
unistd.h \
@@ -38653,7 +38655,8 @@
done
-for ac_func in localtime
+
+for ac_func in localtime get_nprocs_conf
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
Index: kaffe/configure.ac
diff -u kaffe/configure.ac:1.166 kaffe/configure.ac:1.167
--- kaffe/configure.ac:1.166 Fri Sep 9 15:54:24 2005
+++ kaffe/configure.ac Thu Sep 15 03:35:47 2005
@@ -1017,6 +1017,7 @@
jpeglib.h \
kernel/OS.h \
limits.h \
+mach/mach.h \
mach-o/rld.h \
malloc.h \
memory.h \
@@ -1041,16 +1042,16 @@
sys/param.h \
sys/poll.h \
sys/select.h \
+sys/signal.h \
sys/socket.h \
+sys/sockio.h \
sys/stat.h \
+sys/sysctl.h \
+sys/sysinfo.h \
sys/time.h \
sys/types.h \
sys/utsname.h \
-sys/sysctl.h \
-sys/param.h \
-sys/signal.h \
sys/ucontext.h \
-sys/sockio.h \
syslog.h \
time.h \
unistd.h \
@@ -1352,7 +1353,7 @@
AC_CHECK_FUNCS([memcpy memmove])
AC_CHECK_FUNCS([mkdir rmdir])
AC_CHECK_FUNCS([getcwd chdir getwd gettimeofday ftime time uname getuid])
-AC_CHECK_FUNCS([localtime])
+AC_CHECK_FUNCS([localtime get_nprocs_conf])
AC_CHECK_FUNCS([munmap mincore msync madvise getpagesize sysconf])
AM_ICONV
Index: kaffe/config/config.h.in
diff -u kaffe/config/config.h.in:1.151 kaffe/config/config.h.in:1.152
--- kaffe/config/config.h.in:1.151 Sun Aug 21 18:01:01 2005
+++ kaffe/config/config.h.in Thu Sep 15 03:35:48 2005
@@ -186,6 +186,9 @@
/* Define to 1 if you have the `getwd' function. */
#undef HAVE_GETWD
+/* Define to 1 if you have the `get_nprocs_conf' function. */
+#undef HAVE_GET_NPROCS_CONF
+
/* Do we have the right version of libungif */
#undef HAVE_GIF_LIB_H
@@ -317,6 +320,9 @@
/* Define to 1 if you have the `localtime' function. */
#undef HAVE_LOCALTIME
+/* Define to 1 if you have the <mach/mach.h> header file. */
+#undef HAVE_MACH_MACH_H
+
/* Define to 1 if you have the <mach-o/rld.h> header file. */
#undef HAVE_MACH_O_RLD_H
@@ -636,6 +642,9 @@
/* Define to 1 if you have the <sys/sysctl.h> header file. */
#undef HAVE_SYS_SYSCTL_H
+
+/* Define to 1 if you have the <sys/sysinfo.h> header file. */
+#undef HAVE_SYS_SYSINFO_H
/* Define to 1 if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
Index: kaffe/libraries/clib/native/Makefile.am
diff -u kaffe/libraries/clib/native/Makefile.am:1.48 kaffe/libraries/clib/native/Makefile.am:1.49
--- kaffe/libraries/clib/native/Makefile.am:1.48 Tue Jul 19 01:16:31 2005
+++ kaffe/libraries/clib/native/Makefile.am Thu Sep 15 03:35:49 2005
@@ -30,6 +30,7 @@
ClassLoader.c \
Object.c \
Runtime.c \
+ VMRuntime.c \
String.c \
System.c \
Thread.c \
Index: kaffe/libraries/clib/native/Makefile.in
diff -u kaffe/libraries/clib/native/Makefile.in:1.189 kaffe/libraries/clib/native/Makefile.in:1.190
--- kaffe/libraries/clib/native/Makefile.in:1.189 Thu Aug 25 19:22:02 2005
+++ kaffe/libraries/clib/native/Makefile.in Thu Sep 15 03:35:49 2005
@@ -97,9 +97,10 @@
libnative_la-java_lang_VMProcess.lo \
libnative_la-java_lang_VMSystem.lo libnative_la-Class.lo \
libnative_la-ClassLoader.lo libnative_la-Object.lo \
- libnative_la-Runtime.lo libnative_la-String.lo \
- libnative_la-System.lo libnative_la-Thread.lo \
- libnative_la-Throwable.lo libnative_la-ZipFile.lo
+ libnative_la-Runtime.lo libnative_la-VMRuntime.lo \
+ libnative_la-String.lo libnative_la-System.lo \
+ libnative_la-Thread.lo libnative_la-Throwable.lo \
+ libnative_la-ZipFile.lo
am__objects_2 = libnative_la-Array.lo libnative_la-Constructor.lo \
libnative_la-Field.lo libnative_la-Method.lo
am__objects_3 = libnative_la-AccessController.lo
@@ -426,6 +427,7 @@
ClassLoader.c \
Object.c \
Runtime.c \
+ VMRuntime.c \
String.c \
System.c \
Thread.c \
@@ -563,6 +565,7 @@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libnative_la-Thread.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libnative_la-Throwable.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libnative_la-TimeZone.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libnative_la-VMRuntime.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libnative_la-ZipFile.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libnative_la-gnu_classpath_VMStackWalker.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libnative_la-gnu_classpath_VMSystemProperties.Plo at am__quote@
@@ -670,6 +673,13 @@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='Runtime.c' object='libnative_la-Runtime.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnative_la_CFLAGS) $(CFLAGS) -c -o libnative_la-Runtime.lo `test -f 'Runtime.c' || echo '$(srcdir)/'`Runtime.c
+
+libnative_la-VMRuntime.lo: VMRuntime.c
+ at am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnative_la_CFLAGS) $(CFLAGS) -MT libnative_la-VMRuntime.lo -MD -MP -MF "$(DEPDIR)/libnative_la-VMRuntime.Tpo" -c -o libnative_la-VMRuntime.lo `test -f 'VMRuntime.c' || echo '$(srcdir)/'`VMRuntime.c; \
+ at am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libnative_la-VMRuntime.Tpo" "$(DEPDIR)/libnative_la-VMRuntime.Plo"; else rm -f "$(DEPDIR)/libnative_la-VMRuntime.Tpo"; exit 1; fi
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@ source='VMRuntime.c' object='libnative_la-VMRuntime.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnative_la_CFLAGS) $(CFLAGS) -c -o libnative_la-VMRuntime.lo `test -f 'VMRuntime.c' || echo '$(srcdir)/'`VMRuntime.c
libnative_la-String.lo: String.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnative_la_CFLAGS) $(CFLAGS) -MT libnative_la-String.lo -MD -MP -MF "$(DEPDIR)/libnative_la-String.Tpo" -c -o libnative_la-String.lo `test -f 'String.c' || echo '$(srcdir)/'`String.c; \
Index: kaffe/libraries/clib/native/Runtime.c
diff -u kaffe/libraries/clib/native/Runtime.c:1.37 kaffe/libraries/clib/native/Runtime.c:1.38
--- kaffe/libraries/clib/native/Runtime.c:1.37 Sun Aug 21 18:01:02 2005
+++ kaffe/libraries/clib/native/Runtime.c Thu Sep 15 03:35:49 2005
@@ -35,11 +35,6 @@
extern jboolean runFinalizerOnExit;
-/** TODO
- *
- * availableProcessors
- */
-
/*
* Exit this VM
*/
===================================================================
Checking out kaffe/libraries/clib/native/VMRuntime.c
RCS: /home/cvs/kaffe/kaffe/libraries/clib/native/VMRuntime.c,v
VERS: 1.1
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe/libraries/clib/native/VMRuntime.c Thu Sep 15 03:41:00 2005
@@ -0,0 +1,100 @@
+/* src/native/vm/VMRuntime.c - java/lang/VMRuntime
+
+ Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
+ R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
+ C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
+ Institut f. Computersprachen - TU Wien
+
+ Copyright (C) 2005 Dalibor Topic
+
+ This file was taken from CACAO. More information on CACAO project
+ is available at http://www.cacaojvm.org
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ Contact: cacao at complang.tuwien.ac.at
+
+ Authors: Roman Obermaiser
+
+ Changes: Joseph Wenninger
+ Christian Thalinger
+ Dalibor Topic
+*/
+
+#include "config.h"
+
+#include <stdlib.h>
+
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+
+#if defined(HAVE_SYS_SYSINFO_H)
+#include <sys/sysinfo.h>
+#endif
+
+#if defined(HAVE_MACH_MACH_H)
+# include <mach/mach.h>
+#endif
+
+#include "jni.h"
+
+/*
+ * Class: java_lang_Runtime
+ * Method: availableProcessors
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_java_lang_VMRuntime_availableProcessors(JNIEnv *env, jclass clazz)
+{
+#if defined(HAVE_GET_NPROCS_CONF)
+ return get_nprocs_conf();
+#elif defined(_SC_NPROC_ONLN)
+ return (jint) sysconf(_SC_NPROC_ONLN);
+
+#elif defined(_SC_NPROCESSORS_ONLN)
+ return (jint) sysconf(_SC_NPROCESSORS_ONLN);
+
+#elif defined(__DARWIN__)
+ /* this should work in BSD */
+ /*
+ int ncpu, mib[2], rc;
+ size_t len;
+
+ mib[0] = CTL_HW;
+ mib[1] = HW_NCPU;
+ len = sizeof(ncpu);
+ rc = sysctl(mib, 2, &ncpu, &len, NULL, 0);
+
+ return (jint) ncpu;
+ */
+
+ host_basic_info_data_t hinfo;
+ mach_msg_type_number_t hinfo_count = HOST_BASIC_INFO_COUNT;
+ kern_return_t rc;
+
+ rc = host_info(mach_host_self(), HOST_BASIC_INFO,
+ (host_info_t) &hinfo, &hinfo_count);
+
+ if (rc != KERN_SUCCESS) {
+ return -1;
+ }
+
+ return (jint) hinfo.avail_cpus;
+
+#else
+ return 1;
+#endif
+}
More information about the kaffe
mailing list