Auto merge of #686 - marmistrz:regs, r=alexcrichton

Add offsets in user_regs_struct from sys/reg.h
This commit is contained in:
bors 2017-07-22 17:01:15 +00:00
commit 9bbfe4b0ee
3 changed files with 52 additions and 0 deletions

View File

@ -7,6 +7,7 @@ use std::env;
fn main() {
let target = env::var("TARGET").unwrap();
let aarch64 = target.contains("aarch64");
let i686 = target.contains("i686");
let x86_64 = target.contains("x86_64");
let windows = target.contains("windows");
let mingw = target.contains("windows-gnu");
@ -189,6 +190,9 @@ fn main() {
if x86_64 {
cfg.header("sys/io.h");
}
if i686 || x86_64 {
cfg.header("sys/reg.h");
}
}
if linux || android {

View File

@ -696,6 +696,25 @@ pub const SYS_pkey_mprotect: ::c_long = 380;
pub const SYS_pkey_alloc: ::c_long = 381;
pub const SYS_pkey_free: ::c_long = 382;
// offsets in user_regs_structs, from sys/reg.h
pub const EBX: ::c_int = 0;
pub const ECX: ::c_int = 1;
pub const EDX: ::c_int = 2;
pub const ESI: ::c_int = 3;
pub const EDI: ::c_int = 4;
pub const EBP: ::c_int = 5;
pub const EAX: ::c_int = 6;
pub const DS: ::c_int = 7;
pub const ES: ::c_int = 8;
pub const FS: ::c_int = 9;
pub const GS: ::c_int = 10;
pub const ORIG_EAX: ::c_int = 11;
pub const EIP: ::c_int = 12;
pub const CS: ::c_int = 13;
pub const EFL: ::c_int = 14;
pub const UESP: ::c_int = 15;
pub const SS: ::c_int = 16;
extern {
pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int;
pub fn setcontext(ucp: *const ucontext_t) -> ::c_int;

View File

@ -909,6 +909,35 @@ pub const SYS_pkey_mprotect: ::c_long = 329;
pub const SYS_pkey_alloc: ::c_long = 330;
pub const SYS_pkey_free: ::c_long = 331;
// offsets in user_regs_structs, from sys/reg.h
pub const R15: ::c_int = 0;
pub const R14: ::c_int = 1;
pub const R13: ::c_int = 2;
pub const R12: ::c_int = 3;
pub const RBP: ::c_int = 4;
pub const RBX: ::c_int = 5;
pub const R11: ::c_int = 6;
pub const R10: ::c_int = 7;
pub const R9: ::c_int = 8;
pub const R8: ::c_int = 9;
pub const RAX: ::c_int = 10;
pub const RCX: ::c_int = 11;
pub const RDX: ::c_int = 12;
pub const RSI: ::c_int = 13;
pub const RDI: ::c_int = 14;
pub const ORIG_RAX: ::c_int = 15;
pub const RIP: ::c_int = 16;
pub const CS: ::c_int = 17;
pub const EFLAGS: ::c_int = 18;
pub const RSP: ::c_int = 19;
pub const SS: ::c_int = 20;
pub const FS_BASE: ::c_int = 21;
pub const GS_BASE: ::c_int = 22;
pub const DS: ::c_int = 23;
pub const ES: ::c_int = 24;
pub const FS: ::c_int = 25;
pub const GS: ::c_int = 26;
extern {
pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int;
pub fn setcontext(ucp: *const ucontext_t) -> ::c_int;