+static PyObject *
+module_check_kernel_version(PyObject *Py_UNUSED(self), PyObject *args)
+{
+ unsigned int req_maj, req_min, req_rel, curr_maj, curr_min, curr_rel;
+ struct utsname un;
+ int ret;
+
+ ret = PyArg_ParseTuple(args, "III", &req_maj, &req_min, &req_rel);
+ if (!ret)
+ return NULL;
+
+ ret = uname(&un);
+ if (ret)
+ return PyErr_SetFromErrno(PyExc_OSError);
+
+ ret = sscanf(un.release, "%u.%u.%u", &curr_maj, &curr_min, &curr_rel);
+ if (ret != 3) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "invalid linux version read from the kernel");
+ return NULL;
+ }
+
+ if (KERNEL_VERSION(curr_maj, curr_min, curr_rel) <
+ KERNEL_VERSION(req_maj, req_min, req_rel))
+ Py_RETURN_FALSE;
+
+ Py_RETURN_TRUE;
+}
+