Skip to content

Commit b6cf286

Browse files
xingxue-ibmtgross35
authored andcommitted
Add 'ucontext_t' and related structures and functions.
1 parent ffab35a commit b6cf286

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

libc-test/semver/linux-powerpc64.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,19 @@ TIOCCBRK
143143
TIOCGRS485
144144
TIOCSBRK
145145
TIOCSRS485
146+
__NFPREG
147+
__NGREG
148+
__NVRREG
149+
clone_args
146150
flock64
151+
fpregset_t
152+
getcontext
153+
gregset_t
154+
makecontext
155+
mcontext_t
156+
pt_regs
157+
setcontext
158+
swapcontext
159+
ucontext_t
160+
vrregset_t
161+
vscr_t

src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ pub type blksize_t = i64;
99
pub type suseconds_t = i64;
1010
pub type __u64 = c_ulong;
1111
pub type __s64 = c_long;
12+
pub type gregset_t = [c_ulong; __NGREG];
13+
pub type fpregset_t = [c_ulong; __NFPREG];
1214

1315
s! {
1416
// FIXME(1.0): This should not implement `PartialEq`
@@ -191,13 +193,86 @@ s! {
191193
pub ss_flags: c_int,
192194
pub ss_size: size_t,
193195
}
196+
197+
#[repr(align(8))]
198+
pub struct clone_args {
199+
pub flags: c_ulonglong,
200+
pub pidfd: c_ulonglong,
201+
pub child_tid: c_ulonglong,
202+
pub parent_tid: c_ulonglong,
203+
pub exit_signal: c_ulonglong,
204+
pub stack: c_ulonglong,
205+
pub stack_size: c_ulonglong,
206+
pub tls: c_ulonglong,
207+
pub set_tid: c_ulonglong,
208+
pub set_tid_size: c_ulonglong,
209+
pub cgroup: c_ulonglong,
210+
}
194211
}
195212

196213
s_no_extra_traits! {
197214
#[repr(align(16))]
198215
pub struct max_align_t {
199216
priv_: [i64; 4],
200217
}
218+
219+
pub struct ucontext_t {
220+
pub uc_flags: c_ulong,
221+
pub uc_link: *mut ucontext_t,
222+
pub uc_stack: crate::stack_t,
223+
pub uc_sigmask: crate::sigset_t,
224+
pub uc_mcontext: mcontext_t,
225+
}
226+
227+
pub struct pt_regs {
228+
pub gpr: [c_ulong; 32],
229+
pub nip: c_ulong,
230+
pub msr: c_ulong,
231+
pub orig_gpr3: c_ulong,
232+
pub ctr: c_ulong,
233+
pub link: c_ulong,
234+
pub xer: c_ulong,
235+
pub ccr: c_ulong,
236+
pub softe: c_ulong,
237+
pub trap: c_ulong,
238+
pub dar: c_ulong,
239+
pub dsisr: c_ulong,
240+
pub result: c_ulong,
241+
}
242+
243+
pub struct mcontext_t {
244+
__glibc_reserved: [c_ulong; 4],
245+
pub signal: c_int,
246+
__pad0: c_int,
247+
pub handler: c_ulong,
248+
pub oldmask: c_ulong,
249+
pub regs: *mut pt_regs,
250+
pub gp_regs: crate::gregset_t,
251+
pub fp_regs: crate::fpregset_t,
252+
pub v_regs: *mut vrregset_t,
253+
pub vmx_reserve: [c_long; __NVRREG + __NVRREG + 1],
254+
}
255+
256+
#[repr(align(16))]
257+
pub struct vrregset_t {
258+
pub vrregs: [[c_uint; 4]; 32],
259+
pub vscr: vscr_t,
260+
pub vrsave: c_uint,
261+
__pad: [c_uint; 3],
262+
}
263+
264+
#[repr(align(4))]
265+
pub struct vscr_t {
266+
#[cfg(target_endian = "big")]
267+
__pad: [c_uint; 3],
268+
#[cfg(target_endian = "big")]
269+
pub vscr_word: c_uint,
270+
271+
#[cfg(target_endian = "little")]
272+
pub vscr_word: c_uint,
273+
#[cfg(target_endian = "little")]
274+
__pad: [c_uint; 3],
275+
}
201276
}
202277

203278
pub const POSIX_FADV_DONTNEED: c_int = 4;
@@ -210,6 +285,10 @@ pub const VEOF: usize = 4;
210285
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
211286
pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32;
212287

288+
pub const __NGREG: usize = 48;
289+
pub const __NFPREG: usize = 33;
290+
pub const __NVRREG: usize = 34;
291+
213292
pub const O_APPEND: c_int = 1024;
214293
pub const O_CREAT: c_int = 64;
215294
pub const O_EXCL: c_int = 128;
@@ -971,4 +1050,9 @@ extern "C" {
9711050
newp: *mut c_void,
9721051
newlen: size_t,
9731052
) -> c_int;
1053+
1054+
pub fn getcontext(ucp: *mut ucontext_t) -> c_int;
1055+
pub fn setcontext(ucp: *const ucontext_t) -> c_int;
1056+
pub fn swapcontext(oucp: *mut ucontext_t, ucp: *const ucontext_t) -> c_int;
1057+
pub fn makecontext(ucp: *mut ucontext_t, func: extern "C" fn(), argc: c_int, ...);
9741058
}

0 commit comments

Comments
 (0)