Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright (c) 2022 Marvell.
3 : : */
4 : :
5 : : #ifndef ML_COMMON_H
6 : : #define ML_COMMON_H
7 : :
8 : : #include <stdio.h>
9 : :
10 : : #define CLNRM "\x1b[0m"
11 : : #define CLRED "\x1b[31m"
12 : : #define CLGRN "\x1b[32m"
13 : : #define CLYEL "\x1b[33m"
14 : :
15 : : #define ML_STR_FMT 20
16 : :
17 : : #define ml_err(fmt, args...) fprintf(stderr, CLRED "error: %s() " fmt CLNRM "\n", __func__, ##args)
18 : :
19 : : #define ml_info(fmt, args...) fprintf(stdout, CLYEL "" fmt CLNRM "\n", ##args)
20 : :
21 : : #define ml_dump(str, fmt, val...) printf("\t%-*s : " fmt "\n", ML_STR_FMT, str, ##val)
22 : :
23 : : #define ml_dump_begin(str) printf("\t%-*s :\n\t{\n", ML_STR_FMT, str)
24 : :
25 : : #define ml_dump_list(str, id, val) printf("\t%*s[%2u] : %s\n", ML_STR_FMT - 4, str, id, val)
26 : :
27 : : #define ml_dump_end printf("\b\t}\n\n")
28 : :
29 : : static inline void
30 : 0 : ml_print_line(uint16_t len)
31 : : {
32 : : uint16_t i;
33 : :
34 : 0 : for (i = 0; i < len; i++)
35 : : printf("-");
36 : :
37 : : printf("\n");
38 : 0 : }
39 : :
40 : : #endif /* ML_COMMON_H */
|