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

Add MSVC implementations for ULong__maxIndex and ULong__minIndex #8

Merged
merged 1 commit into from
Apr 12, 2017

Conversation

0xbc
Copy link
Contributor

@0xbc 0xbc commented Apr 10, 2017

Builds are currently broken for pyvex on MSVC due to a couple of issues. One is here in the vex project (which I'll describe below) and one is in the pyvex project, which I've submitted another PR for (see angr/pyvex#70).

Currently, vex is using a couple of gcc builtin functions which, unsurprisngly, aren't present in the MSVC ecosystem. There are some very similar builtins in MSVC (_BitScanForward64, _BitScanReverse64) which would have done the job with some minor tweaks. However, those builtins are only present in the 64-bit compiler, which is problematic given that the default VS2015 developer prompt has the 32-bit version of cl.exe on its path.

As such, I've come up with a 32-bit friendly solution by adding some implementations of the relevant algorithms from https://chessprogramming.wikispaces.com/BitScan. I haven't formally verified my implementation (and I lack the wizardry to fully understand the implementations I'm using), but from the limitied testing I've done, the results they're producing look sane (and identical to the output from the gcc functions).

If you'd prefer an alternate strategy for resolving this though, let me know and I'll go back to the drawing board.

The 64-bit versions of the relevant compiler intrinsic functions
(_BitScanForward64, _BitScanReverse64) are only available
when using the 64-bit version of cl.exe. Therefore, a 32-bit
friendly implementation of these functions has been implemented
instead.
@rhelmot
Copy link
Member

rhelmot commented Apr 10, 2017

god dammit! I thought I fixed the MSVC build last month!

this is a little complicated because we're in the process of trying to upstream our patches to valgrind. I'll merge this, but do note that you're submitting a pull request to a GPL project, this patch is licensed under the terms of the license at the top of each file, etc etc, and I may change it according to whatever the valigrind maintainers want.

Does this fix (along with the pyvex one) fix the MSVC build entirely, or is there still work to do?

@0xbc
Copy link
Contributor Author

0xbc commented Apr 10, 2017 via email

@0xbc
Copy link
Contributor Author

0xbc commented Apr 11, 2017

OK, MSVC build seems to be working and running after adding some extra exports to pyvex.def in the other PR (and a bunch of example scripts from angr-doc run fine). (Note that I used the setup.bat from angr/angr-dev#16 to build it.)

The code from the website I used to implement bit-scanning seems to be licensed as CC BY-SA 3.0. Is that going to be a problem? Apart from that, no licensing concerns from me.

@rhelmot rhelmot merged commit 3a620e4 into angr:master Apr 12, 2017
@rhelmot
Copy link
Member

rhelmot commented Apr 12, 2017

If there are problems, I'm sure we'll find out about them :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants