File tree 1 file changed +11
-4
lines changed
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -172,8 +172,11 @@ fn get_num_cpus() -> usize {
172
172
}
173
173
count as usize
174
174
} else {
175
- unsafe {
176
- libc:: sysconf ( libc:: _SC_NPROCESSORS_ONLN) as usize
175
+ let cpus = unsafe { libc:: sysconf ( libc:: _SC_NPROCESSORS_ONLN) } ;
176
+ if cpus < 1 {
177
+ 1
178
+ } else {
179
+ cpus as usize
177
180
}
178
181
}
179
182
}
@@ -187,10 +190,14 @@ fn get_num_cpus() -> usize {
187
190
target_os = "fuchsia" )
188
191
) ]
189
192
fn get_num_cpus ( ) -> usize {
190
- unsafe {
191
- libc:: sysconf ( libc:: _SC_NPROCESSORS_ONLN) as usize
193
+ let cpus = unsafe { libc:: sysconf ( libc:: _SC_NPROCESSORS_ONLN) } ;
194
+ if cpus < 1 {
195
+ 1
196
+ } else {
197
+ cpus as usize
192
198
}
193
199
}
200
+
194
201
#[ cfg( any( target_os = "emscripten" , target_os = "redox" , target_os = "haiku" ) ) ]
195
202
fn get_num_cpus ( ) -> usize {
196
203
1
You can’t perform that action at this time.
0 commit comments