Skip to content

Commit 91dee18

Browse files
[#1798] Add musl support
1 parent e9a06b7 commit 91dee18

5 files changed

Lines changed: 29 additions & 10 deletions

File tree

doc/release-notes/iceoryx2-unreleased.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* [#1707](https://github.com/eclipse-iceoryx/iceoryx2/issues/1707) Expose `CustomHeaderMarker` and `CustomPayloadMarker` in C++ bindings
2424
* [#1722](https://github.com/eclipse-iceoryx/iceoryx2/issues/1722) Remove allocations in tunnel hot path
2525
* [#1773](https://github.com/eclipse-iceoryx/iceoryx2/issues/1773) Make ports identifiable by name
26+
* [#1798](https://github.com/eclipse-iceoryx/iceoryx2/issues/1798) Add musl support
2627

2728
### Bugfixes
2829

iceoryx2-bb/posix/src/socket_ancillary.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,19 +251,18 @@ impl UdsMsgHeader {
251251

252252
impl Default for SocketAncillary {
253253
fn default() -> Self {
254+
let mut message = posix::msghdr::new_zeroed();
255+
message.msg_name = core::ptr::null_mut::<posix::void>();
256+
message.msg_iov = core::ptr::null_mut();
257+
message.msg_iovlen = IOVEC_BUFFER_CAPACITY as _;
258+
message.msg_control = core::ptr::null_mut::<posix::void>();
259+
message.msg_controllen = buffer_capacity() as _;
260+
254261
let mut new_self = Self {
255262
message_buffer: [0u8; BUFFER_CAPACITY],
256263
iovec_buffer: [0u8; IOVEC_BUFFER_CAPACITY],
257264
iovec: unsafe { core::mem::zeroed() },
258-
message: posix::msghdr {
259-
msg_name: core::ptr::null_mut::<posix::void>(),
260-
msg_namelen: 0,
261-
msg_iov: core::ptr::null_mut(),
262-
msg_iovlen: IOVEC_BUFFER_CAPACITY as _,
263-
msg_control: core::ptr::null_mut::<posix::void>(),
264-
msg_controllen: buffer_capacity() as _,
265-
msg_flags: 0,
266-
},
265+
message,
267266
file_descriptors: vec![],
268267
credentials: None,
269268
is_prepared_for_send: false,

iceoryx2-pal/posix/src/common/cpu_set_t.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ use crate::posix::{CPU_SETSIZE, MemZeroedStruct};
1818
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
1919
#[repr(C)]
2020
pub struct cpu_set_t {
21+
#[cfg(not(target_env = "musl"))]
2122
pub __bits: [u8; CPU_SETSIZE / 8],
23+
#[cfg(target_env = "musl")]
24+
pub __bits: [u8; CPU_SETSIZE],
2225
}
2326
impl MemZeroedStruct for cpu_set_t {}
2427

@@ -46,7 +49,10 @@ impl cpu_set_t {
4649

4750
pub(crate) fn new_allow_all() -> Self {
4851
Self {
52+
#[cfg(not(target_env = "musl"))]
4953
__bits: [0xff; CPU_SETSIZE / 8],
54+
#[cfg(target_env = "musl")]
55+
__bits: [0xff; CPU_SETSIZE],
5056
}
5157
}
5258
}

iceoryx2-pal/posix/src/linux/pthread.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@
1515

1616
use crate::posix::*;
1717

18+
#[allow(unused_variables)]
1819
pub unsafe fn pthread_rwlockattr_setkind_np(attr: *mut pthread_rwlockattr_t, pref: int) -> int {
19-
unsafe { libc::pthread_rwlockattr_setkind_np(attr, pref) }
20+
#[cfg(target_env = "musl")]
21+
todo!(); // TODO this function is not used; shall we remove it
22+
#[cfg(not(target_env = "musl"))]
23+
unsafe {
24+
libc::pthread_rwlockattr_setkind_np(attr, pref)
25+
}
2026
}
2127

2228
pub unsafe fn pthread_barrier_wait(barrier: *mut pthread_barrier_t) -> int {
@@ -81,11 +87,15 @@ pub unsafe fn pthread_attr_setstacksize(attr: *mut pthread_attr_t, stacksize: si
8187
unsafe { libc::pthread_attr_setstacksize(attr, stacksize) }
8288
}
8389

90+
#[allow(unused_variables)]
8491
pub unsafe fn pthread_attr_setaffinity_np(
8592
attr: *mut pthread_attr_t,
8693
cpusetsize: size_t,
8794
cpuset: *const cpu_set_t,
8895
) -> int {
96+
#[cfg(target_env = "musl")]
97+
return 0;
98+
#[cfg(not(target_env = "musl"))]
8999
unsafe {
90100
let cpuset = core::mem::transmute::<cpu_set_t, native_cpu_set_t>(*cpuset);
91101

iceoryx2-pal/posix/src/linux/support.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ pub const POSIX_SUPPORT_ACL: bool = true;
1414
pub const POSIX_SUPPORT_NAMED_SEMAPHORE: bool = true;
1515
pub const POSIX_SUPPORT_PERSISTENT_SHARED_MEMORY: bool = true;
1616
pub const POSIX_SUPPORT_UNIX_DATAGRAM_SOCKETS_ANCILLARY_DATA: bool = true;
17+
#[cfg(not(target_env = "musl"))]
1718
pub const POSIX_SUPPORT_CPU_AFFINITY: bool = true;
19+
#[cfg(target_env = "musl")]
20+
pub const POSIX_SUPPORT_CPU_AFFINITY: bool = false;
1821
pub const POSIX_SUPPORT_USERS_AND_GROUPS: bool = true;
1922
pub const POSIX_SUPPORT_PERMISSIONS: bool = true;
2023
pub const POSIX_SUPPORT_FILE_LOCK: bool = true;

0 commit comments

Comments
 (0)