diff options
| author | Brian Anderson <banderson@mozilla.com> | 2013-06-05 22:34:35 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2013-06-06 17:53:13 -0700 |
| commit | f9a5005f52d528797d6b98a3bee73ab2d71b9aa3 (patch) | |
| tree | b68bb1dab39c064efdc3e275d03de3c8365c1613 | |
| parent | 80849e78a847f7834f71b36a66251ba0ea37a982 (diff) | |
| download | rust-f9a5005f52d528797d6b98a3bee73ab2d71b9aa3.tar.gz rust-f9a5005f52d528797d6b98a3bee73ab2d71b9aa3.zip | |
rt: Add rust_get_num_cpus
| -rw-r--r-- | src/rt/rust_builtin.cpp | 7 | ||||
| -rw-r--r-- | src/rt/rust_env.cpp | 6 | ||||
| -rw-r--r-- | src/rt/rustrt.def.in | 1 |
3 files changed, 11 insertions, 3 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 5e7357c9b7b..fe4e75fb8d2 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -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++ diff --git a/src/rt/rust_env.cpp b/src/rt/rust_env.cpp index ed38be3550f..c3d38851e7b 100644 --- a/src/rt/rust_env.cpp +++ b/src/rt/rust_env.cpp @@ -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); } diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index e3e522aa7ce..9b49583519e 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -239,3 +239,4 @@ rust_valgrind_stack_deregister rust_take_env_lock rust_drop_env_lock rust_update_log_settings +rust_get_num_cpus \ No newline at end of file |
