-
Notifications
You must be signed in to change notification settings - Fork 710
Expand file tree
/
Copy pathlibnvme-wrap.c
More file actions
38 lines (33 loc) · 831 Bytes
/
libnvme-wrap.c
File metadata and controls
38 lines (33 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* This file is part of nvme-cli
*
* Copyright (c) 2022 Daniel Wagner, SUSE
*/
#include <dlfcn.h>
#include <errno.h>
#include <stdlib.h>
#include <libnvme.h>
#include "nvme-print.h"
#define PROTO(args...) args
#define ARGS(args...) args
#define VOID_FN(name, proto, args) \
void __attribute__((weak)) name(proto) \
{ \
void (*fn)(proto); \
fn = dlsym(RTLD_NEXT, #name); \
if (!fn) { \
nvme_show_error("libnvme function " #name " not found");\
exit(EXIT_FAILURE); \
} \
fn(args); \
}
#define FN(name, rtype, proto, args, defret) \
rtype __attribute__((weak)) name(proto) \
{ \
rtype (*fn)(proto); \
fn = dlsym(RTLD_NEXT, #name); \
if (fn) \
return fn(args); \
return defret; \
}