Skip to content

Commit f9a5005

Browse files
committed
rt: Add rust_get_num_cpus
1 parent 80849e7 commit f9a5005

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

src/rt/rust_builtin.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,13 @@ rust_begin_unwind(uintptr_t token) {
930930
#endif
931931
}
932932

933+
extern int get_num_cpus();
934+
935+
extern "C" CDECL uintptr_t
936+
rust_get_num_cpus() {
937+
return get_num_cpus();
938+
}
939+
933940
//
934941
// Local Variables:
935942
// mode: C++

src/rt/rust_env.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ rust_drop_env_lock() {
4040
}
4141

4242
#if defined(__WIN32__)
43-
static int
43+
int
4444
get_num_cpus() {
4545
SYSTEM_INFO sysinfo;
4646
GetSystemInfo(&sysinfo);
4747

4848
return (int) sysinfo.dwNumberOfProcessors;
4949
}
5050
#elif defined(__BSD__)
51-
static int
51+
int
5252
get_num_cpus() {
5353
/* swiped from http://stackoverflow.com/questions/150355/
5454
programmatically-find-the-number-of-cores-on-a-machine */
@@ -75,7 +75,7 @@ get_num_cpus() {
7575
return numCPU;
7676
}
7777
#elif defined(__GNUC__)
78-
static int
78+
int
7979
get_num_cpus() {
8080
return sysconf(_SC_NPROCESSORS_ONLN);
8181
}

src/rt/rustrt.def.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,4 @@ rust_valgrind_stack_deregister
239239
rust_take_env_lock
240240
rust_drop_env_lock
241241
rust_update_log_settings
242+
rust_get_num_cpus

0 commit comments

Comments
 (0)