Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix building of the project on ARM64 with VisualStudio #228

Merged

Conversation

dlemstra
Copy link
Contributor

@dlemstra dlemstra commented Jan 8, 2022

This pull requests adds a missing check to fix building with VisualStudio on ARM64. The __lzcnt method is only supported on x86 or x64.

Signed-off-by: Dirk Lemstra <dirk@lemstra.org>
@dlemstra dlemstra changed the title Added missing check _M_IX86 or _M_X64 when using __lzcnt. Fix building of the project on ARM64 with VisualStudio Jan 8, 2022
Copy link
Contributor

@lgritz lgritz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely a step forward, but I'll leave a comment about a better long-term solution.

@lgritz
Copy link
Contributor

lgritz commented Jan 8, 2022

I think a better solution is to take advantage of the C++20 features when available:

https://en.cppreference.com/w/cpp/numeric#Bit_manipulation_.28since_C.2B.2B20.29

apparently, it's already available in newish MSVS versions:

https://devblogs.microsoft.com/cppblog/bit-in-visual-studio-2019-version-16-8-preview-2/

So rather than fall all the way back to the "while" loop on other architectures or compilers, they should also check for being on a sufficiently new MSVS (or other C++20 compliant library -- there is a specific testing macro for this) and use the new std functions if available, and those are expected to compile to the most efficient instructions (akin to gcc's __builtin_clz).

@cary-ilm cary-ilm merged commit 3206446 into AcademySoftwareFoundation:master Jan 14, 2022
@dlemstra dlemstra deleted the fix-windows-arm64 branch January 15, 2022 00:01
cary-ilm pushed a commit to cary-ilm/Imath that referenced this pull request Jan 17, 2022
cary-ilm pushed a commit that referenced this pull request Jan 20, 2022
Signed-off-by: Dirk Lemstra <dirk@lemstra.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants