Skip to content

Commit

Permalink
Use stricter atomic ordering for soundness
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpratt committed Feb 22, 2023
1 parent de65b71 commit ec81282
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions time/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ pub mod local_offset {
/// - [`UtcOffset::local_offset_at`](crate::UtcOffset::local_offset_at)
/// - [`UtcOffset::current_local_offset`](crate::UtcOffset::current_local_offset)
pub unsafe fn set_soundness(soundness: Soundness) {
LOCAL_OFFSET_IS_SOUND.store(soundness == Soundness::Sound, Ordering::Relaxed);
LOCAL_OFFSET_IS_SOUND.store(soundness == Soundness::Sound, Ordering::SeqCst);
}

/// Obtains the soundness of obtaining the local UTC offset. If it is [`Soundness::Unsound`],
/// it is allowed to invoke undefined behavior when obtaining the local UTC offset.
pub fn get_soundness() -> Soundness {
match LOCAL_OFFSET_IS_SOUND.load(Ordering::Relaxed) {
match LOCAL_OFFSET_IS_SOUND.load(Ordering::SeqCst) {
false => Soundness::Unsound,
true => Soundness::Sound,
}
Expand Down

0 comments on commit ec81282

Please sign in to comment.