Skip to content

Commit b53043d

Browse files
authored
Merge pull request #212 from elfenpiff/iox2-200-integrate-iox-atomic
[#200] integrate iox atomic
2 parents 874dcf2 + 8a3fdbc commit b53043d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+564
-484
lines changed

.github/workflows/build-test.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,46 @@ jobs:
9393
artifact-bin-name: cargo-nextest
9494
artifact-upload-name: ${{ runner.os }}-cargo-nextest
9595

96+
x86_32:
97+
needs: [preflight-check, static-code-analysis, cargo-nextest]
98+
if: ${{ needs.changes.outputs.source-code == 'true' }}
99+
strategy:
100+
matrix:
101+
os: [ubuntu-latest] # [windows-latest, ubuntu-latest, macos-latest]
102+
toolchain: [stable] # [stable, 1.73.0, beta, nightly]
103+
mode:
104+
- name: "release"
105+
arg: "--release"
106+
- name: "debug"
107+
arg: ""
108+
timeout-minutes: 60
109+
runs-on: ${{ matrix.os }}
110+
steps:
111+
- name: Checkout sources
112+
uses: actions/checkout@v4
113+
114+
- name: Setup Rust
115+
uses: dtolnay/rust-toolchain@v1
116+
with:
117+
toolchain: ${{ matrix.toolchain }}
118+
targets: i686-unknown-linux-gnu
119+
components: rustfmt, clippy
120+
121+
- name: Download artifact cargo-nextest
122+
uses: ./.github/actions/download-cached-rust-tool
123+
with:
124+
artifact-bin-name: cargo-nextest
125+
artifact-upload-name: ${{ runner.os }}-cargo-nextest
126+
127+
- name: Prepare system
128+
run: ${{ matrix.os == 'windows-latest' && 'internal\scripts\ci_prepare_windows.bat' || ( matrix.os == 'ubuntu-latest' && './internal/scripts/ci_prepare_ubuntu.sh' || 'uname -a' ) }}
129+
130+
- name: Run cargo build
131+
run: cargo build --workspace --all-targets ${{ matrix.mode.arg }} --target i686-unknown-linux-gnu
132+
133+
- name: Run cargo nextest
134+
run: cargo nextest run --workspace --no-fail-fast ${{ matrix.mode.arg }} --target i686-unknown-linux-gnu
135+
96136
x86_64:
97137
needs: [preflight-check, static-code-analysis, cargo-nextest]
98138
if: ${{ needs.changes.outputs.source-code == 'true' }}

clippy.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
disallowed-types = [
2+
"std::sync::atomic::AtomicI8",
3+
"std::sync::atomic::AtomicI16",
4+
"std::sync::atomic::AtomicI32",
5+
"std::sync::atomic::AtomicI64",
6+
"std::sync::atomic::AtomicU8",
7+
"std::sync::atomic::AtomicU16",
8+
"std::sync::atomic::AtomicU32",
9+
"std::sync::atomic::AtomicU64",
10+
"std::sync::atomic::AtomicBool",
11+
"std::sync::atomic::AtomicIsize",
12+
"std::sync::atomic::AtomicPtr",
13+
"std::sync::atomic::AtomicUsize",
14+
"core::sync::atomic::AtomicI8",
15+
"core::sync::atomic::AtomicI16",
16+
"core::sync::atomic::AtomicI32",
17+
"core::sync::atomic::AtomicI64",
18+
"core::sync::atomic::AtomicU8",
19+
"core::sync::atomic::AtomicU16",
20+
"core::sync::atomic::AtomicU32",
21+
"core::sync::atomic::AtomicU64",
22+
"core::sync::atomic::AtomicBool",
23+
"core::sync::atomic::AtomicIsize",
24+
"core::sync::atomic::AtomicPtr",
25+
"core::sync::atomic::AtomicUsize",
26+
]

doc/release-notes/iceoryx2-unreleased.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@
4040
sample.send()?;
4141
}
4242
```
43-
* Introduce `IoxAtomic` that supports up to 128bit atomics on 32-bit architecture with a ReadWriteLock [#200](https://github.com/eclipse-iceoryx/iceoryx2/issues/200)
43+
* 32-bit support [#200](https://github.com/eclipse-iceoryx/iceoryx2/issues/200)
44+
* Introduce `IoxAtomic` that supports up to 128bit atomics on 32-bit architecture with a ReadWriteLock
45+
* add CI targets to officially support 32-bit
4446
* Example that demonstrates publish-subscribe communication with dynamic data [#205](https://github.com/eclipse-iceoryx/iceoryx2/issues/205)
4547

48+
4649
### Bugfixes
4750

4851
<!-- NOTE: Add new entries sorted by issue number to minimize the possibility of conflicts when merging. -->

iceoryx2-bb/container/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ version = { workspace = true }
1515
[dependencies]
1616
iceoryx2-bb-elementary = { workspace = true }
1717
iceoryx2-bb-log = { workspace = true }
18+
iceoryx2-pal-concurrency-sync = { workspace = true }
1819

1920
[dev-dependencies]
2021
generic-tests = { workspace = true }

iceoryx2-bb/container/src/queue.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,15 @@
9797
//!
9898
use iceoryx2_bb_elementary::allocator::{AllocationError, BaseAllocator};
9999
use iceoryx2_bb_elementary::math::align_to;
100+
use iceoryx2_bb_elementary::math::unaligned_mem_size;
100101
use iceoryx2_bb_elementary::owning_pointer::OwningPointer;
101102
use iceoryx2_bb_elementary::pointer_trait::PointerTrait;
103+
pub use iceoryx2_bb_elementary::relocatable_container::RelocatableContainer;
102104
use iceoryx2_bb_elementary::relocatable_ptr::RelocatablePointer;
103105
use iceoryx2_bb_log::{fail, fatal_panic};
104-
use std::sync::atomic::AtomicBool;
105-
use std::{alloc::Layout, fmt::Debug, mem::MaybeUninit};
106-
107-
use iceoryx2_bb_elementary::math::unaligned_mem_size;
108-
pub use iceoryx2_bb_elementary::relocatable_container::RelocatableContainer;
106+
use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicBool;
109107
use std::marker::PhantomData;
108+
use std::{alloc::Layout, fmt::Debug, mem::MaybeUninit};
110109

111110
/// Queue with run-time fixed size capacity. In contrast to its counterpart the
112111
/// [`RelocatableQueue`] it is movable but is not shared memory compatible.
@@ -124,7 +123,7 @@ pub mod details {
124123
start: usize,
125124
len: usize,
126125
capacity: usize,
127-
is_initialized: AtomicBool,
126+
is_initialized: IoxAtomicBool,
128127
_phantom_data: PhantomData<T>,
129128
}
130129

@@ -138,7 +137,7 @@ pub mod details {
138137
start: 0,
139138
len: 0,
140139
capacity,
141-
is_initialized: AtomicBool::new(true),
140+
is_initialized: IoxAtomicBool::new(true),
142141
_phantom_data: PhantomData,
143142
}
144143
}
@@ -200,7 +199,7 @@ pub mod details {
200199
start: 0,
201200
len: 0,
202201
capacity,
203-
is_initialized: AtomicBool::new(true),
202+
is_initialized: IoxAtomicBool::new(true),
204203
_phantom_data: PhantomData,
205204
}
206205
}
@@ -211,7 +210,7 @@ pub mod details {
211210
start: 0,
212211
len: 0,
213212
capacity,
214-
is_initialized: AtomicBool::new(false),
213+
is_initialized: IoxAtomicBool::new(false),
215214
_phantom_data: PhantomData,
216215
}
217216
}

iceoryx2-bb/container/src/vec.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,7 @@
7575
//! unsafe { vec.init(&bump_allocator).expect("vec init failed") };
7676
//! ```
7777
78-
use std::{
79-
alloc::Layout,
80-
mem::MaybeUninit,
81-
ops::Deref,
82-
ops::DerefMut,
83-
sync::atomic::{AtomicBool, Ordering},
84-
};
78+
use std::{alloc::Layout, mem::MaybeUninit, ops::Deref, ops::DerefMut, sync::atomic::Ordering};
8579

