Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Kerilk
Copy link
Contributor

@Kerilk Kerilk commented Apr 13, 2022

Hello,

I encountered an issue with the current Bitmask implementation (I wrote those, so I am to blame), when the native type is signed, and a flag uses the most significant bit. The fact that the native value is negative in this case was causing some incorrect remainders when decoding the flags, and range errors when synthesizing the value from the flags.

This PR fixes the above issue, and adds relevant tests.
One of those tests fails on TruffleRuby: testing UINT64 bitmasks with most significant bit set:
unsupported type [9223372036854775811] which corresponds to 0x8000000000000003 == (1<<63) | (1<<1) | (1<<0)
I assume this is a limitation of TruffleRuby, but wanted to check before adding this to the expected failure list.

I've also taken the opportunity to clean the code up a bit.

Thanks,
Brice

@eregon
Copy link
Collaborator

eregon commented Apr 13, 2022

Regarding the failure on TruffleRuby, could you simply skip that test on TruffleRuby for the moment?
It seems I need to handle types which include DataConverter like Enum/Bitmask by using their native_type, similar to how Type::Mapped is handled currently, in TruffleRuby's backend.
The test fails because that value if a Bignum-range Integer, and Truffle NFI can't understand that.

@Kerilk
Copy link
Contributor Author

Kerilk commented Apr 13, 2022

@eregon, Thanks for the quick feedback. I was unsure of the diagnostic as the signed case did not cause the same trouble, despite also being out of bound for a FixNum. I'll iterate on the fix if other related issues pop.

Edit: Seems to pass now. The appveyor seems to be throwing unrelated certificate errors.

@larskanis larskanis merged commit 2635992 into ffi:master Apr 21, 2022
@larskanis
Copy link
Member

LGTM, merged! Thank you very much!

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.

3 participants