Newer
Older
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
69
/*
* debug.h - defines macros for debugging.
*
* Copyright (C) 2020 iopsys Software Solutions AB. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef LIBWIFI_DEBUG_H
#define LIBWIFI_DEBUG_H
#define ERR_LEVEL (3)
#define WARN_LEVEL (4)
#define INFO_LEVEL (6)
#define DBG_LEVEL (7)
#ifdef __cplusplus
extern "C" {
#endif
extern void log_stderr(int level, const char *fmt, ...);
#define pr_error(...) log_stderr(ERR_LEVEL, __VA_ARGS__)
#define pr_warn(...) log_stderr(WARN_LEVEL, __VA_ARGS__)
#define pr_info(...) log_stderr(INFO_LEVEL, __VA_ARGS__)
#define pr_debug(...) log_stderr(DBG_LEVEL, __VA_ARGS__)
#define WARN_ON(cond) \
({ \
typeof(cond) __c = (cond); \
if (__c) \
pr_warn("%sL%d@%s: [%s] failed\n", __FILE__, __LINE__, __func__, #cond); \
__c; \
})
#ifdef LIBEASY_TRACE_TIME
#define ENTER() clock_t _clk_end, _clk_begin; \
_clk_begin = clock(); \
pr_error("%s called\n", __func__)
#define EXIT(__res__) _clk_end = clock(); \
pr_error("%s ret %d consume %u us\n\n", __func__, __res__, \
(unsigned int) _clk_end - _clk_begin)
#define EXITV() _clk_end = clock(); \
pr_error("%s exit consume %u us\n\n", __func__, \
(unsigned int) _clk_end - _clk_begin)
#else
#define ENTER()
#define EXIT(__res__)
#define EXITV()
#endif
#ifdef __cplusplus
}
#endif
#endif /* LIBWIFI_DEBUG_H */