-
Notifications
You must be signed in to change notification settings - Fork 2
/
unvmed.h
68 lines (56 loc) · 1.36 KB
/
unvmed.h
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef UNVMED_H
#define UNVMED_H
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
static inline void unvme_free(void *p)
{
void **ptr = (void **)p;
if (*ptr) {
free(*ptr);
*ptr = NULL;
}
}
#pragma GCC diagnostic pop
#define __unvme_free __attribute__((cleanup(unvme_free)))
struct unvme_msg;
struct unvme;
union nvme_cmd;
struct nvme_cqe;
/*
* unvmed-print.c
*/
void unvme_pr_raw(void *vaddr, size_t len);
void unvme_pr_id_ns(void *vaddr);
void unvme_pr_id_active_nslist(void *vaddr);
void unvme_pr_show_regs(struct unvme *u);
void unvme_pr_status(struct unvme *u);
/*
* unvmed-file.c
*/
bool unvme_is_abspath(const char *path);
char *unvme_get_filepath(char *pwd, const char *filename);
int unvme_write_file(const char *abspath, void *buf, size_t len);
int unvme_read_file(const char *abspath, void *buf, size_t len);
const char *unvmed_get_libfio(void);
/*
* per-thread stdio stream objects
*/
extern __thread FILE *__stdout;
extern __thread FILE *__stderr;
void unvme_exit_job(int ret);
#ifdef unvme_pr
#undef unvme_pr
#endif
#ifdef unvme_pr_err
#undef unvme_pr_err
#endif
#define unvme_pr(fmt, ...) \
do { \
fprintf(__stdout, fmt, ##__VA_ARGS__); \
} while(0)
#define unvme_pr_err(fmt, ...) \
do { \
fprintf(__stderr, fmt, ##__VA_ARGS__); \
} while(0)
#endif