Skip to content

Commit

Permalink
Linux x32 does not support sysctl
Browse files Browse the repository at this point in the history
  • Loading branch information
malbarbo committed Oct 18, 2017
1 parent c3408c1 commit 343b7c1
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 8 deletions.
4 changes: 3 additions & 1 deletion libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ fn main() {
let aarch64 = target.contains("aarch64");
let i686 = target.contains("i686");
let x86_64 = target.contains("x86_64");
let x32 = target.ends_with("gnux32");
let windows = target.contains("windows");
let mingw = target.contains("windows-gnu");
let linux = target.contains("unknown-linux");
Expand Down Expand Up @@ -135,9 +136,10 @@ fn main() {
cfg.header("sys/quota.h");
}

if !musl {
if !musl && !x32 {
cfg.header("sys/sysctl.h");
}

if !musl && !uclibc {

if !netbsd && !openbsd && !uclibc {
Expand Down
11 changes: 11 additions & 0 deletions src/unix/notbsd/linux/other/b32/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,17 @@ pub const PTRACE_SETFPREGS: ::c_uint = 15;
pub const PTRACE_GETREGS: ::c_uint = 12;
pub const PTRACE_SETREGS: ::c_uint = 13;

#[link(name = "util")]
extern {
pub fn sysctl(name: *mut ::c_int,
namelen: ::c_int,
oldp: *mut ::c_void,
oldlenp: *mut ::size_t,
newp: *mut ::c_void,
newlen: ::size_t)
-> ::c_int;
}

cfg_if! {
if #[cfg(target_arch = "x86")] {
mod x86;
Expand Down
12 changes: 12 additions & 0 deletions src/unix/notbsd/linux/other/b64/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ pub const TIOCSWINSZ: ::c_ulong = 0x5414;
pub const FIONREAD: ::c_ulong = 0x541B;

// Syscall table
<<<<<<< HEAD
pub const SYS_io_setup: ::c_ulong = 0;
pub const SYS_io_destroy: ::c_ulong = 1;
pub const SYS_io_submit: ::c_ulong = 2;
Expand Down Expand Up @@ -751,3 +752,14 @@ pub const SYS_pkey_mprotect: ::c_ulong = 288;
pub const SYS_pkey_alloc: ::c_ulong = 289;
pub const SYS_pkey_free: ::c_ulong = 290;
pub const SYS_syscalls: ::c_ulong = 291;

#[link(name = "util")]
extern {
pub fn sysctl(name: *mut ::c_int,
namelen: ::c_int,
oldp: *mut ::c_void,
oldlenp: *mut ::size_t,
newp: *mut ::c_void,
newlen: ::size_t)
-> ::c_int;
}
8 changes: 8 additions & 0 deletions src/unix/notbsd/linux/other/b64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ cfg_if! {
} else if #[cfg(any(target_arch = "x86_64"))] {
mod x86_64;
pub use self::x86_64::*;
cfg_if! {
if #[cfg(target_pointer_width = "32")] {
// x32
} else {
mod not_x32;
pub use self::not_x32::*;
}
}
} else {
// Unknown target_arch
}
Expand Down
10 changes: 10 additions & 0 deletions src/unix/notbsd/linux/other/b64/not_x32.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#[link(name = "util")]
extern {
pub fn sysctl(name: *mut ::c_int,
namelen: ::c_int,
oldp: *mut ::c_void,
oldlenp: *mut ::size_t,
newp: *mut ::c_void,
newlen: ::size_t)
-> ::c_int;
}
12 changes: 12 additions & 0 deletions src/unix/notbsd/linux/other/b64/powerpc64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ pub const TIOCSWINSZ: ::c_ulong = 0x80087467;
pub const FIONREAD: ::c_ulong = 0x4004667f;

// Syscall table
<<<<<<< HEAD
pub const SYS_restart_syscall: ::c_ulong = 0;
pub const SYS_exit: ::c_ulong = 1;
pub const SYS_fork: ::c_ulong = 2;
Expand Down Expand Up @@ -841,3 +842,14 @@ pub const SYS_copy_file_range: ::c_ulong = 379;
pub const SYS_preadv2: ::c_ulong = 380;
pub const SYS_pwritev2: ::c_ulong = 381;
pub const SYS_kexec_file_load: ::c_ulong = 382;

#[link(name = "util")]
extern {
pub fn sysctl(name: *mut ::c_int,
namelen: ::c_int,
oldp: *mut ::c_void,
oldlenp: *mut ::size_t,
newp: *mut ::c_void,
newlen: ::size_t)
-> ::c_int;
}
11 changes: 11 additions & 0 deletions src/unix/notbsd/linux/other/b64/sparc64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,3 +419,14 @@ pub const TIOCOUTQ: ::c_ulong = 0x40047473;
pub const TIOCGWINSZ: ::c_ulong = 0x40087468;
pub const TIOCSWINSZ: ::c_ulong = 0x80087467;
pub const FIONREAD: ::c_ulong = 0x4004667f;

#[link(name = "util")]
extern {
pub fn sysctl(name: *mut ::c_int,
namelen: ::c_int,
oldp: *mut ::c_void,
oldlenp: *mut ::size_t,
newp: *mut ::c_void,
newlen: ::size_t)
-> ::c_int;
}
7 changes: 0 additions & 7 deletions src/unix/notbsd/linux/other/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,13 +568,6 @@ extern {

#[link(name = "util")]
extern {
pub fn sysctl(name: *mut ::c_int,
namelen: ::c_int,
oldp: *mut ::c_void,
oldlenp: *mut ::size_t,
newp: *mut ::c_void,
newlen: ::size_t)
-> ::c_int;
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
pub fn backtrace(buf: *mut *mut ::c_void,
sz: ::c_int) -> ::c_int;
Expand Down

0 comments on commit 343b7c1

Please sign in to comment.