summaryrefslogtreecommitdiffstats
path: root/wrapper.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-08-15 12:32:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-08-15 12:32:10 +0000
commitd183dae21720faf38bc4f516052a31227a58f212 (patch)
treeb44b23345eb9b308e49c96e616bc2faaf0ef256b /wrapper.c
parentAdding upstream version 2.1~rc0. (diff)
downloadnvme-cli-d183dae21720faf38bc4f516052a31227a58f212.tar.xz
nvme-cli-d183dae21720faf38bc4f516052a31227a58f212.zip
Adding upstream version 2.1.2.upstream/2.1.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--wrapper.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/wrapper.c b/wrapper.c
index 7341631..2ba5b32 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0-only
+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* This file is part of nvme-cli
*
@@ -9,14 +9,34 @@
#include <libnvme.h>
-const char * __attribute__((weak)) nvme_get_version(enum nvme_version type)
-{
- const char *(*libnvme_get_version)(enum nvme_version type);
+#define PROTO(args...) args
+#define ARGS(args...) args
- libnvme_get_version = dlsym(RTLD_NEXT, "nvme_get_version");
-
- if (libnvme_get_version)
- return libnvme_get_version(type);
+#define VOID_FN(name, proto, args) \
+void __attribute__((weak)) name(proto) \
+{ \
+ void (*fn)(proto); \
+ fn = dlsym(RTLD_NEXT, #name); \
+ if (fn) \
+ fn(args); \
+}
- return "n/a";
+#define FN(name, rtype, proto, args, fallback) \
+rtype __attribute__((weak)) name(proto) \
+{ \
+ rtype (*fn)(proto); \
+ fn = dlsym(RTLD_NEXT, #name); \
+ if (fn) \
+ return fn(args); \
+ return fallback; \
}
+
+FN(nvme_get_version,
+ const char *, PROTO(enum nvme_version type),
+ ARGS(type), "n/a")
+
+VOID_FN(nvme_init_copy_range_f1,
+ PROTO(struct nvme_copy_range_f1 *copy, __u16 *nlbs,
+ __u64 *slbas, __u64 *eilbrts, __u32 *elbatms,
+ __u32 *elbats, __u16 nr),
+ ARGS(copy, nlbs, slbas, eilbrts, elbatms, elbats, nr))