8
8
#include < assert.h>
9
9
#include < string.h>
10
10
11
+ #if !defined(DISABLE_OPTIMIZED_SHA256)
11
12
#include < compat/cpuid.h>
12
13
13
- #if defined(__linux__) && defined(ENABLE_ARM_SHANI) && !defined(BUILD_BITCOIN_INTERNAL)
14
+ #if defined(__linux__) && defined(ENABLE_ARM_SHANI)
14
15
#include < sys/auxv.h>
15
16
#include < asm/hwcap.h>
16
17
#endif
17
18
18
- #if defined(MAC_OSX) && defined(ENABLE_ARM_SHANI) && !defined(BUILD_BITCOIN_INTERNAL)
19
+ #if defined(MAC_OSX) && defined(ENABLE_ARM_SHANI)
19
20
#include < sys/types.h>
20
21
#include < sys/sysctl.h>
21
22
#endif
@@ -58,6 +59,7 @@ namespace sha256d64_arm_shani
58
59
{
59
60
void Transform_2way (unsigned char * out, const unsigned char * in);
60
61
}
62
+ #endif // DISABLE_OPTIMIZED_SHA256
61
63
62
64
// Internal implementation code.
63
65
namespace
@@ -567,6 +569,7 @@ bool SelfTest() {
567
569
return true ;
568
570
}
569
571
572
+ #if !defined(DISABLE_OPTIMIZED_SHA256)
570
573
#if defined(USE_ASM) && (defined(__x86_64__) || defined(__amd64__) || defined(__i386__))
571
574
/* * Check whether the OS has enabled AVX registers. */
572
575
bool AVXEnabled ()
@@ -576,6 +579,7 @@ bool AVXEnabled()
576
579
return (a & 6 ) == 6 ;
577
580
}
578
581
#endif
582
+ #endif // DISABLE_OPTIMIZED_SHA256
579
583
} // namespace
580
584
581
585
@@ -588,6 +592,7 @@ std::string SHA256AutoDetect(sha256_implementation::UseImplementation use_implem
588
592
TransformD64_4way = nullptr ;
589
593
TransformD64_8way = nullptr ;
590
594
595
+ #if !defined(DISABLE_OPTIMIZED_SHA256)
591
596
#if defined(USE_ASM) && defined(HAVE_GETCPUID)
592
597
bool have_sse4 = false ;
593
598
bool have_xsave = false ;
@@ -616,7 +621,7 @@ std::string SHA256AutoDetect(sha256_implementation::UseImplementation use_implem
616
621
}
617
622
}
618
623
619
- #if defined(ENABLE_X86_SHANI) && !defined(BUILD_BITCOIN_INTERNAL)
624
+ #if defined(ENABLE_X86_SHANI)
620
625
if (have_x86_shani) {
621
626
Transform = sha256_x86_shani::Transform;
622
627
TransformD64 = TransformD64Wrapper<sha256_x86_shani::Transform>;
@@ -633,21 +638,21 @@ std::string SHA256AutoDetect(sha256_implementation::UseImplementation use_implem
633
638
TransformD64 = TransformD64Wrapper<sha256_sse4::Transform>;
634
639
ret = " sse4(1way)" ;
635
640
#endif
636
- #if defined(ENABLE_SSE41) && !defined(BUILD_BITCOIN_INTERNAL)
641
+ #if defined(ENABLE_SSE41)
637
642
TransformD64_4way = sha256d64_sse41::Transform_4way;
638
643
ret += " ,sse41(4way)" ;
639
644
#endif
640
645
}
641
646
642
- #if defined(ENABLE_AVX2) && !defined(BUILD_BITCOIN_INTERNAL)
647
+ #if defined(ENABLE_AVX2)
643
648
if (have_avx2 && have_avx && enabled_avx) {
644
649
TransformD64_8way = sha256d64_avx2::Transform_8way;
645
650
ret += " ,avx2(8way)" ;
646
651
}
647
652
#endif
648
653
#endif // defined(USE_ASM) && defined(HAVE_GETCPUID)
649
654
650
- #if defined(ENABLE_ARM_SHANI) && !defined(BUILD_BITCOIN_INTERNAL)
655
+ #if defined(ENABLE_ARM_SHANI)
651
656
bool have_arm_shani = false ;
652
657
if (use_implementation & sha256_implementation::USE_SHANI) {
653
658
#if defined(__linux__)
@@ -679,6 +684,7 @@ std::string SHA256AutoDetect(sha256_implementation::UseImplementation use_implem
679
684
ret = " arm_shani(1way,2way)" ;
680
685
}
681
686
#endif
687
+ #endif // DISABLE_OPTIMIZED_SHA256
682
688
683
689
assert (SelfTest ());
684
690
return ret;
0 commit comments