Use target_has_atomic
on Rust 1.60+ to enable atomic (de)serialization
#2337
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.
I recently ran into the issue that serde didn't implement
Deserialize
for atomics when compiled for Android on Arm (armv7-linux-androideabi
).This was once reported in #1579 and might have been addressed back then.
Current version doesn't enable it for arm ever, so it's still an issue regardless.
target_has_atomic
has become stable in Rust 1.60 (see rust-lang/rust#32976 (comment)), so now it is possible to use it, at least when compiled for 1.60 and above.I implemented it the quick way, just duplicating the code when a different cfg is enabled.
I might be able to merge those two into a single macro if that's desired.
I tested it locally by building the test suite for Android (requires proper set up of the Android NDK, etc.):