Skip to content

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

Open
ardera wants to merge 2 commits into
pezi:mainfrom
ardera:new-architecture-detection
Open

library loader: use dart:ffi Abi instead of uname() for architecture detection#22
ardera wants to merge 2 commits into
pezi:mainfrom
ardera:new-architecture-detection

Conversation

@ardera

@ardera ardera commented May 16, 2023

Copy link
Copy Markdown

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

pezi commented May 17, 2023

Copy link
Copy Markdown
Owner

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