Skip to content

Commit 80e1422

Browse files
committed
Auto merge of #599 - xd009642:master, r=alexcrichton
Adding missing structs from linux/user.h Adding structs from linux/user.h (or sys/user.h depending on OS version). This adds the linux user_regs_struct and user struct from sys/user.h into libc for x86 and x86_64. Also, bumping the version number. As an aside, I was wondering if this was also the right place to add the bit offsets for the [EFLAGS register ](https://en.wikibooks.org/wiki/X86_Assembly/X86_Architecture#EFLAGS_Register)? These aren't defined anywhere in the linux system libraries instead the definition seems to just be in the x86 and x86_64 documentation but they are useful for anyone looking to interpret eflags. If libc is the right place for these constants I'd like the opportunity to add them before it's merged in. :)
2 parents 3c28e47 + 6acbf87 commit 80e1422

File tree

4 files changed

+131
-3
lines changed

4 files changed

+131
-3
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libc-test/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ fn main() {
177177
cfg.header("sys/sem.h");
178178
cfg.header("sys/msg.h");
179179
cfg.header("sys/shm.h");
180+
cfg.header("sys/user.h");
180181
cfg.header("sys/fsuid.h");
181182
cfg.header("pty.h");
182183
cfg.header("shadow.h");

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

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,71 @@ s! {
2020
pub status: ::c_ulong,
2121
}
2222

23+
pub struct user_fpregs_struct {
24+
pub cwd: ::c_long,
25+
pub swd: ::c_long,
26+
pub twd: ::c_long,
27+
pub fip: ::c_long,
28+
pub fcs: ::c_long,
29+
pub foo: ::c_long,
30+
pub fos: ::c_long,
31+
pub st_space: [::c_long; 20],
32+
}
33+
34+
pub struct user_fpxregs_struct {
35+
pub cwd: ::c_ushort,
36+
pub swd: ::c_ushort,
37+
pub twd: ::c_ushort,
38+
pub fop: ::c_ushort,
39+
pub fip: ::c_long,
40+
pub fcs: ::c_long,
41+
pub foo: ::c_long,
42+
pub fos: ::c_long,
43+
pub mxcsr: ::c_long,
44+
__reserved: ::c_long,
45+
pub st_space: [::c_long; 32],
46+
pub xmm_space: [::c_long; 32],
47+
padding: [::c_long; 56],
48+
}
49+
50+
pub struct user_regs_struct {
51+
pub ebx: ::c_long,
52+
pub ecx: ::c_long,
53+
pub edx: ::c_long,
54+
pub esi: ::c_long,
55+
pub edi: ::c_long,
56+
pub ebp: ::c_long,
57+
pub eax: ::c_long,
58+
pub xds: ::c_long,
59+
pub xes: ::c_long,
60+
pub xfs: ::c_long,
61+
pub xgs: ::c_long,
62+
pub orig_eax: ::c_long,
63+
pub eip: ::c_long,
64+
pub xcs: ::c_long,
65+
pub eflags: ::c_long,
66+
pub esp: ::c_long,
67+
pub xss: ::c_long,
68+
}
69+
70+
pub struct user {
71+
pub regs: user_regs_struct,
72+
pub u_fpvalid: ::c_int,
73+
pub i387: user_fpregs_struct,
74+
pub u_tsize: ::c_ulong,
75+
pub u_dsize: ::c_ulong,
76+
pub u_ssize: ::c_ulong,
77+
pub start_code: ::c_ulong,
78+
pub start_stack: ::c_ulong,
79+
pub signal: ::c_long,
80+
__reserved: ::c_int,
81+
pub u_ar0: *mut user_regs_struct,
82+
pub u_fpstate: *mut user_fpregs_struct,
83+
pub magic: ::c_ulong,
84+
pub u_comm: [c_char; 32],
85+
pub u_debugreg: [::c_int; 8],
86+
}
87+
2388
pub struct mcontext_t {
2489
pub gregs: [greg_t; 19],
2590
pub fpregs: *mut _libc_fpstate,

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

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,68 @@ s! {
7878
__private: [u64; 12],
7979
}
8080

81+
pub struct user_fpregs_struct {
82+
pub cwd: ::c_ushort,
83+
pub swd: ::c_ushort,
84+
pub ftw: ::c_ushort,
85+
pub fop: ::c_ushort,
86+
pub rip: ::c_ulonglong,
87+
pub rdp: ::c_ulonglong,
88+
pub mxcsr: ::c_uint,
89+
pub mxcr_mask: ::c_uint,
90+
pub st_space: [::c_uint; 32],
91+
pub xmm_space: [::c_uint; 64],
92+
padding: [::c_uint; 24],
93+
}
94+
95+
pub struct user_regs_struct {
96+
pub r15: ::c_ulonglong,
97+
pub r14: ::c_ulonglong,
98+
pub r13: ::c_ulonglong,
99+
pub r12: ::c_ulonglong,
100+
pub rbp: ::c_ulonglong,
101+
pub rbx: ::c_ulonglong,
102+
pub r11: ::c_ulonglong,
103+
pub r10: ::c_ulonglong,
104+
pub r9: ::c_ulonglong,
105+
pub r8: ::c_ulonglong,
106+
pub rax: ::c_ulonglong,
107+
pub rcx: ::c_ulonglong,
108+
pub rdx: ::c_ulonglong,
109+
pub rsi: ::c_ulonglong,
110+
pub rdi: ::c_ulonglong,
111+
pub orig_rax: ::c_ulonglong,
112+
pub rip: ::c_ulonglong,
113+
pub cs: ::c_ulonglong,
114+
pub eflags: ::c_ulonglong,
115+
pub rsp: ::c_ulonglong,
116+
pub ss: ::c_ulonglong,
117+
pub fs_base: ::c_ulonglong,
118+
pub gs_base: ::c_ulonglong,
119+
pub ds: ::c_ulonglong,
120+
pub es: ::c_ulonglong,
121+
pub fs: ::c_ulonglong,
122+
pub gs: ::c_ulonglong,
123+
}
124+
125+
pub struct user {
126+
pub regs: user_regs_struct,
127+
pub u_fpvalid: ::c_int,
128+
pub i387: user_fpregs_struct,
129+
pub u_tsize: ::c_ulonglong,
130+
pub u_dsize: ::c_ulonglong,
131+
pub u_ssize: ::c_ulonglong,
132+
pub start_code: ::c_ulonglong,
133+
pub start_stack: ::c_ulonglong,
134+
pub signal: ::c_longlong,
135+
__reserved: ::c_int,
136+
pub u_ar0: *mut user_regs_struct,
137+
pub u_fpstate: *mut user_fpregs_struct,
138+
pub magic: ::c_ulonglong,
139+
pub u_comm: [::c_char; 32],
140+
pub u_debugreg: [::c_ulonglong; 8],
141+
}
142+
81143
pub struct mcontext_t {
82144
pub gregs: [greg_t; 23],
83145
pub fpregs: *mut _libc_fpstate,

0 commit comments

Comments
 (0)