Skip to content

Commit bd50e59

Browse files
committed
Improve types for uclibc/x86_64
* fix dirent, dirent64 * port pthread_attr_t * add l4re-specific pthread code
1 parent 2a5b50b commit bd50e59

File tree

1 file changed

+59
-20
lines changed

1 file changed

+59
-20
lines changed

src/unix/uclibc/x86_64/mod.rs

Lines changed: 59 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,29 @@ 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+
2531
s! {
32+
pub struct dirent {
33+
pub d_ino: ::ino64_t,
34+
pub d_off: ::off64_t,
35+
pub d_reclen: u16,
36+
pub d_type: u8,
37+
pub d_name: [::c_char; 256],
38+
}
39+
40+
pub struct dirent64 {
41+
pub d_ino: ::ino64_t,
42+
pub d_off: ::off64_t,
43+
pub d_reclen: u16,
44+
pub d_type: u8,
45+
pub d_name: [::c_char; 256],
46+
}
47+
2648
pub struct ipc_perm {
2749
pub __key: ::key_t,
2850
pub uid: ::uid_t,
@@ -37,6 +59,43 @@ s! {
3759
__unused2: ::c_ulong
3860
}
3961

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+
80+
pub struct pthread_attr_t {
81+
__detachstate: ::c_int,
82+
__schedpolicy: ::c_int,
83+
__schedparam: __sched_param,
84+
__inheritsched: ::c_int,
85+
__scope: ::c_int,
86+
__guardsize: ::size_t,
87+
__stackaddr_set: ::c_int,
88+
__stackaddr: *mut ::c_void, // better don't use it
89+
__stacksize: ::size_t,
90+
// L4Re specifics
91+
affinity: l4_sched_cpu_set_t,
92+
create_flags: ::c_uint,
93+
}
94+
95+
pub struct __sched_param {
96+
__sched_priority: ::c_int,
97+
}
98+
4099
pub struct siginfo_t {
41100
si_signo: ::c_int, // signal number
42101
si_errno: ::c_int, // if not zero: error value of signal, see errno.h
@@ -147,26 +206,6 @@ s! {
147206
__f_spare: [::c_int; 6],
148207
}
149208

150-
pub struct dirent { // Todo
151-
pub d_ino: ::ino64_t,
152-
pub d_off: ::off64_t,
153-
d_reclen: u16,
154-
pub d_type: u8,
155-
pub d_name: [i8; 256],
156-
}
157-
158-
pub struct dirent64 { //
159-
pub d_ino: ::ino64_t,
160-
pub d_off: ::off64_t,
161-
pub d_reclen: u16,
162-
pub d_type: u8,
163-
pub d_name: [i8; 256],
164-
}
165-
166-
pub struct pthread_attr_t { // ToDo
167-
__size: [u64; 7]
168-
}
169-
170209
pub struct sigaction { // TODO!!
171210
pub sa_sigaction: ::sighandler_t,
172211
pub sa_mask: ::sigset_t,

0 commit comments

Comments
 (0)