Skip to content

Add FreeBSD BPF structures #2080

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 2 commits into from
Feb 26, 2021
Merged

Add FreeBSD BPF structures #2080

merged 2 commits into from
Feb 26, 2021

Conversation

jbit
Copy link
Contributor

@jbit jbit commented Feb 25, 2021

This PR adds BPF structures that are common between FreeBSD 11, FreeBSD 12, FreeBSD mainline/13 and DragonFlyBSD 5.9.

It also fixes the definition of BPF_ALIGNMENT, which should be equal to sizeof(long), which is 4 on 32bit FreeBSD.

https://www.freebsd.org/cgi/man.cgi?query=arch&sektion=7

All supported ABIs can be divided into two groups:

  • ILP32: int, long, void * types machine representations all have 4-byte size.
  • LP64: int type machine representation uses 4 bytes, while long and void * are 8 bytes.

I introduced the private SIZEOF_LONG const, since I didn't want to introduce a dependency on rust 1.24+ by depending on libc_const_size_of.

These changes allow my experimental crate to build on FreeBSD: https://github.com/jbit/powerline

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @JohnTitor (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

Copy link
Member

@JohnTitor JohnTitor left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@JohnTitor
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Feb 26, 2021

📌 Commit 4b55c87 has been approved by JohnTitor

@bors
Copy link
Contributor

bors commented Feb 26, 2021

⌛ Testing commit 4b55c87 with merge 83d8c39...

@bors
Copy link
Contributor

bors commented Feb 26, 2021

☀️ Test successful - checks-actions, checks-cirrus-freebsd-11, checks-cirrus-freebsd-12, checks-cirrus-freebsd-13
Approved by: JohnTitor
Pushing 83d8c39 to master...

@bors bors merged commit 83d8c39 into rust-lang:master Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants