Skip to content

Commit 24405fa

Browse files
author
Xing Xue
committed
Add 'struct ld_info' and friends.
1 parent 0fb5309 commit 24405fa

File tree

3 files changed

+210
-0
lines changed

3 files changed

+210
-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
});
@@ -5623,6 +5635,11 @@ fn test_aix(target: &str) {
56235635
("__context64", "fpr") => true,
56245636
("__tm_context_t", "fpr") => true,
56255637

5638+
// The type of `_file` is `__ld_info_file`, which is defined
5639+
// specifically for the union inside `struct ld_info`. The AIX
5640+
// header does not define a separate standalone union type for it.
5641+
("ld_info", "_file") => true,
5642+
56265643
_ => false,
56275644
}
56285645
});

libc-test/semver/aix.txt

Lines changed: 5 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

src/unix/aix/powerpc64.rs

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#[allow(unused_imports)]
2+
use core::ptr;
3+
14
use crate::off_t;
25
use crate::prelude::*;
36

@@ -256,6 +259,70 @@ s_no_extra_traits! {
256259
pub __pad: [c_int; 3],
257260
}
258261

262+
pub union _kernel_simple_lock {
263+
pub _slock: c_long,
264+
// Should be pointer to 'lock_data_instrumented'
265+
pub _slockp: *mut c_void,
266+
}
267+
268+
pub struct fileops_t {
269+
pub fo_rw: extern "C" fn(
270+
file: *mut file,
271+
rw: crate::uio_rw,
272+
io: *mut c_void,
273+
ext: c_long,
274+
secattr: *mut c_void,
275+
) -> c_int,
276+
pub fo_ioctl: extern "C" fn(
277+
file: *mut file,
278+
a: c_long,
279+
b: crate::caddr_t,
280+
c: c_long,
281+
d: c_long,
282+
) -> c_int,
283+
pub fo_select:
284+
extern "C" fn(file: *mut file, a: c_int, b: *mut c_ushort, c: extern "C" fn()) -> c_int,
285+
pub fo_close: extern "C" fn(file: *mut file) -> c_int,
286+
pub fo_fstat: extern "C" fn(file: *mut file, sstat: *mut crate::stat) -> c_int,
287+
}
288+
289+
pub struct file {
290+
pub f_flag: c_long,
291+
pub f_count: c_int,
292+
pub f_options: c_short,
293+
pub f_type: c_short,
294+
// Should be pointer to 'vnode'
295+
pub f_data: *mut c_void,
296+
pub f_offset: c_longlong,
297+
pub f_dir_off: c_long,
298+
// Should be pointer to 'cred'
299+
pub f_cred: *mut c_void,
300+
pub f_lock: _kernel_simple_lock,
301+
pub f_offset_lock: _kernel_simple_lock,
302+
pub f_vinfo: crate::caddr_t,
303+
pub f_ops: *mut fileops_t,
304+
pub f_parentp: crate::caddr_t,
305+
pub f_fnamep: crate::caddr_t,
306+
pub f_fdata: [c_char; 160],
307+
}
308+
309+
pub union __ld_info_file {
310+
pub _ldinfo_fd: c_int,
311+
pub _ldinfo_fp: *mut file,
312+
pub _core_offset: c_long,
313+
}
314+
315+
pub struct ld_info {
316+
pub ldinfo_next: c_uint,
317+
pub ldinfo_flags: c_uint,
318+
pub _file: __ld_info_file,
319+
pub ldinfo_textorg: *mut c_void,
320+
pub ldinfo_textsize: c_ulong,
321+
pub ldinfo_dataorg: *mut c_void,
322+
pub ldinfo_datasize: c_ulong,
323+
pub ldinfo_filename: [c_char; 2],
324+
}
325+
259326
pub union __pollfd_ext_u {
260327
pub addr: *mut c_void,
261328
pub data32: u32,
@@ -327,6 +394,127 @@ cfg_if! {
327394
self.__si_flags.hash(state);
328395
}
329396
}
397+
398+
impl PartialEq for _kernel_simple_lock {
399+
fn eq(&self, other: &_kernel_simple_lock) -> bool {
400+
unsafe { self._slock == other._slock && self._slockp == other._slockp }
401+
}
402+
}
403+
impl Eq for _kernel_simple_lock {}
404+
impl hash::Hash for _kernel_simple_lock {
405+
fn hash<H: hash::Hasher>(&self, state: &mut H) {
406+
unsafe {
407+
self._slock.hash(state);
408+
self._slockp.hash(state);
409+
}
410+
}
411+
}
412+
413+
impl PartialEq for fileops_t {
414+
fn eq(&self, other: &fileops_t) -> bool {
415+
ptr::fn_addr_eq(self.fo_rw, other.fo_rw)
416+
&& ptr::fn_addr_eq(self.fo_ioctl, other.fo_ioctl)
417+
&& ptr::fn_addr_eq(self.fo_select, other.fo_select)
418+
&& ptr::fn_addr_eq(self.fo_close, other.fo_close)
419+
&& ptr::fn_addr_eq(self.fo_fstat, other.fo_fstat)
420+
}
421+
}
422+
impl Eq for fileops_t {}
423+
impl hash::Hash for fileops_t {
424+
fn hash<H: hash::Hasher>(&self, state: &mut H) {
425+
self.fo_rw.hash(state);
426+
self.fo_ioctl.hash(state);
427+
self.fo_select.hash(state);
428+
self.fo_close.hash(state);
429+
self.fo_fstat.hash(state);
430+
}
431+
}
432+
433+
impl PartialEq for file {
434+
fn eq(&self, other: &file) -> bool {
435+
self.f_flag == other.f_flag
436+
&& self.f_count == other.f_count
437+
&& self.f_options == other.f_options
438+
&& self.f_type == other.f_type
439+
&& self.f_data == other.f_data
440+
&& self.f_offset == other.f_offset
441+
&& self.f_dir_off == other.f_dir_off
442+
&& self.f_cred == other.f_cred
443+
&& self.f_vinfo == other.f_vinfo
444+
&& self.f_ops == other.f_ops
445+
&& self.f_parentp == other.f_parentp
446+
&& self.f_fnamep == other.f_fnamep
447+
&& self.f_fdata == other.f_fdata
448+
&& self.f_lock == other.f_lock
449+
&& self.f_offset_lock == other.f_offset_lock
450+
}
451+
}
452+
impl Eq for file {}
453+
impl hash::Hash for file {
454+
fn hash<H: hash::Hasher>(&self, state: &mut H) {
455+
self.f_flag.hash(state);
456+
self.f_count.hash(state);
457+
self.f_options.hash(state);
458+
self.f_type.hash(state);
459+
self.f_data.hash(state);
460+
self.f_offset.hash(state);
461+
self.f_dir_off.hash(state);
462+
self.f_cred.hash(state);
463+
self.f_lock.hash(state);
464+
self.f_offset_lock.hash(state);
465+
self.f_vinfo.hash(state);
466+
self.f_ops.hash(state);
467+
self.f_parentp.hash(state);
468+
self.f_fnamep.hash(state);
469+
self.f_fdata.hash(state);
470+
}
471+
}
472+
473+
impl PartialEq for __ld_info_file {
474+
fn eq(&self, other: &__ld_info_file) -> bool {
475+
unsafe {
476+
self._ldinfo_fd == other._ldinfo_fd
477+
&& self._ldinfo_fp == other._ldinfo_fp
478+
&& self._core_offset == other._core_offset
479+
}
480+
}
481+
}
482+
impl Eq for __ld_info_file {}
483+
impl hash::Hash for __ld_info_file {
484+
fn hash<H: hash::Hasher>(&self, state: &mut H) {
485+
unsafe {
486+
self._ldinfo_fd.hash(state);
487+
self._ldinfo_fp.hash(state);
488+
self._core_offset.hash(state);
489+
}
490+
}
491+
}
492+
493+
impl PartialEq for ld_info {
494+
fn eq(&self, other: &ld_info) -> bool {
495+
self.ldinfo_next == other.ldinfo_next
496+
&& self.ldinfo_flags == other.ldinfo_flags
497+
&& self.ldinfo_textorg == other.ldinfo_textorg
498+
&& self.ldinfo_textsize == other.ldinfo_textsize
499+
&& self.ldinfo_dataorg == other.ldinfo_dataorg
500+
&& self.ldinfo_datasize == other.ldinfo_datasize
501+
&& self.ldinfo_filename == other.ldinfo_filename
502+
&& self._file == other._file
503+
}
504+
}
505+
impl Eq for ld_info {}
506+
impl hash::Hash for ld_info {
507+
fn hash<H: hash::Hasher>(&self, state: &mut H) {
508+
self.ldinfo_next.hash(state);
509+
self.ldinfo_flags.hash(state);
510+
self.ldinfo_textorg.hash(state);
511+
self.ldinfo_textsize.hash(state);
512+
self.ldinfo_dataorg.hash(state);
513+
self.ldinfo_datasize.hash(state);
514+
self.ldinfo_filename.hash(state);
515+
self._file.hash(state);
516+
}
517+
}
330518
impl PartialEq for __pollfd_ext_u {
331519
fn eq(&self, other: &__pollfd_ext_u) -> bool {
332520
unsafe {

0 commit comments

Comments
 (0)