From 67f5cd4def04719ebf0dbaf995cf37846e6d105d Mon Sep 17 00:00:00 2001 From: Autumnal Date: Mon, 16 Aug 2021 14:25:13 +0200 Subject: [PATCH 1/2] arm l4re patch --- src/unix/linux_like/linux/uclibc/arm/l4re.rs | 42 +++++++++++++++++++ src/unix/linux_like/linux/uclibc/arm/mod.rs | 13 +++++- src/unix/linux_like/linux/uclibc/arm/other.rs | 5 +++ .../linux_like/linux/uclibc/x86_64/l4re.rs | 4 +- 4 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 src/unix/linux_like/linux/uclibc/arm/l4re.rs create mode 100644 src/unix/linux_like/linux/uclibc/arm/other.rs 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..3c5a59cc9aed5 --- /dev/null +++ b/src/unix/linux_like/linux/uclibc/arm/l4re.rs @@ -0,0 +1,42 @@ +/// 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 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; \ No newline at end of file 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..68d402781fd49 --- /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; \ No newline at end of file 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..579a87a294c24 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs @@ -13,9 +13,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 | /// | ---------------- | ------------------- | From f5d96565a73c990f8e476d7cfccde3f37f120b8a Mon Sep 17 00:00:00 2001 From: Autumnal Date: Tue, 17 Aug 2021 00:52:06 +0200 Subject: [PATCH 2/2] added l4re signed word --- src/unix/linux_like/linux/uclibc/arm/l4re.rs | 3 ++- src/unix/linux_like/linux/uclibc/arm/other.rs | 2 +- src/unix/linux_like/linux/uclibc/x86_64/l4re.rs | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/unix/linux_like/linux/uclibc/arm/l4re.rs b/src/unix/linux_like/linux/uclibc/arm/l4re.rs index 3c5a59cc9aed5..6c9c0232c6ba9 100644 --- a/src/unix/linux_like/linux/uclibc/arm/l4re.rs +++ b/src/unix/linux_like/linux/uclibc/arm/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! { @@ -39,4 +40,4 @@ pub struct pthread_attr_t { // 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; \ No newline at end of file +pub const PTHREAD_STACK_MIN: usize = 65536; diff --git a/src/unix/linux_like/linux/uclibc/arm/other.rs b/src/unix/linux_like/linux/uclibc/arm/other.rs index 68d402781fd49..e7e9fb94284e3 100644 --- a/src/unix/linux_like/linux/uclibc/arm/other.rs +++ b/src/unix/linux_like/linux/uclibc/arm/other.rs @@ -2,4 +2,4 @@ // separate module pub type pthread_t = ::c_ulong; -pub const PTHREAD_STACK_MIN: ::size_t = 16384; \ No newline at end of file +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 579a87a294c24..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! {