ec251b79d7e45bda9f4f675176ba17c37bf801b9
[o-du/phy.git] / fhi_lib / lib / src / xran_printf.h
1 /******************************************************************************\r
2 *\r
3 *   Copyright (c) 2019 Intel.\r
4 *\r
5 *   Licensed under the Apache License, Version 2.0 (the "License");\r
6 *   you may not use this file except in compliance with the License.\r
7 *   You may obtain a copy of the License at\r
8 *\r
9 *       http://www.apache.org/licenses/LICENSE-2.0\r
10 *\r
11 *   Unless required by applicable law or agreed to in writing, software\r
12 *   distributed under the License is distributed on an "AS IS" BASIS,\r
13 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14 *   See the License for the specific language governing permissions and\r
15 *   limitations under the License.\r
16 *\r
17 *******************************************************************************/\r
18 \r
19 /**\r
20  * @brief Modules provide debug prints and utility functions\r
21  * @file xran_printf.h\r
22  * @ingroup group_source_xran\r
23  * @author Intel Corporation\r
24  **/\r
25 \r
26 #ifndef XRAN_PRINTF_H\r
27 #define XRAN_PRINTF_H\r
28 \r
29 #ifdef __cplusplus\r
30 extern "C" {\r
31 #endif\r
32 #include <stdio.h>\r
33 #include <stdlib.h>\r
34 \r
35 #define PRINTF_LOG_OK\r
36 #define PRINTF_INF_OK\r
37 #define PRINTF_ERR_OK\r
38 //#define PRINTF_DBG_OK\r
39 \r
40 #ifndef WIN32\r
41 #ifdef PRINTF_LOG_OK\r
42 #define print_log(fmt, args...) printf("%s:" fmt "\n", __FUNCTION__, ## args)\r
43 #else  /* PRINTF_LOG_OK */\r
44 #define print_log(fmt, args...)\r
45 #endif  /* PRINTF_LOG_OK */\r
46 #else\r
47 #define print_log(fmt, ...) printf("%s:" fmt "\n", __FUNCTION__, __VA_ARGS__)\r
48 #endif\r
49 \r
50 #ifndef WIN32\r
51 #ifdef PRINTF_DBG_OK\r
52 #define print_dbg(fmt, args...) printf("%s:[dbg] " fmt "\n", __FUNCTION__, ## args)\r
53 #else  /* PRINTF_LOG_OK */\r
54 #define print_dbg(fmt, args...)\r
55 #endif  /* PRINTF_LOG_OK */\r
56 #else\r
57 #define print_dbg(fmt, ...) printf("%s:[dbg] " fmt "\n", __FUNCTION__, __VA_ARGS__)\r
58 #endif\r
59 \r
60 #ifndef WIN32\r
61 #ifdef PRINTF_ERR_OK\r
62 #define print_err(fmt, args...) printf("%s:[err] " fmt "\n", __FUNCTION__, ## args)\r
63 #else  /* PRINTF_LOG_OK */\r
64 #define print_err(fmt, args...)\r
65 #endif  /* PRINTF_LOG_OK */\r
66 #else\r
67 #define print_err(fmt, ...) printf("%s:[err] " fmt "\n", __FUNCTION__, __VA_ARGS__)\r
68 #endif\r
69 \r
70 #ifndef WIN32\r
71 #ifdef PRINTF_INF_OK\r
72 #define print_inf               printf\r
73 #else  /* PRINTF_LOG_OK */\r
74 #define print_inf\r
75 #endif  /* PRINTF_LOG_OK */\r
76 #else\r
77 #define print_inf               printf\r
78 #endif\r
79 \r
80 #ifdef __cplusplus\r
81 }\r
82 #endif\r
83 \r
84 #ifndef _IASSERT_\r
85 #define _IASSERT_\r
86 \r
87 #ifdef _DEBUG\r
88 #define iAssert(p) if(!(p)){fprintf(stderr,\\r
89     "Assertion failed: %s, file %s, line %d, val %d\n",\\r
90     #p, __FILE__, __LINE__, p);exit(-1);}\r
91 #else /* _DEBUG */\r
92 #define iAssert(p)\r
93 #endif /* _DEBUG */\r
94 \r
95 #ifndef PHY_APP\r
96 #ifndef _assert\r
97 #define _assert(x)\r
98 #endif\r
99 #endif\r
100 \r
101 #endif /* _IASSERT_*/\r
102 \r
103 #ifdef CHECK_PARAMS\r
104 #define CHECK_NOT_NULL(param, returnValue)      \\r
105 if (param == NULL)                          \\r
106 {                                           \\r
107     print_err("%s is NULL!\n", #param);   \\r
108     return returnValue;                     \\r
109 }\r
110 #else\r
111 #define CHECK_NOT_NULL(param, returnValue)\r
112 #endif\r
113 \r
114 #ifdef __cplusplus\r
115 }\r
116 #endif\r
117 \r
118 #endif // PHY_PRINTF_H\r