Use cpuid intrinsics instead of asm code #10820

Merged
merged 2 commits into from Jul 16, 2017

Conversation

Projects
None yet
4 participants
Owner

sipa commented Jul 13, 2017 edited

Less platform-specific code is better.

Owner

laanwj commented Jul 14, 2017

Let's see if this works on all platforms...

It builds on OpenBSD at least! Keeping #10670 in mind that probably means it will work on anything.

laanwj added the Refactoring label Jul 14, 2017

src/random.cpp
- //! When calling cpuid function #1, ecx register will have this set if RDRAND is available.
- if (ecx & CPUID_F1_ECX_RDRAND) {
+ uint32_t eax, ebx, ecx, edx;
+ if (__get_cpuid(1, &eax, &ebx, &ecx, &edx) && (ecx & CPUID_F1_ECX_RDRAND)) {
@laanwj

laanwj Jul 14, 2017

Owner

Definitely an improvement...

Contributor

TheBlueMatt commented Jul 14, 2017

ACK 674848f (I didnt actually test on other platforms, so I'm just kinda assuming they support this stuff).

@gmaxwell

ACK.

@sipa sipa merged commit 674848f into bitcoin:master Jul 16, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@sipa sipa added a commit that referenced this pull request Jul 16, 2017

@sipa sipa Merge #10820: Use cpuid intrinsics instead of asm code
674848f Clarify entropy source (Pieter Wuille)
a9e82f6 Use cpuid intrinsics instead of asm code (Pieter Wuille)

Pull request description:

  Less platform-specific code is better.

Tree-SHA512: 14f1b9accd9882859acdf516d2ada7ccb0ad92a3b3edf95b9cb8a8e514d4b1748d4555bcfb560779792c4f664f920d681ae42e9cebd0e6410f13f94c3a8729a0
ef37f20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment