Guard against unlikely overflow

This commit is contained in:
Eric Fischer 2016-01-12 14:16:17 -08:00
parent ecae14e2d4
commit 83322d8e35

View File

@ -69,6 +69,11 @@ void init_cpus() {
CPUS = 1;
}
// Guard against short struct index.segment
if (CPUS > 32767) {
CPUS = 32767;
}
// Round down to a power of 2
CPUS = 1 << (int) (log(CPUS) / log(2));