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

Use Rustix #180

Merged
merged 4 commits into from
Nov 14, 2023
Merged

Use Rustix #180

merged 4 commits into from
Nov 14, 2023

Conversation

ids1024
Copy link
Member

@ids1024 ids1024 commented Nov 7, 2023

Updates drm-ffi to use Rustix.

Based on #179.

Not too hard to update by defining macros like Nix had, though it's probably not ideal.

The generic ioctl API for Rustix seems a bit awkward when dealing with APIs like drm that involve very large numbers of ioctls. Instead of generating functions with a macro like this, it's possible to define types aliases with ReadWriteOpcode, etc. But it's still necessary to deal with Getter/Setter, etc...

ids1024 added a commit to ids1024/rustix that referenced this pull request Nov 9, 2023
`<sys/ioccom.h>` defines `IOC_OUT` as `0x40000000UL`. But this is "out"
from the perspective of the kernel, not the application. So this
corresponds to `READ` rather than `WRITE`.

Tested with Smithay/drm-rs#180. This also seems
to be correct for NetBSD and OpenBSD.
ids1024 added a commit to ids1024/rustix that referenced this pull request Nov 9, 2023
`<sys/ioccom.h>` defines `IOC_OUT` as `0x40000000UL`. But this is "out"
from the perspective of the kernel, not the application. So this
corresponds to `READ` rather than `WRITE`.

Tested on FreeBSD with Smithay/drm-rs#180. This also
seems to be correct for NetBSD and OpenBSD.
ids1024 added a commit to ids1024/rustix that referenced this pull request Nov 10, 2023
`<sys/ioccom.h>` defines `IOC_OUT` as `0x40000000UL`. But this is "out"
from the perspective of the kernel, not the application. So this
corresponds to `READ` rather than `WRITE`.

Tested on FreeBSD with Smithay/drm-rs#180. This also
seems to be correct for NetBSD and OpenBSD.
sunfishcode pushed a commit to bytecodealliance/rustix that referenced this pull request Nov 10, 2023
`<sys/ioccom.h>` defines `IOC_OUT` as `0x40000000UL`. But this is "out"
from the perspective of the kernel, not the application. So this
corresponds to `READ` rather than `WRITE`.

Tested on FreeBSD with Smithay/drm-rs#180. This also
seems to be correct for NetBSD and OpenBSD.
@ids1024 ids1024 force-pushed the rustix branch 2 times, most recently from fb1d1f0 to 47260f1 Compare November 13, 2023 23:35
Not *too* hard to update by defining macros like Nix had. It would be
possible to replace use of the macro with just type aliases for opcodes,
but it's still necessary to deal with `Getter`/`Setter`/`Updater`, and
repeat the type.
Since torvalds/linux@d79cdc831 in 2013, the
`GET_STATS` ioctl has been a no-op. A wrapper for this was not exported
in the API here anyway.
Somehow Cargo didn't complain about the previous generated ioctl function
being unused, but does now with the macro based on Rustix.

Taking an `&mut` matches the API of `drmSetInterfaceVersion` in libdrm,
so it makes sense to just stick with that.
This shouldn't be too much worse to use, and avoids any kind of public
dependency of Rustix. So a new version of it won't be a breaking change.
@ids1024
Copy link
Member Author

ids1024 commented Nov 13, 2023

With bytecodealliance/rustix#925 and bytecodealliance/rustix#926 merged and after a few more changes here, this should be good to merged.

@ids1024 ids1024 marked this pull request as ready for review November 13, 2023 23:49
@ids1024 ids1024 changed the title WIP Use Rustix Use Rustix Nov 13, 2023
Copy link
Member

@Drakulix Drakulix left a comment

Choose a reason for hiding this comment

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

Thanks!

@Drakulix Drakulix merged commit c0ee108 into Smithay:develop Nov 14, 2023
16 checks passed
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.

2 participants