Front Haul Interface Library update to third seed code contribution
[o-du/phy.git] / fhi_lib / lib / src / xran_printf.h
1 /******************************************************************************
2 *
3 *   Copyright (c) 2019 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 #include <stdio.h>
33 #include <stdlib.h>
34
35 #define PRINTF_LOG_OK
36 #define PRINTF_INF_OK
37 #define PRINTF_ERR_OK
38 //#define PRINTF_DBG_OK
39
40 #ifndef WIN32
41 #ifdef PRINTF_LOG_OK
42 #define print_log(fmt, args...) printf("%s:" fmt "\n", __FUNCTION__, ## args)
43 #else  /* PRINTF_LOG_OK */
44 #define print_log(fmt, args...)
45 #endif  /* PRINTF_LOG_OK */
46 #else
47 #define print_log(fmt, ...) printf("%s:" fmt "\n", __FUNCTION__, __VA_ARGS__)
48 #endif
49
50 #ifndef WIN32
51 #ifdef PRINTF_DBG_OK
52 #define print_dbg(fmt, args...) printf("%s:[dbg] " fmt "\n", __FUNCTION__, ## args)
53 #else  /* PRINTF_LOG_OK */
54 #define print_dbg(fmt, args...)
55 #endif  /* PRINTF_LOG_OK */
56 #else
57 #define print_dbg(fmt, ...) printf("%s:[dbg] " fmt "\n", __FUNCTION__, __VA_ARGS__)
58 #endif
59
60 #ifndef WIN32
61 #ifdef PRINTF_ERR_OK
62 #define print_err(fmt, args...) printf("%s:[err] " fmt "\n", __FUNCTION__, ## args)
63 #else  /* PRINTF_LOG_OK */
64 #define print_err(fmt, args...)
65 #endif  /* PRINTF_LOG_OK */
66 #else
67 #define print_err(fmt, ...) printf("%s:[err] " fmt "\n", __FUNCTION__, __VA_ARGS__)
68 #endif
69
70 #ifndef WIN32
71 #ifdef PRINTF_INF_OK
72 #define print_inf               printf
73 #else  /* PRINTF_LOG_OK */
74 #define print_inf
75 #endif  /* PRINTF_LOG_OK */
76 #else
77 #define print_inf               printf
78 #endif
79
80 #ifdef __cplusplus
81 }
82 #endif
83
84 #ifndef _IASSERT_
85 #define _IASSERT_
86
87 #ifdef _DEBUG
88 #define iAssert(p) if(!(p)){fprintf(stderr,\
89     "Assertion failed: %s, file %s, line %d, val %d\n",\
90     #p, __FILE__, __LINE__, p);exit(-1);}
91 #else /* _DEBUG */
92 #define iAssert(p)
93 #endif /* _DEBUG */
94
95 #ifndef PHY_APP
96 #ifndef _assert
97 #define _assert(x)
98 #endif
99 #endif
100
101 #endif /* _IASSERT_*/
102
103 #ifdef CHECK_PARAMS
104 #define CHECK_NOT_NULL(param, returnValue)      \
105 if (param == NULL)                          \
106 {                                           \
107     print_err("%s is NULL!\n", #param);   \
108     return returnValue;                     \
109 }
110 #else
111 #define CHECK_NOT_NULL(param, returnValue)
112 #endif
113
114 #ifdef __cplusplus
115 }
116 #endif
117
118 #endif // PHY_PRINTF_H