8680
use iceoryx2_bb_elementary::{
8781
math::{align_to, unaligned_mem_size},
@@ -90,6 +84,7 @@ use iceoryx2_bb_elementary::{
9084
relocatable_ptr::RelocatablePointer,
9185
};
9286
use iceoryx2_bb_log::{fail, fatal_panic};
87+
use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicBool;
9388

9489
/// **Non-movable** relocatable vector with runtime fixed size capacity.
9590
#[repr(C)]
@@ -98,7 +93,7 @@ pub struct RelocatableVec<T> {
9893
data_ptr: RelocatablePointer<MaybeUninit<T>>,
9994
capacity: usize,
10095
len: usize,
101-
is_initialized: AtomicBool,
96+
is_initialized: IoxAtomicBool,
10297
}
10398

10499
unsafe impl<T: Send> Send for RelocatableVec<T> {}
@@ -115,7 +110,7 @@ impl<T> RelocatableContainer for RelocatableVec<T> {
115110
data_ptr: RelocatablePointer::new(distance_to_data),
116111
capacity,
117112
len: 0,
118-
is_initialized: AtomicBool::new(true),
113+
is_initialized: IoxAtomicBool::new(true),
119114
}
120115
}
121116

@@ -124,7 +119,7 @@ impl<T> RelocatableContainer for RelocatableVec<T> {
124119
data_ptr: RelocatablePointer::new_uninit(),
125120
capacity,
126121
len: 0,
127-
is_initialized: AtomicBool::new(false),
122+
is_initialized: IoxAtomicBool::new(false),
128123
}
129124
}
130125

