• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef __HI_DEBUG_ADAPT_H__
17 #define __HI_DEBUG_ADAPT_H__
18 
19 #ifndef __KERNEL__
20 #include <stdio.h>
21 #include <stdarg.h>
22 #endif
23 
24 #ifdef __HuaweiLite__
25 #include<assert.h>
26 #else
27 #ifndef __KERNEL__
28 #include<assert.h>
29 #endif
30 #endif
31 
32 #include "hi_type.h"
33 #include "hi_common_adapt.h"
34 #include "hi_debug.h"
35 
36 #ifdef __cplusplus
37 #if __cplusplus
38 extern "C" {
39 #endif
40 #endif /* __cplusplus */
41 
42 typedef struct {
43     hi_mod_id  mod_id;
44     hi_s32  level;
45     hi_char mod_name[16];
46 } hi_log_level_conf;
47 
48 #define MPI_STATIC static inline
49 
50 #ifdef __HuaweiLite__
51 
52 #ifdef CONFIG_HI_LOG_TRACE_SUPPORT
53 
54 #define MPI_ASSERT(expr)              \
55     do {                                   \
56         if (!(expr)) {                    \
57             (hi_void)printf("\nASSERT at:\n"       \
58                    "  >Function : %s\n"   \
59                    "  >Line No. : %d\n"   \
60                    "  >Condition: %s\n",  __FUNCTION__, __LINE__, #expr); \
61             assert(0 == 1); \
62         } \
63     } while (0)
64 
65 #else
66 
67 #define MPI_ASSERT(expr)
68 
69 #endif
70 
71 #else
72 
73 #ifndef __KERNEL__
74 
75 #ifdef CONFIG_HI_LOG_TRACE_SUPPORT
76 
77 #define MPI_ASSERT(expr)              \
78     do {                                   \
79         if (!(expr)) {                    \
80             (hi_void)printf("\nASSERT at:\n"       \
81                    "  >Function : %s\n"   \
82                    "  >Line No. : %d\n"   \
83                    "  >Condition: %s\n",  __FUNCTION__, __LINE__, #expr); \
84             assert(0 == 1); \
85         } \
86     } while (0)
87 
88 #else
89 
90 #define MPI_ASSERT(expr)
91 
92 #endif
93 
94 #endif
95 
96 #endif
97 
98 #ifdef __KERNEL__
99 
100 int hi_log(hi_s32 level, hi_mod_id mod_id, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
101 
102 #endif /* end of __KERNEL__ */
103 
104 #ifdef __cplusplus
105 #if __cplusplus
106 }
107 #endif
108 #endif /* __cplusplus */
109 
110 #endif /* __HI_DEBUG_ADAPT_H__ */
111 
112