Skip to content

bsd: add BPF_WORDALIGN#5320

Open
sbogomolov wants to merge 1 commit into
rust-lang:mainfrom
sbogomolov:bsd-bpf-wordalign
Open

bsd: add BPF_WORDALIGN#5320
sbogomolov wants to merge 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

rustbot commented Jul 23, 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.

@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).

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 S-waiting-on-review 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.

2 participants