• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 
19 #ifndef __HI_DEBUG_ADAPT_H__
20 #define __HI_DEBUG_ADAPT_H__
21 
22 #ifndef __KERNEL__
23 #include <stdio.h>
24 #include <stdarg.h>
25 #endif
26 
27 #ifdef __HuaweiLite__
28 #include<assert.h>
29 #else
30 #ifndef __KERNEL__
31 #include<assert.h>
32 #endif
33 #endif
34 
35 #include "hi_type.h"
36 #include "hi_common_adapt.h"
37 #include "hi_debug.h"
38 
39 #ifdef __cplusplus
40 #if __cplusplus
41 extern "C" {
42 #endif
43 #endif /* __cplusplus */
44 
45 typedef struct {
46     hi_mod_id  mod_id;
47     hi_s32  level;
48     hi_char mod_name[16];
49 } hi_log_level_conf;
50 
51 #define MPI_STATIC static inline
52 
53 #ifdef __HuaweiLite__
54 
55 #ifdef CONFIG_HI_LOG_TRACE_SUPPORT
56 
57     #define MPI_ASSERT(expr)              \
58     do {                                   \
59         if (!(expr)) {                    \
60             (hi_void)printf("\nASSERT at:\n"       \
61                    "  >Function : %s\n"   \
62                    "  >Line No. : %d\n"   \
63                    "  >Condition: %s\n",  __FUNCTION__, __LINE__, #expr); \
64             assert(0 == 1); \
65         } \
66     } while (0)
67 
68 #else
69 
70     #define MPI_ASSERT(expr)
71 
72 #endif
73 
74 #else
75 
76 #ifndef __KERNEL__
77 
78 #ifdef CONFIG_HI_LOG_TRACE_SUPPORT
79 
80     #define MPI_ASSERT(expr)              \
81     do {                                   \
82         if (!(expr)) {                    \
83             (hi_void)printf("\nASSERT at:\n"       \
84                    "  >Function : %s\n"   \
85                    "  >Line No. : %d\n"   \
86                    "  >Condition: %s\n",  __FUNCTION__, __LINE__, #expr); \
87             assert(0 == 1); \
88         } \
89     } while (0)
90 
91 #else
92 
93     #define MPI_ASSERT(expr)
94 
95 #endif
96 
97 #endif
98 
99 #endif
100 
101 #ifdef __KERNEL__
102 
103 int hi_log(hi_s32 level, hi_mod_id mod_id, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
104 
105 #endif /* end of __KERNEL__ */
106 
107 #ifdef __cplusplus
108 #if __cplusplus
109 }
110 #endif
111 #endif /* __cplusplus */
112 
113 #endif /* __HI_DEBUG_ADAPT_H__ */
114 
115