-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Reformat code in little-endian patch #3016
Conversation
The cast relies on implementation-defined behaviour, which is why I used memcpy(). Of course any sane compiler implementation will leave the underlying bits unaffected... |
yes, I agree that the use of memcpy here is the recommended way of doing this. I think our CI might pick this up. |
Looks like C++20 will allow us to get rid of the memcpy(): |
Fine with me (except if there is a retinterpret_blah_blah_cast() in the C++ standard for doing that, of course).. |
No, reinterpret_cast can't be used for this, I tried :-). Apparently that is meant for pointers. |
Well, perhaps one could reinterpret_cast a pointer to the unsigned value as a pointer to a signed value and then read it out... |
I think memcpy is just fine for now. The compiler will replace the call, there is no performance impact, and right now this is a relatively clean way to do things. |
I will squash the two commits into one. Done, patch is ready IMO. |
Reformat code and rename the function to "read_little_endian()" in the recent commit by Ronald de Man for support of big endian systems. closes official-stockfish/Stockfish#3016 No functional change
e759dc4
to
48d6e54
Compare
That's implementation dependent behavior too. In C++ (as opposed to C) you can only read memory that has been initialized by a constructor for the correct type and the only way around this is |
Reformat code and rename the function to "read_little_endian()" in the recent commit by Ronald de Man for support of big endian systems. closes official-stockfish/Stockfish#3016 No functional change ----- Recommended net: https://tests.stockfishchess.org/api/nn/nn-82215d0fd0df.nnue
48d6e54
to
81d716f
Compare
Merged via 81d716f |
Reformat code and rename the function to "read_little_endian()" in the recent commit by Ronald de Man for support of big endian systems. closes official-stockfish/Stockfish#3016 No functional change ----- Recommended net: https://tests.stockfishchess.org/api/nn/nn-82215d0fd0df.nnue
Reformat code and rename the function to "read_little_endian()" in the recent commit by Ronald de Man for support of big endian systems. closes official-stockfish/Stockfish#3016 No functional change ----- Recommended net: https://tests.stockfishchess.org/api/nn/nn-82215d0fd0df.nnue
Reformat code and rename the function to "read_little_endian()" in the recent
commit by Ronald de Man for support of big endian systems.
closes #3016
No functional change