Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add L4re support for arm #2362

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/unix/linux_like/linux/uclibc/arm/l4re.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/// L4Re specifics
/// This module contains definitions required by various L4Re libc backends.
/// Some of them are formally not part of the libc, but are a dependency of the
/// libc and hence we should provide them here.

pub type l4_umword_t = ::c_ulong; // Unsigned machine word.
pub type l4_mword_t = ::c_long; // Signed machine word.
pub type pthread_t = *mut ::c_void;

s! {
/// CPU sets.
pub struct l4_sched_cpu_set_t {
// from the L4Re docs
/// Combination of granularity and offset.
///
/// The granularity defines how many CPUs each bit in map describes.
/// The offset is the number of the first CPU described by the first
/// bit in the bitmap.
/// offset must be a multiple of 2^granularity.
///
/// | MSB | LSB |
/// | ---------------- | ------------------- |
/// | 8bit granularity | 24bit offset .. |
gran_offset: l4_umword_t ,
/// Bitmap of CPUs.
map: l4_umword_t ,
}
}

#[cfg(target_os = "l4re")]
#[allow(missing_debug_implementations)]
pub struct pthread_attr_t {
//including additional l4re members
__size: [::c_long; 11],

// L4Re specifics
pub affinity: l4_sched_cpu_set_t,
pub create_flags: ::c_uint,
}

// L4Re requires a min stack size of 64k; that isn't defined in uClibc, but
// somewhere in the core libraries. uClibc wants 16k, but that's not enough.
pub const PTHREAD_STACK_MIN: usize = 65536;
13 changes: 11 additions & 2 deletions src/unix/linux_like/linux/uclibc/arm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pub type fsblkcnt_t = ::c_ulong;
pub type fsfilcnt_t = ::c_ulong;
pub type ino_t = ::c_ulong;
pub type off_t = ::c_long;
pub type pthread_t = ::c_ulong;
pub type rlim_t = ::c_ulong;
pub type suseconds_t = ::c_long;

Expand Down Expand Up @@ -38,6 +37,7 @@ s! {
pub msg_flags: ::c_int,
}

#[cfg(not(target_os = "l4re"))]
pub struct pthread_attr_t {
__size: [::c_long; 9],
}
Expand Down Expand Up @@ -468,7 +468,6 @@ pub const PARODD: ::tcflag_t = 0x200;
pub const PENDIN: ::tcflag_t = 0x4000;
pub const POLLWRBAND: ::c_short = 0x200;
pub const POLLWRNORM: ::c_short = 0x100;
pub const PTHREAD_STACK_MIN: ::size_t = 16384;

// These are typed unsigned to match sigaction
pub const SA_NOCLDSTOP: ::c_ulong = 0x1;
Expand Down Expand Up @@ -900,3 +899,13 @@ cfg_if! {
pub use self::no_align::*;
}
}

cfg_if! {
if #[cfg(target_os = "l4re")] {
mod l4re;
pub use self::l4re::*;
} else {
mod other;
pub use other::*;
}
}
5 changes: 5 additions & 0 deletions src/unix/linux_like/linux/uclibc/arm/other.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Thestyle checker discourages the use of #[cfg], so this has to go into a
// separate module
pub type pthread_t = ::c_ulong;

pub const PTHREAD_STACK_MIN: ::size_t = 16384;
5 changes: 3 additions & 2 deletions src/unix/linux_like/linux/uclibc/x86_64/l4re.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/// libc and hence we should provide them here.

pub type l4_umword_t = ::c_ulong; // Unsigned machine word.
pub type l4_mword_t = ::c_long; // Signed machine word.
pub type pthread_t = *mut ::c_void;

s! {
Expand All @@ -13,9 +14,9 @@ s! {
/// Combination of granularity and offset.
///
/// The granularity defines how many CPUs each bit in map describes.
/// The offset is the numer of the first CPU described by the first
/// The offset is the number of the first CPU described by the first
/// bit in the bitmap.
/// offset must be a multiple of 2^graularity.
/// offset must be a multiple of 2^granularity.
///
/// | MSB | LSB |
/// | ---------------- | ------------------- |
Expand Down