Skip to content
Snippets Groups Projects
Commit 2a7b7b70 authored by Philippe Gerum's avatar Philippe Gerum
Browse files

treewide: derive common convenience traits


Signed-off-by: default avatarPhilippe Gerum <rpm@xenomai.org>
parent 06792710
No related branches found
No related tags found
No related merge requests found
......@@ -39,7 +39,11 @@ use embedded_time::{
/// A core system clock which has nanosecond resolution. This type is
/// a wrapper to an EVL [clock
/// element](https://evlproject.org/core/user-api/clock/).
#[derive(Debug)]
///
/// The CoreClock struct is a facade to access built in clocks which
/// never vanish, therefore there is no attempt to discard/close the
/// latter upon Drop.
#[derive(PartialEq, Debug)]
pub struct CoreClock(pub(crate) BuiltinClock);
impl Clock for CoreClock {
......
......@@ -52,7 +52,7 @@ pub const DEFAULT_PROXY_BUFSZ: usize = 4096;
/// A proxy builder contains properties and settings to be used for
/// creating a new proxy.
#[derive(Default)]
#[derive(Default, Debug)]
pub struct Builder {
/// The proxy name. See [this
/// document](https://evlproject.org/core/user-api/#element-naming-convention)
......@@ -362,6 +362,7 @@ impl Builder {
}
}
#[derive(Default, PartialEq, Debug)]
pub struct Proxy(pub(crate) c_int);
unsafe impl Send for Proxy {}
......
......@@ -54,12 +54,14 @@ const RING_EMPTY_VAL: usize = !0;
/// Cursor pointing at the head of a ring buffer, aligned on a
/// (conservative) cacheline size to prevent too much bouncing.
#[derive(Debug)]
#[repr(align(128))] // CACHELINE_ALIGNMENT
struct Head {
d: AtomicUsize,
}
/// Value of the threshold bound for livelock prevention.
#[derive(Debug)]
#[repr(align(128))]
struct Threshold {
d: AtomicIsize,
......@@ -67,6 +69,7 @@ struct Threshold {
/// Cursor pointing at the tail of a ring buffer, aligned on the
/// cacheline size to prevent too much bouncing.
#[derive(Debug)]
#[repr(align(128))]
struct Tail {
d: AtomicUsize,
......@@ -80,6 +83,7 @@ fn sub_with_overflow(lhs: usize, rhs: usize) -> isize {
/// buffers, one storing indices of messages pending receive which are
/// available at the corresponding cells from the data vector, another
/// storing indices of free cells into the data vector.
#[derive(Debug)]
#[repr(align(128))]
// Revisit when we have complex const generics, so that we can
// define an array inline [ AtomicUsize; 1 << (ORDER + 1) ].
......@@ -275,6 +279,7 @@ impl<const ORDER: usize> Ring<ORDER> {
///
/// Messages can be sent to the associated FIFO through this channel
/// with [send()](crate::ring::Sender::send).
#[derive(Debug)]
pub struct Sender<T, const ORDER: usize> {
/// The associated FIFO to send messages to.
rq: Arc<RingQueue<T, ORDER>>,
......@@ -340,6 +345,7 @@ impl<T: Default, const ORDER: usize> Clone for Sender<T, ORDER> {
///
/// Messages can be received from the associated FIFO through this
/// channel with [recv()](crate::ring::Receiver::recv).
#[derive(Debug)]
pub struct Receiver<T, const ORDER: usize> {
/// The associated FIFO to receive messages from.
rq: Arc<RingQueue<T, ORDER>>,
......@@ -400,6 +406,7 @@ impl<T: Default, const ORDER: usize> Clone for Receiver<T, ORDER> {
}
}
#[derive(Debug)]
struct RingQueue<T, const ORDER: usize> {
/// Ring buffer containing indices pointing at busy cells into the
/// data vector.
......
......@@ -44,7 +44,7 @@ use crate::thread::Thread;
/// An event builder contains properties and settings to be used for
/// creating a new event.
#[derive(Default)]
#[derive(Default, Debug)]
pub struct Builder {
/// The event name. See [this
/// document](https://evlproject.org/core/user-api/#element-naming-convention)
......@@ -178,6 +178,7 @@ impl Builder {
}
}
#[derive(Debug)]
pub struct WaitTimeoutResult(bool);
impl WaitTimeoutResult {
......@@ -189,6 +190,7 @@ impl WaitTimeoutResult {
/// An event synchronization object while allows for waiting for
/// notifications in a raceless way.
#[derive(Debug)]
pub struct Event(UnsafeCell<evl_event>);
unsafe impl Send for Event {}
......
......@@ -50,7 +50,7 @@ use crate::clock::CoreClock;
/// A builder contains properties and settings to be used for creating
/// a new flag group.
#[derive(Default)]
#[derive(Default, Debug)]
pub struct Builder {
/// The flag group name. See [this
/// document](https://evlproject.org/core/user-api/#element-naming-convention)
......@@ -221,6 +221,7 @@ impl Builder {
/// The Flags struct implements a thread synchronization mechanism
/// based on an atomically-accessed bitmask.
#[derive(Debug)]
pub struct Flags(UnsafeCell<evl_flags>);
unsafe impl Send for Flags {}
......
......@@ -36,7 +36,7 @@ use crate::clock::CoreClock;
/// A builder contains properties and settings to be used for creating
/// a new mutex.
#[derive(Default)]
#[derive(Default, Debug)]
pub struct Builder {
/// The mutex name. See [this
/// document](https://evlproject.org/core/user-api/#element-naming-convention)
......
......@@ -38,7 +38,7 @@ use crate::clock::CoreClock;
/// An event builder contains properties and settings to be used for
/// creating a new semaphore.
#[derive(Default)]
#[derive(Default, Debug)]
pub struct Builder {
/// The semaphore name. See [this
/// document](https://evlproject.org/core/user-api/#element-naming-convention)
......@@ -224,6 +224,7 @@ impl Builder {
}
}
#[derive(Debug)]
pub struct Semaphore(UnsafeCell<evl_sem>);
unsafe impl Send for Semaphore {}
......
......@@ -42,6 +42,7 @@ use embedded_time::{
use crate::clock::CoreClock;
/// A timer based on a particular clock.
#[derive(PartialEq, Debug)]
pub struct Timer(pub(crate) c_int);
impl Timer {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment