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

library loader: use dart:ffi Abi instead of uname() for architecture detection #22

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ardera
Copy link

@ardera ardera commented May 16, 2023

Hey, thanks for the project! It's really helpful!

dart:ffi has it's own Abi class now, which you can use for architecture detection: https://api.dart.dev/stable/2.18.1/dart-ffi/Abi-class.html. It's used internally for @AbiSpecificInteger for example.

Also, make nativeUname() use /proc/sys/kernel/{ostype,hostname,osrelease,version} files and uname -m for architecture instead. (Not strictly necessary, just thought that'd be better, I think the previous method of guessing _UTSNAME_LENGTH, was nice, but maybe a bit hacky :p )

Make CpuArch._internal() use dart:ffi Abi for architecture detection, too now, instead of querying uname.

You could also remove the whole cpu_architecture.dart file since people should really be using dart:ffi's Abi class :) But that'd be a breaking change of course.

- dart:ffi has it's own Abi class now, which you can use for
  architecture detection
- (used internally for @AbiSpecificInteger for example)
- make nativeUname() use `/proc/sys/kernel` files instead of uname binding
- make `CpuArch._internal()` use `Abi.current()` for architecture
  detection, instead of querying uname
@ardera ardera force-pushed the new-architecture-detection branch from cea3b08 to ce352ec Compare May 16, 2023 13:12
@pezi
Copy link
Owner

pezi commented May 17, 2023

Thanks for your submission. I will include these changes for the next relaase 0.9.6. For this release I will update the https://github.com/vsergeev/c-periphery libs. After two years an update is available.

throw an error if `!_abiSupported`, not `_abiSupported`
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