Skip to content

Commit

Permalink
Auto merge of #2788 - semio-ai:master, r=<try>
Browse files Browse the repository at this point in the history
Complete i686-unknown-linux-musl ucontext_t #2787

Fix #2787
  • Loading branch information
bors committed Mar 23, 2023
2 parents 74e81a5 + 8bb4cff commit d8a7448
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 5 deletions.
1 change: 1 addition & 0 deletions ci/run.sh
Expand Up @@ -82,6 +82,7 @@ if [ "$QEMU" != "" ]; then
exec grep -E "^(PASSED)|(test result: ok)" "${CARGO_TARGET_DIR}/out.log"
fi

export RUST_BACKTRACE=1
if [ "$TARGET" = "s390x-unknown-linux-gnu" ]; then
# FIXME: s390x-unknown-linux-gnu often fails to test due to timeout,
# so we retry this N times.
Expand Down
4 changes: 3 additions & 1 deletion libc-test/build.rs
Expand Up @@ -3095,6 +3095,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 @@ -3107,7 +3108,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 @@ -3286,6 +3287,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

0 comments on commit d8a7448

Please sign in to comment.