Skip to content

Commit e412497

Browse files
committed
Move L4Re-specific code into separate module.
1 parent 86cb2a2 commit e412497

File tree

2 files changed

+55
-30
lines changed

2 files changed

+55
-30
lines changed

src/unix/uclibc/x86_64/l4re.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/// L4Re specifics
2+
/// This module contains definitions required by various L4Re libc backends.
3+
/// These are formally not part of the libc, but are a dependency of the libc
4+
/// and hence we should provide them here.
5+
6+
pub type l4_umword_t = ::c_ulong; // Unsigned machine word.
7+
8+
s! {
9+
/// CPU sets.
10+
pub struct l4_sched_cpu_set_t {
11+
// from the L4Re docs
12+
/// Combination of granularity and offset.
13+
///
14+
/// The granularity defines how many CPUs each bit in map describes.
15+
/// The offset is the numer of the first CPU described by the first
16+
/// bit in the bitmap.
17+
/// offset must be a multiple of 2^graularity.
18+
///
19+
/// | MSB | LSB |
20+
/// | ---------------- | ------------------- |
21+
/// | 8bit granularity | 24bit offset .. |
22+
gran_offset: l4_umword_t ,
23+
/// Bitmap of CPUs.
24+
map: l4_umword_t ,
25+
}
26+
}
27+
28+
#[cfg(target_os = "l4re")]
29+
pub struct pthread_attr_t {
30+
pub __detachstate: ::c_int,
31+
pub __schedpolicy: ::c_int,
32+
pub __schedparam: super::__sched_param,
33+
pub __inheritsched: ::c_int,
34+
pub __scope: ::c_int,
35+
pub __guardsize: ::size_t,
36+
pub __stackaddr_set: ::c_int,
37+
pub __stackaddr: *mut ::c_void, // better don't use it
38+
pub __stacksize: ::size_t,
39+
// L4Re specifics
40+
pub affinity: l4_sched_cpu_set_t,
41+
pub create_flags: ::c_uint,
42+
}
43+

src/unix/uclibc/x86_64/mod.rs

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//! Definitions for l4re-uclibc on 64bit systems
2-
1+
//! Definitions for uclibc on 64bit systems
2+
//!
33
pub type blkcnt_t = i64;
44
pub type blksize_t = i64;
55
pub type clock_t = i64;
@@ -22,12 +22,6 @@ pub type wchar_t = ::c_int;
2222
//pub type d_ino = ::c_ulong;
2323
pub type nfds_t = ::c_ulong;
2424

25-
// L4Re specifics
26-
// Some of these aren't actually part of the libc, but of l4sys, but since libc
27-
// depends on l4sys on this platform, we should dump the few important
28-
// definitions here.
29-
pub type l4_umword_t = ::c_ulong; // Unsigned machine word.
30-
3125
s! {
3226
pub struct dirent {
3327
pub d_ino: ::ino64_t,
@@ -59,24 +53,7 @@ s! {
5953
__unused2: ::c_ulong
6054
}
6155

62-
/// CPU sets.
63-
pub struct l4_sched_cpu_set_t {
64-
// from the L4Re docs
65-
/// Combination of granularity and offset.
66-
///
67-
/// The granularity defines how many CPUs each bit in map describes.
68-
/// The offset is the numer of the first CPU described by the first
69-
/// bit in the bitmap.
70-
/// offset must be a multiple of 2^graularity.
71-
///
72-
/// | MSB | LSB |
73-
/// | ---------------- | ------------------- |
74-
/// | 8bit granularity | 24bit offset .. |
75-
gran_offset: l4_umword_t ,
76-
/// Bitmap of CPUs.
77-
map: l4_umword_t ,
78-
}
79-
56+
#[cfg(not(target_os = "l4re"))]
8057
pub struct pthread_attr_t {
8158
__detachstate: ::c_int,
8259
__schedpolicy: ::c_int,
@@ -87,9 +64,6 @@ s! {
8764
__stackaddr_set: ::c_int,
8865
__stackaddr: *mut ::c_void, // better don't use it
8966
__stacksize: ::size_t,
90-
// L4Re specifics
91-
affinity: l4_sched_cpu_set_t,
92-
create_flags: ::c_uint,
9367
}
9468

9569
pub struct __sched_param {
@@ -399,7 +373,7 @@ pub const O_EXCL: ::c_int = 0200;
399373
pub const O_NONBLOCK: ::c_int = 04000;
400374
pub const O_TRUNC: ::c_int = 01000;
401375
pub const NCCS: usize = 32;
402-
pub const PTHREAD_STACK_MIN: ::c_int = 16384;
376+
pub const PTHREAD_STACK_MIN: usize = 16384;
403377
pub const SIG_SETMASK: ::c_int = 2; // Set the set of blocked signals
404378
pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
405379
pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
@@ -415,3 +389,11 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
415389
extern {
416390
pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
417391
}
392+
393+
cfg_if! {
394+
if #[cfg(target_os = "l4re")] {
395+
mod l4re;
396+
pub use self::l4re::*;
397+
} else { }
398+
}
399+

0 commit comments

Comments
 (0)