iceoryx2-bb/elementary/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ repository = { workspace = true }
1010
rust-version = { workspace = true }
1111
version = { workspace = true }
1212

13+
[dependencies]
14+
iceoryx2-pal-concurrency-sync = { workspace = true }
15+
1316
[dev-dependencies]
1417
iceoryx2-bb-testing = { workspace = true }
1518

iceoryx2-bb/elementary/src/bump_allocator.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,22 @@
1111
// SPDX-License-Identifier: Apache-2.0 OR MIT
1212

1313
use crate::{allocator::BaseAllocator, math::align};
14-
use std::sync::atomic::{AtomicUsize, Ordering};
14+
use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicUsize;
15+
use std::sync::atomic::Ordering;
1516

1617
/// Simple BumpAllocator for testing purposes. Do not use this in production. If you are looking
1718
/// for a production ready BumpAllocator use the one from iceoryx2_bb_memory::bump_allocator
1819
#[doc(hidden)]
1920
pub struct BumpAllocator {
2021
start: usize,
21-
pos: AtomicUsize,
22+
pos: IoxAtomicUsize,
2223
}
2324

2425
impl BumpAllocator {
2526
pub fn new(start: usize) -> Self {
2627
Self {
2728
start,
28-
pos: AtomicUsize::new(start),
29+
pos: IoxAtomicUsize::new(start),
2930
}
3031
}
3132
}

iceoryx2-bb/elementary/src/lazy_singleton.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,33 @@
3333
//! println!("{}", LAZY_GLOBAL.get());
3434
//! ```
3535
36-
use std::{
37-
cell::UnsafeCell,
38-
sync::atomic::{AtomicBool, Ordering},
39-
};
36+
use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicBool;
37+
use std::{cell::UnsafeCell, sync::atomic::Ordering};
4038

4139
/// The lazy initialized singleton building block of type T
4240
#[derive(Debug)]
4341
pub struct LazySingleton<T> {
4442
data: UnsafeCell<Option<T>>,
45-
is_initialized: AtomicBool,
46-
is_finalized: AtomicBool,
43+
is_initialized: IoxAtomicBool,
44+
is_finalized: IoxAtomicBool,
4745
}
4846

4947
unsafe impl<T: Send> Send for LazySingleton<T> {}
5048
unsafe impl<T: Send + Sync> Sync for LazySingleton<T> {}
5149

