Skip to content
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

WIP: Fix OpenBSD support #216

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open

WIP: Fix OpenBSD support #216

wants to merge 3 commits into from

Conversation

tobhe
Copy link

@tobhe tobhe commented Feb 25, 2025

This makes OpenBSD work properly on my machine.

WIP because it depends on a libc change in rust-lang/libc#4285 (comment)

My rust experience is rather limited so I'm looking forward to hear how this could be improved.

One potential problem I see is that devname() is not thread-safe as is because the name buffer is static. Does this need to be copied safely, guarded by a lock or marked unsafe?

@MarijnS95
Copy link
Contributor

This was based on upstream libdrm, which still defines those original constants for OpenBSD to be different from the rest: https://gitlab.freedesktop.org/mesa/drm/-/blob/a7eb2cfd53a70fcd9ba9dcfad80a3994642f362f/xf86drm.h#L79-90

Any clue as to how/when this was changing, and is this PR backwards-compatible "enough"?

@tobhe
Copy link
Author

tobhe commented Mar 2, 2025

Any clue as to how/when this was changing, and is this PR backwards-compatible "enough"?

It looks like this changed in 2021 openbsd/xenocara@9d1e1e2

OpenBSD only supports the last two releases, with one release every 6 months that means we don't need to worry (besides, breaking API and ABI across releases is not a huge issue in OpenBSD land).

@tobhe
Copy link
Author

tobhe commented Mar 2, 2025

Latest push includes a few fixes based on feedback from @MarijnS95. I also added a check to handle the actual error case "??" properly. I am not convinced that buf.is_null() is actually possible here but it probably doesn't hurt to keep that check.

@Drakulix
Copy link
Member

Drakulix commented Mar 3, 2025

One potential problem I see is that devname() is not thread-safe as is because the name buffer is static. Does this need to be copied safely, guarded by a lock or marked unsafe?

We can't really mark a function as thread-unsafe in rust, so I am afraid this would need a global lock variable.

@tobhe
Copy link
Author

tobhe commented Mar 3, 2025

Clarified the /dev/dri node change in the commit message, changed the libc dependency to a more realistic target (if I understand their versioning right) and added a global lock for the static buffer returned by devname().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants