diff --git a/src/unix/linux_like/linux/uclibc/arm/l4re.rs b/src/unix/linux_like/linux/uclibc/arm/l4re.rs new file mode 100644 index 0000000000000..6c9c0232c6ba9 --- /dev/null +++ b/src/unix/linux_like/linux/uclibc/arm/l4re.rs @@ -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; diff --git a/src/unix/linux_like/linux/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index dc6518c0daf8f..04fa28c4bdc2d 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -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; @@ -38,6 +37,7 @@ s! { pub msg_flags: ::c_int, } + #[cfg(not(target_os = "l4re"))] pub struct pthread_attr_t { __size: [::c_long; 9], } @@ -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; @@ -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::*; + } +} diff --git a/src/unix/linux_like/linux/uclibc/arm/other.rs b/src/unix/linux_like/linux/uclibc/arm/other.rs new file mode 100644 index 0000000000000..e7e9fb94284e3 --- /dev/null +++ b/src/unix/linux_like/linux/uclibc/arm/other.rs @@ -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; diff --git a/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs b/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs index 16ec0ef966473..72922510c338f 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs @@ -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! { @@ -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 | /// | ---------------- | ------------------- |