50+
impl<T> Default for LazySingleton<T> {
51+
fn default() -> Self {
52+
Self::new()
53+
}
54+
}
55+
5256
impl<T> LazySingleton<T> {
5357
/// Creates a new [`LazySingleton`] where the underlying value is not yet initialized.
5458
pub const fn new() -> Self {
5559
Self {
5660
data: UnsafeCell::new(None),
57-
is_initialized: AtomicBool::new(false),
58-
is_finalized: AtomicBool::new(false),
61+
is_initialized: IoxAtomicBool::new(false),
62+
is_finalized: IoxAtomicBool::new(false),
5963
}
6064
}
6165

iceoryx2-bb/elementary/src/package_version.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
//
1111
// SPDX-License-Identifier: Apache-2.0 OR MIT
1212

13-
use std::{
14-
fmt::Display,
15-
sync::atomic::{AtomicU64, Ordering},
16-
};
13+
use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicU64;
14+
use std::{fmt::Display, sync::atomic::Ordering};
1715

1816
/// Represents the crates version acquired through the internal environment variables set by cargo,
1917
/// ("CARGO_PKG_VERSION_{MAJOR|MINOR|PATCH}").
@@ -65,7 +63,7 @@ impl PackageVersion {
6563

6664
/// Returns the current [`PackageVersion`]
6765
pub fn get() -> PackageVersion {
68-
static PACKAGE_VERSION: AtomicU64 = AtomicU64::new(0);
66+
static PACKAGE_VERSION: IoxAtomicU64 = IoxAtomicU64::new(0);
6967

7068
if PACKAGE_VERSION.load(Ordering::Relaxed) == 0 {
7169
let major = option_env!("CARGO_PKG_VERSION_MAJOR")

iceoryx2-bb/elementary/src/relocatable_ptr.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
//! ```
6666
6767
pub use crate::pointer_trait::PointerTrait;
68-
use std::{marker::PhantomData, ptr::NonNull, sync::atomic::AtomicIsize};
68+
use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicIsize;
69+
use std::{marker::PhantomData, ptr::NonNull};
6970

7071
/// A [`RelocatablePointer`] stores only the distance from its memory starting position to the
7172
/// memory location it is pointing to. When the [`RelocatablePointer`] is now shared between
@@ -83,7 +84,7 @@ use std::{marker::PhantomData, ptr::NonNull, sync::atomic::AtomicIsize};
8384
#[repr(C)]
8485
#[derive(Debug)]
8586
pub struct RelocatablePointer<T> {
86-
distance: AtomicIsize,
87+
distance: IoxAtomicIsize,
8788
_phantom: PhantomData<T>,
8889
}
8990

@@ -92,7 +93,7 @@ impl<T> RelocatablePointer<T> {
9293
/// destination starting from the memory location of this [`RelocatablePointer`].
9394
pub fn new(distance: isize) -> Self {
9495
Self {
95-
distance: AtomicIsize::new(distance),
96+
distance: IoxAtomicIsize::new(distance),
9697
_phantom: PhantomData,
9798
}
9899
}

iceoryx2-bb/elementary/src/unique_id.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,8 @@
6363
//! }
6464
//! ```
6565
66-
use std::{
67-
marker::PhantomData,
68-
sync::atomic::{AtomicU64, Ordering},
69-
};
66+
use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicU64;
67+
use std::{marker::PhantomData, sync::atomic::Ordering};
7068

7169
/// A building block to generate global unique ids
7270
#[derive(Debug, Eq, Hash, PartialEq)]
@@ -76,7 +74,7 @@ pub struct UniqueId {
7674

7775
impl Default for UniqueId {
7876
fn default() -> Self {
79-
static COUNTER: AtomicU64 = AtomicU64::new(0);
77+
static COUNTER: IoxAtomicU64 = IoxAtomicU64::new(0);
8078

8179
UniqueId {
8280
value: COUNTER.fetch_add(1, Ordering::Relaxed),
@@ -106,7 +104,7 @@ pub struct TypedUniqueId<T> {
106104

107105
impl<T> Default for TypedUniqueId<T> {
108106
fn default() -> Self {
109-
static COUNTER: AtomicU64 = AtomicU64::new(0);
107+
static COUNTER: IoxAtomicU64 = IoxAtomicU64::new(0);
110108

111109
Self {
112110
value: COUNTER.fetch_add(1, Ordering::Relaxed),

iceoryx2-bb/lock-free/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ version = { workspace = true }
1313
[dependencies]
1414
iceoryx2-bb-log = { workspace = true }
1515
iceoryx2-bb-elementary = { workspace = true }
16+
iceoryx2-pal-concurrency-sync = { workspace = true }
1617

1718
tiny-fn = { workspace = true }
1819

0 commit comments

Comments
 (0)