Skip to content

Restore 'struct ld_info' and related types for AIX #4578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5625,6 +5625,18 @@ fn test_aix(target: &str) {
// allow type 'double' to be used in signal contexts.
"fpreg_t" => true,

// This type is defined for a union used within `struct ld_info`.
// The AIX header does not declare a separate standalone union
// type for it.
"__ld_info_file" => true,

// This is a simplified version of the AIX union `_simple_lock`.
"_kernel_simple_lock" => true,

// These structures are guarded by the `_KERNEL` macro in the AIX
// header.
"fileops_t" | "file" => true,

_ => false,
}
});
Expand All @@ -5642,6 +5654,11 @@ fn test_aix(target: &str) {
// The _ALL_SOURCE type of 'f_fsid' differs from POSIX's on AIX.
("statvfs", "f_fsid") => true,

// The type of `_file` is `__ld_info_file`, which is defined
// specifically for the union inside `struct ld_info`. The AIX
// header does not define a separate standalone union type for it.
("ld_info", "_file") => true,

_ => false,
}
});
Expand Down
6 changes: 6 additions & 0 deletions libc-test/semver/aix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1791,12 +1791,14 @@ _W_STOPPED
_W_STRC
__context64
__extctx_t
__ld_info_file
__pollfd_ext_u
__tm_context_t
__vmx_context_t
__vmxreg_t
__vsx_context_t
_exit
_kernel_simple_lock
abort
accept
access
Expand Down Expand Up @@ -1915,7 +1917,9 @@ fgetpos
fgetpos64
fgetpwent
fgets
file
fileno
fileops_t
flock
flock64
fnmatch
Expand Down Expand Up @@ -2079,6 +2083,7 @@ kill
lchown
lcong48
lconv
ld_info
lfind
linger
link
Expand All @@ -2090,6 +2095,7 @@ locale_t
localeconv
localtime
localtime_r
lock_data_instrumented
lpar_get_info
lpar_set_resources
lrand48
Expand Down
75 changes: 75 additions & 0 deletions src/unix/aix/powerpc64.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
use crate::off_t;
use crate::prelude::*;

// Define lock_data_instrumented as an empty enum
missing! {
#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum lock_data_instrumented {}
}

s! {
pub struct sigset_t {
pub ss_set: [c_ulong; 4],
Expand Down Expand Up @@ -256,6 +262,74 @@ s_no_extra_traits! {
pub __pad: [c_int; 3],
}

pub union _kernel_simple_lock {
pub _slock: c_long,
pub _slockp: *mut lock_data_instrumented,
}

pub struct fileops_t {
pub fo_rw: Option<
extern "C" fn(
file: *mut file,
rw: crate::uio_rw,
io: *mut c_void,
ext: c_long,
secattr: *mut c_void,
) -> c_int,
>,
pub fo_ioctl: Option<
extern "C" fn(
file: *mut file,
a: c_long,
b: crate::caddr_t,
c: c_long,
d: c_long,
) -> c_int,
>,
pub fo_select: Option<
extern "C" fn(file: *mut file, a: c_int, b: *mut c_ushort, c: extern "C" fn()) -> c_int,
>,
pub fo_close: Option<extern "C" fn(file: *mut file) -> c_int>,
pub fo_fstat: Option<extern "C" fn(file: *mut file, sstat: *mut crate::stat) -> c_int>,
}

pub struct file {
pub f_flag: c_long,
pub f_count: c_int,
pub f_options: c_short,
pub f_type: c_short,
// Should be pointer to 'vnode'
pub f_data: *mut c_void,
pub f_offset: c_longlong,
pub f_dir_off: c_long,
// Should be pointer to 'cred'
pub f_cred: *mut c_void,
pub f_lock: _kernel_simple_lock,
pub f_offset_lock: _kernel_simple_lock,
pub f_vinfo: crate::caddr_t,
pub f_ops: *mut fileops_t,
pub f_parentp: crate::caddr_t,
pub f_fnamep: crate::caddr_t,
pub f_fdata: [c_char; 160],
}

pub union __ld_info_file {
pub _ldinfo_fd: c_int,
pub _ldinfo_fp: *mut file,
pub _core_offset: c_long,
}

pub struct ld_info {
pub ldinfo_next: c_uint,
pub ldinfo_flags: c_uint,
pub _file: __ld_info_file,
pub ldinfo_textorg: *mut c_void,
pub ldinfo_textsize: c_ulong,
pub ldinfo_dataorg: *mut c_void,
pub ldinfo_datasize: c_ulong,
pub ldinfo_filename: [c_char; 2],
}

pub union __pollfd_ext_u {
pub addr: *mut c_void,
pub data32: u32,
Expand Down Expand Up @@ -327,6 +401,7 @@ cfg_if! {
self.__si_flags.hash(state);
}
}

impl PartialEq for __pollfd_ext_u {
fn eq(&self, other: &__pollfd_ext_u) -> bool {
unsafe {
Expand Down
Loading