KernelUtils.h - add helpers

Change-Id: I03eff7e10a81f07d5e08fad49f753fa5b6be344e
This commit is contained in:
Maciej Żenczykowski 2024-04-25 14:18:56 -07:00
parent a1b23e8caa
commit 5016d6f801

View file

@ -42,10 +42,26 @@ static inline unsigned kernelVersion() {
return kver;
}
static inline __unused bool isAtLeastKernelVersion(unsigned major, unsigned minor, unsigned sub) {
static inline bool isAtLeastKernelVersion(unsigned major, unsigned minor, unsigned sub) {
return kernelVersion() >= KVER(major, minor, sub);
}
static inline bool isKernelVersion(unsigned major, unsigned minor) {
return isAtLeastKernelVersion(major, minor, 0) && !isAtLeastKernelVersion(major, minor + 1, 0);
}
static inline bool __unused isLtsKernel() {
return isKernelVersion(4, 4) || // minimum for Android R
isKernelVersion(4, 9) || // minimum for Android S & T
isKernelVersion(4, 14) || // minimum for Android U
isKernelVersion(4, 19) || // minimum for Android V
isKernelVersion(5, 4) || // first supported in Android R
isKernelVersion(5, 10) || // first supported in Android S
isKernelVersion(5, 15) || // first supported in Android T
isKernelVersion(6, 1) || // first supported in Android U
isKernelVersion(6, 6); // first supported in Android V
}
// Figure out the bitness of userspace.
// Trivial and known at compile time.
static constexpr bool isUserspace32bit() {