1 /* src/vm/system.c - system (OS) functions
4 CACAOVM - Verein zu Foerderung der freien virtuellen Machine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
31 #if defined(__DARWIN__)
32 # include <mach/mach.h>
33 # include <mach/mach_host.h>
34 # include <mach/host_info.h>
37 /* this should work on BSD */
38 /* #include <sys/sysctl.h> */
41 /* system_processors_online ****************************************************
43 Returns the number of online processors in the system.
46 online processor count
48 *******************************************************************************/
50 int system_processors_online(void)
52 #if defined(_SC_NPROC_ONLN)
54 return (int) sysconf(_SC_NPROC_ONLN);
56 #elif defined(_SC_NPROCESSORS_ONLN)
58 return (int) sysconf(_SC_NPROCESSORS_ONLN);
60 #elif defined(__DARWIN__)
62 host_basic_info_data_t hinfo;
63 mach_msg_type_number_t hinfo_count = HOST_BASIC_INFO_COUNT;
66 rc = host_info(mach_host_self(), HOST_BASIC_INFO,
67 (host_info_t) &hinfo, &hinfo_count);
69 if (rc != KERN_SUCCESS) {
73 /* XXX michi: according to my infos this should be
74 hinfo.max_cpus, can someone please confirm or deny that? */
75 return (int) hinfo.avail_cpus;
77 #elif defined(__FREEBSD__)
80 /* this should work in BSD */
88 rc = sysctl(mib, 2, &ncpu, &len, NULL, 0);
90 return (int32_t) ncpu;
102 * These are local overrides for various environment variables in Emacs.
103 * Please do not remove this and leave it at the end of the file, where
104 * Emacs will automagically detect them.
105 * ---------------------------------------------------------------------
108 * indent-tabs-mode: t
112 * vim:noexpandtab:sw=4:ts=4: