rt: Add rust_get_num_cpus

This commit is contained in:
Brian Anderson
2013-06-05 22:34:35 -07:00
parent 80849e78a8
commit f9a5005f52
3 changed files with 11 additions and 3 deletions

View File

@@ -930,6 +930,13 @@ rust_begin_unwind(uintptr_t token) {
#endif
}
extern int get_num_cpus();
extern "C" CDECL uintptr_t
rust_get_num_cpus() {
return get_num_cpus();
}
//
// Local Variables:
// mode: C++

View File

@@ -40,7 +40,7 @@ rust_drop_env_lock() {
}
#if defined(__WIN32__)
static int
int
get_num_cpus() {
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
@@ -48,7 +48,7 @@ get_num_cpus() {
return (int) sysinfo.dwNumberOfProcessors;
}
#elif defined(__BSD__)
static int
int
get_num_cpus() {
/* swiped from http://stackoverflow.com/questions/150355/
programmatically-find-the-number-of-cores-on-a-machine */
@@ -75,7 +75,7 @@ get_num_cpus() {
return numCPU;
}
#elif defined(__GNUC__)
static int
int
get_num_cpus() {
return sysconf(_SC_NPROCESSORS_ONLN);
}

View File

@@ -239,3 +239,4 @@ rust_valgrind_stack_deregister
rust_take_env_lock
rust_drop_env_lock
rust_update_log_settings
rust_get_num_cpus