Skip to content

Commit 9bbfe4b

Browse files
committed
Auto merge of rust-lang#686 - marmistrz:regs, r=alexcrichton
Add offsets in user_regs_struct from sys/reg.h
2 parents 365b429 + 2a59767 commit 9bbfe4b

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

libc-test/build.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::env;
77
fn main() {
88
let target = env::var("TARGET").unwrap();
99
let aarch64 = target.contains("aarch64");
10+
let i686 = target.contains("i686");
1011
let x86_64 = target.contains("x86_64");
1112
let windows = target.contains("windows");
1213
let mingw = target.contains("windows-gnu");
@@ -189,6 +190,9 @@ fn main() {
189190
if x86_64 {
190191
cfg.header("sys/io.h");
191192
}
193+
if i686 || x86_64 {
194+
cfg.header("sys/reg.h");
195+
}
192196
}
193197

194198
if linux || android {

src/unix/notbsd/linux/other/b32/x86.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,25 @@ pub const SYS_pkey_mprotect: ::c_long = 380;
696696
pub const SYS_pkey_alloc: ::c_long = 381;
697697
pub const SYS_pkey_free: ::c_long = 382;
698698

699+
// offsets in user_regs_structs, from sys/reg.h
700+
pub const EBX: ::c_int = 0;
701+
pub const ECX: ::c_int = 1;
702+
pub const EDX: ::c_int = 2;
703+
pub const ESI: ::c_int = 3;
704+
pub const EDI: ::c_int = 4;
705+
pub const EBP: ::c_int = 5;
706+
pub const EAX: ::c_int = 6;
707+
pub const DS: ::c_int = 7;
708+
pub const ES: ::c_int = 8;
709+
pub const FS: ::c_int = 9;
710+
pub const GS: ::c_int = 10;
711+
pub const ORIG_EAX: ::c_int = 11;
712+
pub const EIP: ::c_int = 12;
713+
pub const CS: ::c_int = 13;
714+
pub const EFL: ::c_int = 14;
715+
pub const UESP: ::c_int = 15;
716+
pub const SS: ::c_int = 16;
717+
699718
extern {
700719
pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int;
701720
pub fn setcontext(ucp: *const ucontext_t) -> ::c_int;

src/unix/notbsd/linux/other/b64/x86_64.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,35 @@ pub const SYS_pkey_mprotect: ::c_long = 329;
909909
pub const SYS_pkey_alloc: ::c_long = 330;
910910
pub const SYS_pkey_free: ::c_long = 331;
911911

912+
// offsets in user_regs_structs, from sys/reg.h
913+
pub const R15: ::c_int = 0;
914+
pub const R14: ::c_int = 1;
915+
pub const R13: ::c_int = 2;
916+
pub const R12: ::c_int = 3;
917+
pub const RBP: ::c_int = 4;
918+
pub const RBX: ::c_int = 5;
919+
pub const R11: ::c_int = 6;
920+
pub const R10: ::c_int = 7;
921+
pub const R9: ::c_int = 8;
922+
pub const R8: ::c_int = 9;
923+
pub const RAX: ::c_int = 10;
924+
pub const RCX: ::c_int = 11;
925+
pub const RDX: ::c_int = 12;
926+
pub const RSI: ::c_int = 13;
927+
pub const RDI: ::c_int = 14;
928+
pub const ORIG_RAX: ::c_int = 15;
929+
pub const RIP: ::c_int = 16;
930+
pub const CS: ::c_int = 17;
931+
pub const EFLAGS: ::c_int = 18;
932+
pub const RSP: ::c_int = 19;
933+
pub const SS: ::c_int = 20;
934+
pub const FS_BASE: ::c_int = 21;
935+
pub const GS_BASE: ::c_int = 22;
936+
pub const DS: ::c_int = 23;
937+
pub const ES: ::c_int = 24;
938+
pub const FS: ::c_int = 25;
939+
pub const GS: ::c_int = 26;
940+
912941
extern {
913942
pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int;
914943
pub fn setcontext(ucp: *const ucontext_t) -> ::c_int;

0 commit comments

Comments
 (0)