Commit 1565744d authored by Philippe Gerum's avatar Philippe Gerum
Browse files

lib/init: state ABI requirement explicitly



Instead of matching whatever ABI we might be compiled against like
previously, define the kernel ABI we need as a prerequisite
(EVL_KABI_PREREQ), checking for sanity at build time and runtime.

This prerequisite is matched against the range of ABI revisions the
kernel supports (from EVL_ABI_BASE to EVL_ABI_CURRENT). In the
simplest case, the kernel implements a single ABI with no backward
compatibility mechanism (EVL_ABI_BASE == EVL_ABI_CURRENT).

This addresses two issues:

- the fact that libevl might build against a given set of uapi/ files
  does not actually mean that the corresponding kernel ABI found there
  is fully compatible with what libevl expects. Specifying a
  compatible ABI prereq explicitly addresses this problem.

- we can obtain services from EVL cores supporting multiple ABI
  revisions (i.e. providing backward compat feat).
Signed-off-by: Philippe Gerum's avatarPhilippe Gerum <rpm@xenomai.org>
parent 01f1cc27
......@@ -13,7 +13,7 @@
struct evl_version {
int api_level; /* libevl.so: __EVL__ */
int abi_level; /* core: EVL_ABI_LEVEL, -1 for ESHI */
int abi_level; /* -1 for ESHI */
const char *version_string;
};
......
......@@ -22,9 +22,11 @@
#define __EVL__ 9 /* API version */
#define EVL_KABI_PREREQ 18
struct evl_version {
int api_level; /* libevl.so: __EVL__ */
int abi_level; /* core: EVL_ABI_LEVEL, -1 for ESHI */
int abi_level; /* core: EVL_KABI_PREREQ, -1 for ESHI */
const char *version_string;
};
......
......@@ -22,6 +22,10 @@
#include <uapi/evl/signal.h>
#include "internal.h"
#if !(EVL_KABI_PREREQ >= EVL_ABI_BASE && EVL_KABI_PREREQ <= EVL_ABI_LEVEL)
#error "kernel does not meet our ABI requirements (uapi vs EVL_KABI_PREREQ)"
#endif
static pthread_once_t init_once = PTHREAD_ONCE_INIT;
static int init_status;
......@@ -84,7 +88,8 @@ static inline int generic_init(void)
goto fail;
}
if (core_info.abi_level != EVL_ABI_LEVEL) {
if (EVL_KABI_PREREQ < core_info.abi_base ||
EVL_KABI_PREREQ > core_info.abi_current) {
fprintf(stderr,
"evl: ABI mismatch, see -ENOEXEC at https://evlproject.org/"
"core/user-api/thread/#evl_attach_self\n");
......
......@@ -18,7 +18,7 @@ struct evl_version evl_get_version(void)
{
return (struct evl_version){
.api_level = __EVL__,
.abi_level = EVL_ABI_LEVEL,
.abi_level = EVL_KABI_PREREQ,
.version_string = "evl." LIBSERIAL git_hash,
};
}
......@@ -77,9 +77,9 @@ int main(int argc, char *const argv[])
cmddir = optarg;
break;
case 'V':
printf("%s [ABI %d]\n",
printf("%s [requires ABI %d]\n",
evl_get_version().version_string,
EVL_ABI_LEVEL);
EVL_KABI_PREREQ);
exit(0);
case '?':
usage();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment