Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete i686-unknown-linux-musl ucontext_t #2787 #2788

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion libc-test/build.rs
Expand Up @@ -3101,6 +3101,7 @@ fn test_linux(target: &str) {
),
}

let aarch64 = target.contains("aarch64");
let arm = target.contains("arm");
let i686 = target.contains("i686");
let mips = target.contains("mips");
Expand All @@ -3113,7 +3114,7 @@ fn test_linux(target: &str) {
let x32 = target.contains("x32");
let x86_32 = target.contains("i686");
let x86_64 = target.contains("x86_64");
let aarch64_musl = target.contains("aarch64") && musl;
let aarch64_musl = aarch64 && musl;
let gnueabihf = target.contains("gnueabihf");
let x86_64_gnux32 = target.contains("gnux32") && x86_64;
let riscv64 = target.contains("riscv64");
Expand Down Expand Up @@ -3292,6 +3293,7 @@ fn test_linux(target: &str) {
"linux/vm_sockets.h",
"linux/wait.h",
"sys/fanotify.h",
[!aarch64 && !mips && !i686 && !arm && musl]: "asm/sigcontext.h",
// <sys/auxv.h> is not present on uclibc
[!uclibc]: "sys/auxv.h",
}
Expand Down
49 changes: 45 additions & 4 deletions src/unix/linux_like/linux/musl/b32/x86/mod.rs
@@ -1,5 +1,6 @@
pub type c_char = i8;
pub type wchar_t = i32;
pub type greg_t = i32;

s! {
pub struct stat {
Expand Down Expand Up @@ -49,7 +50,7 @@ s! {
pub struct stack_t {
pub ss_sp: *mut ::c_void,
pub ss_flags: ::c_int,
pub ss_size: ::size_t
pub ss_size: ::size_t,
}

pub struct ipc_perm {
Expand All @@ -61,7 +62,7 @@ s! {
pub mode: ::mode_t,
pub __seq: ::c_int,
__unused1: ::c_long,
__unused2: ::c_long
__unused2: ::c_long,
}

pub struct shmid_ds {
Expand Down Expand Up @@ -112,8 +113,23 @@ s! {
pub f_spare: [::c_ulong; 4],
}

pub struct _fpstate {
pub cw: ::c_ulong,
pub sw: ::c_ulong,
pub tag: ::c_ulong,
pub ipoff: ::c_ulong,
pub cssel: ::c_ulong,
pub dataoff: ::c_ulong,
pub datasel: ::c_ulong,
pub _st: [u16; 40], // anonymous struct replaced by a placeholder
pub status: ::c_ulong,
}

pub struct mcontext_t {
__private: [u32; 22]
pub gregs: [greg_t; 19],
pub fpregs: *mut _fpstate,
pub oldmask: ::c_ulong,
pub cr2: ::c_ulong,
}

pub struct siginfo_t {
Expand All @@ -124,6 +140,10 @@ s! {
_align: [usize; 0],
}

pub struct sigset_t {
pub sig: [::c_ulong; 2]
}

pub struct statfs64 {
pub f_type: ::c_ulong,
pub f_bsize: ::c_ulong,
Expand Down Expand Up @@ -163,7 +183,7 @@ s_no_extra_traits! {
pub uc_stack: ::stack_t,
pub uc_mcontext: mcontext_t,
pub uc_sigmask: ::sigset_t,
__private: [u8; 112],
pub __fpregs_mem: [::c_ulong; 28],
}
}

Expand Down Expand Up @@ -884,6 +904,27 @@ pub const EFL: ::c_int = 14;
pub const UESP: ::c_int = 15;
pub const SS: ::c_int = 16;

// offsets in mcontext_t.gregs from sys/ucontext.h
pub const REG_GS: ::c_int = 0;
pub const REG_FS: ::c_int = 1;
pub const REG_ES: ::c_int = 2;
pub const REG_DS: ::c_int = 3;
pub const REG_EDI: ::c_int = 4;
pub const REG_ESI: ::c_int = 5;
pub const REG_EBP: ::c_int = 6;
pub const REG_ESP: ::c_int = 7;
pub const REG_EBX: ::c_int = 8;
pub const REG_EDX: ::c_int = 9;
pub const REG_ECX: ::c_int = 10;
pub const REG_EAX: ::c_int = 11;
pub const REG_TRAPNO: ::c_int = 12;
pub const REG_ERR: ::c_int = 13;
pub const REG_EIP: ::c_int = 14;
pub const REG_CS: ::c_int = 15;
pub const REG_EFL: ::c_int = 16;
pub const REG_UESP: ::c_int = 17;
pub const REG_SS: ::c_int = 18;

extern "C" {
pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
}
Expand Down