From: Christian Thalinger Date: Thu, 18 Oct 2007 13:49:34 +0000 (+0200) Subject: * src/vm/system.c: Removed. X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=66717746992521298528c1c23f09f1321cf9e9b1;p=cacao.git * src/vm/system.c: Removed. * src/vm/system.h: Likewise. * src/vm/Makefile.am (libvm_la_SOURCES): Removed system.[ch]. * src/vmcore/system.c: Added. * src/vmcore/system.h: Likewise. * src/vmcore/Makefile.am (libvmcore_la_SOURCES): Added system.[ch]. * src/native/vm/gnu/java_lang_VMRuntime.c (vm/system.h): Renamed to vmcore/system.h. * src/native/vm/sun/jvm.c: Likewise. --HG-- rename : src/vm/system.c => src/vmcore/system.c rename : src/vm/system.h => src/vmcore/system.h --- diff --git a/src/native/vm/gnu/java_lang_VMRuntime.c b/src/native/vm/gnu/java_lang_VMRuntime.c index 098e183d5..a48cc03e0 100644 --- a/src/native/vm/gnu/java_lang_VMRuntime.c +++ b/src/native/vm/gnu/java_lang_VMRuntime.c @@ -57,9 +57,9 @@ #include "vm/builtin.h" #include "vm/exceptions.h" #include "vm/stringlocal.h" -#include "vm/system.h" #include "vm/vm.h" +#include "vmcore/system.h" #include "vmcore/utf8.h" diff --git a/src/native/vm/sun/jvm.c b/src/native/vm/sun/jvm.c index ecd2279b2..d2d9d3352 100644 --- a/src/native/vm/sun/jvm.c +++ b/src/native/vm/sun/jvm.c @@ -99,13 +99,13 @@ #include "vm/resolve.h" #include "vm/signallocal.h" #include "vm/stringlocal.h" -#include "vm/system.h" #include "vm/vm.h" #include "vm/jit/stacktrace.h" #include "vmcore/classcache.h" #include "vmcore/options.h" +#include "vmcore/system.h" /* debugging macros ***********************************************************/ diff --git a/src/vm/Makefile.am b/src/vm/Makefile.am index 26b98a95e..bdc79e4f8 100644 --- a/src/vm/Makefile.am +++ b/src/vm/Makefile.am @@ -71,8 +71,6 @@ libvm_la_SOURCES = \ signallocal.h \ string.c \ stringlocal.h \ - system.c \ - system.h \ vm.c \ vm.h diff --git a/src/vm/system.c b/src/vm/system.c deleted file mode 100644 index 7edc04196..000000000 --- a/src/vm/system.c +++ /dev/null @@ -1,113 +0,0 @@ -/* src/vm/system.c - system (OS) functions - - Copyright (C) 2007 - CACAOVM - Verein zu Foerderung der freien virtuellen Machine CACAO - - This file is part of CACAO. - - 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include - -#if defined(__DARWIN__) -# include -# include -# include -#endif - -/* this should work on BSD */ -/* #include */ - - -/* system_processors_online **************************************************** - - Returns the number of online processors in the system. - - RETURN: - online processor count - -*******************************************************************************/ - -int system_processors_online(void) -{ -#if defined(_SC_NPROC_ONLN) - - return (int) sysconf(_SC_NPROC_ONLN); - -#elif defined(_SC_NPROCESSORS_ONLN) - - return (int) sysconf(_SC_NPROCESSORS_ONLN); - -#elif defined(__DARWIN__) - - 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; - } - - /* XXX michi: according to my infos this should be - hinfo.max_cpus, can someone please confirm or deny that? */ - return (int) hinfo.avail_cpus; - -#elif defined(__FREEBSD__) -# error IMPLEMENT ME! - - /* 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 (int32_t) ncpu; - */ - -#else - - return 1; - -#endif -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/system.h b/src/vm/system.h deleted file mode 100644 index 42e130c34..000000000 --- a/src/vm/system.h +++ /dev/null @@ -1,53 +0,0 @@ -/* src/vm/system.h - system (OS) functions - - Copyright (C) 2007 - CACAOVM - Verein zu Foerderung der freien virtuellen Machine CACAO - - This file is part of CACAO. - - 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _VM_SYSTEM_H -#define _VM_SYSTEM_H - -#include "config.h" - -#include - - -/* function prototypes ********************************************************/ - -int system_processors_online(void); - -#endif /* _VM_SYSTEM_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/Makefile.am b/src/vmcore/Makefile.am index 00ca24c96..1b288f401 100644 --- a/src/vmcore/Makefile.am +++ b/src/vmcore/Makefile.am @@ -85,6 +85,8 @@ libvmcore_la_SOURCES = \ $(STATISTICS_SOURCES) \ suck.c \ suck.h \ + system.c \ + system.h \ utf8.c \ utf8.h \ $(ZLIB_SOURCES) diff --git a/src/vmcore/system.c b/src/vmcore/system.c new file mode 100644 index 000000000..7edc04196 --- /dev/null +++ b/src/vmcore/system.c @@ -0,0 +1,113 @@ +/* src/vm/system.c - system (OS) functions + + Copyright (C) 2007 + CACAOVM - Verein zu Foerderung der freien virtuellen Machine CACAO + + This file is part of CACAO. + + 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., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include + +#if defined(__DARWIN__) +# include +# include +# include +#endif + +/* this should work on BSD */ +/* #include */ + + +/* system_processors_online **************************************************** + + Returns the number of online processors in the system. + + RETURN: + online processor count + +*******************************************************************************/ + +int system_processors_online(void) +{ +#if defined(_SC_NPROC_ONLN) + + return (int) sysconf(_SC_NPROC_ONLN); + +#elif defined(_SC_NPROCESSORS_ONLN) + + return (int) sysconf(_SC_NPROCESSORS_ONLN); + +#elif defined(__DARWIN__) + + 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; + } + + /* XXX michi: according to my infos this should be + hinfo.max_cpus, can someone please confirm or deny that? */ + return (int) hinfo.avail_cpus; + +#elif defined(__FREEBSD__) +# error IMPLEMENT ME! + + /* 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 (int32_t) ncpu; + */ + +#else + + return 1; + +#endif +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vmcore/system.h b/src/vmcore/system.h new file mode 100644 index 000000000..42e130c34 --- /dev/null +++ b/src/vmcore/system.h @@ -0,0 +1,53 @@ +/* src/vm/system.h - system (OS) functions + + Copyright (C) 2007 + CACAOVM - Verein zu Foerderung der freien virtuellen Machine CACAO + + This file is part of CACAO. + + 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., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _VM_SYSTEM_H +#define _VM_SYSTEM_H + +#include "config.h" + +#include + + +/* function prototypes ********************************************************/ + +int system_processors_online(void); + +#endif /* _VM_SYSTEM_H */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */