Skip to content

Commit 95ed722

Browse files
author
Xing Xue
committed
Add 'struct ld_info' and friends.
1 parent b94681f commit 95ed722

File tree

3 files changed

+159
-0
lines changed

3 files changed

+159
-0
lines changed

libc-test/build.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5609,6 +5609,18 @@ fn test_aix(target: &str) {
56095609
// allow type 'double' to be used in signal contexts.
56105610
"fpreg_t" => true,
56115611

5612+
// This type is defined for a union used within `struct ld_info`.
5613+
// The AIX header does not declare a separate standalone union
5614+
// type for it.
5615+
"__ld_info_file" => true,
5616+
5617+
// This is a simplified version of the AIX union `_simple_lock`.
5618+
"_kernel_simple_lock" => true,
5619+
5620+
// These structures are guarded by the `_KERNEL` macro in the AIX
5621+
// header.
5622+
"fileops_t" | "file" => true,
5623+
56125624
_ => false,
56135625
}
56145626
});
@@ -5626,6 +5638,11 @@ fn test_aix(target: &str) {
56265638
// The _ALL_SOURCE type of 'f_fsid' differs from POSIX's on AIX.
56275639
("statvfs", "f_fsid") => true,
56285640

5641+
// The type of `_file` is `__ld_info_file`, which is defined
5642+
// specifically for the union inside `struct ld_info`. The AIX
5643+
// header does not define a separate standalone union type for it.
5644+
("ld_info", "_file") => true,
5645+
56295646
_ => false,
56305647
}
56315648
});

libc-test/semver/aix.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,12 +1791,14 @@ _W_STOPPED
17911791
_W_STRC
17921792
__context64
17931793
__extctx_t
1794+
__ld_info_file
17941795
__pollfd_ext_u
17951796
__tm_context_t
17961797
__vmx_context_t
17971798
__vmxreg_t
17981799
__vsx_context_t
17991800
_exit
1801+
_kernel_simple_lock
18001802
abort
18011803
accept
18021804
access
@@ -1915,7 +1917,9 @@ fgetpos
19151917
fgetpos64
19161918
fgetpwent
19171919
fgets
1920+
file
19181921
fileno
1922+
fileops_t
19191923
flock
19201924
flock64
19211925
fnmatch
@@ -2079,6 +2083,7 @@ kill
20792083
lchown
20802084
lcong48
20812085
lconv
2086+
ld_info
20822087
lfind
20832088
linger
20842089
link
@@ -2090,6 +2095,7 @@ locale_t
20902095
localeconv
20912096
localtime
20922097
localtime_r
2098+
lock_data_instrumented
20932099
lpar_get_info
20942100
lpar_set_resources
20952101
lrand48

src/unix/aix/powerpc64.rs

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
use crate::off_t;
22
use crate::prelude::*;
33

4+
// Define lock_data_instrumented as an empty enum
5+
missing! {
6+
#[cfg_attr(feature = "extra_traits", derive(Debug))]
7+
pub enum lock_data_instrumented {}
8+
}
9+
410
s! {
511
pub struct sigset_t {
612
pub ss_set: [c_ulong; 4],
@@ -256,6 +262,69 @@ s_no_extra_traits! {
256262
pub __pad: [c_int; 3],
257263
}
258264

265+
pub union _kernel_simple_lock {
266+
pub _slock: c_long,
267+
pub _slockp: *mut lock_data_instrumented,
268+
}
269+
270+
pub struct fileops_t {
271+
pub fo_rw: Option<extern "C" fn(
272+
file: *mut file,
273+
rw: crate::uio_rw,
274+
io: *mut c_void,
275+
ext: c_long,
276+
secattr: *mut c_void,
277+
) -> c_int>,
278+
pub fo_ioctl: Option<extern "C" fn(
279+
file: *mut file,
280+
a: c_long,
281+
b: crate::caddr_t,
282+
c: c_long,
283+
d: c_long,
284+
) -> c_int>,
285+
pub fo_select:
286+
Option<extern "C" fn(file: *mut file, a: c_int, b: *mut c_ushort, c: extern "C" fn()) -> c_int>,
287+
pub fo_close: Option<extern "C" fn(file: *mut file) -> c_int>,
288+
pub fo_fstat: Option<extern "C" fn(file: *mut file, sstat: *mut crate::stat) -> c_int>,
289+
}
290+
291+
pub struct file {
292+
pub f_flag: c_long,
293+
pub f_count: c_int,
294+
pub f_options: c_short,
295+
pub f_type: c_short,
296+
// Should be pointer to 'vnode'
297+
pub f_data: *mut c_void,
298+
pub f_offset: c_longlong,
299+
pub f_dir_off: c_long,
300+
// Should be pointer to 'cred'
301+
pub f_cred: *mut c_void,
302+
pub f_lock: _kernel_simple_lock,
303+
pub f_offset_lock: _kernel_simple_lock,
304+
pub f_vinfo: crate::caddr_t,
305+
pub f_ops: *mut fileops_t,
306+
pub f_parentp: crate::caddr_t,
307+
pub f_fnamep: crate::caddr_t,
308+
pub f_fdata: [c_char; 160],
309+
}
310+
311+
pub union __ld_info_file {
312+
pub _ldinfo_fd: c_int,
313+
pub _ldinfo_fp: *mut file,
314+
pub _core_offset: c_long,
315+
}
316+
317+
pub struct ld_info {
318+
pub ldinfo_next: c_uint,
319+
pub ldinfo_flags: c_uint,
320+
pub _file: __ld_info_file,
321+
pub ldinfo_textorg: *mut c_void,
322+
pub ldinfo_textsize: c_ulong,
323+
pub ldinfo_dataorg: *mut c_void,
324+
pub ldinfo_datasize: c_ulong,
325+
pub ldinfo_filename: [c_char; 2],
326+
}
327+
259328
pub union __pollfd_ext_u {
260329
pub addr: *mut c_void,
261330
pub data32: u32,
@@ -327,6 +396,73 @@ cfg_if! {
327396
self.__si_flags.hash(state);
328397
}
329398
}
399+
400+
impl Eq for _kernel_simple_lock {}
401+
impl hash::Hash for _kernel_simple_lock {
402+
fn hash<H: hash::Hasher>(&self, state: &mut H) {
403+
unsafe {
404+
self._slock.hash(state);
405+
self._slockp.hash(state);
406+
}
407+
}
408+
}
409+
410+
impl Eq for fileops_t {}
411+
impl hash::Hash for fileops_t {
412+
fn hash<H: hash::Hasher>(&self, state: &mut H) {
413+
self.fo_rw.hash(state);
414+
self.fo_ioctl.hash(state);
415+
self.fo_select.hash(state);
416+
self.fo_close.hash(state);
417+
self.fo_fstat.hash(state);
418+
}
419+
}
420+
421+
impl Eq for file {}
422+
impl hash::Hash for file {
423+
fn hash<H: hash::Hasher>(&self, state: &mut H) {
424+
self.f_flag.hash(state);
425+
self.f_count.hash(state);
426+
self.f_options.hash(state);
427+
self.f_type.hash(state);
428+
self.f_data.hash(state);
429+
self.f_offset.hash(state);
430+
self.f_dir_off.hash(state);
431+
self.f_cred.hash(state);
432+
self.f_lock.hash(state);
433+
self.f_offset_lock.hash(state);
434+
self.f_vinfo.hash(state);
435+
self.f_ops.hash(state);
436+
self.f_parentp.hash(state);
437+
self.f_fnamep.hash(state);
438+
self.f_fdata.hash(state);
439+
}
440+
}
441+
442+
impl Eq for __ld_info_file {}
443+
impl hash::Hash for __ld_info_file {
444+
fn hash<H: hash::Hasher>(&self, state: &mut H) {
445+
unsafe {
446+
self._ldinfo_fd.hash(state);
447+
self._ldinfo_fp.hash(state);
448+
self._core_offset.hash(state);
449+
}
450+
}
451+
}
452+
453+
impl Eq for ld_info {}
454+
impl hash::Hash for ld_info {
455+
fn hash<H: hash::Hasher>(&self, state: &mut H) {
456+
self.ldinfo_next.hash(state);
457+
self.ldinfo_flags.hash(state);
458+
self.ldinfo_textorg.hash(state);
459+
self.ldinfo_textsize.hash(state);
460+
self.ldinfo_dataorg.hash(state);
461+
self.ldinfo_datasize.hash(state);
462+
self.ldinfo_filename.hash(state);
463+
self._file.hash(state);
464+
}
465+
}
330466
impl PartialEq for __pollfd_ext_u {
331467
fn eq(&self, other: &__pollfd_ext_u) -> bool {
332468
unsafe {

0 commit comments

Comments
 (0)