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