1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 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 DISP_COMMON_H 17 #define DISP_COMMON_H 18 #include <string.h> 19 #include <stdint.h> 20 #include "hilog/log.h" 21 #ifdef HDF_LOG_TAG 22 #undef HDF_LOG_TAG 23 #endif 24 25 #if defined(__cplusplus) 26 extern "C" { 27 #endif 28 29 #define FENCE_TIMEOUT 3000 30 31 #undef LOG_TAG 32 #undef LOG_DOMAIN 33 #define LOG_TAG "DISP" 34 #define LOG_DOMAIN 0xD001400 35 36 #ifndef DISPLAY_UNUSED 37 #define DISPLAY_UNUSED(x) ((void)(x)) 38 #endif 39 40 #define DISP_FILENAME (strrchr(__FILE__, '/') ? (strrchr(__FILE__, '/') + 1) : __FILE__) 41 42 #ifndef DISPLAY_DEBUG_ENABLE 43 #define DISPLAY_DEBUG_ENABLE 1 44 #endif 45 46 #ifndef DISPLAY_LOGD 47 #define DISPLAY_LOGD(format, ...) \ 48 do { \ 49 if (DISPLAY_DEBUG_ENABLE) { \ 50 HILOG_DEBUG(LOG_CORE, "[%{public}s@%{public}s:%{public}d] " format "\n", \ 51 __FUNCTION__, DISP_FILENAME, __LINE__, \ 52 ##__VA_ARGS__); \ 53 } \ 54 } while (0) 55 #endif 56 57 #ifndef DISPLAY_LOGI 58 #define DISPLAY_LOGI(format, ...) \ 59 do { \ 60 HILOG_INFO(LOG_CORE, "[%{public}s@%{public}s:%{public}d] " format "\n", __FUNCTION__, DISP_FILENAME, __LINE__, \ 61 ##__VA_ARGS__); \ 62 } while (0) 63 #endif 64 65 #ifndef DISPLAY_LOGW 66 #define DISPLAY_LOGW(format, ...) \ 67 do { \ 68 HILOG_WARN(LOG_CORE, "[%{public}s@%{public}s:%{public}d] " format "\n", __FUNCTION__, DISP_FILENAME, __LINE__, \ 69 ##__VA_ARGS__); \ 70 } while (0) 71 #endif 72 73 #ifndef DISPLAY_LOGE 74 #define DISPLAY_LOGE(format, ...) \ 75 do { \ 76 HILOG_ERROR(LOG_CORE, \ 77 "\033[0;32;31m" \ 78 "[%{public}s@%{public}s:%{public}d] " format "\033[m" \ 79 "\n", \ 80 __FUNCTION__, DISP_FILENAME, __LINE__, ##__VA_ARGS__); \ 81 } while (0) 82 #endif 83 84 #ifndef CHECK_NULLPOINTER_RETURN_VALUE 85 #define CHECK_NULLPOINTER_RETURN_VALUE(pointer, ret) \ 86 do { \ 87 if ((pointer) == NULL) { \ 88 DISPLAY_LOGE("pointer is null and return ret\n"); \ 89 return (ret); \ 90 } \ 91 } while (0) 92 #endif 93 94 #ifndef CHECK_NULLPOINTER_RETURN 95 #define CHECK_NULLPOINTER_RETURN(pointer) \ 96 do { \ 97 if ((pointer) == NULL) { \ 98 DISPLAY_LOGE("pointer is null and return\n"); \ 99 return; \ 100 } \ 101 } while (0) 102 #endif 103 104 #ifndef DISPLAY_CHK_RETURN 105 #define DISPLAY_CHK_RETURN(val, ret, ...) \ 106 do { \ 107 if (val) { \ 108 __VA_ARGS__; \ 109 return (ret); \ 110 } \ 111 } while (0)extern "C" { 112 113 #endif 114 115 #ifndef DISPLAY_CHK_RETURN_NOT_VALUE 116 #define DISPLAY_CHK_RETURN_NOT_VALUE(val, ...) \ 117 do { \ 118 if (val) { \ 119 __VA_ARGS__; \ 120 return; \ 121 } \ 122 } while (0) 123 #endif 124 125 #ifdef __cplusplus 126 } 127 #endif 128 129 #endif /* DISP_COMMON_H */ 130