AC_DEFUN([HEADER_NOT_FOUND_LIB],
[ERR_NOT_FOUND([$1 header], [the library])])
+AC_DEFUN([HEADER_NOT_FOUND_TESTS],
+ [ERR_NOT_FOUND([$1 header], [the test suite])])
+
# This is always checked (library needs this)
AC_HEADER_STDC
AC_FUNC_MALLOC
then
AC_CHECK_FUNC([qsort], [], [FUNC_NOT_FOUND_TESTS([qsort])])
AC_CHECK_FUNC([regexec], [], [FUNC_NOT_FOUND_TESTS([regexec])])
+ AC_CHECK_HEADERS([linux/version.h], [], [HEADER_NOT_FOUND_TESTS([linux/version.h])])
PKG_CHECK_MODULES([KMOD], [libkmod >= 18])
PKG_CHECK_MODULES([UDEV], [libudev >= 215])
#include <errno.h>
#include <libkmod.h>
#include <libudev.h>
+#include <linux/version.h>
#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
#include "gpio-mockup.h"
#define EXPORT __attribute__((visibility("default")))
-
-static const unsigned int min_kern_major = 5;
-static const unsigned int min_kern_minor = 1;
-static const unsigned int min_kern_release = 0;
+#define MIN_KERNEL_VERSION KERNEL_VERSION(5, 1, 0)
struct gpio_mockup_chip {
char *name;
return false;
}
- if (major < min_kern_major) {
- goto bad_version;
- } else if (major > min_kern_major) {
- goto good_version;
- } else {
- if (minor < min_kern_minor) {
- goto bad_version;
- } else if (minor > min_kern_minor) {
- goto good_version;
- } else {
- if (release < min_kern_release)
- goto bad_version;
- else
- goto good_version;
- }
+ if (KERNEL_VERSION(major, minor, release) < MIN_KERNEL_VERSION) {
+ errno = EOPNOTSUPP;
+ return false;
}
-good_version:
return true;
-
-bad_version:
- errno = EOPNOTSUPP;
- return false;
}
EXPORT struct gpio_mockup *gpio_mockup_new(void)