pezi / dart_periphery

dart_periphery is a Dart port of the native c-periphery library
BSD 3-Clause "New" or "Revised" License
36 stars 9 forks source link

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

Open ardera opened 1 year ago

ardera commented 1 year ago

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.

pezi commented 1 year ago

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.