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

Conversation

xingxue-ibm
Copy link
Contributor

Description

struct ld_info and related types are used by the AIX system call loadquery(). This patch reintroduces them with adjustments to pass CI.

Sources

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are
    included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI

@@ -327,6 +394,127 @@ cfg_if! {
self.__si_flags.hash(state);
}
}

impl PartialEq for _kernel_simple_lock {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We aren't adding PartialEq traits anymore, since they are planned to be remove in 1.0 (trivial unsoundness). These can just be dropped.

Some more info at #3880

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed them, thanks!

Are these PartialEqs needed when cherry-picking this patch to the stable branch?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry, I missed part of my sentence; we aren't doing PartialEq or the other traits (Eq, Hash) so they can all be removed. (Does this actually build in its current state with Eq but not PartialEq?)

Are these PartialEqs needed when cherry-picking this patch to the stable branch?

They aren't, basically everything new should follow the 1.0 rules so this is good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, and thanks for the clarification! I’ve removed Eq and Hash as well. The code builds with Eq and Hash without PartialEq, but having Debug fails the build.

Comment on lines 268 to 294
pub struct fileops_t {
pub fo_rw: 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: extern "C" fn(
file: *mut file,
a: c_long,
b: crate::caddr_t,
c: c_long,
d: c_long,
) -> c_int,
pub fo_select:
extern "C" fn(file: *mut file, a: c_int, b: *mut c_ushort, c: extern "C" fn()) -> c_int,
pub fo_close: extern "C" fn(file: *mut file) -> c_int,
pub fo_fstat: extern "C" fn(file: *mut file, sstat: *mut crate::stat) -> c_int,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the function pointers here ever null? They may need to be Option<fn(...)>

Also, are the headers/docs for any of these structs public?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find the sys/file.h header file online. It’s only mentioned in the AIX 7.3 documentation under t List of Major Control Block Header Files. The header is installed by default on AIX systems.

It seems that struct fileops defines the file operations for an open file or pipe. I'm not completely sure whether its function pointers can ever be NULL, but I suppose using Option<fn(...)> in Rust is a safe choice. Thanks for the guidance!

struct fileops and struct file are guarded under macro _KERNEL.

typedef struct fileops
{
        int     (*fo_rw)(struct file *, enum uio_rw, struct uio *,
                         ext_t, file_secattr_t *);
        int     (*fo_ioctl)(struct file *, long, caddr_t, ext_t, long);
        int     (*fo_select)(struct file *, int, ushort, ushort *, void (*)());
        int     (*fo_close)(struct file *);
        int     (*fo_fstat)(struct file *, struct stat *);
} fileops_t;
...
/* One file structure is allocated for each open/creat/pipe call. Main use is
 * to hold the read/write pointer associated with each open file.
 *
 * Portions of this structure are overlaid when placed on the freelist.
 * Binary compatibility concerns require that fields *not* be rearranged for
 * sanity.
 */
__align(256) struct file {
        long    f_flag;         /* see fcntl.h for definitions               */
        int     f_count;        /* reference count                           */
        short   f_options;      /* file flags not passed through vnode layer */
        short   f_type;         /* descriptor type                           */

        /* The following fields are overloaded when the file struct is freed,
         * except for the locks which must remain static. See struct freefile.
         */

        struct vnode *f_data;           /* pointer to vnode struct           */
#define f_vnode       f_data

        offset_t        f_offset;       /* read/write character pointer      */
        off_t           f_dir_off;      /* BSD style dir offsets             */
        struct ucred    *f_cred;        /* process cred at open              */

        Simple_lock     f_lock;         /* file structure fields lock        */
        Simple_lock     f_offset_lock;  /* file structure offset field lock  */

        caddr_t         f_vinfo;        /* any info vfs needs                */
        fileops_t       *f_ops;         /* operations vector                 */

        caddr_t         f_parentp;      /* the file's parent vnode or fid    */
        caddr_t         f_fnamep;       /* fname pointer, may be embedded    */
        char            f_fdata[F_FDATASZ];/* embedded file data, pad to 256 */
};

There is a description of struct ld_info.

@xingxue-ibm xingxue-ibm force-pushed the add-ld_info branch 3 times, most recently from 95ed722 to c10873a Compare July 26, 2025 19:37
@tgross35
Copy link
Contributor

One more request at #4578 (comment) then lgtm

@tgross35 tgross35 added this pull request to the merge queue Jul 28, 2025
@tgross35 tgross35 added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Jul 28, 2025
Merged via the queue into rust-lang:main with commit 925eb0c Jul 28, 2025
48 of 52 checks passed
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Jul 29, 2025
(backport <rust-lang#4578>)
(cherry picked from commit 925eb0c)
@tgross35 tgross35 mentioned this pull request Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-powerpc O-unix stable-nominated This PR should be considered for cherry-pick to libc's stable release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants