Skip to content

Commit ce955e9

Browse files
committed
Auto merge of rust-lang#618 - jcowgill:mips-cleanups, r=alexcrichton
Various MIPS cleanups This PR contains a few cleanups to the MIPS part of the bindings. It mostly moves stuff out of `mips/mips32.rs` into `mips/mod.rs` which is identical between mips32 and mips64, mostly because mips64 is missing a number of syscalls. In addition, I add `struct flock` which was missing on mips64.
2 parents 0bfcd7a + 3799b7b commit ce955e9

File tree

3 files changed

+75
-67
lines changed

3 files changed

+75
-67
lines changed

src/unix/notbsd/linux/mips/mips32.rs

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ pub type ino_t = u32;
1010
pub type blkcnt_t = i32;
1111
pub type blksize_t = i32;
1212
pub type nlink_t = u32;
13-
pub type fsblkcnt_t = ::c_ulong;
14-
pub type fsfilcnt_t = ::c_ulong;
15-
pub type rlim_t = c_ulong;
1613

1714
s! {
1815
pub struct aiocb {
@@ -107,19 +104,6 @@ s! {
107104
pub _pad: [::c_int; 29],
108105
}
109106

110-
pub struct glob64_t {
111-
pub gl_pathc: ::size_t,
112-
pub gl_pathv: *mut *mut ::c_char,
113-
pub gl_offs: ::size_t,
114-
pub gl_flags: ::c_int,
115-
116-
__unused1: *mut ::c_void,
117-
__unused2: *mut ::c_void,
118-
__unused3: *mut ::c_void,
119-
__unused4: *mut ::c_void,
120-
__unused5: *mut ::c_void,
121-
}
122-
123107
pub struct ipc_perm {
124108
pub __key: ::key_t,
125109
pub uid: ::uid_t,
@@ -238,15 +222,6 @@ s! {
238222
pub mem_unit: ::c_uint,
239223
pub _f: [::c_char; 8],
240224
}
241-
242-
// FIXME this is actually a union
243-
pub struct sem_t {
244-
#[cfg(target_pointer_width = "32")]
245-
__size: [::c_char; 16],
246-
#[cfg(target_pointer_width = "64")]
247-
__size: [::c_char; 32],
248-
__align: [::c_long; 0],
249-
}
250225
}
251226

252227
pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
@@ -257,31 +232,3 @@ pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
257232
pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff;
258233

259234
pub const SYS_gettid: ::c_long = 4222; // Valid for O32
260-
261-
#[link(name = "util")]
262-
extern {
263-
pub fn sysctl(name: *mut ::c_int,
264-
namelen: ::c_int,
265-
oldp: *mut ::c_void,
266-
oldlenp: *mut ::size_t,
267-
newp: *mut ::c_void,
268-
newlen: ::size_t)
269-
-> ::c_int;
270-
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
271-
pub fn backtrace(buf: *mut *mut ::c_void,
272-
sz: ::c_int) -> ::c_int;
273-
pub fn glob64(pattern: *const ::c_char,
274-
flags: ::c_int,
275-
errfunc: ::dox::Option<extern fn(epath: *const ::c_char,
276-
errno: ::c_int)
277-
-> ::c_int>,
278-
pglob: *mut glob64_t) -> ::c_int;
279-
pub fn globfree64(pglob: *mut glob64_t);
280-
pub fn ptrace(request: ::c_uint, ...) -> ::c_long;
281-
pub fn pthread_attr_getaffinity_np(attr: *const ::pthread_attr_t,
282-
cpusetsize: ::size_t,
283-
cpuset: *mut ::cpu_set_t) -> ::c_int;
284-
pub fn pthread_attr_setaffinity_np(attr: *mut ::pthread_attr_t,
285-
cpusetsize: ::size_t,
286-
cpuset: *const ::cpu_set_t) -> ::c_int;
287-
}

src/unix/notbsd/linux/mips/mips64.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@ pub type blksize_t = i64;
33
pub type c_char = i8;
44
pub type c_long = i64;
55
pub type c_ulong = u64;
6-
pub type fsblkcnt_t = ::c_ulong;
7-
pub type fsfilcnt_t = ::c_ulong;
86
pub type ino_t = u64;
97
pub type nlink_t = u64;
108
pub type off_t = i64;
11-
pub type rlim_t = ::c_ulong;
129
pub type suseconds_t = i64;
1310
pub type time_t = i64;
1411
pub type wchar_t = i32;
@@ -187,6 +184,14 @@ s! {
187184
pub c_cc: [::cc_t; ::NCCS],
188185
}
189186

187+
pub struct flock {
188+
pub l_type: ::c_short,
189+
pub l_whence: ::c_short,
190+
pub l_start: ::off_t,
191+
pub l_len: ::off_t,
192+
pub l_pid: ::pid_t,
193+
}
194+
190195
pub struct sysinfo {
191196
pub uptime: ::c_long,
192197
pub loads: [::c_ulong; 3],
@@ -203,12 +208,6 @@ s! {
203208
pub mem_unit: ::c_uint,
204209
pub _f: [::c_char; 0],
205210
}
206-
207-
// FIXME this is actually a union
208-
pub struct sem_t {
209-
__size: [::c_char; 32],
210-
__align: [::c_long; 0],
211-
}
212211
}
213212

214213
pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
@@ -219,8 +218,3 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
219218
pub const RLIM_INFINITY: ::rlim_t = 0xffff_ffff_ffff_ffff;
220219

221220
pub const SYS_gettid: ::c_long = 5178; // Valid for n64
222-
223-
#[link(name = "util")]
224-
extern {
225-
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
226-
}

src/unix/notbsd/linux/mips/mod.rs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
pub type fsblkcnt_t = ::c_ulong;
2+
pub type fsfilcnt_t = ::c_ulong;
3+
pub type rlim_t = c_ulong;
4+
pub type __priority_which_t = ::c_uint;
5+
6+
s! {
7+
pub struct glob64_t {
8+
pub gl_pathc: ::size_t,
9+
pub gl_pathv: *mut *mut ::c_char,
10+
pub gl_offs: ::size_t,
11+
pub gl_flags: ::c_int,
12+
13+
__unused1: *mut ::c_void,
14+
__unused2: *mut ::c_void,
15+
__unused3: *mut ::c_void,
16+
__unused4: *mut ::c_void,
17+
__unused5: *mut ::c_void,
18+
}
19+
20+
// FIXME this is actually a union
21+
pub struct sem_t {
22+
#[cfg(target_pointer_width = "32")]
23+
__size: [::c_char; 16],
24+
#[cfg(target_pointer_width = "64")]
25+
__size: [::c_char; 32],
26+
__align: [::c_long; 0],
27+
}
28+
}
29+
130
pub const CLONE_NEWCGROUP: ::c_int = 0x02000000;
231

332
pub const SFD_CLOEXEC: ::c_int = 0x080000;
@@ -496,6 +525,44 @@ pub const B3000000: ::speed_t = 0o010015;
496525
pub const B3500000: ::speed_t = 0o010016;
497526
pub const B4000000: ::speed_t = 0o010017;
498527

528+
#[link(name = "util")]
529+
extern {
530+
pub fn sysctl(name: *mut ::c_int,
531+
namelen: ::c_int,
532+
oldp: *mut ::c_void,
533+
oldlenp: *mut ::size_t,
534+
newp: *mut ::c_void,
535+
newlen: ::size_t)
536+
-> ::c_int;
537+
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
538+
pub fn backtrace(buf: *mut *mut ::c_void,
539+
sz: ::c_int) -> ::c_int;
540+
pub fn glob64(pattern: *const ::c_char,
541+
flags: ::c_int,
542+
errfunc: ::dox::Option<extern fn(epath: *const ::c_char,
543+
errno: ::c_int)
544+
-> ::c_int>,
545+
pglob: *mut glob64_t) -> ::c_int;
546+
pub fn globfree64(pglob: *mut glob64_t);
547+
pub fn ptrace(request: ::c_uint, ...) -> ::c_long;
548+
pub fn pthread_attr_getaffinity_np(attr: *const ::pthread_attr_t,
549+
cpusetsize: ::size_t,
550+
cpuset: *mut ::cpu_set_t) -> ::c_int;
551+
pub fn pthread_attr_setaffinity_np(attr: *mut ::pthread_attr_t,
552+
cpusetsize: ::size_t,
553+
cpuset: *const ::cpu_set_t) -> ::c_int;
554+
pub fn getpriority(which: ::__priority_which_t, who: ::id_t) -> ::c_int;
555+
pub fn setpriority(which: ::__priority_which_t, who: ::id_t,
556+
prio: ::c_int) -> ::c_int;
557+
pub fn pthread_getaffinity_np(thread: ::pthread_t,
558+
cpusetsize: ::size_t,
559+
cpuset: *mut ::cpu_set_t) -> ::c_int;
560+
pub fn pthread_setaffinity_np(thread: ::pthread_t,
561+
cpusetsize: ::size_t,
562+
cpuset: *const ::cpu_set_t) -> ::c_int;
563+
pub fn sched_getcpu() -> ::c_int;
564+
}
565+
499566
cfg_if! {
500567
if #[cfg(target_arch = "mips")] {
501568
mod mips32;

0 commit comments

Comments
 (0)