sel4_atomic_ptr/
ordering.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// Copyright 2023, Colias Group, LLC
//
// SPDX-License-Identifier: MIT OR Apache-2.0
//

use core::sync::atomic::Ordering;

pub(crate) enum OrderingExhaustive {
    Relaxed,
    Release,
    Acquire,
    AcqRel,
    SeqCst,
}

impl From<OrderingExhaustive> for Ordering {
    fn from(order: OrderingExhaustive) -> Self {
        match order {
            OrderingExhaustive::Relaxed => Self::Relaxed,
            OrderingExhaustive::Release => Self::Release,
            OrderingExhaustive::Acquire => Self::Acquire,
            OrderingExhaustive::AcqRel => Self::AcqRel,
            OrderingExhaustive::SeqCst => Self::SeqCst,
        }
    }
}

impl From<Ordering> for OrderingExhaustive {
    fn from(order: Ordering) -> Self {
        match order {
            Ordering::Relaxed => Self::Relaxed,
            Ordering::Release => Self::Release,
            Ordering::Acquire => Self::Acquire,
            Ordering::AcqRel => Self::AcqRel,
            Ordering::SeqCst => Self::SeqCst,
            _ => panic!(),
        }
    }
}