Skip to content

nuttx: use updated pollfd definition - #163202

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
bkueng:nuttx_poll_update
Nov 7, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
bkueng:nuttx_poll_update

Conversation

@bkueng

@bkueng bkueng commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

This goes together with this libc PR: rust-lang/libc#5555

@rustbot rustbot added O-unix Operating system: Unix-like S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 23, 2026
@rustbot

rustbot commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project has assigned @LawnGnome (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks.

Please see the contribution instructions and our LLM policy for more information.

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ChrisDenton, libs
  • @ChrisDenton, libs expanded to 13 candidates
  • Random selection from 7 candidates

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@LawnGnome

Copy link
Copy Markdown
Contributor

Just catching up on the last month of notifications, sorry. I don't have any context on nuttx, so I'm going to re-roll this.

@rustbot reroll

@rustbot rustbot assigned hanna-kruppe and unassigned LawnGnome Oct 27, 2026
@hanna-kruppe

Copy link
Copy Markdown
Contributor

I don't know anything about nuttx either, cc @no1wudi as target maintainer

From a quick glance it looks like rust-lang/libc#5555 was merged now, but only into the main branch, so it's only in the libc 1.0 pre-release, not in any 0.2.x release. My understanding is that more steps are needed before std can use the updated libc definitions:

  1. Backport the libc change to the 0.2 branch
  2. Wait until a new libc 0.2.x release includes the change
  3. Update the standard library workspace to use that libc version

However, looking at the actual changes here, I'm not sure if this is the right way. Duplicating various struct literals just to add fields which are internal to the libc implementation on some platform doesn't seem great for maintainability. Perhaps there's a way to rewrite the affected code that works the same on all platforms including NuttX?

@bkueng

bkueng commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

so it's only in the libc 1.0 pre-release, not in any 0.2.x release. My understanding is that more steps are needed before std can use the updated libc definitions:

I'm not sure what the update process for libc is, I just wanted to provide the required changes upfront so it won't break.

However, looking at the actual changes here, I'm not sure if this is the right way. Duplicating various struct literals just to add fields which are internal to the libc implementation on some platform doesn't seem great for maintainability.

I agree, do you see a better solution? The primary alternative I see is using Default:

let mut pollfd = libc::pollfd {
            fd: self.as_raw_fd(),
            events: libc::POLLOUT,
            revents: 0,
            ..Default::default()
    };

Which would require implementing Default for pollfd.

@hanna-kruppe

Copy link
Copy Markdown
Contributor

I would suggest the pattern of creating the C struct with mem::zeroed() and setting the relevant fields by assigning afterwards. Similar to what's done here, for example:

let mut pidfd_info: libc::pidfd_info = unsafe { crate::mem::zeroed() };
pidfd_info.mask = libc::PIDFD_INFO_PID as u64;

Then we should be able to merge this PR independently of when the libc fix makes it into a libc 0.2.x release and that release is adopted by the standard library.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 29, 2026
@rustbot

rustbot commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@bkueng
bkueng force-pushed the nuttx_poll_update branch from 89eb084 to 4e405ed Compare November 3, 2026 13:58
@rustbot

rustbot commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@bkueng

bkueng commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

I would suggest the pattern of creating the C struct with mem::zeroed() and setting the relevant fields by assigning afterwards.

That works too (if unsafe is acceptable), and I updated accordingly.

@rust-log-analyzer

This comment has been minimized.

@bkueng
bkueng force-pushed the nuttx_poll_update branch from 4e405ed to f9f9cd6 Compare November 4, 2026 12:27
@rust-log-analyzer

This comment has been minimized.

@bkueng
bkueng force-pushed the nuttx_poll_update branch from f9f9cd6 to 4731e88 Compare November 4, 2026 13:08
@rust-log-analyzer

This comment has been minimized.

@bkueng
bkueng force-pushed the nuttx_poll_update branch from 4731e88 to eeb36a0 Compare November 4, 2026 14:43

@hanna-kruppe hanna-kruppe left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, r=me after removing the need for allow(unused_imports).

View changes since this review

Comment thread library/std/src/sys/pal/unix/mod.rs Outdated
Comment on lines +3 to +4
#[allow(unused_imports)]
use crate::{io, mem};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of allowing unused imports, please either use the full path without import, or move the import into the cfg block where it's needed (like the use crate::sys::io::errno).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I changed it to the full path.

while libc::poll(pfds.as_mut_ptr(), 3, 0) == -1 {
let mut pfds: [libc::pollfd; 3] = mem::zeroed();
pfds[0].fd = 0;
pfds[0].events = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Setting events to zero explicitly seems a bit redundant in this context. But I could see the argument that it's more consistent to always set the "input" parts explicitly. So I'm fine with either, just wanted to ask if this is an intentional choice.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes I considered both and ended up setting it so that someone reading it does not get the impression it was forgotten (pfds[0].fd = 0; could also be removed).

Corresponding libc PR: rust-lang/libc#5555

pollfd has some extra internal fields on NuttX, so we use mem::zeroed() to
initialze.
@bkueng
bkueng force-pushed the nuttx_poll_update branch from eeb36a0 to 2cab4ca Compare November 5, 2026 08:39
@hanna-kruppe

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-bors Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 2cab4ca has been approved by hanna-kruppe

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 7, 2026
Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 7, 2026
…kruppe

nuttx: use updated pollfd definition

This goes together with this libc PR: rust-lang/libc#5555
rust-bors Bot pushed a commit that referenced this pull request Nov 7, 2026
Rollup of 5 pull requests

Successful merges:

 - #164784 (Introduce OptimizationObjective and fix the entry shim's size attributes)
 - #147696 (Implement `bit` and `set_bit` for integral types.)
 - #163202 (nuttx: use updated pollfd definition)
 - #163571 ([rustdoc] Render `Deref` methods on aliased items)
 - #165482 (apply `-Zcrate-attr` attributes before the crate attributes)
Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 7, 2026
…kruppe

nuttx: use updated pollfd definition

This goes together with this libc PR: rust-lang/libc#5555
rust-bors Bot pushed a commit that referenced this pull request Nov 7, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #164784 (Introduce OptimizationObjective and fix the entry shim's size attributes)
 - #165469 (Make notable trait `i` badges `<span>` instead of `<a>`)
 - #165576 (compiletest: Reject whitespace between `//` & `@` and reject leading revision conditions like (e.g., `//[rev]@ dir`))
 - #147696 (Implement `bit` and `set_bit` for integral types.)
 - #163202 (nuttx: use updated pollfd definition)
 - #165482 (apply `-Zcrate-attr` attributes before the crate attributes)
 - #165517 (Migrate basic block ctors to require Terminator where possible)
 - #165552 (use lang item instead of name when assembling builtin `Clone::clone` instances)
rust-bors Bot pushed a commit that referenced this pull request Nov 7, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #164784 (Introduce OptimizationObjective and fix the entry shim's size attributes)
 - #165469 (Make notable trait `i` badges `<span>` instead of `<a>`)
 - #165576 (compiletest: Reject whitespace between `//` & `@` and reject leading revision conditions like (e.g., `//[rev]@ dir`))
 - #147696 (Implement `bit` and `set_bit` for integral types.)
 - #163202 (nuttx: use updated pollfd definition)
 - #165482 (apply `-Zcrate-attr` attributes before the crate attributes)
 - #165517 (Migrate basic block ctors to require Terminator where possible)
 - #165552 (use lang item instead of name when assembling builtin `Clone::clone` instances)
@rust-bors
rust-bors Bot merged commit 2014c63 into rust-lang:main Nov 7, 2026
14 checks passed
@rustbot rustbot added this to the 1.102.0 milestone Nov 7, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 7, 2026
Rollup merge of #163202 - bkueng:nuttx_poll_update, r=hanna-kruppe

nuttx: use updated pollfd definition

This goes together with this libc PR: rust-lang/libc#5555
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-unix Operating system: Unix-like S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants