• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021–2022 Beijing OSWare Technology Co., Ltd
3  * This file contains confidential and proprietary information of
4  * OSWare Technology Co., Ltd
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #ifndef DISP_COMMON_H
20 #define DISP_COMMON_H
21 #include <string.h>
22 #include <stdint.h>
23 #include "hilog/log.h"
24 #include "stdio.h"
25 #ifdef HDF_LOG_TAG
26 #undef HDF_LOG_TAG
27 #endif
28 
29 #if defined(__cplusplus)
30 extern "C" {
31 #endif
32 
33 #undef LOG_TAG
34 #undef LOG_DOMAIN
35 #define LOG_TAG "DISP"
36 #define LOG_DOMAIN 0xD001400
37 
38 #ifndef DISPLAY_UNUSED
39 #define DISPLAY_UNUSED(x) (void)(x)
40 #endif
41 
42 #define __FILENAME__ (strrchr(__FILE__, '/') ? (strrchr(__FILE__, '/') + 1) : __FILE__)
43 
44 #ifndef DISPLAY_DEBUG_ENABLE
45 #define DISPLAY_DEBUG_ENABLE 0
46 #endif
47 
48 #ifndef DISPLAY_LOGD
49 #define DISPLAY_LOGD(format, ...)                                                                                     \
50     do {                                                                                                              \
51         if (DISPLAY_DEBUG_ENABLE) {                                                                                   \
52             HILOG_DEBUG(LOG_CORE, "[%{public}s@%{public}s:%{public}d] " format "\n",                                  \
53                 __FUNCTION__, __FILENAME__, __LINE__,                                                                 \
54                 ##__VA_ARGS__);                                                                                       \
55         }                                                                                                             \
56     } while (0)
57 #endif
58 
59 #ifndef DISPLAY_LOGI
60 #define DISPLAY_LOGI(format, ...)                                                                                     \
61     do {                                                                                                              \
62         HILOG_INFO(LOG_CORE, "[%{public}s@%{public}s:%{public}d] " format "\n", __FUNCTION__, __FILENAME__, __LINE__, \
63             ##__VA_ARGS__);                                                                                           \
64     } while (0)
65 #endif
66 
67 #ifndef DISPLAY_LOGW
68 #define DISPLAY_LOGW(format, ...)                                                                                     \
69     do {                                                                                                              \
70         HILOG_WARN(LOG_CORE, "[%{public}s@%{public}s:%{public}d] " format "\n", __FUNCTION__, __FILENAME__, __LINE__, \
71             ##__VA_ARGS__);                                                                                           \
72     } while (0)
73 #endif
74 
75 #ifndef DISPLAY_LOGE
76 #define DISPLAY_LOGE(format, ...)                                 \
77     do {                                                          \
78         HILOG_ERROR(LOG_CORE,                                     \
79             "\033[0;32;31m"                                       \
80             "[%{public}s@%{public}s:%{public}d] " format "\033[m" \
81             "\n",                                                 \
82             __FUNCTION__, __FILENAME__, __LINE__, ##__VA_ARGS__); \
83     } while (0)
84 #endif
85 
86 #ifndef CHECK_NULLPOINTER_RETURN_VALUE
87 #define CHECK_NULLPOINTER_RETURN_VALUE(pointer, ret)          \
88     do {                                                      \
89         if ((pointer) == NULL) {                              \
90             DISPLAY_LOGE("pointer is null and return ret\n"); \
91             return (ret);                                     \
92         }                                                     \
93     } while (0)
94 #endif
95 
96 #ifndef CHECK_NULLPOINTER_RETURN
97 #define CHECK_NULLPOINTER_RETURN(pointer)                 \
98     do {                                                  \
99         if ((pointer) == NULL) {                          \
100             DISPLAY_LOGE("pointer is null and return\n"); \
101             return;                                       \
102         }                                                 \
103     } while (0)
104 #endif
105 
106 #ifndef DISPLAY_CHK_RETURN
107 #define DISPLAY_CHK_RETURN(val, ret, ...) \
108     do {                                  \
109         if (val) {                        \
110             __VA_ARGS__;                  \
111             return (ret);                 \
112         }                                 \
113     } while (0)
114 #endif
115 
116 #ifndef DISPLAY_CHK_RETURN_NOT_VALUE
117 #define DISPLAY_CHK_RETURN_NOT_VALUE(val, ...) \
118     do {                                            \
119         if (val) {                                  \
120             __VA_ARGS__;                            \
121             return;                                 \
122         }                                           \
123     } while (0)
124 #endif
125 
126 #ifdef __cplusplus
127 }
128 #endif
129 
130 #endif /* DISP_COMMON_H */
131