-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[Flang] Shift the data from lower to higher order bits in the big endian environment #73670
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-flang-runtime Author: None (madanial0) ChangesShift the data from lower to higher order bits when memcpy the value in the namelist in the big endian environment Full diff: https://github.com/llvm/llvm-project/pull/73670.diff 1 Files Affected:
diff --git a/flang/runtime/edit-input.cpp b/flang/runtime/edit-input.cpp
index 4e8c9aa868a691c..305d85afe480ffe 100644
--- a/flang/runtime/edit-input.cpp
+++ b/flang/runtime/edit-input.cpp
@@ -222,7 +222,15 @@ bool EditIntegerInput(
value = -value;
}
if (any || !io.GetConnectionState().IsAtEOF()) {
- std::memcpy(n, &value, kind); // a blank field means zero
+ // For integer kind <= 4, the value is stored in the lower order bits on
+ // the big endian platform. When memcpy the value, shift the value, shift
+ // the value to the higher order bit.
+ if (!isHostLittleEndian && kind <= 4) {
+ auto l{value.low() << (8 * (sizeof(value.low()) - kind))};
+ std::memcpy(n, &l, kind);
+ } else {
+ std::memcpy(n, &value, kind); // a blank field means zero
+ }
}
return any;
}
|
klausler
reviewed
Nov 28, 2023
66d78df
to
3d02fb7
Compare
✅ With the latest revision this PR passed the C/C++ code formatter. |
3d02fb7
to
1936743
Compare
friendly ping! Thanks! |
klausler
requested changes
Dec 18, 2023
df44ab3
to
e6cfcf1
Compare
Friendly ping! Thanks! |
klausler
approved these changes
Dec 28, 2023
Thanks for the review! |
e6cfcf1
to
89a44e1
Compare
89a44e1
to
ef72557
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Shift the data from lower to higher order bits when memcpy the value in the namelist in the big endian environment