Skip to content

bsd: add BPF_WORDALIGN - #5320

Merged
tgross35 merged 1 commit into
rust-lang:mainfrom
sbogomolov:bsd-bpf-wordalign
Aug 2, 2026
Merged

bsd: add BPF_WORDALIGN#5320
tgross35 merged 1 commit into
rust-lang:mainfrom
sbogomolov:bsd-bpf-wordalign

Conversation

@sbogomolov

@sbogomolov sbogomolov commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Description

Add the BPF_WORDALIGN macro on Apple and the freebsdlike platforms. DragonFly writes it as roundup2(x, BPF_ALIGNMENT), which expands to the same expression FreeBSD uses, so the two share one definition.

Sources

Apple BPF_WORDALIGN / BPF_ALIGNMENT (net/bpf.h):

FreeBSD BPF_WORDALIGN / BPF_ALIGNMENT (net/bpf.h):

DragonFly BPF_WORDALIGN / BPF_ALIGNMENT (net/bpf.h) and roundup2 (sys/param.h):

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are included
  • Tested locally (cd libc-test && cargo test --target mytarget)

@rustbot label +stable-nominated

@rustbot rustbot added O-bsd O-dragonfly O-freebsd O-macos O-unix S-waiting-on-review stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Jul 23, 2026
@rustbot

This comment has been minimized.

@sbogomolov

sbogomolov commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Two questions to the reviewer:

  1. As I mentioned in the PR description, DragonFly uses a roundup2 helper macro. If you don't like skipping it here - I can move BPF_WORDALIGN under src/new/freebsd and leave DragonFly out of it.
  2. Currently BPF_ALIGNMENT for Apple is defined with the wrong type (c_int instead of usize, sizeof(int32_t)). If you want, we can fix it in this PR (as a separate commit).

@tgross35 tgross35 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

Reusing for FreeBSD and Dragonfly seems fine to me. I think it would be good to fix BPF_ALIGNMENT at least in 1.0, please feel free to send a follow up!

View changes since this review

@tgross35
tgross35 added this pull request to the merge queue Jul 31, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 31, 2026
@tgross35
tgross35 added this pull request to the merge queue Jul 31, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 31, 2026
@sbogomolov

sbogomolov commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

@tgross35 merge queue errors do not seem to be related to my change.

@sbogomolov

Copy link
Copy Markdown
Contributor Author

I think it would be good to fix BPF_ALIGNMENT at least in 1.0, please feel free to send a follow up!

#5348

@rustbot

rustbot commented Aug 2, 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.

@tgross35
tgross35 added this pull request to the merge queue Aug 2, 2026
Merged via the queue into rust-lang:main with commit 257f77c Aug 2, 2026
57 checks passed
@sbogomolov
sbogomolov deleted the bsd-bpf-wordalign branch August 3, 2026 09:04
@tgross35 tgross35 mentioned this pull request Aug 31, 2026
@tgross35 tgross35 added stable-applied This PR has been cherry-picked to libc's stable release branch and removed stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Aug 31, 2026
tgross35 pushed a commit to dybucc/libc that referenced this pull request Aug 31, 2026
(backport <rust-lang#5320>)
(cherry picked from commit 257f77c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-bsd O-dragonfly O-freebsd O-macos O-unix stable-applied This PR has been cherry-picked to libc's stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants