mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
Limit configurable CPU count to the number of detected CPU cores.
This commit is contained in:
parent
dfabad37d9
commit
908b8ca0b3
3 changed files with 10 additions and 4 deletions
|
@ -1004,8 +1004,9 @@ int main(int argc, char *argv[]) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
long int ncpus = strtol(argv[i + 1], NULL, 10);
|
long int ncpus = strtol(argv[i + 1], NULL, 10);
|
||||||
if (ncpus < 0 || ncpus >= INT_MAX) {
|
const int detected_cpus = detect_num_CPUs();
|
||||||
PrintAndLogEx(ERR, _RED_("ERROR:") " invalid number of CPU cores: --ncpu " _YELLOW_("%s") "\n", argv[i + 1]);
|
if (ncpus < 0 || ncpus >= detected_cpus) {
|
||||||
|
PrintAndLogEx(ERR, _RED_("ERROR:") " invalid number of CPU cores: --ncpu " _YELLOW_("%s") " (available: %d)\n", argv[i + 1], detected_cpus);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
g_numCPUs = ncpus;
|
g_numCPUs = ncpus;
|
||||||
|
|
|
@ -1079,12 +1079,16 @@ uint64_t HornerScheme(uint64_t num, uint64_t divider, uint64_t factor) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine number of logical CPU cores (use for multithreaded functions)
|
|
||||||
int num_CPUs(void) {
|
int num_CPUs(void) {
|
||||||
if (g_numCPUs > 0) {
|
if (g_numCPUs > 0) {
|
||||||
return g_numCPUs;
|
return g_numCPUs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return detect_num_CPUs();
|
||||||
|
}
|
||||||
|
|
||||||
|
// determine number of logical CPU cores (use for multithreaded functions)
|
||||||
|
int detect_num_CPUs(void) {
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include <sysinfoapi.h>
|
#include <sysinfoapi.h>
|
||||||
SYSTEM_INFO sysinfo;
|
SYSTEM_INFO sysinfo;
|
||||||
|
|
|
@ -131,7 +131,8 @@ void wiegand_add_parity_swapped(uint8_t *target, uint8_t *source, uint8_t length
|
||||||
uint32_t PackBits(uint8_t start, uint8_t len, const uint8_t *bits);
|
uint32_t PackBits(uint8_t start, uint8_t len, const uint8_t *bits);
|
||||||
uint64_t HornerScheme(uint64_t num, uint64_t divider, uint64_t factor);
|
uint64_t HornerScheme(uint64_t num, uint64_t divider, uint64_t factor);
|
||||||
|
|
||||||
int num_CPUs(void); // number of logical CPUs
|
int num_CPUs(void);
|
||||||
|
int detect_num_CPUs(void); // number of logical CPUs
|
||||||
|
|
||||||
void str_lower(char *s); // converts string to lower case
|
void str_lower(char *s); // converts string to lower case
|
||||||
void str_upper(char *s); // converts string to UPPER case
|
void str_upper(char *s); // converts string to UPPER case
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue