hardnested: more readable preprocessing

This commit is contained in:
Philippe Teuwen
2020-05-12 13:26:16 +02:00
parent 5e4c83cc2f
commit 66fd6d70a0
5 changed files with 81 additions and 130 deletions

View File

@@ -163,16 +163,14 @@ static int usage_hf14_hardnested(void) {
PrintAndLogEx(NORMAL, " f <name> read/write <name> instead of default name");
PrintAndLogEx(NORMAL, " t tests?");
PrintAndLogEx(NORMAL, " i <X> set type of SIMD instructions. Without this flag programs autodetect it.");
#if defined (__i386__) || defined (__x86_64__)
#if !defined(__APPLE__) || (defined(__APPLE__) && (__clang_major__ > 8 || __clang_major__ == 8 && __clang_minor__ >= 1))
#if (__GNUC__ >= 5) && (__GNUC__ > 5 || __GNUC_MINOR__ > 2)
#if defined(COMPILER_HAS_SIMD_AVX512)
PrintAndLogEx(NORMAL, " i 5 = AVX512");
#endif
#if defined(COMPILER_HAS_SIMD)
PrintAndLogEx(NORMAL, " i 2 = AVX2");
PrintAndLogEx(NORMAL, " i a = AVX");
PrintAndLogEx(NORMAL, " i s = SSE2");
PrintAndLogEx(NORMAL, " i m = MMX");
#endif
#endif
PrintAndLogEx(NORMAL, " i n = none (use CPU regular instruction set)");
PrintAndLogEx(NORMAL, "");
@@ -228,15 +226,13 @@ static int usage_hf14_autopwn(void) {
PrintAndLogEx(NORMAL, " * 2 = 2k");
PrintAndLogEx(NORMAL, " * 4 = 4k");
PrintAndLogEx(NORMAL, " i <simd type> set type of SIMD instructions for hardnested. Default: autodetection.");
#if defined (__i386__) || defined (__x86_64__)
#if !defined(__APPLE__) || (defined(__APPLE__) && (__clang_major__ > 8 || __clang_major__ == 8 && __clang_minor__ >= 1))
#if (__GNUC__ >= 5) && (__GNUC__ > 5 || __GNUC_MINOR__ > 2)
#if defined(COMPILER_HAS_SIMD_AVX512)
PrintAndLogEx(NORMAL, " i 5 = AVX512");
#endif
#if defined(COMPILER_HAS_SIMD)
PrintAndLogEx(NORMAL, " i 2 = AVX2");
PrintAndLogEx(NORMAL, " i a = AVX");
PrintAndLogEx(NORMAL, " i s = SSE2");
#endif
#endif
PrintAndLogEx(NORMAL, " i m = MMX");
PrintAndLogEx(NORMAL, " i n = none (use CPU regular instruction set)");
@@ -1817,13 +1813,12 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
SetSIMDInstr(SIMD_AUTO);
ctmp = tolower(param_getchar(Cmd, cmdp + 1));
switch (ctmp) {
#if defined (__i386__) || defined (__x86_64__)
#if !defined(__APPLE__) || (defined(__APPLE__) && (__clang_major__ > 8 || __clang_major__ == 8 && __clang_minor__ >= 1))
#if (__GNUC__ >= 5) && (__GNUC__ > 5 || __GNUC_MINOR__ > 2)
#if defined(COMPILER_HAS_SIMD_AVX512)
case '5':
SetSIMDInstr(SIMD_AVX512);
break;
#endif
#if defined(COMPILER_HAS_SIMD)
case '2':
SetSIMDInstr(SIMD_AVX2);
break;
@@ -1836,7 +1831,6 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
case 'm':
SetSIMDInstr(SIMD_MMX);
break;
#endif
#endif
case 'n':
SetSIMDInstr(SIMD_NONE);
@@ -2004,13 +1998,12 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
SetSIMDInstr(SIMD_AUTO);
ctmp = tolower(param_getchar(Cmd, cmdp + 1));
switch (ctmp) {
#if defined (__i386__) || defined (__x86_64__)
#if !defined(__APPLE__) || (defined(__APPLE__) && (__clang_major__ > 8 || __clang_major__ == 8 && __clang_minor__ >= 1))
#if (__GNUC__ >= 5) && (__GNUC__ > 5 || __GNUC_MINOR__ > 2)
#if defined(COMPILER_HAS_SIMD_AVX512)
case '5':
SetSIMDInstr(SIMD_AVX512);
break;
#endif
#if defined(COMPILER_HAS_SIMD)
case '2':
SetSIMDInstr(SIMD_AVX2);
break;
@@ -2023,7 +2016,6 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
case 'm':
SetSIMDInstr(SIMD_MMX);
break;
#endif
#endif
case 'n':
SetSIMDInstr(SIMD_NONE);

View File

@@ -75,13 +75,12 @@ static float brute_force_per_second;
static void get_SIMD_instruction_set(char *instruction_set) {
switch (GetSIMDInstrAuto()) {
#if defined (__i386__) || defined (__x86_64__)
#if !defined(__APPLE__) || (defined(__APPLE__) && (__clang_major__ > 8 || __clang_major__ == 8 && __clang_minor__ >= 1))
#if (__GNUC__ >= 5) && (__GNUC__ > 5 || __GNUC_MINOR__ > 2)
#if defined(COMPILER_HAS_SIMD_AVX512)
case SIMD_AVX512:
strcpy(instruction_set, "AVX512F");
break;
#endif
#if defined(COMPILER_HAS_SIMD)
case SIMD_AVX2:
strcpy(instruction_set, "AVX2");
break;
@@ -94,7 +93,6 @@ static void get_SIMD_instruction_set(char *instruction_set) {
case SIMD_MMX:
strcpy(instruction_set, "MMX");
break;
#endif
#endif
case SIMD_AUTO:
case SIMD_NONE: